mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-10 15:36:38 +02:00
* NRF24 amlifierer power level can be configured in web setup
* fixed MQTT status (was inverted) * fixed interval uint from seconds to ms
This commit is contained in:
parent
df9f050313
commit
04d31200cb
5 changed files with 42 additions and 8 deletions
|
@ -68,6 +68,9 @@ void app::setup(const char *ssid, const char *pwd, uint32_t timeout) {
|
|||
mEep->read(ADDR_PINOUT+2, &mSys->Radio.pinIrq);
|
||||
|
||||
|
||||
// nrf24 amplifier power
|
||||
mEep->read(ADDR_RF24_AMP_PWR, &mSys->Radio.AmplifierPower);
|
||||
|
||||
// mqtt
|
||||
uint8_t mqttAddr[MQTT_ADDR_LEN];
|
||||
char mqttUser[MQTT_USER_LEN];
|
||||
|
@ -93,7 +96,7 @@ void app::setup(const char *ssid, const char *pwd, uint32_t timeout) {
|
|||
|
||||
mSys->setup();
|
||||
|
||||
if(!mSettingsValid)
|
||||
if(!mWifiSettingsValid)
|
||||
Serial.println("Warn: your settings are not valid! check [IP]/setup");
|
||||
}
|
||||
|
||||
|
@ -285,6 +288,17 @@ void app::showSetup(void) {
|
|||
html.replace("{PINOUT}", String(pinout));
|
||||
|
||||
|
||||
// nrf24l01+
|
||||
String rf24;
|
||||
for(uint8_t i = 0; i <= 3; i++) {
|
||||
rf24 += "<option value=\"" + String(i) + "\"";
|
||||
if(i == mSys->Radio.AmplifierPower)
|
||||
rf24 += " selected";
|
||||
rf24 += ">" + String(rf24AmpPower[i]) + "</option>";
|
||||
}
|
||||
html.replace("{RF24}", String(rf24));
|
||||
|
||||
|
||||
if(mSettingsValid) {
|
||||
mEep->read(ADDR_INV_INTERVAL, &interval);
|
||||
html.replace("{INV_INTERVAL}", String(interval));
|
||||
|
@ -409,7 +423,7 @@ void app::showLiveData(void) {
|
|||
//-----------------------------------------------------------------------------
|
||||
void app::showMqtt(void) {
|
||||
String txt = "connected";
|
||||
if(mMqtt.isConnected())
|
||||
if(!mMqtt.isConnected())
|
||||
txt = "not " + txt;
|
||||
mWeb->send(200, "text/plain", txt);
|
||||
}
|
||||
|
@ -456,6 +470,10 @@ void app::saveValues(bool webSend = true) {
|
|||
}
|
||||
|
||||
|
||||
// nrf24 amplifier power
|
||||
mSys->Radio.AmplifierPower = mWeb->arg(String(pinArgNames[i])).toInt() & 0x03;
|
||||
mEep->write(ADDR_RF24_AMP_PWR, mSys->Radio.AmplifierPower);
|
||||
|
||||
// mqtt
|
||||
uint8_t mqttAddr[MQTT_ADDR_LEN] = {0};
|
||||
char mqttUser[MQTT_USER_LEN];
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
//-------------------------------------
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_PATCH 6
|
||||
#define VERSION_PATCH 7
|
||||
|
||||
|
||||
//-------------------------------------
|
||||
|
@ -50,6 +50,8 @@ typedef struct {
|
|||
|
||||
#define PINOUT_LEN 3 // 3 pins: CS, CE, IRQ
|
||||
|
||||
#define RF24_AMP_PWR_LEN 1
|
||||
|
||||
#define MQTT_ADDR_LEN 4 // IP
|
||||
#define MQTT_USER_LEN 16
|
||||
#define MQTT_PWD_LEN 32
|
||||
|
@ -66,7 +68,9 @@ typedef struct {
|
|||
|
||||
#define ADDR_PINOUT ADDR_START_SETTINGS
|
||||
|
||||
#define ADDR_INV_ADDR ADDR_PINOUT + PINOUT_LEN
|
||||
#define ADDR_RF24_AMP_PWR ADDR_PINOUT + PINOUT_LEN
|
||||
|
||||
#define ADDR_INV_ADDR ADDR_RF24_AMP_PWR + RF24_AMP_PWR_LEN
|
||||
#define ADDR_INV_NAME ADDR_INV_ADDR + INV_ADDR_LEN
|
||||
#define ADDR_INV_TYPE ADDR_INV_NAME + INV_NAME_LEN
|
||||
#define ADDR_INV_INTERVAL ADDR_INV_TYPE + INV_TYPE_LEN
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
#define DUMMY_RADIO_ID ((uint64_t)0xDEADBEEF01ULL)
|
||||
|
||||
|
||||
const char* const rf24AmpPower[] = {"MIN", "LOW", "HIGH", "MAX"};
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MACROS
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -54,7 +58,8 @@ class HmRadio {
|
|||
pinCe = CE_PIN;
|
||||
pinIrq = IRQ_PIN;
|
||||
|
||||
mSendCnt = 0;
|
||||
AmplifierPower = 1;
|
||||
mSendCnt = 0;
|
||||
}
|
||||
~HmRadio() {}
|
||||
|
||||
|
@ -79,7 +84,8 @@ class HmRadio {
|
|||
// enable only receiving interrupts
|
||||
mNrf24.maskIRQ(true, true, false);
|
||||
|
||||
mNrf24.setPALevel(RF24_PA_MAX);
|
||||
Serial.println("RF24 Amp Pwr: RF24_PA_" + String(rf24AmpPower[AmplifierPower]));
|
||||
mNrf24.setPALevel(AmplifierPower & 0x03);
|
||||
mNrf24.startListening();
|
||||
|
||||
Serial.println("Radio Config:");
|
||||
|
@ -180,6 +186,8 @@ class HmRadio {
|
|||
uint8_t pinCe;
|
||||
uint8_t pinIrq;
|
||||
|
||||
uint8_t AmplifierPower;
|
||||
|
||||
private:
|
||||
void sendPacket(uint64_t invId, uint8_t buf[], uint8_t len) {
|
||||
//Serial.println("sent packet: #" + String(mSendCnt));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __SETUP_H__
|
||||
#define __SETUP_H__
|
||||
const char setup_html[] PROGMEM = "<!doctype html><html><head><title>Setup - {DEVICE}</title><link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\"/><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"></head><body><h1>Setup</h1><div id=\"setup\" class=\"content\"><div id=\"content\"><p>Enter the credentials to your prefered WiFi station. After rebooting the device tries to connect with this information. </p><form method=\"post\" action=\"/save\"><p class=\"des\">WiFi</p><label for=\"ssid\">SSID</label><input type=\"text\" class=\"text\" name=\"ssid\" value=\"{SSID}\"/><label for=\"pwd\">Password</label><input type=\"password\" class=\"text\" name=\"pwd\" value=\"{PWD}\"/><p class=\"des\">Device Host Name</p><label for=\"device\">Device Name</label><input type=\"text\" class=\"text\" name=\"device\" value=\"{DEVICE}\"/><a class=\"erase\" href=\"/erase\">ERASE SETTINGS (not WiFi)</a><p class=\"des\">Inverter</p>{INVERTERS}<br/><p class=\"subdes\">General</p><label for=\"invInterval\">Interval (ms)</label><input type=\"text\" class=\"text\" name=\"invInterval\" value=\"{INV_INTERVAL}\"/><p class=\"des\">Pinout (Wemos)</p>{PINOUT}<p class=\"des\">MQTT</p><label for=\"mqttAddr\">Broker / Server IP</label><input type=\"text\" class=\"text\" name=\"mqttAddr\" value=\"{MQTT_ADDR}\"/><label for=\"mqttUser\">Username (optional)</label><input type=\"text\" class=\"text\" name=\"mqttUser\" value=\"{MQTT_USER}\"/><label for=\"mqttPwd\">Password (optional)</label><input type=\"text\" class=\"text\" name=\"mqttPwd\" value=\"{MQTT_PWD}\"/><label for=\"mqttTopic\">Topic</label><input type=\"text\" class=\"text\" name=\"mqttTopic\" value=\"{MQTT_TOPIC}\"/><label for=\"mqttInterval\">Interval (seconds)</label><input type=\"text\" class=\"text\" name=\"mqttInterval\" value=\"{MQTT_INTERVAL}\"/><p class=\"des\"> </p><input type=\"checkbox\" class=\"cb\" name=\"reboot\"/><label for=\"reboot\">Reboot device after successful save</label><input type=\"submit\" value=\"save\" class=\"btn\" /></form></div></div><div id=\"footer\"><p class=\"left\"><a href=\"/\">Home</a></p><p class=\"left\"><a href=\"/update\">Update Firmware</a></p><p class=\"right\">AHOY - {VERSION}</p></div></body></html>";
|
||||
const char setup_html[] PROGMEM = "<!doctype html><html><head><title>Setup - {DEVICE}</title><link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\"/><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"></head><body><h1>Setup</h1><div id=\"setup\" class=\"content\"><div id=\"content\"><p>Enter the credentials to your prefered WiFi station. After rebooting the device tries to connect with this information. </p><form method=\"post\" action=\"/save\"><p class=\"des\">WiFi</p><label for=\"ssid\">SSID</label><input type=\"text\" class=\"text\" name=\"ssid\" value=\"{SSID}\"/><label for=\"pwd\">Password</label><input type=\"password\" class=\"text\" name=\"pwd\" value=\"{PWD}\"/><p class=\"des\">Device Host Name</p><label for=\"device\">Device Name</label><input type=\"text\" class=\"text\" name=\"device\" value=\"{DEVICE}\"/><a class=\"erase\" href=\"/erase\">ERASE SETTINGS (not WiFi)</a><p class=\"des\">Inverter</p>{INVERTERS}<br/><p class=\"subdes\">General</p><label for=\"invInterval\">Interval (ms)</label><input type=\"text\" class=\"text\" name=\"invInterval\" value=\"{INV_INTERVAL}\"/><p class=\"des\">Pinout (Wemos)</p>{PINOUT}<p class=\"des\">Radio (NRF24L01+)</p><label for=\"rf24Power\">Amplifier Power Level</label><select name=\"rf24Power\">{RF24}</select><p class=\"des\">MQTT</p><label for=\"mqttAddr\">Broker / Server IP</label><input type=\"text\" class=\"text\" name=\"mqttAddr\" value=\"{MQTT_ADDR}\"/><label for=\"mqttUser\">Username (optional)</label><input type=\"text\" class=\"text\" name=\"mqttUser\" value=\"{MQTT_USER}\"/><label for=\"mqttPwd\">Password (optional)</label><input type=\"text\" class=\"text\" name=\"mqttPwd\" value=\"{MQTT_PWD}\"/><label for=\"mqttTopic\">Topic</label><input type=\"text\" class=\"text\" name=\"mqttTopic\" value=\"{MQTT_TOPIC}\"/><label for=\"mqttInterval\">Interval (ms)</label><input type=\"text\" class=\"text\" name=\"mqttInterval\" value=\"{MQTT_INTERVAL}\"/><p class=\"des\"> </p><input type=\"checkbox\" class=\"cb\" name=\"reboot\"/><label for=\"reboot\">Reboot device after successful save</label><input type=\"submit\" value=\"save\" class=\"btn\" /></form></div></div><div id=\"footer\"><p class=\"left\"><a href=\"/\">Home</a></p><p class=\"left\"><a href=\"/update\">Update Firmware</a></p><p class=\"right\">AHOY - {VERSION}</p></div></body></html>";
|
||||
#endif /*__SETUP_H__*/
|
||||
|
|
|
@ -34,6 +34,10 @@
|
|||
<p class="des">Pinout (Wemos)</p>
|
||||
{PINOUT}
|
||||
|
||||
<p class="des">Radio (NRF24L01+)</p>
|
||||
<label for="rf24Power">Amplifier Power Level</label>
|
||||
<select name="rf24Power">{RF24}</select>
|
||||
|
||||
<p class="des">MQTT</p>
|
||||
<label for="mqttAddr">Broker / Server IP</label>
|
||||
<input type="text" class="text" name="mqttAddr" value="{MQTT_ADDR}"/>
|
||||
|
@ -43,7 +47,7 @@
|
|||
<input type="text" class="text" name="mqttPwd" value="{MQTT_PWD}"/>
|
||||
<label for="mqttTopic">Topic</label>
|
||||
<input type="text" class="text" name="mqttTopic" value="{MQTT_TOPIC}"/>
|
||||
<label for="mqttInterval">Interval (seconds)</label>
|
||||
<label for="mqttInterval">Interval (ms)</label>
|
||||
<input type="text" class="text" name="mqttInterval" value="{MQTT_INTERVAL}"/>
|
||||
|
||||
<p class="des"> </p>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue