diff --git a/RFLink/1_Radio.cpp b/RFLink/1_Radio.cpp index c00be731..2e29f2b1 100644 --- a/RFLink/1_Radio.cpp +++ b/RFLink/1_Radio.cpp @@ -9,9 +9,7 @@ #include "RFLink.h" #include "1_Radio.h" #include "4_Display.h" -#ifdef AUTOCONNECT_ENABLED -#include "9_AutoConnect.h" -#else + uint8_t PIN_RF_RX_PMOS = PIN_RF_RX_PMOS_0; uint8_t PIN_RF_RX_NMOS = PIN_RF_RX_NMOS_0; uint8_t PIN_RF_RX_VCC = PIN_RF_RX_VCC_0; @@ -25,7 +23,6 @@ uint8_t PIN_RF_TX_VCC = PIN_RF_TX_VCC_0; uint8_t PIN_RF_TX_GND = PIN_RF_TX_GND_0; uint8_t PIN_RF_TX_NA = PIN_RF_TX_NA_0; uint8_t PIN_RF_TX_DATA = PIN_RF_TX_DATA_0; -#endif //AUTOCONNECT_ENABLED Radio_State current_State = Radio_NA; diff --git a/RFLink/3_Serial.cpp b/RFLink/3_Serial.cpp index 3da585bc..85d47d36 100644 --- a/RFLink/3_Serial.cpp +++ b/RFLink/3_Serial.cpp @@ -49,36 +49,6 @@ boolean CheckMQTT(byte *byte_in) return false; } -#ifdef AUTOCONNECT_ENABLED -boolean CheckWeb(String &String_in) -{ - if (!String_in.isEmpty()) - { - String_in.trim(); - char char_in[INPUT_COMMAND_SIZE]; - String_in.toCharArray(char_in, String_in.length() + 1); - char_in[String_in.length() + 1] = 0; - - if (CopySerial(char_in)) - { -#ifdef SERIAL_ENABLED - Serial.flush(); - Serial.print(F("Message arrived [Web] ")); - Serial.println(InputBuffer_Serial); -#endif - if (CheckCmd()) - { - String_in.clear(); - return true; - } - } - String_in.clear(); - return false; - } - return false; -} -#endif // AUTOCONNECT_ENABLED - boolean CopySerial(char *src) { return (strncpy(InputBuffer_Serial, src, INPUT_COMMAND_SIZE - 2)); diff --git a/RFLink/3_Serial.h b/RFLink/3_Serial.h index e06415cc..13c548f4 100644 --- a/RFLink/3_Serial.h +++ b/RFLink/3_Serial.h @@ -18,7 +18,4 @@ extern char InputBuffer_Serial[INPUT_COMMAND_SIZE]; boolean CheckSerial(); boolean CheckMQTT(byte *); -#ifdef AUTOCONNECT_ENABLED -boolean CheckWeb(String &); -#endif // AUTOCONNECT_ENABLED #endif \ No newline at end of file diff --git a/RFLink/5_Plugin.cpp b/RFLink/5_Plugin.cpp index e29d29da..7a37afb5 100644 --- a/RFLink/5_Plugin.cpp +++ b/RFLink/5_Plugin.cpp @@ -9,17 +9,6 @@ #include "RFLink.h" #include "2_Signal.h" #include "5_Plugin.h" -#ifdef AUTOCONNECT_ENABLED -#include "9_AutoConnect.h" -#ifdef ESP8266 -#include -#include -#elif ESP32 -#include -#define LittleFS SPIFFS -#endif // ESP8266 -#include -#endif // AUTOCONNECT boolean (*Plugin_ptr[PLUGIN_MAX])(byte, char *); // Receive plugins byte Plugin_id[PLUGIN_MAX]; @@ -1695,43 +1684,6 @@ void PluginInit(void) Plugin_ptr[x++] = &Plugin_255; #endif -// read config file to desactivated protocols -#ifdef AUTOCONNECT_ENABLED - LittleFS.begin(); - Serial.print("Param "); - Serial.print(PROTOCOL_FILE); - Serial.print(F(" :\t")); - File configFile = LittleFS.open(PROTOCOL_FILE, "r"); - if (configFile) - { - // const int capacity = JSON_ARRAY_SIZE(254) + 2 * JSON_OBJECT_SIZE(2); // 4128 - // StaticJsonDocument<4128> doc; - DynamicJsonDocument doc(4128); - - if (deserializeJson(doc, configFile)) - { - Serial.println(F("Failed to load")); - } - else - { - for (x = 0; x < PLUGIN_MAX; x++) - { - if (doc[x][String(Plugin_id[x])] == 0) - Plugin_State[x] = P_Disabled; - } - Serial.println(F("Loaded")); - } - doc.clear(); - configFile.close(); - } - else - { - Serial.println(F("Failed to open(+r)")); - } - LittleFS.end(); - -#endif // AUTOCONNECT_ENABLED - // Initialiseer alle plugins door aanroep met verwerkingsparameter PLUGIN_INIT PluginInitCall(0, 0); } diff --git a/RFLink/6_Credentials.h b/RFLink/6_Credentials.h index 90964610..056c5949 100644 --- a/RFLink/6_Credentials.h +++ b/RFLink/6_Credentials.h @@ -9,7 +9,6 @@ #define CREDENTIALS_h #include "RFLink.h" -#ifndef AUTOCONNECT_ENABLED // local AP String WIFI_SSID = "your_AP_ssid"; @@ -36,5 +35,4 @@ String MQTT_TOPIC_OUT = "/RFLink/msg"; String MQTT_TOPIC_IN = "/RFLink/cmd"; String MQTT_TOPIC_LWT = "/RFLink/lwt"; -#endif #endif \ No newline at end of file diff --git a/RFLink/6_WiFi_MQTT.cpp b/RFLink/6_WiFi_MQTT.cpp index d8402bf5..dcebc509 100644 --- a/RFLink/6_WiFi_MQTT.cpp +++ b/RFLink/6_WiFi_MQTT.cpp @@ -10,19 +10,13 @@ #include "3_Serial.h" #include "4_Display.h" #include "6_WiFi_MQTT.h" -#ifdef AUTOCONNECT_ENABLED -#include "9_AutoConnect.h" -#else #include "6_Credentials.h" -#endif -#ifndef AUTOCONNECT_ENABLED #ifdef ESP32 #include #elif ESP8266 #include #endif -#endif // !AUTOCONNECT_ENABLED #ifdef MQTT_ENABLED @@ -42,7 +36,6 @@ PubSubClient MQTTClient; // MQTTClient(WIFIClient); void callback(char *, byte *, unsigned int); -#ifndef AUTOCONNECT_ENABLED static String WIFI_PWR = String(WIFI_PWR_0); void setup_WIFI() @@ -78,7 +71,6 @@ void setup_WIFI() Serial.print(F("WiFi RSSI :\t\t")); Serial.println(WiFi.RSSI()); } -#endif void setup_MQTT() { @@ -97,12 +89,7 @@ void callback(char *topic, byte *payload, unsigned int length) } void reconnect() -{ // MQTT connection (documented way from AutoConnect : https://github.com/Hieromon/AutoConnect/tree/master/examples/mqttRSSI_NA) - -#ifdef AUTOCONNECT_ENABLED - uint8_t retry = 3; -#endif // AUTOCONNECT_ENABLED - +{ bResub = true; while (!MQTTClient.connected()) { @@ -129,25 +116,17 @@ void reconnect() { Serial.print(F("Failed - rc=")); Serial.println(MQTTClient.state()); -#ifdef AUTOCONNECT_ENABLED - if (!--retry) - break; - delay(500); -#else // AUTOCONNECT_ENABLED Serial.println(F("MQTT Retry :\tTry again in 5 seconds")); // Wait 5 seconds before retrying for (byte i = 0; i < 10; i++) delay(500); // delay(5000) may cause hang -#endif // AUTOCONNECT_ENABLED } } } void publishMsg() { -#ifndef AUTOCONNECT_ENABLED static boolean MQTT_RETAINED = MQTT_RETAINED_0; -#endif // !AUTOCONNECT_ENABLED if (!MQTTClient.connected()) reconnect(); @@ -174,9 +153,9 @@ void checkMQTTloop() lastCheck = millis(); } } -#endif // MQTT_ENABLED -#if (!defined(AUTOCONNECT_ENABLED) && !defined(MQTT_ENABLED)) +#else // MQTT_ENABLED + #if (defined(ESP32) || defined(ESP8266)) void setup_WIFI_OFF() { diff --git a/RFLink/6_WiFi_MQTT.h b/RFLink/6_WiFi_MQTT.h index 105daab5..0f4f91a6 100644 --- a/RFLink/6_WiFi_MQTT.h +++ b/RFLink/6_WiFi_MQTT.h @@ -11,42 +11,27 @@ #include #include "RFLink.h" -#ifdef AUTOCONNECT_ENABLED -extern String MQTT_SERVER; -extern String MQTT_PORT; -extern String MQTT_ID; -extern String MQTT_USER; -extern String MQTT_PSWD; -extern String MQTT_TOPIC_OUT; -extern String MQTT_TOPIC_IN; -extern boolean MQTT_RETAINED; -extern String Adv_HostName; -extern String Adv_Power; -#else #ifdef ESP32 #include #elif ESP8266 #include #endif -#endif // AUTOCONNECT_ENABLED #ifdef MQTT_ENABLED extern char MQTTbuffer[PRINT_BUFFER_SIZE]; // Buffer for MQTT message -#ifndef AUTOCONNECT_ENABLED void setup_WIFI(); -#endif // !AUTOCONNECT_ENABLED - void setup_MQTT(); void reconnect(); void publishMsg(); void checkMQTTloop(); -#endif // MQTT_ENABLED -#if (!defined(AUTOCONNECT_ENABLED) && !defined(MQTT_ENABLED)) +#else // MQTT_ENABLED + #if (defined(ESP32) || defined(ESP8266)) void setup_WIFI_OFF(); #endif -#endif + +#endif // MQTT_ENABLED #endif // WiFi_MQTT_h \ No newline at end of file diff --git a/RFLink/9_AutoConnect.cpp b/RFLink/9_AutoConnect.cpp deleted file mode 100644 index b4085cb9..00000000 --- a/RFLink/9_AutoConnect.cpp +++ /dev/null @@ -1,539 +0,0 @@ -// ************************************* // -// * Arduino Project RFLink-esp * // -// * https://github.com/couin3/RFLink * // -// * 2018..2020 Stormteam - Marc RIVES * // -// * 2020 Schmutzm, Autoconnect Stuff * // -// * 2020 Allexum, Web "Send" button * // -// * More details in RFLink.ino file * // -// ************************************* // - -#include -#include "RFLink.h" -#ifdef AUTOCONNECT_ENABLED - -#include "1_Radio.h" -#include "4_Display.h" // To allow displaying the last message -#include "5_Plugin.h" -#include "6_WiFi_MQTT.h" -#include "9_AutoConnect.h" -#ifdef ESP8266 -#include -#include -typedef ESP8266WebServer WebServer; -#include -#include -#elif ESP32 -#include -#include -typedef WebServer WebServer; -#include -#define LittleFS SPIFFS -#endif // ESP8266 -#include -#include - -AutoConnect portal; -AutoConnectConfig config; - -String MQTT_SERVER; -String MQTT_PORT; -String MQTT_ID; -String MQTT_USER; -String MQTT_PSWD; -String MQTT_TOPIC_OUT; -String MQTT_TOPIC_IN; -boolean MQTT_RETAINED; -// Adds advanced tab to Autoconnect -String Adv_HostName; -String Adv_Power; -String LastMsg; -String CmdMsg; -// Radio pins settings -uint8_t PIN_RF_RX_PMOS; -uint8_t PIN_RF_RX_NMOS; -uint8_t PIN_RF_RX_VCC; -uint8_t PIN_RF_RX_GND; -uint8_t PIN_RF_RX_NA; -uint8_t PIN_RF_RX_DATA; -boolean PULLUP_RF_RX_DATA; -uint8_t PIN_RF_TX_PMOS; -uint8_t PIN_RF_TX_NMOS; -uint8_t PIN_RF_TX_VCC; -uint8_t PIN_RF_TX_GND; -uint8_t PIN_RF_TX_NA; -uint8_t PIN_RF_TX_DATA; - -// Prototypes -String loadParams(AutoConnectAux &aux, PageArgument &args); -String saveParams(AutoConnectAux &aux, PageArgument &args); - -void rootPage() -{ - WebServer &webServer = portal.host(); - - if (webServer.hasArg("BtnSend")) - { - // Récupération de la valeur dans la fenêtre Send - CmdMsg = webServer.arg(0); - } - - if (webServer.hasArg("BtnSave")) - { - // const int capacity = JSON_ARRAY_SIZE(254) + 2 * JSON_OBJECT_SIZE(2); - // StaticJsonDocument<4128> doc; - DynamicJsonDocument doc(4128); - - for (byte x = 0; x < PLUGIN_MAX; x++) - { - if (Plugin_id[x] != 0) - { - // pour chaque plugin activé lors de la compilation du firmware, - // on créé un enregistrement dans le fichier protocols.json - // si le serveur a un argument c'est que la checkbox est cochée - if (webServer.hasArg(String(Plugin_id[x]) + "_ProtocolState")) - { - doc[x][String(Plugin_id[x])] = 1; - Plugin_State[x] = 2; - } - else - { - doc[x][String(Plugin_id[x])] = 0; - Plugin_State[x] = 1; - } - } - } - - Serial.print("Param "); - Serial.print(PROTOCOL_FILE); - Serial.print(F(" :\t")); - - LittleFS.begin(); - File configFile = LittleFS.open(PROTOCOL_FILE, "w"); - serializeJson(doc, configFile); - - Serial.println(F("Saved")); - doc.clear(); - configFile.close(); - LittleFS.end(); - } - - // This is the Home Page - Choose theme here : https://www.bootstrapcdn.com/bootswatch/?theme - String content = - "" - "RFLink-ESP" - "" - "" - "" - "" - "" - - // !!!!!!!!!!!!!!! Ajax auto refresh, disable it to avoid a lot of request on the ESP !!!!!!!!!!!!!!! - // to do : add a checkbox to enable/disable it dynamically - "" - // !!!!!!!!!!!!!!! Ajax auto refresh, disable it to avoid a lot of request on the ESP !!!!!!!!!!!!!!! - - // Navigation bar - - ""; - - //// Graphical icon to access network config - // ""; - // "

