|
ESP_IOT v2.5
IOT ESP Coding
|
#include "../../Defines.h"#include <libb64/cdecode.h>#include "SMARTButton.h"#include "MQTTNetworking.h"#include "OTAImageUpdate.h"#include <ArduinoJson.h>#include <Preferences.h>#include <WiFi.h>#include <PubSubClient.h>#include "FS.h"#include "SPIFFS.h"
Go to the source code of this file.
Macros | |
| #define | DECODE_BASE64 |
| #define | ESP_EPROM_NAME "ESP32" |
| 9.27.23 to decode a base64 string (a Semantic Marker) More... | |
| #define | MAXglobalMQTTAttempts 10 |
| #define | MAX_MQTT_ATTEMPTS 10 |
| #define | MAX_WIFI_CONNECT_ATTEMPTS 30 |
| #define | OTA "#OTA" |
| #define | STATUS "#STATUS" |
| #define | REMOTEME "#remoteMe" |
| #define | REMOTE2 "#REMOTE" |
| #define | FEED "#FEED" |
| #define | FEED_2 "#feedme" |
| #define | ACK_FEED "#actMe" |
| #define | ACK_FEED2 "#ackMe" |
| #define | CONNECTED "#connectedMe" |
| #define | NOT_CONNECTED "#noconnectedMe" |
| #define | NO_ACK_FEED "#noactMe" |
| #define | PLAY_ME "#playMe" |
| #define | DOCFOLLOW "#docFollow" |
| #define | DOCFOLLOW2 "#DOCFOLLOW" |
| #define | DOCSYNC "#docSync" |
| #define | NO_CAN "#NO_CAN" |
| #define | FOLLOW_ME "#followMe" |
| #define | MAX_MESSAGE 1024 |
| #define | MAX_MESSAGE_DOCFOLLOW 300 |
| #define | _preferencesJSONName "JSONPrefs" |
| Points to strings read from JSON (limited to 15 char key name) More... | |
| #define | TRY_MORE_ASYNC_PROCESSING |
| #define | TRY_READING_BACK |
| #define | WIFI_MQTT_STATES |
| 4.26.22 50 year anniverssery of Grateful Dead in Frankfurt 1972 More... | |
| #define | USE_TIMER_DELAY_CLASS |
| #define | SINGLE_DELAY |
| a call to see if the WIFI is connected More... | |
| #define | TRY_GROUP |
| #define | ACK_FOR_PAIR_TOO |
| #define | TRY_MORE_URL |
| #define | USE_WITHOUT_DEVICE_NAME |
| #define | NO_NEED_AND_GRU_CRASH |
Enumerations | |
| enum | WIFI_MQTTStates { preSetupWIFI , waitingForWIFI , preSetupMQTT , waitingForMQTT , connectedWIFI , connectedMQTT , disconnectedWIFI , disconnectedMQTT } |
| state variables More... | |
| enum | MQTTMessageTopicType { userTopic , dawgpackTopic , superTopic , groupTopic } |
| break up the MQTT Handler 8.12.22 as per "My guess is that you have your data collection (from some I2C device) and data delivery intermingled. Separate them so that you have the data in hand before you make the network connection. That will reduce the possibility of timeouts and race conditions. It also makes it easier to add new collection and delivery processes. The more asynchronous you can make these steps, the more robust your application will be overall." More... | |
Functions | |
| void | updatePreferencesInEPROM () |
| just update the EPROM, and send that to the WIFI_AP module as well More... | |
| void | setupWIFI (char *arg_ssid, char *arg_password) |
| setup the WIFI using ssid and password More... | |
| void | processBarkletMessage (String message, String topic) |
| process an MQTT message looking for keywords (barklet language) More... | |
| void | setupMQTT (char *mqttServerString, char *mqttPortString, char *mqttPasswordString, char *mqttUserString, char *deviceNameString, char *uuidString) |
| setup the MQTT server More... | |
| boolean | processJSONMessageMQTT (char *ascii, char *topic) |
| process the JSON message (looking for FEED, etc). Note: topic can be nil, or if not, it's an MQTT topic (so send replies if you want) More... | |
| void | checkMQTTMessages_loop () |
| check for MQTT messages, called from the main loop() More... | |
| void | blinkBlueLightMQTT () |
| blinks the blue light More... | |
| void | callPreSetupMQTT () |
| called to setup the MQTT (which is really the _mqttClient setup). Done on it's own thread.. More... | |
| void | MQTTModule_readPreferences () |
| setup the WIFI More... | |
| PubSubClient | _mqttClient (_espClient) |
| The PubSub MQTT Client. More... | |
| String | MQTT_urlDecode (String input) |
| Decode the URL (copied from WIFI_APModule. Easier than breaking modules) More... | |
| void | performOTAUpdateMethod () |
| perform the OTA update. This calls the OTAImageUpdate methods (via preformOTAUpdateSimple()) More... | |
| void | cleanSSID_EPROM_Method () |
| calls the method for cleaning the SSID eprom. This calls the WIFI_APModule callback More... | |
| void | performFeedMethod (char *topic) |
| calls the FEED message via the callback (which calls the BLE code) More... | |
| char * | shortVersion () |
| return a short version of VERSION More... | |
| void | initShortVersion () |
| init short version More... | |
| int | getUptime () |
| returns seconds since first booted More... | |
| boolean | skipMessageProcessing () |
| this is sent from the backend as a message {'guest':'guest password'} .. but lets' add to the credentials.. More... | |
| void | publishMQTTMessage (char *topic, char *message) |
| Wrapper of the mqttclient publish. NOTE: this might need to be in the loop as well, as the BLE could be the way the message arrived, and we are sending out over MQTT (while in the BLE thread). Don't know?? More... | |
| void | publishMQTTMessageDefaultTopic (char *message) |
| Wrapper of the mqttclient publish. More... | |
| void | publishSMRunMessage (char *smrunMessage) |
| void | publishBinaryFile (char *topic, uint8_t *buf, size_t len, String fileExtension) |
| void | publishSPIFFFile_MQTT (char *topic, char *path, int len) |
| String | getJSONConfigString () |
| retrieve the Configuration JSON string in JSON format.. More... | |
| char * | getDeviceNameMQTT () |
| called for things like the advertisement More... | |
| void | getChipInfo () |
| create a unique ID (but it needs to be stored.. otherwise it's unique each time?? More... | |
| const char * | getDynamicStatusFunc () |
| char * | getLastDocFollowSemanticMarker_MQTTNetworking () |
| void | setLastDocFollowSemanticMarker_MQTTNetworking (char *semanticMarker) |
| sets the last DocFollow SemanticMarker More... | |
| void | initAllArrayStorage () |
| Put all the storage initialization here.. More... | |
| void | setLastMessageStatus (char *token) |
| void | emptyLastMessageStatus () |
| empty the status message More... | |
| char * | currentMessageStatusURL () |
| returns a string in in URL so: status?battery=84'&buzzon='off' } .. etc More... | |
| const char * | getDynamicMessageFunc () |
| used by the displayModule to call this for each new status More... | |
| void | setupWIFI_loop () |
| the loop part of WIFI More... | |
| void | finishWIFI_Setup () |
| end of WIFI loop.. More... | |
| void | reconnectMQTT_loop () |
| void | startDelay_WIFI_MQTTState () |
| boolean | delayFinished_WIFI_MQTTState () |
| void | stopDelay_WIFI_MQTTState () |
| void | sendSpiffStatus () |
| void | setup_MQTTNetworking () |
| setup the MQTT part of networking More... | |
| boolean | isConnectedWIFI_MQTTState () |
| value of WIFI connected More... | |
| boolean | isConnectedMQTT_MQTTState () |
| value of MQTT connected More... | |
| void | loop_MQTTNetworking () |
| called for the loop() of this plugin More... | |
| char * | wifiStatus_MQTT () |
| show the status in string form (from Library/Adruino... WiFiType.h) More... | |
| void | startDelayCheckWIFI_MQTTNetworking (int seconds) |
| init the delay More... | |
| int | getDelayCheckWIFISeconds_MQTTNetworking () |
| get the delay values More... | |
| void | restartDelayCheckWIFI_MQTTNetworking () |
| starts the delay for WIFI checking, called at startup, and each time the timer finished.. More... | |
| boolean | delayCheckWIFIFinished_MQTTNetworking () |
| if finished.. More... | |
| void | stopDelayCheckWIFI_MQTTNetworking () |
| stop the delay (not called) More... | |
| void | checkDelaySinceWIFICheck_MQTTNetworking () |
| checks delay for the WIFI connectivity More... | |
| void | checkAndReconnectWIFI_MQTTNetworking () |
| print a SPIFF timestamp.. More... | |
| String | get_WIFIInfoString () |
| retrieve the WIFIInfoString More... | |
| String | get_WIFI_SSID () |
| 3.22.24 get the WIFI SSID for the status More... | |
| void | printWIFIInfo () |
| print the WIFI info More... | |
| boolean | isDawgpackTopic () |
| helper to know it's a dawgpack topic (and not process in most cases). Only support DOCFOLLOW for now.. More... | |
| boolean | isSuperTopic () |
| helper to know it's a superuser topic (and not process in most cases). More... | |
| boolean | isGroupTopic () |
| helper to know it's a superuser topic (and not process in most cases). More... | |
| void | classifyTopic (char *topic) |
| classify a topic More... | |
| void | printTopicType () |
| prints the topic on debug More... | |
| void | callbackMQTTHandler (char *topic, byte *payload, unsigned int length) |
| called when data on the MQTT socket More... | |
| bool | stringMatch (String message, String substring) |
| check if the string matches More... | |
| boolean | bluetoothOnline () |
| ! should be a definition that the bluetooth is ONLINE More... | |
| void | cleanEPROM_MQTTNetworking () |
| cleans the eprom info More... | |
| void | sendMessageMQTT (char *message) |
| void | sendMessageMQTT_Topic (char *message, char *topic) |
| for now only send if it start message starts with "#" More... | |
| void | sendMessageNoChangeMQTT_Topic (char *message, char *topic) |
| just send a message but without any extras More... | |
| void | sendMessageNoChangeMQTT (char *message) |
| just send a message but without any extras More... | |
| void | sendStatusMessageMQTT_deviceName (char *deviceName, const char *semanticMarker) |
| sends the semantic marker as a doc follow message #remoteMe (vs STATUS, as that triggers a status reply.. ) More... | |
| void | sendStatusMessageMQTT (const char *semanticMarker) |
| sends the semantic marker as a doc follow message #remoteMe (vs STATUS, as that triggers a status reply.. ) More... | |
| void | sendDocFollowMessageMQTT (const char *semanticMarker) |
| sends the semantic marker as a doc follow message More... | |
| boolean | isTrueString (String valCmdString) |
| whether the string is TRUE, ON, 1 More... | |
| void | invokeCurrentSMModePage (char *topic) |
| send message to ourself to change to current specifed SM Mode More... | |
| void | restartWIFI_MQTTState () |
| restart the WIFI and then MQTT connection More... | |
| void | cleanMQTTpasswordsUpdateInEPROM () |
| 9.18.23 LA (after Eagle Rock bike ride, Van Morrison tomorrow) More... | |
Variables | |
| Preferences | _preferencesMQTTNetworking |
| 8.16.25 MQTT More... | |
| int | _globalMQTTAttempts = 0 |
| int | _startTimestamp = 0 |
| uptime since last reboot. More... | |
| WiFiClient | _espClient |
| The WIFI client. More... | |
| int | _counterLoop |
| CONNECTION counters. More... | |
| int | _maxCounterLoop |
| char | _shortVersion [30] |
| the short version More... | |
| const char * | _ntpServer = "pool.ntp.org" |
| define here as well.. NOTE: this could be passed is as well... TODO More... | |
| boolean | _MQTTRunning = false |
| char | _fullMessageIn [MAX_MESSAGE] |
| message received on subscription More... | |
| char | _fullMessageOut [MAX_MESSAGE] |
| message to send out More... | |
| char | _semanticMarkerString [MAX_MESSAGE] |
| char | _lastGroupTopic [100] |
| saves the group topic .. to write back on .. More... | |
| char * | _ssidString |
| char * | _ssidPasswordString |
| char * | _mqttServerString |
| char * | _mqttPortString |
| char * | _mqttPasswordString |
| char * | _mqttGuestPasswordString |
| char * | _mqttUserString |
| char * | _mqttTopicString |
| char * | _deviceNameString |
| char * | _uuidString |
| char * | _jsonVersionString |
| char * | _jsonHeaderString |
| char * | _jsonLocationString |
| boolean | _newMQTTMessageArrived = false |
| String | _topic |
| the topic the new message came in on.. More... | |
| String | _fullJSONString |
| storage for the full JSON message string to send around.. More... | |
| char | _chipName [100] |
| char | _lastDocFollowSemanticMarker [MAX_MESSAGE_DOCFOLLOW] |
| storage for last doc follow semantic marker More... | |
| int | _countSinceLastChangedMessageStatus = 0 |
| a counter to erase the last message if not changed in N calls.. More... | |
| char | _lastMessageStatusURL [MAX_MESSAGE_DOCFOLLOW] |
| storage of the last message status More... | |
| WIFI_MQTTStates | _WIFI_MQTTState = preSetupWIFI |
| the state we are in.. More... | |
| float | _WIFI_MQTTStateDelays [] |
| the delay in seconds for each state More... | |
| TimerDelayClass * | _timerDelayClass_WIFI_MQTTState = new TimerDelayClass(1.0) |
| 3.29.25 RaiiiinIeeeeR Beer movie More... | |
| boolean | _setupMQTTNetworkingAlready = false |
| try a flag so setupMQTTnetworking only called 1 times.. More... | |
| unsigned long | _delayCheckWIFIStart_MQTTNetworking |
| the time the delay started More... | |
| boolean | _delayCheckWIFIRunning_MQTTNetworking = false |
| true if still waiting for delayCheckWIFI to finish More... | |
| int | _delayCheckWIFISeconds_MQTTNetworking |
| length of delay More... | |
| enum MQTTMessageTopicType | _MQTTMessageTopicType = userTopic |
| #define _preferencesJSONName "JSONPrefs" |
Points to strings read from JSON (limited to 15 char key name)
Definition at line 248 of file MQTTNetworking.cpp.
| #define ACK_FEED "#actMe" |
Definition at line 146 of file MQTTNetworking.cpp.
| #define ACK_FEED2 "#ackMe" |
Definition at line 147 of file MQTTNetworking.cpp.
| #define ACK_FOR_PAIR_TOO |
| #define CONNECTED "#connectedMe" |
Definition at line 148 of file MQTTNetworking.cpp.
| #define DECODE_BASE64 |
MQTTModule The MQTT + WIFI part
Created: on Jan 1, 2022 Author: Scott Moody test..
Definition at line 21 of file MQTTNetworking.cpp.
| #define DOCFOLLOW "#docFollow" |
Definition at line 152 of file MQTTNetworking.cpp.
| #define DOCFOLLOW2 "#DOCFOLLOW" |
Definition at line 153 of file MQTTNetworking.cpp.
| #define DOCSYNC "#docSync" |
Definition at line 154 of file MQTTNetworking.cpp.
| #define ESP_EPROM_NAME "ESP32" |
9.27.23 to decode a base64 string (a Semantic Marker)
Definition at line 57 of file MQTTNetworking.cpp.
| #define FEED "#FEED" |
Definition at line 144 of file MQTTNetworking.cpp.
| #define FEED_2 "#feedme" |
Definition at line 145 of file MQTTNetworking.cpp.
| #define FOLLOW_ME "#followMe" |
DOCFOLLOW syntax 8.11.22 syntax: #followMe {AVM=<avm address>} .. no quotes
Definition at line 158 of file MQTTNetworking.cpp.
| #define MAX_MESSAGE 1024 |
Definition at line 227 of file MQTTNetworking.cpp.
| #define MAX_MESSAGE_DOCFOLLOW 300 |
Definition at line 234 of file MQTTNetworking.cpp.
| #define MAX_MQTT_ATTEMPTS 10 |
Definition at line 101 of file MQTTNetworking.cpp.
| #define MAX_WIFI_CONNECT_ATTEMPTS 30 |
Definition at line 104 of file MQTTNetworking.cpp.
| #define MAXglobalMQTTAttempts 10 |
Definition at line 99 of file MQTTNetworking.cpp.
| #define NO_ACK_FEED "#noactMe" |
Definition at line 150 of file MQTTNetworking.cpp.
| #define NO_CAN "#NO_CAN" |
Definition at line 155 of file MQTTNetworking.cpp.
| #define NO_NEED_AND_GRU_CRASH |
| #define NOT_CONNECTED "#noconnectedMe" |
Definition at line 149 of file MQTTNetworking.cpp.
| #define OTA "#OTA" |
Definition at line 138 of file MQTTNetworking.cpp.
| #define PLAY_ME "#playMe" |
Definition at line 151 of file MQTTNetworking.cpp.
| #define REMOTE2 "#REMOTE" |
Definition at line 143 of file MQTTNetworking.cpp.
| #define REMOTEME "#remoteMe" |
Definition at line 142 of file MQTTNetworking.cpp.
| #define SINGLE_DELAY |
a call to see if the WIFI is connected
Definition at line 1133 of file MQTTNetworking.cpp.
| #define STATUS "#STATUS" |
Definition at line 140 of file MQTTNetworking.cpp.
| #define TRY_GROUP |
| #define TRY_MORE_ASYNC_PROCESSING |
the publishMQTTMessage is placed here as a placeholder for making the mqtt publish. If needed, this could be moved to another thread (or the next loop)
Definition at line 296 of file MQTTNetworking.cpp.
| #define TRY_MORE_URL |
| #define TRY_READING_BACK |
| #define USE_TIMER_DELAY_CLASS |
Definition at line 870 of file MQTTNetworking.cpp.
| #define USE_WITHOUT_DEVICE_NAME |
| #define WIFI_MQTT_STATES |
4.26.22 50 year anniverssery of Grateful Dead in Frankfurt 1972
Definition at line 823 of file MQTTNetworking.cpp.
| enum MQTTMessageTopicType |
break up the MQTT Handler 8.12.22 as per "My guess is that you have your data collection (from some I2C device) and data delivery intermingled. Separate them so that you have the data in hand before you make the network connection. That will reduce the possibility of timeouts and race conditions. It also makes it easier to add new collection and delivery processes. The more asynchronous you can make these steps, the more robust your application will be overall."
add globals for knowing the type of message. call the check message processing state variables
| Enumerator | |
|---|---|
| userTopic | |
| dawgpackTopic | |
| superTopic | |
| groupTopic | |
Definition at line 1557 of file MQTTNetworking.cpp.
| enum WIFI_MQTTStates |
state variables
| Enumerator | |
|---|---|
| preSetupWIFI | |
| waitingForWIFI | |
| preSetupMQTT | |
| waitingForMQTT | |
| connectedWIFI | |
| connectedMQTT | |
| disconnectedWIFI | |
| disconnectedMQTT | |
Definition at line 835 of file MQTTNetworking.cpp.
| PubSubClient _mqttClient | ( | _espClient | ) |
The PubSub MQTT Client.
8.17.25 for use by others, like RTSP return the WiFi Client

| void blinkBlueLightMQTT | ( | ) |
blinks the blue light
https://www.arduino.cc/en/Tutorial/Foundations/DigitalPins
Definition at line 1284 of file MQTTNetworking.cpp.


| boolean bluetoothOnline | ( | ) |
! should be a definition that the bluetooth is ONLINE
Definition at line 2044 of file MQTTNetworking.cpp.

| void callbackMQTTHandler | ( | char * | topic, |
| byte * | payload, | ||
| unsigned int | length | ||
| ) |
called when data on the MQTT socket
too many printouts which actully slows things down.. start with actMe (or collect a count of #actme and report that??)
classify the topic type
7.26.23 don't process if a group message and FLAG not set
called to set a preference (which will be an identifier and a string, which can be converted to a number or boolean)
8.2.24 support the not receiving message on some topics (such as a users GuestTopic) Idea would be some devices won't listen to the guest topic (instead only the user safe ones)
1.14.24 https://github.com/konacurrents/ESP_IOT/issues/297 Only lets group messages for specific messages. For now, lets have a method() that
NOTE: This assumes the callbackMQTTHandler is only called once per message processed, as the next time in the loop(), it processes this _fullMessage since the _newMQTTMessageArrived == true
Definition at line 1633 of file MQTTNetworking.cpp.


| void callPreSetupMQTT | ( | ) |
called to setup the MQTT (which is really the _mqttClient setup). Done on it's own thread..
Definition at line 1534 of file MQTTNetworking.cpp.


| void checkAndReconnectWIFI_MQTTNetworking | ( | ) |
print a SPIFF timestamp..
checks if the WIFI is off (or not reachable) and tries consecting again (the 'W' command)
The setup() will call restartDelay_MQTTNetworking Each loop will call checkDelaySinceButtonTouched_MQTTNetworking checks if the WIFI is off (or not reachable) and tries consecting again (the 'W' command)
start outputing SPIFF info
it seems the WIFI can reconnect – but all the MQTT isn't restarted.. So if our internal state things WIFI is off, reconnect anyway..
try reconnecting if not connected (and ssid is available)
start outputing SPIFF info
restart the WIFI and then MQTT connection
Definition at line 1206 of file MQTTNetworking.cpp.


| void checkDelaySinceWIFICheck_MQTTNetworking | ( | ) |
checks delay for the WIFI connectivity
check and reconnect to the WIFI is not connected
restart the timer
Definition at line 1188 of file MQTTNetworking.cpp.


| void checkMQTTMessages_loop | ( | ) |
check for MQTT messages, called from the main loop()
don't do the loop at same time as check, do it at another time..
save some part of this message for later display by SemanticMarker 8.4.22
11.7.22 if it's an #actMe .. don't show
call the MQTT infrastructure loop which does it's MQTT messaging
Definition at line 2009 of file MQTTNetworking.cpp.


| void classifyTopic | ( | char * | topic | ) |
classify a topic
set the topic type
Definition at line 1586 of file MQTTNetworking.cpp.


| void cleanEPROM_MQTTNetworking | ( | ) |
cleans the eprom info
Definition at line 2050 of file MQTTNetworking.cpp.

| void cleanMQTTpasswordsUpdateInEPROM | ( | ) |
9.18.23 LA (after Eagle Rock bike ride, Van Morrison tomorrow)
now update the eprom with these null values
Definition at line 5211 of file MQTTNetworking.cpp.


| void cleanSSID_EPROM_Method | ( | ) |
calls the method for cleaning the SSID eprom. This calls the WIFI_APModule callback
call the callback for cleaning the SSID eprom..
Definition at line 2685 of file MQTTNetworking.cpp.


| char * currentMessageStatusURL | ( | ) |
returns a string in in URL so: status?battery=84'&buzzon='off' } .. etc
increment the count
Definition at line 793 of file MQTTNetworking.cpp.


| boolean delayCheckWIFIFinished_MQTTNetworking | ( | ) |
if finished..
Definition at line 1167 of file MQTTNetworking.cpp.


| boolean delayFinished_WIFI_MQTTState | ( | ) |
Definition at line 881 of file MQTTNetworking.cpp.


| void emptyLastMessageStatus | ( | ) |
empty the status message
Definition at line 786 of file MQTTNetworking.cpp.


| void finishWIFI_Setup | ( | ) |
end of WIFI loop..
Definition at line 1494 of file MQTTNetworking.cpp.


| String get_WIFI_SSID | ( | ) |
3.22.24 get the WIFI SSID for the status
Definition at line 1472 of file MQTTNetworking.cpp.

| String get_WIFIInfoString | ( | ) |
retrieve the WIFIInfoString
Definition at line 1463 of file MQTTNetworking.cpp.
| void getChipInfo | ( | ) |
create a unique ID (but it needs to be stored.. otherwise it's unique each time??
get the chip info
Definition at line 681 of file MQTTNetworking.cpp.


| int getDelayCheckWIFISeconds_MQTTNetworking | ( | ) |
get the delay values
Definition at line 1154 of file MQTTNetworking.cpp.

| char * getDeviceNameMQTT | ( | ) |
called for things like the advertisement
NOTE: The following are only called from MainModule or ESP_IOT.ino (basically main)
callback with the message if required (like sending the FEED message) !function pointers: https://www.cprogramming.com/tutorial/function-pointers.html define as: void callback(char* message) call processMessage(message, &callback);
5.3.25 notset for somereason ..
Definition at line 663 of file MQTTNetworking.cpp.


| const char * getDynamicMessageFunc | ( | ) |
used by the displayModule to call this for each new status
Definition at line 807 of file MQTTNetworking.cpp.


| const char * getDynamicStatusFunc | ( | ) |
This uses the String (*getStatusFunc)(void)) to re-create this.. used by the displayModule to call this for each new status
Definition at line 708 of file MQTTNetworking.cpp.


| String getJSONConfigString | ( | ) |
retrieve the Configuration JSON string in JSON format..
9.16.23 some debug information retrieve the Configuration JSON string in JSON format..
NEW: 2.21.22 TRY: reading back..
check ... _fullMessageOut Close the Preferences
Definition at line 637 of file MQTTNetworking.cpp.

| char * getLastDocFollowSemanticMarker_MQTTNetworking | ( | ) |
retrieves the last DocFollow SemanticMarker (from the message DOCFOLLOW | #followMe {AVM=<SM>} Or the JSON: {'set':'semanticMarker','val','<URL>}
Definition at line 731 of file MQTTNetworking.cpp.

| int getUptime | ( | ) |
returns seconds since first booted
Definition at line 207 of file MQTTNetworking.cpp.


| void initAllArrayStorage | ( | ) |
Put all the storage initialization here..
3.22.24 add the short version
Definition at line 748 of file MQTTNetworking.cpp.


| void initShortVersion | ( | ) |
init short version
Definition at line 198 of file MQTTNetworking.cpp.

| void invokeCurrentSMModePage | ( | char * | topic | ) |
send message to ourself to change to current specifed SM Mode
send message to ourself to process the current mode..
Definition at line 3212 of file MQTTNetworking.cpp.


| boolean isConnectedMQTT_MQTTState | ( | ) |
value of MQTT connected
Definition at line 1046 of file MQTTNetworking.cpp.

| boolean isConnectedWIFI_MQTTState | ( | ) |
value of WIFI connected
Definition at line 1032 of file MQTTNetworking.cpp.


| boolean isDawgpackTopic | ( | ) |
helper to know it's a dawgpack topic (and not process in most cases). Only support DOCFOLLOW for now..
Definition at line 1571 of file MQTTNetworking.cpp.

| boolean isGroupTopic | ( | ) |
helper to know it's a superuser topic (and not process in most cases).
Definition at line 1581 of file MQTTNetworking.cpp.

| boolean isSuperTopic | ( | ) |
helper to know it's a superuser topic (and not process in most cases).
Definition at line 1576 of file MQTTNetworking.cpp.

| boolean isTrueString | ( | String | valCmdString | ) |
whether the string is TRUE, ON, 1
Definition at line 3195 of file MQTTNetworking.cpp.

| void loop_MQTTNetworking | ( | ) |
called for the loop() of this plugin
State: 0 .
waitingForWIFI (delaying when Nice writeup: https://microcontrollerslab.com/esp32-mqtt-publish-multiple-sensor-readings-node-red/
called for the loop() of this plugin
check if should try to reconnect to WIF
check if a delay was running.. for the STATE..
Definition at line 1058 of file MQTTNetworking.cpp.


| String MQTT_urlDecode | ( | String | input | ) |
Decode the URL (copied from WIFI_APModule. Easier than breaking modules)
Decode the URL (exposed 12.17.23 for the scanner.
Decode the URL
Definition at line 5297 of file MQTTNetworking.cpp.

| void MQTTModule_readPreferences | ( | ) |
setup the WIFI
*********************** END METHODS invoked from BLE (JSON) and MQTT messages ***************
read any values from EPROM
This is in case corruption when changing what's written.. defining BOOTSTRAP will clean up the EPROM read the eprom..
seems the JSON object only returns these const char*, and not easy to just create a char *, so they are created in their own memory..
the MQTT host/port/user/password (topic is created in this code...)
Note: This is where the code could look for backward compatability, etc..
sets the MQTT user/password. It's up to the code to decide who needs to know (currently saves in the WIFI_APModule
Definition at line 2852 of file MQTTNetworking.cpp.


| void performFeedMethod | ( | char * | topic | ) |
calls the FEED message via the callback (which calls the BLE code)
//!calls the FEED message via the callback (which calls the BLE code) NOTE: this will send a BLE command if connected via the GATEWAY to a GEN3 (or other gateway in the future) NOTE: This sends the _full message on the topic ..
get the temperature
get the connected status save some part of this message for later display by SemanticMarker 8.4.22 set the feed
2.21.25 add a way to change the button color (if any)
8.16.25 BLE CLIENT
7.20.25 https://stackoverflow.com/questions/7352099/stdstring-to-char
FOR NOW , copy the code and create a _fullMessageOut that is for the Paired device...
5.21.22 WORKS!! topic is the topic we can in on.. so could be super user..
7.15.23 anniversery of 1799 finding Rosetta Stone in Egypt
output the main #actMe message .. but it get's nothing from the plugins - like ATOM status
close the JSON message
5.21.22 WORKS!! topic is the topic we can in on.. so could be super user..
7.15.23 anniversery of 1799 finding Rosetta Stone in Egypt
Definition at line 2694 of file MQTTNetworking.cpp.


| void performOTAUpdateMethod | ( | ) |
perform the OTA update. This calls the OTAImageUpdate methods (via preformOTAUpdateSimple())
*********************** METHODS invoked from BLE (JSON) and MQTT messages ***************
perform the OTA update. This calls the OTAImageUpdate methods (via preformOTAUpdateSimple())
dispatches a call to the command specified. This is run on the next loop()
Definition at line 2662 of file MQTTNetworking.cpp.


| void printTopicType | ( | ) |
prints the topic on debug
Definition at line 1604 of file MQTTNetworking.cpp.
| void printWIFIInfo | ( | ) |
print the WIFI info
Definition at line 1478 of file MQTTNetworking.cpp.

| void processBarkletMessage | ( | String | message, |
| String | topic | ||
| ) |
process an MQTT message looking for keywords (barklet language)
process an MQTT message looking for keywords (this version uses the Barklet Language Grammer 2014) NOTE: The processJSONMessage() is part of this (called if straight JSON). TODO: merge these two methods..
https://stackoverflow.com/questions/7352099/stdstring-to-char
convert String to char *
flag to send the message back on MQTT
debug printout..
new 4.12.22 if this is straight JSON .. then sent to the processJSONmessage
If the dawgpack, only process the DOCFOLLOW message
note: these messages are sent to MQTT. But the messages comming down originated on WebSocket barklets language so the 'remoteMe ..." gets up there, but not back to the rest. It's rewritten by nodered. save some part of this message for later display by SemanticMarker 8.4.22 set the status 8.16.25 BLE CLIENT process the pair if match FOR NOW , copy the code and create a _fullMessageOut that is for the Paired device... 8.16.25 BLE SERVER retrieve the service name (PTFEEDER, PTFeeder:Name, PTClicker:Name, etc) 5.21.22 WORKS!! topic is the topic we can in on.. so could be super user.. 8.16.25 BLE SERVER retrieve the service name (PTFEEDER, PTFeeder:Name, PTClicker:Name, etc) 'chipid':'%s' 'ssid':'%s' last %s OOPS .. the getPreference overrides the values .. remember!! so this needs to be a strcat version.... add the sensorPlugs 'splug':'%s' 8.10.25 add the Stepper Angle Kind #393 'sa':'%s 5.21.25 add the Atom Kind and the Sensors 'atom':'%s sensors':'%s' last is the dynamic main_currentStatusJSON() finish send SPIFF status 4.4.24 flag for whether feed will occur. it won't if a device is specified and it's not our device (unless super topic) check against the super feeder. If super feeder, then feed all devices, otherwise logic below perform the feed message already sent ... DOCFOLLOW .. support Dawgpack retrieves the last DocFollow SemanticMarker (from the message #DOCFOLLOW | #followMe {AVM=<SM>} need to parse to the AVM= grab the <SM> up to the "}" parse the #followMe {AVM=<url>} 3.23.25 parse into JSON Then internall process this message (only for this device) now process this as JSON, 3.25.22 – trying the CLEAN the ePROM SSID call the callback for cleaning the SSID eprom.. 3.8.22 – trying the OTA. IT WORKS!!! NOW: 2 versions, 3.28.22, try to parse {v:'version starts with.." ) -- or just contains substring. eg. OTA Version-1.6a ... and check against our "VERSION"
dispatches a call to the command specified. This is run on the next loop()
5.21.22 WORKS!! topic is the topic we can in on.. so could be super user..
7.15.23 anniversery of 1799 finding Rosetta Stone in Egypt
Definition at line 2214 of file MQTTNetworking.cpp.


| boolean processJSONMessageMQTT | ( | char * | ascii, |
| char * | topic | ||
| ) |
process the JSON message (looking for FEED, etc). Note: topic can be nil, or if not, it's an MQTT topic (so send replies if you want)
process the JSON message (looking for FEED, etc). Note: topic can be nil, or if not, it's an MQTT topic (so send replies if you want) 1.14.24 THIS is the main JSON processor of messages. But now that groups can send almost any message, there needs to be a way define a subset of messages that groups can send on.. 6.20.25 added Serial Monitor input, API Manual described:
6.16.25 Nice out, yellow field set below when looking at whether a command was found if false then continue the if/else
use the default user topic if not specified...
sets the global so isGroupTopic() will work
7.26.23 don't process if a group message and FLAG not set
called to set a preference (which will be an identifier and a string, which can be converted to a number or boolean)
8.2.24 support the not receiving message on some topics (such as a users GuestTopic) Idea would be some devices won't listen to the guest topic (instead only the user safe ones)
empty the status for the last message. Then various places the feed or status, etc are set
Basically processing as a JSON if the "{" is somewhere.. could still be invalid code
9.18.23 add this .. so it doesnt' fall through
devName is if a dev=<NAME> was specified, then dissregard if not our device
this is to ensure that the credentials are not processed.. there is a return 'true' after processing commands
for dawgPack, only support the DOCFOLLOW message for now 8.19.22
a couple commands, like bleserveron require a device name to be specified (so everyone listening doesn't perform operation)
if a dev:<dev> is specified, then only process if the device name is that same
parses a line of text, The caller then uses queryMatchesName() to see if their name matches
per #314 support the chipId as well as the name.. 3.17.24
we are in gateway mode, and the paired device isn't ours..
basically, processMessageOrGateway is set to TRUE if the device isn't mentioned, OR the dev is mentioned, and the wildcard works (or is paired) In either case, the deviceNameSpecified will be true if "dev" was specified (even with wildcard) So code below that only work if "dev" specified will work and know it's their device For the SemanticMarker, if the onlyDevSM==true, then look for deviceNameSpecified
after this, if true, then ifDeviceNameSpecified .. then it's a good name..
as per issue #122, if a device is in gateway mode, and paired with a device name specified, then the message can be sent
{"cmd", <cmd>)
1.14.24 use the isGroupTopic() where needed..
per #206 .. only change the page when not in doc_follow 1.22.24 if switching to mode 0 then it's ok.. 11.9.22
Issue: #222 for #206, this sets the current mode to SM_doc_follow, but when at that page in the the current mode (which is now SM_doc_follow) won't let the page go somewhere else (except in this case we are the same page). Only but a physical button click. I THINK THE ANSWER: if current and next are the same an SM_doc_follow, then do the page change..
the 4th page, start of smart clicker
create the SemanticMarker address
call the displayModuleFunc passing our dynamic status fund
create the SemanticMarker address
tack on the device name..
call the displayModuleFunc passing our dynamic status fund
NOTE this could be "NONE" the "P:" is so the display knows this is a paired device command
#issue 136 create a SM for the WIFI syntax WIFI:S:<SSID>;T:<WEP|WPA|blank>;P:<PASSWORD>;H:<true|false|blank>;
turn this OFF if it came in via a SemanticMarker command ... ???
calls the OTA update method (this doesn't return as device is rebooted...)
add click to any device, and to a group 5.14.25 (Dead 5.14.74 3rd wall of sound)
click call
calls the method for cleaning the SSID eprom. This calls the WIFI_APModule callback
print status of the WIFI and MQTT
send SPIFF status 4.4.24
request a STATUS be sent.
TODO: duplicate and depreciate these and replace with set:buzz,val:on
resetFirstTime
for now just reboot which will use this perference
for now just reboot which will use this perference
for now just reboot which will use this perference
for now just reboot which will use this perference
for now just reboot which will use this perference
for now just reboot which will use this perference
zoom == the NON semantic marker version.. so min menu is true
zoom only if in the max menu set..
zoom only if in the max menu set..
send message to ourself to process the current mode..
These are the ASYNC_CALL_PARAMETERS_MAX NO: just change our credentials ...
request a CAPTURE be sent.
and print any preferences to show
publich back on topic
12.27.23 pass this onto those registered (which mainModule is handling..) 1.14.24 .. what about groups?? 8.16.25 Gods of War (Hawaii) send this .. and let the caller decide if deviceNameSpecified needed..
12.28.23, 8.28.23 Tell Main about the set,val and if others are registered .. then get informed
{'guest':'guest password'}
9.28.29 devOnlySM if set, then
use the name/cat/uuid ..
5.12.22 {set:<set>,"val":val, device?)
options: hightemp, feedcount, timeout
12.27.23 pass this onto those registered (which mainModule is handling..) 8.28.23 Tell Main about the set,val and if others are registered .. then get informed 1.10.24 if deviceNameSpecified then this matches this device, otherwise for all. It's up to the receiver to decide if it has to be specified 1.14.24 for now, setVal in the ATOM will support GROUP commands if turned on (and if off it doesn't get here)
set flag (if a boolean command)
try 5.12.22 {'set':'item'},{'val':'value'} eg. set:hightemp, val:80) TODO: confirm valid integer values...
set the high temp value..
9.29.22 duplicating a couple of 'set':'cmd', 'val':'feed", since the QUERY for a device is sent that way sometimes.. request a STATUS be sent. 7.31.25 copied from below .. so it doesn't need 'dev' name in message eg: 7.31.25 make this without DEV to make it easier.. set the stepperangle. 8.14.25 Dead Movie from 10.19.1974 tonight.. issue #394 stepperRPM stepper RPM set the stepperangle. issue #338 sensor definition (in work) This will be a string in JSON format with various PIN and BUS information reboot the device to set subscribe or not for groups issue #365 sensors 5.14.25 (Dead 5.14.74 3rd wall of sound) currently not rebooting the device, but letting the user do that.. this way multiple can be done, and a "" will reset 5.17.25 plowing field Mark and Bud this is now a full set, and resets first.. new 1.4.24 setting ATOM kind (eg. M5AtomSocket, M5AtomScanner). MQTT message "set":"M5AtomKind", val= for now just reboot which will use this perference if not found .. keep searching 9.28.23 #272 devOnlySM only show a SM if sent to this device 8.2.24 to let older Tumbler NOT do the auto direction (back and forth) Isue #332 it will set via message: autoMotorDirection {"set":"autoMotorDirection","val":"true"} 8.2.24 add includeGroups Isue #332 it will set via message: includeGroups {"set":"includeGroups","val":"group1,group2"} 8.2.24 set the include group (and cache it), called from MQTT 11.9.22 restarts all the menu states to the first one .. useful for getting a clean start. This doesn't care if the menu is being shown set the stepperangle. 8.14.25 Dead Movie from 10.19.1974 tonight.. issue #394 stepperRPM stepper RPM set the stepperangle. set the timeout from no click to poweroff called to set a preference (which will be an identifier and a string, which can be converted to a number or boolean) 10.4.22 called to set a preference (which will be an identifier and a string, which can be converted to a number or boolean) called to set a preference (which will be an identifier and a string, which can be converted to a number or boolean) the setup for this module 4.4.24 called to set a preference (which will be an identifier and a string, which can be converted to a number or boolean) called to set a preference (which will be an identifier and a string, which can be converted to a number or boolean) NOTE: thes PIR and ATOM settings could be done in their modules AtomSocket but the LUX is in the butto 1.10.24 per issue#289 support PIR calling a SM in JSON (not just the FEED) 1.12.24 AtomSocketGlobalOnOff to turn on/off global onoff set global on/off is supported.. 1.12.24 set the value for the LUX sepearator from light and dark save temporally .. 1.13.24 scannedGroup temporary setting of the group name save temporally .. 1.13.24 scannedDevice temporary setting of the group name save temporally .. MQTT: set: timerdelay, val:seconds set the timer delay (0 == stop). start or stop the timer.. MQTT: set: timerdelay, val:seconds set the timer delay (0 == stop). start or stop the timer.. MQTT: set: starttimer, val: true/false (true == start timer, false = stop timer) start or stop the timer.. start or stop the timer.. issue #338 sensor definition (in work) This will be a string in JSON format with various PIN and BUS information reboot the device to set subscribe or not for groups issue #365 sensors 5.14.25 (Dead 5.14.74 3rd wall of sound) currently not rebooting the device, but letting the user do that.. this way multiple can be done, and a "" will reset 5.17.25 plowing field Mark and Bud this is now a full set, and resets first.. add stepper type set the stepperAngle as well for a default value as of 8l18.24, the stepperAngle isn't used by the MINI (only the Tumbler) NOTE: 'mini' is deprecated mini will be backdoor to set the angle to 45 set autoRotoate as well.. set autoRotoate as well.. called to set a preference (which will be an identifier and a string, which can be converted to a number or boolean) set stepperAngle default as well (int or float ok..) Issue #332 8.17.2024 default to clockwise == 1 8.18.24 setting this will check for the factory setting.. note since clockwise == 0 we set the opposite of the value.. 8.18.24 setting this will check for the factory setting.. 8.18.24 setting this will check for the factory setting.. 8.18.24 (back deck with Tyler - Maggie - stormy lightning last night and rain toggleMotor the 'Q' 'set':'toggleMotor':'val':'on/off" TODO: call the 'Q' code ..
9.30.23 reverse direction
note: reboot not needed as the next time a feed happens, it reads this value
add stepper type
set the location
pairnow is for invoking the pair when there isn't a user interface. Basically once an ESP32 gets connected, especially to a GEN3, the pairnow will make it paired for future. 10.24.22
TRUE will pair, FALSE will unpair
performs the pairing.. to whatever is currently connected, this means a message could make that happen for a device (ESP-32) with no user interface.
just unpair .. don't skip performs the unpairing
paireddev the paired device (used with BLEUsePairedDeviceName and gen3Only
saves the pair device name TODO: the feed device should use the pair as well.. (DONE..)
paired address is null until found.. Keep whatever is set ...??? 8.16.25 BLE CLIENT if BLE connected, then we keep the address if any and GEN3
erase the ADDRESS (as well as new name) .. and disconnect if connected..
try to disconnect..
sets the PREFERENCE_SUPPORT_GROUPS_SETTING
sets the PREFERENCE_SUPPORT_GROUPS_SETTING flag
reboot the device to set subscribe or not for groups
sets the PREFERENCE_GROUP_NAMES_SETTING
sets the PREFERENCE_GROUP_NAMES_SETTING val (eg. atlasDogs, houndDogs) or (#) or ""
reboot the device to set subscribe or not for groups
if not found, continue BNF options..
rename device
since renaming, lets set a STATUS out.. request a STATUS be sent.
set the screen color 0..n
sets the gen3only flag (only look for BLEServers that are GEN3)
sets the gen3only flag
for now just reboot which will use this perference
BLEUsePairedDeviceName (Says to only look for BLEServers with the paired name..
sets the BLEUseDeviceName flag == the BLEServer will add the name, eg PTFeeder:ScoobyDoo
sets the bleusedevicename flag
for now just reboot which will use this perference and re-create the service name..
8.16.25 BLE CLIENT try to disconnect..
send message to ourself to process the current mode..
send message to ourself to process the current mode..
store the JSON version of these credentials..
per #224 this will also set WIFI_CREDENTIAL_2 (even if it's also setting #1) NOTE: this saving has to be done before calling processJSON (since the string is goofed upand == 'ssid' not the full string
now process the credentials, which will set CREDENTIAL_1
print the preferences to SerialDebug
9.28.29 devOnlySM if set, then
use the name/cat/uuid ..
if flag then blankscreen, otherwise wake the screen..
blanks the screen
wakes up the screen
8.17.22 SubDawgpack
for now just reboot which will use this perference
start a dawgpack subscription 8.15.22 Also subscribe to the dawgpack .. but restrict what it can effect. For example, start with STATUS and DOCFOLLOW
TODO: duplicate and depreciate these and replace with set:buzz,val:on
this uses the ASYNC since it involves a BLE command, and has to be done outside of this WIFI (MQTT) operation..
for now just reboot which will use this perference
for now just reboot which will use this perference
zoom == the NON semantic marker version.. so min menu is true
zoom only if in the max menu set..
zoom only if in the max menu set..
send message to ourself to process the current mode..
9.22.22 added button press from messages..
new 1.4.24 setting ATOM kind (eg. M5AtomSocket, M5AtomScanner). MQTT message "set":"M5AtomKind", val=
for now just reboot which will use this perference
5.24.22 send:<request> .. Note these are for cmd without an argument..
NOTE: This will be calling ourself
8.16.25 call the main to pass onto plugs
request a TEMP be sent.
request a STATUS be sent.
request a CAPTURE be sent.
request a VOLUME be sent.
9.18.23 set64 with a val
currently 9.28.23 no reason for feeder to decode base64 messages. That could change if a stored procedure..
1.11.24 the decoded value might have URL encoded like %7B for '{' and %7D } ACTUALLY the MQTT_urlDecode is missing the 7's https://www.arduino.cc/reference/en/language/variables/data-types/string/functions/indexof/
see if docFollow .. if not then don't show it
9.28.29 devOnlySM if set, then set to whether the deviceNameSpecified (eg. dev=...)
1.11.24 NOTE: this changes the page on the M5 (and I'm sending this message often for a demo of the watch – SO: maybe there should be a mode to NOT accept the SM ??
displays the Semantic Marker (a super QR code) on the M5 screen (title = to display)
1.11.24 support setting the SM to use with the PIR (and eventually other commands)
let others know ??
1.11.24 support setting the SM to use with the PIR (and eventually other commands)
let others know ??
3.22.25 Returned stranded from space station if ScannedSemanticMarker .. call the set
12.27.23 pass this onto those registered (which mainModule is handling..) 8.28.23 Tell Main about the set,val and if others are registered .. then get informed 1.10.24 if deviceNameSpecified then this matches this device, otherwise for all. It's up to the receiver to decide if it has to be specified 1.14.24 for now, setVal in the ATOM will support GROUP commands if turned on (and if off it doesn't get here)
NOTE: if teh command isn't recognized .. then it slips through.. and is treaded like this return is important!!!
end process commands..
ISSUE: when new JSON shows up that isn't process above, it's thought to be setting the credentials. Thus the {set64} continues below..
TRY without 1.30.22 (RAMS win) and it works.. 9.17.23 .. RAMS loose to 49rs in LA (we are in LA) if can talk BLE, then reboot.. 2.2.22
{
"ssid" : "SunnyWhiteriver",
"ssidPassword" : "sunny2021",
"mqtt_topic": "usersP/bark/test",
"mqtt_user" : "test",
"deviceName" : "HowieFeeder",
"mqtt_password" : "password..",
"mqtt_guestPassword" : "password",
"uuid" : "scott",
"mqtt_port" : "1883",
"mqtt_server" : "idogwatch.com",
"mqtt_status" : "Success",
"location": "whatever to reply with, GPS, state, city, etc.."
}
todo pass the guest password too
! Store wifi config. 存储wifi配置信息
THE CHALLENGE: if send use {ssid, ssidPassword} .. it will assume others SO .. only null out the value if (1) there is an attributed {ssid} and empty string..
5.25.22 (50 years since Grateful Dead London Show
To support just setting the ssid and password, a JSON of {ssid:s,ssidPassword:p} is supported, so don't null out if mqtt aren't provided.. this should work (since the SSID is what's checked to go to the AP mode)
the MQTT host/port/user/password (topic is created in this code...)
This should keep the deviceName to whatever was specified
reset the MQTT attempts
setup the WIFI if the ssid string (at least) is specified
new: go out and let the process work... set the state, then the 'loop' will call setupWIF(...)
call the callback specified from the caller (eg. NimBLE_PetTutor_Server .. or others)
don't save the preferences, since it didn't have enough information..
NOTE: this writes over entire values, since it's a string vs an JSON object
new 4.8.22 .. trying to kick out of AP mode if the credentials are good..
putting here .. time might have gone too fast..
Definition at line 3226 of file MQTTNetworking.cpp.

| void publishBinaryFile | ( | char * | topic, |
| uint8_t * | buf, | ||
| size_t | len, | ||
| String | fileExtension | ||
| ) |
publish a binary file.. fileExtension is .jpg, .json, .txt etc
https://randomnerdtutorials.com/esp32-http-get-post-arduino/ https://randomnerdtutorials.com/esp32-cam-post-image-photo-server/ https://raw.githubusercontent.com/RuiSantosdotme/ESP32-CAM-Arduino-IDE/master/ESP32-CAM-HTTP-POST-Image/ESP32-CAM-HTTP-POST-Image.ino Lets do a POSt to my whats-this site..
create a WIFI client that talks to just our upload servlet
tomcat server.. 8080
stop this client (it's recreated each publish)
WORKS FIRST TIME FROM M5 Camera, to tomcat on KnowledgeShark: 9.17.22 publish location of this file.
send this out as a DOCFOLLOW message (but different syntax)
1.20.24 There is an alias on KnowledgeShark.me that points to the http upload location /home/ec2-user/httpd/conf/httpd.conf Alias /uploads "/var/lib/tomcat8/webapps/examples/uploads"
for now only send if it start message starts with "#"
Definition at line 415 of file MQTTNetworking.cpp.


| void publishMQTTMessage | ( | char * | topic, |
| char * | message | ||
| ) |
Wrapper of the mqttclient publish. NOTE: this might need to be in the loop as well, as the BLE could be the way the message arrived, and we are sending out over MQTT (while in the BLE thread). Don't know??
Wrapper of the mqttclient publish.
publish on the mqttClient object
see if this pushs the publish out.. (otherwise a reply might occure .. an break our _fullMessage)
Definition at line 299 of file MQTTNetworking.cpp.


| void publishMQTTMessageDefaultTopic | ( | char * | message | ) |
Wrapper of the mqttclient publish.
Definition at line 319 of file MQTTNetworking.cpp.


| void publishSMRunMessage | ( | char * | smrunMessage | ) |
send semantic /smrun 3.25.24 this is an HTTP not https
https://randomnerdtutorials.com/esp32-http-get-post-arduino/ https://randomnerdtutorials.com/esp32-cam-post-image-photo-server/ https://raw.githubusercontent.com/RuiSantosdotme/ESP32-CAM-Arduino-IDE/master/ESP32-CAM-HTTP-POST-Image/ESP32-CAM-HTTP-POST-Image.ino Lets do a POSt to my whats-this site..
create a WIFI client that talks to just our upload servlet
tomcat server.. 8080
change the & to the %26
also look for "smart" or "smflowinfo" and change to "smrun"
stop this client (it's recreated each publish)
WORKS FIRST TIME FROM M5 Camera, to tomcat on KnowledgeShark: 3.25.24 (previosuly the image was 9.17.22)
Definition at line 327 of file MQTTNetworking.cpp.


| void publishSPIFFFile_MQTT | ( | char * | topic, |
| char * | path, | ||
| int | len | ||
| ) |
publish a binary file.. fileExtension is .jpg, .json, .txt etc
https://randomnerdtutorials.com/esp32-http-get-post-arduino/ https://randomnerdtutorials.com/esp32-cam-post-image-photo-server/ https://raw.githubusercontent.com/RuiSantosdotme/ESP32-CAM-Arduino-IDE/master/ESP32-CAM-HTTP-POST-Image/ESP32-CAM-HTTP-POST-Image.ino Lets do a POSt to my whats-this site..
create a WIFI client that talks to just our upload servlet
tomcat server.. 8080
to make this json, need to add '[' at front and {}] on back so ..
PROBLEM: if only N lines fit into buffer .. how to delete only up to those lines?
7.25.25 (rainiy TDF last mt stage. remove any single quote with double quote
output the tail
stop this client (it's recreated each publish)
1.20.24 There is an alias on KnowledgeShark.me that points to the http upload location /home/ec2-user/httpd/conf/httpd.conf Alias /uploads "/var/lib/tomcat8/webapps/examples/uploads"
7.25.25 print on serial monitor too..
for now only send if it start message starts with "#"
Definition at line 512 of file MQTTNetworking.cpp.


| void reconnectMQTT_loop | ( | ) |
reconnects and re-subscribes NOTE: we need the host info...
9.17.23 .. I think the cleaning call the callback for cleaning the SSID eprom..
try making a bigger packet.. 10.23.22 (seems to help) Looking at the PubSubClient.cpp, if (this->bufferSize < MQTT_MAX_HEADER_SIZE + 2+strnlen(topic, this->bufferSize) + plength) {
get the group names
7.15.23 have it's own root "groups" so those that subscribe to 'bark' won't get it unless published 2 times (which it is) the wildcard WORKS !!!
Only subscribe if turned on.. 8.17.22
8.15.22 Also subscribe to the dawgpack .. but restrict what it can effect. For example, start with STATUS and DOCFOLLOW
reset the global attempts .. since we connected
Definition at line 1708 of file MQTTNetworking.cpp.


| void restartDelayCheckWIFI_MQTTNetworking | ( | ) |
starts the delay for WIFI checking, called at startup, and each time the timer finished..
timed events starts the delay for WIFI checking, called at startup, and each time the timer finished..
Definition at line 1161 of file MQTTNetworking.cpp.


| void restartWIFI_MQTTState | ( | ) |
restart the WIFI and then MQTT connection
Definition at line 5187 of file MQTTNetworking.cpp.


| void sendDocFollowMessageMQTT | ( | const char * | semanticMarker | ) |
sends the semantic marker as a doc follow message
sends the semantic marker as a doc follow message DOCFOLLOW
using the followme syntax for now..
Definition at line 2185 of file MQTTNetworking.cpp.


| void sendMessageMQTT | ( | char * | message | ) |
just send a message (let the internals to figure out topics, etc.. so the BLE can send something on the MQTT for now only send if it start message starts with "#"
Definition at line 2061 of file MQTTNetworking.cpp.


| void sendMessageMQTT_Topic | ( | char * | message, |
| char * | topic | ||
| ) |
for now only send if it start message starts with "#"
Definition at line 2089 of file MQTTNetworking.cpp.


| void sendMessageNoChangeMQTT | ( | char * | message | ) |
just send a message but without any extras
Definition at line 2136 of file MQTTNetworking.cpp.


| void sendMessageNoChangeMQTT_Topic | ( | char * | message, |
| char * | topic | ||
| ) |
just send a message but without any extras
just send a message but without any extras, using a topic specified
Definition at line 2113 of file MQTTNetworking.cpp.


| void sendSpiffStatus | ( | ) |
send SPIFF status 4.4.24
Definition at line 932 of file MQTTNetworking.cpp.


| void sendStatusMessageMQTT | ( | const char * | semanticMarker | ) |
sends the semantic marker as a doc follow message #remoteMe (vs STATUS, as that triggers a status reply.. )
Definition at line 2180 of file MQTTNetworking.cpp.


| void sendStatusMessageMQTT_deviceName | ( | char * | deviceName, |
| const char * | semanticMarker | ||
| ) |
sends the semantic marker as a doc follow message #remoteMe (vs STATUS, as that triggers a status reply.. )
don't call main_currentStatusURL .. since it was already called
Definition at line 2160 of file MQTTNetworking.cpp.


| void setLastDocFollowSemanticMarker_MQTTNetworking | ( | char * | semanticMarker | ) |
sets the last DocFollow SemanticMarker
Definition at line 737 of file MQTTNetworking.cpp.

| void setLastMessageStatus | ( | char * | token | ) |
retrieves a token string.. without spaces. Currently this will be things like
7.20.25 https://stackoverflow.com/questions/7352099/stdstring-to-char
add just the version and device name to start, but add the msg=
Make up a shorter version of the message
TODO: make sure no spaces ... unless escaped
Definition at line 759 of file MQTTNetworking.cpp.


| void setup_MQTTNetworking | ( | ) |
setup the MQTT part of networking
THIS IS the setup() and loop() but using the "component" name, eg MQTTNetworking() called from the setup()
init variables..
starts the delay for WIFI checking, called at startup, and each time the timer finished..
Definition at line 990 of file MQTTNetworking.cpp.


| void setupMQTT | ( | char * | mqttServerString, |
| char * | mqttPortString, | ||
| char * | mqttPasswordString, | ||
| char * | mqttUserString, | ||
| char * | deviceNameString, | ||
| char * | uuidString | ||
| ) |
setup the MQTT server
setup the MQTT (called after the WIFI connected)
print the WIFI info AGAIN..
debug
Definition at line 1951 of file MQTTNetworking.cpp.


| void setupWIFI | ( | char * | arg_ssid, |
| char * | arg_password | ||
| ) |
setup the WIFI using ssid and password
setup the WIFI using ssid and password (called from setup_MQTTNetworking() .. the main setup for this module)
save some reason we are in the AP mode
4.4.24 format as JSON print a time too.. NEED a format for this to distinguish from others..
start the WIFI mode and begin
set the counters..
reset the global attempts .. since we are trying to reconnect
Definition at line 1296 of file MQTTNetworking.cpp.


| void setupWIFI_loop | ( | ) |
the loop part of WIFI
the loop part of WIFI. Call this each time the timer is up (the delay() ) and only go to the next state if state changes to waitingForMQTT
Definition at line 1360 of file MQTTNetworking.cpp.


| char * shortVersion | ( | ) |
return a short version of VERSION
Definition at line 193 of file MQTTNetworking.cpp.

| boolean skipMessageProcessing | ( | ) |
this is sent from the backend as a message {'guest':'guest password'} .. but lets' add to the credentials..
2 kinds of #remoteMe messages, one JSON the other URL query For now skip the URL MessageArrived: '#remoteMe {AliensOnMars} {#connectedMe} {I,F} {'T':'1706135533','dev':'AliensOnMars','user':'scott.nosp@m.@kon.nosp@m.acurr.nosp@m.ents.nosp@m..com','location':'Buckley, WA','ble':'PTFeeder','v':'Version-(2.9a)-1.16.2024-ESP_32_FEEDER_GROUPS3_WIFI_AP',}', onTopic=usersP/bark/scott@konacurrents.com MessageArrived: '#remoteMe {M5AtomSocket} {AVM=status?v=v7&dev=M5AtomSocket&b=100&temp=00&c=0&t=0&socket=off&W=on&M=on&B=off&C=off&A=off&T=off&S=on&bleS=PTClicker:M5AtomSocket&Z=off&G=off}', onTopic=usersP/bark/scott@konacurrents.com whether message should be skipped for display and debug printouts uses _fullMessageIn global
Definition at line 275 of file MQTTNetworking.cpp.


| void startDelay_WIFI_MQTTState | ( | ) |
get delay in seconds
Definition at line 874 of file MQTTNetworking.cpp.


| void startDelayCheckWIFI_MQTTNetworking | ( | int | seconds | ) |
init the delay
Definition at line 1143 of file MQTTNetworking.cpp.


| void stopDelay_WIFI_MQTTState | ( | ) |
Definition at line 885 of file MQTTNetworking.cpp.


| void stopDelayCheckWIFI_MQTTNetworking | ( | ) |
stop the delay (not called)
Definition at line 1180 of file MQTTNetworking.cpp.
| bool stringMatch | ( | String | message, |
| String | substring | ||
| ) |
check if the string matches
Definition at line 2038 of file MQTTNetworking.cpp.

| void updatePreferencesInEPROM | ( | ) |
just update the EPROM, and send that to the WIFI_AP module as well
basically if only the ssid/pass are sent, that is all that's written to EPROM even if the other information is available.. So recreate the JSON instead.. seems c++ you cannot re-use output as it just appends to it.. unreal
JSON
open the preferences
save in EPROM
Close the Preferences
sets the MQTT user/password. It's up to the code to decide who needs to know (currently saves in the WIFI_APModule
NEW: 2.21.22 TRY: reading back..
check ... _fullMessageOut Close the Preferences
Definition at line 5223 of file MQTTNetworking.cpp.


| char * wifiStatus_MQTT | ( | ) |
show the status in string form (from Library/Adruino... WiFiType.h)
Definition at line 1115 of file MQTTNetworking.cpp.

| char _chipName[100] |
Definition at line 678 of file MQTTNetworking.cpp.
| int _counterLoop |
CONNECTION counters.
Definition at line 175 of file MQTTNetworking.cpp.
| int _countSinceLastChangedMessageStatus = 0 |
a counter to erase the last message if not changed in N calls..
Definition at line 743 of file MQTTNetworking.cpp.
| boolean _delayCheckWIFIRunning_MQTTNetworking = false |
true if still waiting for delayCheckWIFI to finish
Definition at line 1139 of file MQTTNetworking.cpp.
| int _delayCheckWIFISeconds_MQTTNetworking |
length of delay
Definition at line 1141 of file MQTTNetworking.cpp.
| unsigned long _delayCheckWIFIStart_MQTTNetworking |
the time the delay started
Definition at line 1137 of file MQTTNetworking.cpp.
| char* _deviceNameString |
Definition at line 257 of file MQTTNetworking.cpp.
| WiFiClient _espClient |
The WIFI client.
Definition at line 161 of file MQTTNetworking.cpp.
| String _fullJSONString |
storage for the full JSON message string to send around..
Definition at line 634 of file MQTTNetworking.cpp.
| char _fullMessageIn[MAX_MESSAGE] |
message received on subscription
Definition at line 236 of file MQTTNetworking.cpp.
| char _fullMessageOut[MAX_MESSAGE] |
message to send out
Definition at line 238 of file MQTTNetworking.cpp.
| int _globalMQTTAttempts = 0 |
Definition at line 97 of file MQTTNetworking.cpp.
| char* _jsonHeaderString |
Definition at line 260 of file MQTTNetworking.cpp.
| char* _jsonLocationString |
Definition at line 261 of file MQTTNetworking.cpp.
| char* _jsonVersionString |
Definition at line 259 of file MQTTNetworking.cpp.
| char _lastDocFollowSemanticMarker[MAX_MESSAGE_DOCFOLLOW] |
storage for last doc follow semantic marker
examples https://SemanticMarker.org/bot/status?v=v5&dev=M5WRR&b=71&temp=59&c=0&t=8&W=on&M=on&B=on&C=off&A=off&T=off&S=on&bleS=PTClicker:M5WRR&Z=off&G=on&P=DukeGEN3&t=8 https://SemanticMarker.org/bot/status?v=v5&dev=M55&b=94&temp=54&c=1&t=2&W=on&M=on&B=on&C=on&A=off&T=off&S=on&bleS=PTClicker:M55&Z=off&G=off&t=2
Definition at line 728 of file MQTTNetworking.cpp.
| char _lastGroupTopic[100] |
saves the group topic .. to write back on ..
Definition at line 245 of file MQTTNetworking.cpp.
| char _lastMessageStatusURL[MAX_MESSAGE_DOCFOLLOW] |
storage of the last message status
Definition at line 745 of file MQTTNetworking.cpp.
| int _maxCounterLoop |
Definition at line 176 of file MQTTNetworking.cpp.
| char* _mqttGuestPasswordString |
Definition at line 254 of file MQTTNetworking.cpp.
| enum MQTTMessageTopicType _MQTTMessageTopicType = userTopic |
| char* _mqttPasswordString |
Definition at line 253 of file MQTTNetworking.cpp.
| char* _mqttPortString |
Definition at line 252 of file MQTTNetworking.cpp.
| boolean _MQTTRunning = false |
Definition at line 220 of file MQTTNetworking.cpp.
| char* _mqttServerString |
Definition at line 251 of file MQTTNetworking.cpp.
| char* _mqttTopicString |
Definition at line 256 of file MQTTNetworking.cpp.
| char* _mqttUserString |
Definition at line 255 of file MQTTNetworking.cpp.
| boolean _newMQTTMessageArrived = false |
These are set by the MQTT callback.. flag to let the processor know there are new messages
Definition at line 629 of file MQTTNetworking.cpp.
| const char* _ntpServer = "pool.ntp.org" |
define here as well.. NOTE: this could be passed is as well... TODO
Definition at line 217 of file MQTTNetworking.cpp.
| Preferences _preferencesMQTTNetworking |
8.16.25 MQTT
added 1.1.2022 by iDogWatch.com CURRENTLY, this code below only has constant: usersP/bark as a super subscription This could be passed in via JSON later.. 3.3.22 Using the new JSON library which is supposed to catch syntax errors without blowing up
Definition at line 85 of file MQTTNetworking.cpp.
| char _semanticMarkerString[MAX_MESSAGE] |
Definition at line 241 of file MQTTNetworking.cpp.
| boolean _setupMQTTNetworkingAlready = false |
try a flag so setupMQTTnetworking only called 1 times..
Definition at line 987 of file MQTTNetworking.cpp.
| char _shortVersion[30] |
the short version
Definition at line 190 of file MQTTNetworking.cpp.
| char* _ssidPasswordString |
Definition at line 250 of file MQTTNetworking.cpp.
| char* _ssidString |
Definition at line 249 of file MQTTNetworking.cpp.
| int _startTimestamp = 0 |
uptime since last reboot.
Definition at line 133 of file MQTTNetworking.cpp.
| TimerDelayClass* _timerDelayClass_WIFI_MQTTState = new TimerDelayClass(1.0) |
3.29.25 RaiiiinIeeeeR Beer movie
Definition at line 873 of file MQTTNetworking.cpp.
| String _topic |
the topic the new message came in on..
Definition at line 631 of file MQTTNetworking.cpp.
| char* _uuidString |
Definition at line 258 of file MQTTNetworking.cpp.
| WIFI_MQTTStates _WIFI_MQTTState = preSetupWIFI |
the state we are in..
Definition at line 855 of file MQTTNetworking.cpp.
| float _WIFI_MQTTStateDelays[] |
the delay in seconds for each state
Definition at line 857 of file MQTTNetworking.cpp.