diff --git a/RFLink/3_Serial.cpp b/RFLink/3_Serial.cpp index f3dc6c28..bea38ea6 100644 --- a/RFLink/3_Serial.cpp +++ b/RFLink/3_Serial.cpp @@ -1,4 +1,4 @@ -/// ************************************* // +// ************************************* // // * Arduino Project RFLink-esp * // // * https://github.com/couin3/RFLink * // // * 2018..2020 Stormteam - Marc RIVES * // @@ -34,9 +34,9 @@ boolean CheckSerial() return false; } -boolean CheckMQTT(byte *mqtt_in) +boolean CheckMQTT(byte *byte_in) { - if (CopySerial((char *)mqtt_in)) + if (CopySerial((char *)byte_in)) { #ifdef SERIAL_ENABLED Serial.flush(); @@ -49,6 +49,34 @@ boolean CheckMQTT(byte *mqtt_in) return false; } +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; +} + 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 e74b0937..0da984a1 100644 --- a/RFLink/3_Serial.h +++ b/RFLink/3_Serial.h @@ -18,5 +18,6 @@ extern char InputBuffer_Serial[INPUT_COMMAND_SIZE]; boolean CheckSerial(); boolean CheckMQTT(byte *); +boolean CheckWeb(String &); #endif \ No newline at end of file diff --git a/RFLink/6_WiFi_MQTT.h b/RFLink/6_WiFi_MQTT.h index 50bb5e9c..105daab5 100644 --- a/RFLink/6_WiFi_MQTT.h +++ b/RFLink/6_WiFi_MQTT.h @@ -22,7 +22,6 @@ extern String MQTT_TOPIC_IN; extern boolean MQTT_RETAINED; extern String Adv_HostName; extern String Adv_Power; -extern String LastMsg; #else #ifdef ESP32 #include diff --git a/RFLink/9_AutoConnect.cpp b/RFLink/9_AutoConnect.cpp index 9156c210..83b90dcb 100644 --- a/RFLink/9_AutoConnect.cpp +++ b/RFLink/9_AutoConnect.cpp @@ -2,6 +2,8 @@ // * 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 * // // ************************************* // @@ -43,6 +45,7 @@ boolean MQTT_RETAINED; 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; @@ -65,6 +68,13 @@ 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")) { // On n'enregistre les values que si ce n'est pas le bouton "test" qui a été appuyé @@ -199,13 +209,25 @@ void rootPage() //========================================== content += " "; 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 Header // é = é content += ""; // Table content content += ""; for (byte x = 0; x < PLUGIN_MAX; x++) @@ -236,7 +258,7 @@ void rootPage() content += ""; // we add a last line to bottom of the table content += "
NameEnabled
Plugin NameEnabled
"; - content += ""; + content += ""; content += ""; content += ""; diff --git a/RFLink/9_AutoConnect.h b/RFLink/9_AutoConnect.h index 1ca2bb9d..d92883f2 100644 --- a/RFLink/9_AutoConnect.h +++ b/RFLink/9_AutoConnect.h @@ -13,6 +13,9 @@ #ifdef AUTOCONNECT_ENABLED +extern String LastMsg; +extern String CmdMsg; + #ifdef ESP8266 #include #elif ESP32 diff --git a/RFLink/RFLink.ino b/RFLink/RFLink.ino index 1e1985fc..421b4bd1 100644 --- a/RFLink/RFLink.ino +++ b/RFLink/RFLink.ino @@ -129,6 +129,11 @@ void loop() sendMsg(); #endif +#ifdef AUTOCONNECT_ENABLED + if(CheckWeb(CmdMsg)) + sendMsg(); +#endif + if (ScanEvent()) sendMsg();