RFLink-ESP " AUTOCONNECT_LINK(COG_32) "


"; - - //// iframe test : - // "" - - // content += "Last refresh : "; // Require NTP time, We'll see that later.... - // content += ctime(&now); - content += "
"; - content += "
"; - content += "
Last Message
"; - content += "
"; - // ======== Ajax = autrefresh mode ======== - content += "

"; - //========================================== - //========================================== - // ===== No Ajax = no autrefresh mode ===== - // content += "

" + LastMsg + "

"; - //========================================== - content += "
"; - content += "
"; - content += "
"; - content += "
"; - - // Zone de saisaie du message à envoyer - content += "
"; - content += "
"; - content += "
Send Message
"; - content += "
"; - if (webServer.hasArg("BtnSend")) - content += ""; - else - content += ""; - content += "
"; - content += "
"; - content += "
"; - content += "
"; - - content += ""; - content += ""; // Table Header // é = é - content += ""; // Table content - content += ""; - for (byte x = 0; x < PLUGIN_MAX; x++) - { - if ((Plugin_id[x] != 0)) // && (Plugin_State[x] >= P_Enabled) - { - ////////////////// One table line /////////////////// - x % 2 ? content += "
Plugin NameEnabled
" : content += "
"; - - content += Plugin_id[x]; - content += ""; - content += Plugin_Description[x]; - content += ""; - content += "().checked; - - ////// advanced settings ////// - Adv_HostName = aux["Adv_HostName"].value; - Adv_HostName.trim(); - Adv_Power = aux["Adv_Power"].value; - Adv_Power.trim(); - - // Radio pins settings - PIN_RF_RX_PMOS = String2GPIO(aux["PIN_RF_RX_PMOS"].value); - PIN_RF_RX_NMOS = String2GPIO(aux["PIN_RF_RX_NMOS"].value); - PIN_RF_RX_VCC = String2GPIO(aux["PIN_RF_RX_VCC"].value); - PIN_RF_RX_GND = String2GPIO(aux["PIN_RF_RX_GND"].value); - PIN_RF_RX_NA = String2GPIO(aux["PIN_RF_RX_NA"].value); - PIN_RF_RX_DATA = String2GPIO(aux["PIN_RF_RX_DATA"].value); - PULLUP_RF_RX_DATA = aux["PULLUP_RF_RX_DATA"].as().checked; - PIN_RF_TX_PMOS = String2GPIO(aux["PIN_RF_TX_PMOS"].value); - PIN_RF_TX_NMOS = String2GPIO(aux["PIN_RF_TX_NMOS"].value); - PIN_RF_TX_VCC = String2GPIO(aux["PIN_RF_TX_VCC"].value); - PIN_RF_TX_GND = String2GPIO(aux["PIN_RF_TX_GND"].value); - PIN_RF_TX_NA = String2GPIO(aux["PIN_RF_TX_NA"].value); - PIN_RF_TX_DATA = String2GPIO(aux["PIN_RF_TX_DATA"].value); -} - -// Load parameters saved with saveParams from SPIFFS into the -// elements defined in /settings JSON. -String loadParams(AutoConnectAux &aux, PageArgument &args) -{ - (void)(args); - //static boolean initConfig = true; - -#ifdef ESP32 - // To prevent error 'SPIFFS: mount failed, -10025', activate formatOnFail option - SPIFFS.begin(true); -#else // ESP32 - LittleFS.begin(); -#endif // ESP32 - - Serial.print("Param "); - Serial.print(PARAM_FILE); - Serial.print(F(" :\t")); - File paramFile = LittleFS.open(PARAM_FILE, "r"); - if (paramFile) - { - if (aux.loadElement(paramFile)) - { - getParams(aux); - Serial.println(F("Loaded")); - } - else - { - Serial.println(F("Failed to load")); - } - paramFile.close(); - } - else - { - Serial.println(F("Failed to open(+r)")); - } - LittleFS.end(); - return String(""); -} - -// Save the value of each element entered by '/settings' to the -// parameter file. The saveParams as below is a callback function of -// /settings_save. When invoking this handler, the input value of each -// element is already stored in '/settings'. -// In Sketch, you can output to stream its elements specified by name. -String saveParams(AutoConnectAux &aux, PageArgument &args) -{ - // The 'where()' function returns the AutoConnectAux that caused - // the transition to this page. - - if (MQTT_PORT == "") - MQTT_PORT = "1883"; // just in case .... - if (MQTT_ID == "") - MQTT_ID = "RFlink-ESP"; // just in case .... - if (MQTT_TOPIC_IN == "") - MQTT_TOPIC_IN = "/RFlink/cmd"; // just in case .... - if (MQTT_TOPIC_OUT == "") - MQTT_TOPIC_OUT = "/RFLink/msg"; // just in case .... - if (Adv_HostName == "") - Adv_HostName = "RFlink-ESP"; // just in case .... - - AutoConnectAux &src_aux = *portal.aux(portal.where()); - getParams(src_aux); - // AutoConnectInput& mqttserver = my_settings["mqttserver"].as(); //-> BUG - // The entered value is owned by AutoConnectAux of /settings. - // To retrieve the elements of /settings, it is necessary to get - // the AutoConnectAux object of /settings. - Serial.print("Param "); - Serial.print(PARAM_FILE); - Serial.print(F(" :\t")); - LittleFS.begin(); - File my_file = LittleFS.open(PARAM_FILE, "w"); - if (my_file) - { - src_aux.saveElement(my_file, {"MQTT_SERVER", "MQTT_PORT", - "MQTT_ID", "MQTT_USER", "MQTT_PSWD", - "MQTT_TOPIC_OUT", "MQTT_TOPIC_IN", "MQTT_RETAINED", - "Adv_HostName", "Adv_Power", - "PIN_RF_RX_PMOS", "PIN_RF_RX_NMOS", - "PIN_RF_RX_VCC", "PIN_RF_RX_GND", - "PIN_RF_RX_NA", "PIN_RF_RX_DATA", "PULLUP_RF_RX_DATA", - "PIN_RF_TX_PMOS", "PIN_RF_TX_NMOS", - "PIN_RF_TX_VCC", "PIN_RF_TX_GND", - "PIN_RF_TX_NA", "PIN_RF_TX_DATA"}); - Serial.println(F("Saved")); - my_file.close(); - } - else - Serial.print(F("Failed to open(+w)")); - LittleFS.end(); - - // Echo back saved parameters to AutoConnectAux page. - AutoConnectText &echo = aux["parameters"].as(); - echo.value = F("MQTT settings"); - echo.value += F("
Connexion"); - echo.value += F("
Server: "); - echo.value += MQTT_SERVER; - echo.value += F("
Port: "); - echo.value += MQTT_PORT; - echo.value += F("
ID: "); - echo.value += MQTT_ID; - echo.value += F("
Username: "); - echo.value += MQTT_USER; - echo.value += F("
Password: "); - echo.value += MQTT_PSWD; - echo.value += F("

Messages"); - echo.value += F("
Out Topic: "); - echo.value += MQTT_TOPIC_OUT; - echo.value += F("
In Topic: "); - echo.value += MQTT_TOPIC_IN; - echo.value += F("
Retained: "); - echo.value += String(MQTT_RETAINED == true ? "true" : "false"); - echo.value += F("

Advanced settings
"); - echo.value += F("
WiFi"); - echo.value += F("
Hostname: "); - echo.value += Adv_HostName; - echo.value += F("
TX Power: "); - echo.value += Adv_Power; - echo.value += F("

GPIO settings
"); - echo.value += F("
Radio Receiver"); - echo.value += F("
RX_PMOS: "); - echo.value += GPIO2String(PIN_RF_RX_PMOS); - echo.value += F("
RX_NMOS: "); - echo.value += GPIO2String(PIN_RF_RX_NMOS); - echo.value += F("
RX_VCC: "); - echo.value += GPIO2String(PIN_RF_RX_VCC); - echo.value += F("
RX_GND: "); - echo.value += GPIO2String(PIN_RF_RX_GND); - echo.value += F("
RX_NA: "); - echo.value += GPIO2String(PIN_RF_RX_NA); - echo.value += F("
RX_DATA: "); - echo.value += GPIO2String(PIN_RF_RX_DATA); - echo.value += F("
Pullup on RX_DATA: "); - echo.value += String(PULLUP_RF_RX_DATA == true ? "true" : "false"); - echo.value += F("

Radio Emitter"); - echo.value += F("
TX_PMOS: "); - echo.value += GPIO2String(PIN_RF_TX_PMOS); - echo.value += F("
TX_NMOS: "); - echo.value += GPIO2String(PIN_RF_TX_NMOS); - echo.value += F("
TX_VCC: "); - echo.value += GPIO2String(PIN_RF_TX_VCC); - echo.value += F("
TX_GND: "); - echo.value += GPIO2String(PIN_RF_TX_GND); - echo.value += F("
TX_NA: "); - echo.value += GPIO2String(PIN_RF_TX_NA); - echo.value += F("
TX_DATA: "); - echo.value += GPIO2String(PIN_RF_TX_DATA); - echo.value += F("
"); - -#ifdef MQTT_ENABLED - setup_MQTT(); // Reload settings -#endif - - return String(""); -} - -#endif // AUTOCONNECT_ENABLE diff --git a/RFLink/9_AutoConnect.h b/RFLink/9_AutoConnect.h deleted file mode 100644 index bf7027e8..00000000 --- a/RFLink/9_AutoConnect.h +++ /dev/null @@ -1,387 +0,0 @@ -// ************************************* // -// * Arduino Project RFLink-esp * // -// * https://github.com/couin3/RFLink * // -// * 2018..2020 Stormteam - Marc RIVES * // -// * More details in RFLink.ino file * // -// ************************************* // - -#ifndef AutoConnect_h -#define AutoConnect_h - -#include -#include "RFLink.h" - -#ifdef AUTOCONNECT_ENABLED - -extern String LastMsg; -extern String CmdMsg; - -#ifdef ESP8266 -#include -#elif ESP32 -#include -#endif // ESP8266 - -#include -#ifdef ESP8266 -#define GET_CHIPID() (ESP.getChipId()) -#elif ESP32 -#define GET_CHIPID() ((uint32_t)ESP.getEfuseMac()) -#endif //ESP8266 - -// --------- These labels can be renamed (Need clean-up before re-build) --------- -// https://hieromon.github.io/AutoConnect/changelabel.html#label-text-replacement-header-file -// AUTOCONNECT_MENULABEL_CONFIGNEW "Configure new AP" -// AUTOCONNECT_MENULABEL_OPENSSIDS "Open SSIDs" -// AUTOCONNECT_MENULABEL_DISCONNECT "Disconnect" -// AUTOCONNECT_MENULABEL_RESET "Reset..." -// AUTOCONNECT_MENULABEL_UPDATE "Update" -// AUTOCONNECT_MENULABEL_HOME "HOME" -// AUTOCONNECT_MENULABEL_DEVINFO "Device info" -// AUTOCONNECT_BUTTONLABEL_RESET "RESET" -// AUTOCONNECT_BUTTONLABEL_UPDATE "UPDATE" - -#ifdef AUTOCONNECT_MENULABEL_CONFIGNEW -#undef AUTOCONNECT_MENULABEL_CONFIGNEW -#define AUTOCONNECT_MENULABEL_CONFIGNEW "Configure Wifi" -#endif - -#ifdef AUTOCONNECT_MENULABEL_RESET -#undef AUTOCONNECT_MENULABEL_RESET -#define AUTOCONNECT_MENULABEL_RESET "Reboot" -#endif - -#ifdef AUTOCONNECT_MENULABEL_OPENSSIDS -#undef AUTOCONNECT_MENULABEL_OPENSSIDS -#define AUTOCONNECT_MENULABEL_OPENSSIDS "Known networks" -#endif - -// Adds MQTT tab to Autoconnect -#define PARAM_FILE "/settings.json" -#define PROTOCOL_FILE "/protocols.json" -#define AUX_SETTING_URI "/settings" -#define AUX_SAVE_URI "/settings_save" -//#define AUX_CLEAR_URI "/settings_clear" - -void setup_AutoConnect(); -void loop_AutoConnect(); - -void rootPage(); -void HandleLastMsg(); - -// JSON definition of AutoConnectAux. -// Multiple AutoConnectAux can be defined in the JSON array. -// In this example, JSON is hard-coded to make it easier to understand -// the AutoConnectAux API. In practice, it will be an external content -// which separated from the sketch, as the mqtt_RSSI_FS example shows. -static const char AUX_settings[] PROGMEM = R"raw( - [ - { - "title": "RFLink settings", - "uri": "/settings", - "menu": true, - "element": [ - { - "name": "style1", - "type": "ACStyle", - "value": "label+input,label+select{position:sticky;left:180px;width:210px!important;box-sizing:border-box;}" - }, - { - "name": "header0", - "type": "ACText", - "value": "

MQTT settings

", - "style": "text-align:center;color:#2f4f4f;padding:10px;" - }, - { - "name": "caption1", - "type": "ACText", - "value": "Connexion", - "style": "font-family:serif;color:#4682b4;" - }, - { - "name": "newline1", - "type": "ACElement", - "value": "
" - }, - { - "name": "MQTT_SERVER", - "type": "ACInput", - "value": "", - "label": "Server", - "pattern": "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])$", - "placeholder": "example : 192.168.0.10" - }, - { - "name": "MQTT_PORT", - "type": "ACInput", - "value": "", - "label": "Port", - "placeholder": "default is 1883" - }, - { - "name": "MQTT_ID", - "type": "ACInput", - "label": "ID", - "placeholder": "example : RFLink-ESP-xx" - }, - { - "name": "MQTT_USER", - "type": "ACInput", - "label": "User" - }, - { - "name": "MQTT_PSWD", - "type": "ACInput", - "label": "Password" - }, - { - "name": "caption2", - "type": "ACText", - "value": "Messages", - "style": "font-family:serif;color:#4682b4;" - }, - { - "name": "newline2", - "type": "ACElement", - "value": "
" - }, - { - "name": "MQTT_TOPIC_OUT", - "type": "ACInput", - "label": "Out Topic", - "pattern": "(.*)[^\/]$", - "placeholder": "example : /RFLink/msg", - "value": "/RFLink/msg" - }, - { - "name": "MQTT_TOPIC_IN", - "type": "ACInput", - "label": "In Topic", - "pattern": "(.*)[^\/]$", - "placeholder": "example : /RFLink/cmd", - "value": "/RFLink/cmd" - }, - { - "name": "MQTT_RETAINED", - "type": "ACCheckbox", - "value": "unique", - "labelPosition" : "AC_Infront", - "post" : "AC_Tag_BR", - "label": "Retained", - "checked": false - }, - { - "name": "newline3", - "type": "ACElement", - "value": "
" - }, - { - "name": "style4", - "type": "ACStyle", - "value": "label+input,label+select{position:sticky;left:180px;width:210px!important;box-sizing:border-box;}" - }, - { - "name": "header4", - "type": "ACText", - "value": "

Advanced settings

", - "style": "text-align:center;color:#2f4f4f;padding:10px;" - }, - { - "name": "caption5", - "type": "ACText", - "value": "Wifi", - "style": "font-family:serif;color:#4682b4;" - }, - { - "name": "newline5", - "type": "ACElement", - "value": "
" - }, - { - "name": "Adv_HostName", - "type": "ACInput", - "value": "RFlink-ESP", - "label": "Hostname" - }, - { - "name": "Adv_Power", - "type": "ACInput", - "label": "TX Power", - "placeholder": "default is 20 (max)" - }, - { - "name": "newline6", - "type": "ACElement", - "value": "
" - }, - { - "name": "style5", - "type": "ACStyle", - "value": "label+input,label+select{position:sticky;left:180px;width:210px!important;box-sizing:border-box;}" - }, - { - "name": "header5", - "type": "ACText", - "value": "

GPIO settings

", - "style": "text-align:center;color:#2f4f4f;padding:10px;" - }, - { - "name": "caption6", - "type": "ACText", - "value": "Radio Receiver", - "style": "font-family:serif;color:#4682b4;" - }, - { - "name": "newline7", - "type": "ACElement", - "value": "
" - }, - { - "name": "PIN_RF_RX_PMOS", - "type": "ACInput", - "label": "RX_PMOS", - "placeholder": "NOT_A_PIN" - }, - { - "name": "PIN_RF_RX_NMOS", - "type": "ACInput", - "label": "RX_NMOS", - "placeholder": "NOT_A_PIN" - }, - { - "name": "PIN_RF_RX_VCC", - "type": "ACInput", - "label": "RX_VCC", - "placeholder": "NOT_A_PIN" - }, - { - "name": "PIN_RF_RX_GND", - "type": "ACInput", - "label": "RX_GND", - "placeholder": "NOT_A_PIN" - }, - { - "name": "PIN_RF_RX_NA", - "type": "ACInput", - "label": "RX_NA", - "placeholder": "NOT_A_PIN" - }, - { - "name": "PIN_RF_RX_DATA", - "type": "ACInput", - "label": "RX_DATA", - "placeholder": "NOT_A_PIN" - }, - { - "name": "PULLUP_RF_RX_DATA", - "type": "ACCheckbox", - "value": "unique", - "labelPosition" : "AC_Infront", - "post" : "AC_Tag_BR", - "label": "Pullup on RX_DATA", - "checked": false - }, - { - "name": "newlineX", - "type": "ACElement", - "value": "
" - }, - { - "name": "caption7", - "type": "ACText", - "value": "Radio Emitter", - "style": "font-family:serif;color:#4682b4;" - }, - { - "name": "newline8", - "type": "ACElement", - "value": "
" - }, - { - "name": "PIN_RF_TX_PMOS", - "type": "ACInput", - "label": "TX_PMOS", - "placeholder": "NOT_A_PIN" - }, - { - "name": "PIN_RF_TX_NMOS", - "type": "ACInput", - "label": "TX_NMOS", - "placeholder": "NOT_A_PIN" - }, - { - "name": "PIN_RF_TX_VCC", - "type": "ACInput", - "label": "TX_VCC", - "placeholder": "NOT_A_PIN" - }, - { - "name": "PIN_RF_TX_GND", - "type": "ACInput", - "label": "TX_GND", - "placeholder": "NOT_A_PIN" - }, - { - "name": "PIN_RF_TX_NA", - "type": "ACInput", - "label": "TX_NA", - "placeholder": "NOT_A_PIN" - }, - { - "name": "PIN_RF_TX_DATA", - "type": "ACInput", - "label": "TX_DATA", - "placeholder": "NOT_A_PIN" - }, - { - "name": "newline9", - "type": "ACElement", - "value": "
" - }, - { - "name": "save", - "type": "ACSubmit", - "value": "Save", - "uri": "/settings_save" - }, - { - "name": "discard", - "type": "ACSubmit", - "value": "Discard", - "uri": "/settings" - } - ] - }, - { - "title": "RFlink ESP settings", - "uri": "/settings_save", - "menu": false, - "element": [ - { - "name": "caption", - "type": "ACText", - "value": "

Saved values

", - "style": "text-align:center;color:#2f4f4f;padding:10px;" - }, - { - "name": "parameters", - "type": "ACText" - }, - { - "name": "newline", - "type": "ACElement", - "value": "
" - }, - { - "name": "clear", - "type": "ACSubmit", - "value": "OK", - "uri": "/settings" - } - ] - } - ] - )raw"; - -#endif // AUTOCONNECT_ENABLED -#endif // AutoConnect_h \ No newline at end of file diff --git a/RFLink/RFLink.h b/RFLink/RFLink.h index b4dbe7b8..0314a86a 100644 --- a/RFLink/RFLink.h +++ b/RFLink/RFLink.h @@ -8,8 +8,8 @@ #ifndef RFLink_h #define RFLink_h -#define BUILDNR 0x04 // 0x07 // shown in version -#define REVNR 0x02 // 0X42 // shown in version and startup string +#define BUILDNR 0x05 // 0x07 // shown in version +#define REVNR 0x01 // 0X42 // shown in version and startup string #define SERIAL_ENABLED // Send RFLink messages over Serial @@ -20,7 +20,6 @@ #define OLED_FLIP true // default false // WIFI -#define AUTOCONNECT_ENABLED #define WIFI_PWR_0 20 // 0~20.5dBm // MQTT messages diff --git a/RFLink/RFLink.ino b/RFLink/RFLink.ino index edf1b737..f10e12b1 100644 --- a/RFLink/RFLink.ino +++ b/RFLink/RFLink.ino @@ -25,7 +25,6 @@ #include "5_Plugin.h" #include "6_WiFi_MQTT.h" #include "8_OLED.h" -#include "9_AutoConnect.h" #if (defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__)) #include @@ -83,25 +82,20 @@ void setup() Serial.print(F("Sketch File :\t\t")); Serial.println(__FILE__); // "RFLink.ino" version is in 20;00 Message Serial.println(F("Compiled on :\t\t" __DATE__ " at " __TIME__)); - -#if (!defined(AUTOCONNECT_ENABLED) && !defined(MQTT_ENABLED)) - setup_WIFI_OFF(); -#endif #endif // ESP32 || ESP8266 -#if (!defined(AUTOCONNECT_ENABLED) && defined(MQTT_ENABLED)) +#ifdef MQTT_ENABLED setup_WIFI(); setup_MQTT(); reconnect(); +#else + setup_WIFI_OFF(); #endif PluginInit(); PluginTXInit(); - -#ifdef AUTOCONNECT_ENABLED - setup_AutoConnect(); -#endif set_Radio_mode(Radio_OFF); + #if ((defined(ESP8266) || defined(ESP32)) && !defined(RFM69_ENABLED)) show_Radio_Pin(); #endif // ESP8266 || ESP32 @@ -134,34 +128,19 @@ void setup() void loop() { -#ifdef AUTOCONNECT_ENABLED - loop_AutoConnect(); - if (WiFi.status() == WL_CONNECTED) - { -#endif #ifdef MQTT_ENABLED - checkMQTTloop(); - sendMsg(); + checkMQTTloop(); + sendMsg(); #endif #ifdef SERIAL_ENABLED #if PIN_RF_TX_DATA_0 != NOT_A_PIN - if (CheckSerial()) - sendMsg(); -#endif -#endif - -#ifdef AUTOCONNECT_ENABLED - if (CheckWeb(CmdMsg)) - sendMsg(); + if (CheckSerial()) + sendMsg(); #endif - - if (ScanEvent()) - sendMsg(); - -#ifdef AUTOCONNECT_ENABLED - } #endif + if (ScanEvent()) + sendMsg(); } void sendMsg() @@ -174,9 +153,6 @@ void sendMsg() #ifdef MQTT_ENABLED publishMsg(); #endif -#ifdef AUTOCONNECT_ENABLED - LastMsg = pbuffer; -#endif #ifdef OLED_ENABLED print_OLED(); #endif diff --git a/platformio.ini b/platformio.ini index 5c0b2a13..17ab2960 100644 --- a/platformio.ini +++ b/platformio.ini @@ -8,7 +8,6 @@ ; Please visit documentation for the other options and examples ; https://docs.platformio.org/page/projectconf.html - [platformio] src_dir = RFLink @@ -16,17 +15,11 @@ src_dir = RFLink framework = arduino monitor_speed = 57600 lib_ldf_mode = chain+ -;build_flags = -DAC_LABELS='"${PROJECT_SRC_DIR}/9_AutoConnect.h"' ; For allowing tabs renaming in AtoConnect menu [common] ESPlibs = PubSubClient -Autoconnectlibs = - Autoconnect - PageBuilder - ArduinoJson - OLEDlibs = Wire U8g2 @@ -35,15 +28,17 @@ OLEDlibs = platform = espressif8266 board = d1_mini upload_speed = 921600 -lib_deps = ${common.ESPlibs} ${common.Autoconnectlibs} ${common.OLEDlibs} -; ESP8266WiFi +lib_deps = ${common.ESPlibs} ${common.OLEDlibs} + ESP8266WiFi +lib_ignore = ;[env:nodemcuv2] ;platform = espressif8266 ;board = nodemcuv2 ;upload_speed = 256000 -;lib_deps = ${common.ESPlibs} ${common.Autoconnectlibs} ${common.OLEDlibs} +;lib_deps = ${common.ESPlibs} ${common.OLEDlibs} ; ESP8266WiFi +;lib_ignore = ;[env:doitESP32] ;platform = espressif32 @@ -53,27 +48,28 @@ lib_deps = ${common.ESPlibs} ${common.Autoconnectlibs} ${common.OLEDlibs} ;board_build.f_flash = 40000000L ;board_build.flash_mode = dio ;upload_speed = 921600 -;lib_deps = ${common.ESPlibs} ${common.Autoconnectlibs} ${common.OLEDlibs} +;lib_deps = ${common.ESPlibs} ${common.OLEDlibs} +;lib_ignore = ;[env:arduino_uno] ;platform = atmelavr ;board = uno ;;board_build.f_cpu = 8000000L ;lib_deps = -;lib_ignore = ${common.ESPlibs} ${common.Autoconnectlibs} ${common.OLEDlibs} +;lib_ignore = ${common.ESPlibs} ${common.OLEDlibs} ;[env:arduino_nano] ;platform = atmelavr ;board = nanoatmega328 ;;board_build.f_cpu = 8000000L -;lib_ignore = ${common.ESPlibs} ${common.Autoconnectlibs} ${common.OLEDlibs} +;lib_ignore = ${common.ESPlibs} ${common.OLEDlibs} ;[env:arduino_promini8] ;platform = atmelavr ;board = pro8MHzatmega328 -;lib_ignore = ${common.ESPlibs} ${common.Autoconnectlibs} ${common.OLEDlibs} +;lib_ignore = ${common.ESPlibs} ${common.OLEDlibs} ;[env:arduino_mega] ;platform = atmelavr ;board = megaatmega2560 -;lib_ignore = ${common.ESPlibs} ${common.Autoconnectlibs} ${common.OLEDlibs} +;lib_ignore = ${common.ESPlibs} ${common.OLEDlibs}