15#include "../../Defines.h"
17#ifdef USE_CAMERA_MODULE_XXX
18#include <HTTPClient.h>
25#include <libb64/cdecode.h>
57#define ESP_EPROM_NAME "ESP32"
76#include <ArduinoJson.h>
79#include <Preferences.h>
81#ifdef USE_REST_MESSAGING
82#include <WiFiClientSecure.h>
86#include <PubSubClient.h>
98void setupWIFI(
char * arg_ssid,
char * arg_password);
103#define MAXglobalMQTTAttempts 10
105#define MAX_MQTT_ATTEMPTS 10
108#define MAX_WIFI_CONNECT_ATTEMPTS 30
115void setupMQTT(
char* mqttServerString,
char *mqttPortString,
char *mqttPasswordString,
char *mqttUserString,
char *deviceNameString,
char *uuidString);
144#define STATUS "#STATUS"
146#define REMOTEME "#remoteMe"
147#define REMOTE2 "#REMOTE"
149#define FEED_2 "#feedme"
150#define ACK_FEED "#actMe"
151#define ACK_FEED2 "#ackMe"
152#define CONNECTED "#connectedMe"
153#define NOT_CONNECTED "#noconnectedMe"
154#define NO_ACK_FEED "#noactMe"
155#define PLAY_ME "#playMe"
156#define DOCFOLLOW "#docFollow"
157#define DOCFOLLOW2 "#DOCFOLLOW"
158#define DOCSYNC "#docSync"
159#define NO_CAN "#NO_CAN"
162#define FOLLOW_ME "#followMe"
204 int len = strlen(
"Version-(3.7)-3.22.24")+3;
226#ifdef PROCESS_SMART_BUTTON_JSON
228#define MAX_MESSAGE 2024
231#define MAX_MESSAGE 1024
233#define MAX_MESSAGE 600
238#define MAX_MESSAGE_DOCFOLLOW 500
252#define _preferencesJSONName "JSONPrefs"
281 boolean skip =
false;
300#define TRY_MORE_ASYNC_PROCESSING
301#ifdef TRY_MORE_ASYNC_PROCESSING
307 SerialMin.printf(
"Publish message(%s): %s\n",topic, message);
310 SerialMin.println(
" *** MQTT not connected .. message will queue until connected (hopefully)" );
333 SerialMin.printf(
"publishSMRunMessage: %s\n", smrunMessage);
334#ifdef ATOM_QRCODE_MODULE
342 WiFiClient postClient;
344 String serverName =
"knowledgeshark.me";
346 String serverPath =
"/examples/servlets/servlet/RequestParamExample";
348 int serverPort = 8080;
349 SerialDebug.println(
"2. Connecting to server: " + serverName);
353 if (postClient.connect(serverName.c_str(), serverPort))
355 String firstname = smrunMessage;
357 firstname.replace(
"&",
"%26");
360 firstname.replace(
"smart",
"smrun");
361 firstname.replace(
"smflowinfo",
"smrun");
365 SerialDebug.printf(
"RequstParamExample Connection successful! \n");
366 String head =
"--KonaCurrents\r\nContent-Disposition: form-data; name=\"firstname\"\r\nContent-Type: image/jpeg\r\n\r\n";
367 String tail =
"\r\n--KonaCurrents--\r\n";
370 head =
"firstname=" + firstname;
372 uint32_t imageLen = 0;
373 uint32_t extraLen = head.length() + tail.length();
374 uint32_t totalLen = imageLen + extraLen;
376 postClient.println(
"POST " + serverPath +
" HTTP/1.1");
377 postClient.println(
"Host: " + serverName);
379 postClient.println(
"Content-Type: application/x-www-form-urlencoded");
380 postClient.println(
"Content-Length: " + String(totalLen));
382 postClient.println();
383 postClient.print(head);
384 postClient.print(tail);
391 SerialTemp.println(
"POST " + serverPath +
" HTTP/1.1");
392 SerialTemp.println(
"Host: " + serverName);
393 SerialTemp.println(
"Content-Type: application/x-www-form-urlencoded");
394 SerialTemp.println(
"Content-Length: " + String(totalLen));
395 SerialTemp.println();
396 SerialTemp.print(head);
397 SerialTemp.println(tail);
402 SerialDebug.printf(
"Connection NOT successful! ");
410#ifdef USE_CAMERA_MODULE_XXX
413#include "esp_camera.h"
421 SerialMin.printf(
"Publish binary file(%s), len=%d\n", topic, len);
433 WiFiClient postClient;
435 String serverName =
"knowledgeshark.me";
437 String serverPath =
"/examples/servlets/UploadServlet";
439 int serverPort = 8080;
440 SerialDebug.println(
"2. Connecting to server: " + serverName);
442 if (postClient.connect(serverName.c_str(), serverPort))
444 SerialDebug.printf(
"Connection successful! len = %d\n", len);
446 String head =
"--KonaCurrents\r\nContent-Disposition: form-data; name=\"imageFile\"; filename=\"" +
447 filename +
"\"\r\nContent-Type: image/jpeg\r\n\r\n";
448 String tail =
"\r\n--KonaCurrents--\r\n";
450 uint32_t imageLen = len;
451 uint32_t extraLen = head.length() + tail.length();
452 uint32_t totalLen = imageLen + extraLen;
454 postClient.println(
"POST " + serverPath +
" HTTP/1.1");
455 postClient.println(
"Host: " + serverName);
456 postClient.println(
"Content-Length: " + String(totalLen));
457 postClient.println(
"Content-Type: multipart/form-data; boundary=KonaCurrents");
458 postClient.println();
459 postClient.print(head);
461 uint8_t *fbBuf = buf;
463 for (
size_t n=0; n<fbLen; n=n+1024)
467 postClient.write(fbBuf, 1024);
470 else if (fbLen%1024>0)
472 size_t remainder = fbLen%1024;
473 postClient.write(fbBuf, remainder);
476 postClient.print(tail);
498 SerialDebug.printf(
"Connection NOT successful! ");
509#ifdef USE_SPIFF_MODULE
518 char *fileExtension = (
char*)
"json";
520 SerialMin.printf(
"publishSPIFFFile topic=%s, file(%s) len = %d\n", topic, path, len);
528 WiFiClient postClient;
530 String serverName =
"knowledgeshark.me";
532 String serverPath =
"/examples/servlets/UploadServlet";
534 int serverPort = 8080;
535 SerialDebug.println(
"2. Connecting to server: " + serverName);
538 char *addFront = (
char*)
"[";
539 char *addBack = (
char*)
"{}]";
540 len = len + strlen(addFront) + strlen(addBack);
542 if (postClient.connect(serverName.c_str(), serverPort))
544 SerialDebug.printf(
"Connection successful! len = %d\n", len);
546 String head =
"--KonaCurrents\r\nContent-Disposition: form-data; name=\"imageFile\"; filename=\"" +
547 filename +
"\"\r\nContent-Type: file/JSON\r\n\r\n";
548 String tail =
"\r\n--KonaCurrents--\r\n";
550 uint32_t imageLen = len;
551 uint32_t extraLen = head.length() + tail.length();
552 uint32_t totalLen = imageLen + extraLen;
554 postClient.println(
"POST " + serverPath +
" HTTP/1.1");
555 postClient.println(
"Host: " + serverName);
556 postClient.println(
"Content-Length: " + String(totalLen));
557 postClient.println(
"Content-Type: multipart/form-data; boundary=KonaCurrents");
558 postClient.println();
559 postClient.print(head);
567 File file = fs.open(path);
568 if(!file || file.isDirectory()){
569 SerialDebug.println(
"- failed to open file for reading");
574 postClient.write(addFront, strlen(addFront));
576 SerialDebug.println(head);
579 while(file.available())
581 String line = file.readString();
586 line.replace(
"'",
"\"");
588 SerialDebug.println(line);
592 postClient.write(line.c_str(), line.length());
595 SerialDebug.println(tail);
598 postClient.write(addBack, strlen(addBack));
603 postClient.print(tail);
612#ifdef STOP_THIS_FOR_NOW
625 SerialDebug.printf(
"Connection NOT successful! ");
646#define TRY_READING_BACK
647#ifdef TRY_READING_BACK
652 SerialDebug.print(
"Reading.12 EPROM JSON = ");
674 if (!savedDeviceName)
675 savedDeviceName = NOTSET_STRING;
693 for (
int i = 0; i < 17; i = i + 8) {
694 _chipId |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
702 Serial.printf(
"ESP32 Chip model = %s Rev %d\n", ESP.getChipModel(), ESP.getChipRevision());
703 Serial.printf(
"This chip has %d cores\n", ESP.getChipCores());
705 Serial.print(
"Chip Name: "); Serial.println(
_chipName);
724 SerialLots.print(
"getDynamicStatusFunc: ");
768 SerialLots.print(
"setLastMessageStatus: ");
769 SerialLots.println(token);
781 if (strcasecmp(token,
"FEED")==0)
783 else if (strcasecmp(token,
"STATUS")==0)
823 SerialTemp.print(
"getDynamicMessageFunc: ");
830#define WIFI_MQTT_STATES
831#ifdef WIFI_MQTT_STATES
877#define USE_TIMER_DELAY_CLASS
879#ifdef USE_TIMER_DELAY_CLASS
900unsigned long _delayStart_WIFI_MQTTState;
902boolean _delayRunning_WIFI_MQTTState =
false;
904float _delaySeconds_WIFI_MQTTState;
909 SerialLots.printf(
"startDelay_WIFI_MQTTState(%f)\n", seconds);
910 _delayStart_WIFI_MQTTState =
millis();
911 _delayRunning_WIFI_MQTTState =
true;
912 _delaySeconds_WIFI_MQTTState = seconds;
918 if (_delayRunning_WIFI_MQTTState && ((
millis() - _delayStart_WIFI_MQTTState) >= (_delaySeconds_WIFI_MQTTState * 1000)))
920 _delayRunning_WIFI_MQTTState =
false;
929 _delayRunning_WIFI_MQTTState =
false;
941#ifdef USE_SPIFF_MODULE
942#ifdef USE_SPIFF_MQTT_SETTING_NOT_NOW
982#ifdef ESP_M5_TOO_MUCH
999 SerialDebug.println(
"setup_MQTTNetworking");
1004 SerialDebug.println(
"setupMQTTNetworking already setup..");
1012 SerialDebug.println(
" .. continue setup_MQTTNetworking");
1026 SerialTemp.println();
1042 SerialLots.printf(
"isConnectedWIFI_MQTTState: %s\n",
_mqttClient.connected()?
"connected":
"not connected");
1047 SerialTemp.printf(
"isConnectedWIFI_MQTTState: %s\n",
_mqttClient.connected()?
"connected":
"not connected");
1071 SerialDebug.println(
"loop_MQTTNetworking .. null ssid");
1124 switch (WiFi.status())
1126 case WL_NO_SHIELD:
return (
char*)
"WL_NO_SHIELD";
1127 case WL_IDLE_STATUS:
return (
char*)
"WL_IDLE_STATUS";
1128 case WL_NO_SSID_AVAIL:
return (
char*)
"WL_NO_SSID_AVAIL";
1129 case WL_SCAN_COMPLETED:
return (
char*)
"WL_SCAN_COMPLETED";
1130 case WL_CONNECTED :
return (
char*)
"WL_CONNECTED";
1131 case WL_CONNECT_FAILED:
return (
char*)
"WL_CONNECT_FAILED";
1132 case WL_CONNECTION_LOST:
return (
char*)
"WL_CONNECTION_LOST";
1134 case WL_DISCONNECTED:
return (
char*)
"WL_DISCONNECTED";
1152 SerialCall.printf(
"startdelayCheckWIFI_MQTTNetworking: %d\n", seconds);
1179 SerialCall.println(
"delayCheckWIFIFinished_MQTTNetworking..");
1189 SerialCall.println(
"stopDelayCheckWIFI_MQTTNetworking _delayRunning=false");
1215 SerialMin.printf(
"checkAndReconnectWIFI_MQTTState: %s\n",
wifiStatus_MQTT());
1216 boolean tryReconnect =
true;
1217 switch (WiFi.status())
1221 case WL_IDLE_STATUS:
1223 case WL_NO_SSID_AVAIL:
1226 case WL_SCAN_COMPLETED:
1237 tryReconnect =
true;
1239 tryReconnect =
false;
1241 case WL_CONNECT_FAILED:
1248 case WL_CONNECTION_LOST:
1256 case WL_DISCONNECTED:
1283 SerialMin.println(
"reconnectAttempt");
1309 SerialDebug.printf(
"1. Connecting to '%s' password = '%s'\n", arg_ssid?arg_ssid:
"NULL", arg_password?arg_password:
"");
1326 if (!arg_ssid || (arg_ssid && strlen(arg_ssid)==0))
1328 SerialDebug.println(
" NULL SSID in setupWIFI .. so leaving");
1347 WiFi.mode(WIFI_STA);
1348 WiFi.begin(arg_ssid, arg_password?arg_password:
"");
1350 SerialDebug.println(
"WIF_STA mode..");
1371 if (WiFi.status() == WL_CONNECTED)
1373 SerialDebug.println(
"WiFi.status() == WL_CONNECTED()");
1374#ifdef STORE_DEBUG_INFO
1382 WiFi.setAutoReconnect(
true);
1389#ifdef STORE_DEBUG_INFO
1412 SerialDebug.println(
"WIFI **** Cannot connect .. try bluetooth update ... ");
1414#ifdef STORE_DEBUG_INFO
1416 SerialTemp.println(
"Before storePref");
1420 SerialTemp.println(
"after 1. storePref");
1423 SerialTemp.println(
"After storePref");
1432#ifdef GO_BACK_TO_ORIGINAL
1455String _WIFIInfoString;
1459 long rssi = WiFi.RSSI();
1461 _WIFIInfoString =
"IP Address: " + WiFi.localIP();
1462 _WIFIInfoString +=
"\n WIFI SSID" + String(WiFi.SSID());
1463 _WIFIInfoString +=
"\n RSSI" + rssi;
1466 SerialDebug.println(_WIFIInfoString.c_str());
1467 return _WIFIInfoString;
1473 sprintf(buf,
"%s",WiFi.SSID());
1474 return "\n WIFI SSID: " + String(WiFi.SSID());
1487 SerialMin.println(
"WiFi connected");
1488 SerialMin.print(
"IP Address: ");
1489 SerialMin.println(WiFi.localIP());
1490 SerialMin.print(
"WiFi SSID:");
1491 SerialMin.println(WiFi.SSID());
1492 long rssi = WiFi.RSSI();
1493 SerialMin.print(
"signal strength (RSSI):");
1494 SerialMin.print(rssi);
1495 SerialMin.println(
" dBm");
1503 SerialMin.println(
"finishWIFI_Setup()");
1506 randomSeed(micros());
1530 SerialDebug.println(
"setupMQTTNetworking_WIFI done..");
1596 if (strcmp(topic,
"usersP/dawgpack")==0)
1598 else if (strcmp(topic,
"usersP/bark") == 0)
1604 SerialDebug.printf(
"Group Topic: %s\n", topic);
1613 SerialDebug.print(
"Topic = ");
1617 SerialDebug.println(
"userTopic");
1621 SerialDebug.println(
"dawgPackTopic");
1625 SerialDebug.println(
"superTopic");
1629 SerialDebug.println(
"groupTopic");
1642 SerialLots.printf(
"callbackMQTTHandler topic: %s\n", topic);
1660 SerialDebug.printf(
"1.MessageArrived: '%s', onTopic=%s\n",
_fullMessageIn, topic);
1672 SerialDebug.printf(
"NOT PRocessing as PREFERENCE_SUPPORT_GROUPS_SETTING not set");
1679 SerialDebug.printf(
"2.NOT Processing as topic not in Include Group: %s", topic);
1690#ifdef TRY_MORE_ASYNC_PROCESSING
1693 SerialLots.printf(
"2.MessageArrived: '%s', onTopic=%s\n",
_fullMessageIn, topic);
1708 SerialLots.println(
" -- DONE processsBarkletMessage ----");
1722 SerialDebug.println(
" *** No ssid or password");
1734 SerialDebug.println(
"reconnectMQTT_loop: _mqttClient.connected()");
1735#ifdef STORE_DEBUG_INFO
1745#ifdef STORE_DEBUG_INFO
1763#ifdef NOT_IN_ORIGINAL
1775 SerialInfo.println(
"FAILED MQTT .. so lets try connecting to WIFI again..");
1776 SerialInfo.println(
"Setting WIFI from JSON parameters");
1778#ifdef STORE_DEBUG_INFO
1788#ifdef USE_REST_MESSAGING
1803 SerialDebug.printf(
" **** NULL mqttServerString .. so not attempting MQTT connect, wait until credentails change \n");
1808#ifdef STORE_DEBUG_INFO
1818 String clientId =
"espM5-";
1821 String clientId =
"esp32-";
1823 clientId += String(random(0xffff), HEX);
1830 SerialDebug.printf(
"attempt _mqttClient.connect(%s)\n", clientId.c_str());
1845#ifdef STORE_DEBUG_INFO
1850 SerialInfo.println(
"MQTT CONNECTED");
1858 sprintf(
_fullMessageOut,
"%s {%s}{'mqttUser':'%s','location':'%s','uptime':'%d',%s,'v':'%s'}",
REMOTEME,
_deviceNameString?
_deviceNameString:
"NULL",
_mqttUserString?
_mqttUserString:
"NULL",
_jsonLocationString?
_jsonLocationString:
"somewhere",
getUptime(),
main_currentStatusJSON(),
shortVersion());
1862#ifdef TRY_MORE_ASYNC_PROCESSING
1868#ifdef DONT_SEND_FROM_HERE
1877#ifdef NOT_NOW_ONLY_DOCFOLLOW
1878#ifdef TRY_MORE_ASYNC_PROCESSING
1896 SerialDebug.printf(
"Subscribing to groups as PREFERENCE_SUPPORT_GROUPS_SETTING was set: %s\n", groupNames);
1898 if (strlen(groupNames)==0 || strcmp(groupNames,
"#")== 0)
1903 SerialTemp.printf(
"Subscribe usersP/groups/#\n");
1921 char *str = groupNames;
1924 for (token = strtok_r(str,
",",&rest); token != NULL; token = strtok_r(NULL,
",", &rest))
1926 sprintf(groupSub,
"usersP/groups/%s", token);
1928 SerialTemp.printf(
"Subscribe %s\n", groupSub);
1961#ifdef STORE_DEBUG_INFO
1970 SerialTemp.printf(
"FAILED, rc=%d, trying again in 0.2 seconds\n",
_mqttClient.state());
1981void setupMQTT(
char* mqttServerString,
char *mqttPortString,
char *mqttPasswordString,
char *mqttUserString,
char *deviceNameString,
char *uuidString)
1983 SerialTemp.println(
"**** setupMQTT *****");
1984#ifdef STORE_DEBUG_INFO
1993 if (mqttServerString && mqttPortString && mqttPasswordString && mqttUserString)
1996 int port = atoi(mqttPortString);
2021#ifdef STORE_DEBUG_INFO
2026 SerialInfo.println(
" *** No MQTT Server/Port Specified ** abort");
2030#ifdef STORE_DEBUG_INFO
2032 SerialTemp.println(
"done setupMQTT");
2044#ifdef TRY_MORE_ASYNC_PROCESSING
2057#define COLLECT_SENSOR_STATUS_turn_off_for_now
2058#ifdef COLLECT_SENSOR_STATUS
2071 sprintf(nameCurly,
"{%s}", connectedBLEDeviceName);
2081 sprintf(
_fullMessageOut,
"#%s Buzzer=%s", connectedBLEDeviceName, buzzerOn?
"on":
"off");
2110 return strcmp(&message[0], &substring[0]) == 0;
2122 SerialDebug.println(
"cleanEPROM_MQTTNetworking");
2147#ifdef TRY_MORE_ASYNC_PROCESSING
2172#ifdef TRY_MORE_ASYNC_PROCESSING
2195#ifdef TRY_MORE_ASYNC_PROCESSING
2220#ifdef TRY_MORE_ASYNC_PROCESSING
2232 SerialTemp.println(
"sendStatusMessageMQTT..");
2234 sprintf(
_fullMessageOut,
"#remoteMe {%s} {AVM=%s}", deviceName, semanticMarker);
2240#ifdef TRY_MORE_ASYNC_PROCESSING
2257 SerialCall.println(
"sendDocFollowMessageMQTT..");
2261#ifdef ESP_M5_ATOM_LITE
2272#ifdef TRY_MORE_ASYNC_PROCESSING
2290 char *messageString = &message[0];
2292 bool messageValidToSendBack =
false;
2293 SerialCall.print(
"processBarkletMessage: ");
2294 SerialCall.print(message);
2295 SerialCall.print(
" topic=");
2296 SerialCall.println(topic);
2324 char pairedDevice[100];
2332 strcpy(pairedDevice,
"none");
2338 if (isConnectedBLE && isGateway)
2342 sprintf(
_fullMessageOut,
"%s {%s} {%s} {I,F} {'T':'%d','dev':'%s','user':'%s','location':'%s','v':'%s','ble':'%s,%s}",
2363#ifdef TRY_MORE_ASYNC_PROCESSING
2374 SerialTemp.println(
"Sending on DawgPack too..");
2377#ifdef TRY_MORE_ASYNC_PROCESSING
2393 sprintf(
_fullMessageOut,
"%s {%s} {%s} {I,F} {'T':'%d','dev':'%s','user':'%s','location':'%s','ble':'%s','v':'%s','k':'%s','chipid':'%s','ssid':'%s',%s",
2395 sprintf(
_fullMessageOut,
"%s {%s} {%s} {I,F} {'T':'%d','dev':'%s','user':'%s','location':'%s','ble':'%s','v':'%s','k':'%s','chipid':'%s','ssid':'%s'}",
2455 messageValidToSendBack =
true;
2473 boolean performFeed =
true;
2475 performFeed =
false;
2500 SerialTemp.println(
" *** Feeding via our gateway ***");
2505 SerialDebug.println(
" ** Not feeding as not our paired device either ***");
2506 performFeed =
false;
2513 SerialDebug.printf(
"**NOT Perform FEED as deviceName doesn't ours: %s\n",
_deviceNameString );
2515 performFeed =
false;
2527 messageValidToSendBack =
false;
2540 char *indexOfEqual = index(&message[0],
'=');
2541 if (strlen(indexOfEqual)>2)
2546 while (*indexOfEqual && *indexOfEqual !=
'}')
2568 if (strlen(JSON_String) > 0)
2571 char * my_argument =
const_cast<char*
> (topic.c_str());
2581 messageValidToSendBack =
true;
2583#ifdef PASS_ONTO_PLUGS
2587#ifdef ESP_M5_CAMERA_not_here
2589 takePicture_MainModule();
2592#ifdef M5_CAPTURE_SCREEN
2599 messageValidToSendBack =
false;
2616 messageValidToSendBack =
true;
2661 sprintf(
_fullMessageOut,
"over the air binary image update from version: %s", VERSION);
2673 sprintf(
_fullMessageOut,
"over the air NOT updating as not matching string: %s",
2688 SerialDebug.println(
"DAWGPACK unsupported message");
2691 if (messageValidToSendBack)
2696#ifdef TRY_MORE_ASYNC_PROCESSING
2708 SerialTemp.println(
"2.Sending on DawgPack too..");
2711#ifdef TRY_MORE_ASYNC_PROCESSING
2723#ifdef TRY_MORE_ASYNC_PROCESSING
2740 sprintf(
_fullMessageOut,
"over the air binary image update, replacing our version: %s", VERSION);
2747#ifdef REALLY_DO_IT_BOMBS
2780 SerialDebug.println(
"Perform FEED internally, calling callbackFunction.. 2");
2795#define ACK_FOR_PAIR_TOO
2796 char pairedDevice[100];
2800 strcpy(pairedDevice,
"none");
2811 if (isConnectedBLE && isGateway)
2814 SerialTemp.print(
"PairedDevice: ");
2815 SerialTemp.println(pairedDevice);
2816 sprintf(
_fullMessageOut,
"%s {%s} {'T':'%d','temp':'%2.0f','topic':'%s','user':'%s','v':'%s','location':'%s'}",
ACK_FEED, pairedDevice, time, temp, &topic[0],
_mqttUserString, VERSION_SHORT,
_jsonLocationString?
_jsonLocationString:
"somewhere");
2821#ifdef TRY_MORE_ASYNC_PROCESSING
2835#ifdef TRY_MORE_ASYNC_PROCESSING
2847#ifdef TRY_MORE_ASYNC_PROCESSING
2857 sprintf(
_fullMessageOut,
"%s {%s} {'T':'%d','temp':'%2.0f','topic':'%s','user':'%s','v':'%s','location':'%s','paired':'%s', 'ble':'%s','connected':'%s','gateway':'%s','chipid':'%s','ssid':'%s'",
ACK_FEED,
_deviceNameString, time, temp, &topic[0]?&topic[0]:
"NULL",
_mqttUserString, VERSION_SHORT,
_jsonLocationString?
_jsonLocationString:
"somewhere",pairedDevice, isConnectedBLE?
"c":
"x",
connectedBLEDeviceName_mainModule()?
connectedBLEDeviceName_mainModule():
"none", isGateway?
"on":
"off",
getChipIdString(),
get_WIFI_SSID().c_str());
2865 if (moreStatus && strlen(moreStatus) > 0)
2883#ifdef TRY_MORE_ASYNC_PROCESSING
2898#ifdef TRY_MORE_ASYNC_PROCESSING
2910#ifdef TRY_MORE_ASYNC_PROCESSING
2929 SerialDebug.println(
"MQTT.readPreferences");
2934 SerialDebug.println(
"BOOTSTRAP device with our own WIFI and MQTT");
2936 char* BOOT_mqtt_server = (
char*)
"iDogWatch.com";
2939 char* BOOT_mqtt_port = (
char*)
"1883";
2940 char* BOOT_ssid = (
char*)
"SunnyWhiteriver";
2941 char* BOOT_ssid_password = (
char*)
"sunny2021";
2942 char *BOOT_mqtt_user = (
char*)
"test";
2943 char *BOOT_mqtt_password = (
char*)
"test";
2944 char *BOOT_mqtt_guestPassword = (
char*)
"test";
2948 char *BOOT_mqtt_topic = (
char*)
"usersP/bark/test";
2950 char *BOOT_deviceName = (
char*)
"name-of-feeder";
2951 char *BOOT_uuidString = (
char*)
"unused";
2952 char *BOOT_jsonHeaderString = (
char*)
"WIFI+MQTT";
2953 char *BOOT_jsonVersionString = (
char*)
"BOOTSTRAP 1.3";
2954 char *BOOT_jsonLocationString = (
char*)
"PetLand";
2973 DynamicJsonDocument myObject(1024);
2975 myObject[
"ssid"] = BOOT_ssid;
2976 myObject[
"ssidPassword"] = BOOT_ssid_password;
2977 myObject[
"mqtt_server"] = BOOT_mqtt_server;
2978 myObject[
"mqtt_port"] = BOOT_mqtt_port;
2979 myObject[
"mqtt_password"] = BOOT_mqtt_password;
2980 myObject[
"mqtt_guestPassword"] = BOOT_mqtt_guestPassword;
2982 myObject[
"mqtt_user"] = BOOT_mqtt_user;
2983 myObject[
"mqtt_topic"] = BOOT_mqtt_topic;
2984 myObject[
"deviceName"] = BOOT_deviceName;
2985 myObject[
"uuid"] = BOOT_uuidString;
2986 myObject[
"jsonHeader"] = BOOT_jsonHeaderString;
2987 myObject[
"jsonVersion"] = BOOT_jsonVersionString;
2988 myObject[
"location"] = BOOT_jsonLocationString;
2995 SerialDebug.print(
"Writing EPROM JSON = ");
2998 serializeJson(myObject, output1);
2999 SerialDebug.println(output1);
3009 SerialDebug.print(
"Reading.3 EPROM JSON = ");
3021#ifdef BOOTSTRAP_AP_MODE_STARTUP
3022 SerialDebug.println(
"*** STARTUP in AP MODE ***");
3035 SerialDebug.print(
"Reading.1 EPROM JSON = ");
3047 SerialDebug.println(
"*** no JSON in preferences, probably first time. use Bootstrap, or BLE update ***");
3053 DynamicJsonDocument myObject(1024);
3056 SerialDebug.print(
"JSON parsed.1 = ");
3058 serializeJson(myObject, output1);
3059 SerialDebug.println(output1);
3070 const char* a1 = myObject[
"ssid"];
3072 if (a1 && strlen(a1)>0)
3085 SerialDebug.println(
"ssid == NULL");
3090 SerialDebug.println(
"No SSID set, try BLE update again.. ");
3118 const char* a2 = myObject[
"ssidPassword"];
3131 const char* a3 = myObject[
"mqtt_server"];
3143 const char* a4 = myObject[
"mqtt_port"];
3154 const char* a5 = myObject[
"mqtt_password"];
3166 const char* a6 = myObject[
"mqtt_user"];
3177 const char* a7 = myObject[
"deviceName"];
3193 const char* a8 = myObject[
"uuid"];
3198 SerialDebug.print(
"UUID: ");
3207 const char* a9 = myObject[
"mqtt_topic"];
3218 const char* a10 = myObject[
"jsonHeader"];
3230 const char* a11 = myObject[
"jsonVersion"];
3241 const char* a12 = myObject[
"location"];
3252 const char* a13 = myObject[
"mqtt_guestPassword"];
3272 return valCmdString.equalsIgnoreCase(
"on") ||
3273 valCmdString.equalsIgnoreCase(
"1") ||
3274 valCmdString.equalsIgnoreCase(
"true");
3278function isFalseString(String valCmdString)
3280 return valCmdString.equalsIgnoreCase(
"off") ||
3281 valCmdString.equalsIgnoreCase(
"0") ||
3282 valCmdString.equalsIgnoreCase(
"false");
3303 SerialLots.println(
" *** processJSONMessageMQTT ***");
3308 boolean foundCommand;
3330 SerialDebug.printf(
"NOT Processing as PREFERENCE_SUPPORT_GROUPS_SETTING not set");
3337 SerialDebug.printf(
"NOT Processing as topic not in Include Group: %s", topic);
3349 SerialLots.printf(
"processJSONMessageMQTT(%s) -> return false, not JSON\n", ascii);
3354 SerialLots.printf(
"processJSONMessageMQTT: '%s'\n", ascii);
3358 SerialLots.printf(
"Ascii before deserializeJson: %s\n", ascii);
3360#ifdef PROCESS_SMART_BUTTON_JSON
3361 DynamicJsonDocument myObject(2024);
3364 DynamicJsonDocument myObject(1024);
3366 DynamicJsonDocument myObject(1024);
3371 deserializeJson(myObject, ascii);
3372#if SERIAL_DEBUG_LOTS
3373 serializeJsonPretty(myObject, Serial);
3377 SerialDebug.print(
"\nJSON parsed = ");
3380 serializeJson(myObject, output1);
3381 SerialDebug.println(output1);
3382 SerialLots.printf(
"Ascii after deserializeJson: %s\n", ascii);
3388 const char* cmd = myObject[
"cmd"];
3389 const char* semanticMarkerCmd = myObject[
"sm"];
3390 const char* guestCmd = myObject[
"guest"];
3393 const char *set64Cmd = myObject[
"set64"];
3395 const char *setCmd = myObject[
"set"];
3396 const char *valCmd = myObject[
"val"];
3398 const char *sendCmd = myObject[
"send"];
3400 const char *devName = myObject[
"dev"];
3402 boolean processCommands =
false;
3403 if (cmd || semanticMarkerCmd || guestCmd || setCmd || sendCmd || set64Cmd)
3404 processCommands =
true;
3406#ifdef PROCESS_SMART_BUTTON_JSON
3411 SerialTemp.printf(
"SMARTButton = %d\n", processSMARTButton);
3413 if (processSMARTButton)
3414 processCommands =
true;
3422 String guestPassword =
"pettutor";
3443 if (processCommands)
3448 char* setCmdString =
const_cast<char*
>(setCmd);
3449 char* valCmdString =
const_cast<char*
>(valCmd);
3451 if (setCmd && strcasecmp(setCmd,
"semanticMarker")==0)
3453 SerialDebug.printf(
"DAWGPACK supported message: %s\n", setCmd);
3457 SerialDebug.println(
"DAWGPACK unsupported message");
3465 boolean deviceNameSpecified = devName != NULL;
3467 boolean processMessageOrGateway =
true;
3468 if (deviceNameSpecified)
3471 processMessageOrGateway =
false;
3472#ifdef WILDCARD_DEVICE_NAME_SUPPORT
3474 parseQueryLine_mainModule((char*)devName);
3477 SerialTemp.printf(
"Query: %s *** Matches our dev name: %s\n", devName,
_deviceNameString);
3478 processMessageOrGateway =
true;
3484 SerialTemp.printf(
"ChipID: %s *** Matches our ChipID name: %s\n", devName,
getChipIdString());
3485 processMessageOrGateway =
true;
3492 SerialTemp.println(
" .. our own device ..");
3493 processMessageOrGateway =
true;
3501#ifdef WILDCARD_DEVICE_NAME_SUPPORT
3505 processMessageOrGateway =
true;
3510 SerialTemp.println(
" .. our paired device ..");
3511 processMessageOrGateway =
true;
3524#ifdef PROCESS_SMART_BUTTON_JSON
3528 if (processMessageOrGateway && processSMARTButton)
3530 StaticJsonDocument<2024> smartButtonObject;
3532 deserializeJson(smartButtonObject, myObject[
"SMARTButton"]);
3534 return processJSONSMARTButton(smartButtonObject);
3538 if (!processMessageOrGateway)
3541 SerialTemp.print(
"Disregard as Device Specified: ");
3542 SerialTemp.print(devName);
3545 SerialTemp.print(
" not ours: ");
3549#ifdef WILDCARD_DEVICE_NAME_SUPPORT
3555 SerialTemp.print(
" .. And not paired device:");
3570 SerialTemp.printf(
"MQTT or BLE CMD = '%s'\n", cmd);
3573 if (whichSMMode >= 0)
3579 SerialDebug.printf(
"currentSMMode = %d whichSMMode = %d\n", currentSMMode, whichSMMode);
3587 if (currentSMMode != whichSMMode)
3589 SerialDebug.println(
" *** Not changing page as in DOCFOLLOW mode ***");
3593 SerialDebug.println(
" *** SM_doc_follow and changing to the same page ***");
3599 boolean markerAlreadyShown =
false;
3600 switch (whichSMMode)
3606 baseString = (
char*)
"https://iDogWatch.com/bot/guestpage2";
3607 title =
"MINI CLICKER";
3615 baseString = (
char*)
"https://iDogWatch.com/bot/guestpage2";
3623 baseString = (
char*)
"https://iDogWatch.com/bot/guestpage2";
3631 baseString = (
char*)
"https://iDogWatch.com/bot/guestpage2";
3645 title =
"WIFI FEED";
3655 markerAlreadyShown =
true;
3679 markerAlreadyShown =
true;
3686 baseString = (
char*)
"https://iDogWatch.com/bot/guestpage";
3687 title =
"Guest Page";
3693 baseString = (
char*)
"https://iDogWatch.com/bot/feedguest";
3694 title =
"Feed Guest";
3700 baseString = (
char*)
"https://iDogWatch.com/bot/feedguestdevice";
3731 title =
"Help Info";
3739 title =
"DOC FOLLOW";
3744 SM =
"https://SemanticMarker.org";
3770 if (!markerAlreadyShown)
3780 SerialDebug.println(
"OTA via BLE");
3786 else if (strcasecmp(cmd,
"click")==0)
3792 else if (strcasecmp(cmd,
"blink")==0)
3797 else if (strcasecmp(cmd,
"clean")==0 && !
isGroupTopic())
3799 SerialDebug.println(
"CLEAN via BLE");
3803 else if (strcasecmp(cmd,
"feed")==0)
3805 SerialDebug.printf(
"FEED via BLE (%s)\n",topic?topic:
"NULL TOPIC!!");
3808 else if (strcasecmp(cmd,
"resettimer")==0)
3812 else if (strcasecmp(cmd,
"status")==0)
3814 SerialDebug.println(
"STATUS via BLE");
3833 SerialLots.println(
"cmd == status");
3837 else if (strcasecmp(cmd,
"erase")==0 && !
isGroupTopic())
3839 SerialDebug.println(
"ERASE via BLE");
3844 else if (strcasecmp(cmd,
"buzzon")==0)
3846 SerialDebug.println(
"BUZZON via BLE");
3849 else if (strcasecmp(cmd,
"buzzoff")==0)
3851 SerialDebug.println(
"BUZZOFF via BLE");
3856 else if (strcasecmp(cmd,
"gatewayOn")==0)
3858 if (deviceNameSpecified)
3860 SerialDebug.println(
"ASYNC_SET_GATEWAY_ON via BLE");
3864 else if (strcasecmp(cmd,
"gatewayOff")==0)
3866 if (deviceNameSpecified)
3868 SerialDebug.println(
"ASYNC_SET_GATEWAY_OFF via BLE");
3873 else if (strcasecmp(cmd,
"resetfirsttime")==0)
3875 if (deviceNameSpecified)
3877 SerialDebug.println(
"PREFERENCE_FIRST_TIME_FEATURE_SETTING ON via BLE");
3884 else if (strcasecmp(cmd,
"bleclientOn")==0 && !
isGroupTopic())
3886 if (deviceNameSpecified)
3888 SerialDebug.println(
"PREFERENCE_MAIN_BLE_CLIENT_VALUE ON via BLE");
3894 else if (strcasecmp(cmd,
"bleclientOff")==0 && !
isGroupTopic())
3896 if (deviceNameSpecified)
3898 SerialDebug.println(
"PREFERENCE_MAIN_BLE_CLIENT_VALUE OFF via BLE");
3904 else if (strcasecmp(cmd,
"bleserverOn")==0 && !
isGroupTopic())
3906 if (deviceNameSpecified)
3908 SerialDebug.println(
"PREFERENCE_MAIN_BLE_SERVER_VALUE ON via BLE");
3914 else if (strcasecmp(cmd,
"bleserverOff")==0 && !
isGroupTopic())
3916 if (deviceNameSpecified)
3918 SerialDebug.println(
"PREFERENCE_MAIN_BLE_SERVER_VALUE OFF via BLE");
3924 else if (strcasecmp(cmd,
"reboot")==0 && !
isGroupTopic())
3926 if (deviceNameSpecified)
3928 SerialDebug.println(
"REBOOT via BLE");
3933 else if (strcasecmp(cmd,
"tiltOn")==0)
3935 SerialDebug.println(
"PREFERENCE_SENSOR_TILT_VALUE ON via BLE");
3938 else if (strcasecmp(cmd,
"tiltOff")==0)
3940 SerialDebug.println(
"PREFERENCE_SENSOR_TILT_VALUE OFF via BLE");
3944 else if (strcasecmp(cmd,
"zoomSMOn")==0)
3949 SerialDebug.println(
"PREFERENCE_SEMANTIC_MARKER_ZOOMED_VALUE ON via BLE");
3960 else if (strcasecmp(cmd,
"zoomSMOff")==0)
3964 SerialDebug.println(
"PREFERENCE_SEMANTIC_MARKER_ZOOMED_VALUE OFF via BLE");
3982 else if (strcasecmp(cmd,
"poweroff")==0 && !
isGroupTopic())
3984 SerialDebug.println(
"ASYNC_POWEROFF OFF via BLE");
3988 else if (strcasecmp(cmd,
"wifi")==0)
3990 SerialDebug.println(
"cmd=wifi via BLE");
3993 else if (strcasecmp(cmd,
"swapwifi")==0)
3995 SerialDebug.println(
"cmd=swapwifi via BLE");
4006#ifdef USE_SPIFF_MODULE
4008 else if (strcasecmp(cmd,
"readspiff")==0)
4010 SerialDebug.println(
"readspiff...");
4014 else if (strcasecmp(cmd,
"sendspiff")==0)
4018 else if (strcasecmp(cmd,
"deletespiff")==0 && !
isGroupTopic())
4023 else if (strcasecmp(cmd,
"capture")==0)
4032 else if (strcasecmp(cmd,
"help")==0)
4037 sprintf(
_fullMessageOut,
"Syntax {\'cmd': \'[. | ota|clean|feed|erase|status|buzzon|buzzoff| MORE..help]\'} ");
4040#ifdef TRY_MORE_ASYNC_PROCESSING
4054 char* sendCmdString =
const_cast<char*
>(cmd);
4068 else if (semanticMarkerCmd)
4071 char* baseString = (
char*)
"https://SemanticMarker.org/bot/";
4075 boolean showSM =
true;
4077 showSM = deviceNameSpecified;
4083 SerialDebug.println(
"Not showing SemanticMarker ");
4088 else if (setCmd && valCmd)
4091 char* setCmdString =
const_cast<char*
>(setCmd);
4092 char* valCmdString =
const_cast<char*
>(valCmd);
4093 SerialTemp.print(
"Set: ");
4094 SerialTemp.print(setCmdString);
4095 SerialTemp.print(
", Val: ");
4096 SerialTemp.println(valCmdString);
4111 if (strcasecmp(setCmdString,
"hightemp")==0)
4117 else if (strcasecmp(setCmdString,
"cmd")==0)
4119 if (strcasecmp(valCmdString,
"feed")==0)
4121 SerialCall.printf(
"feed via set,cmd (%s)\n",topic?topic:
"NULL TOPIC!!");
4124 else if (strcasecmp(valCmdString,
"status")==0)
4126 SerialCall.println(
"status via set,cmd");
4130 else if (strcasecmp(valCmdString,
"resettimer")==0)
4137 SerialTemp.printf(
"1.Unknown cmd: %s\n", valCmdString);
4140#pragma mark COPIED FROM BELOW .. so can set without DEVICE name
4141#define USE_WITHOUT_DEVICE_NAME
4153 {"set":"sensors","val":"BuzzerSensorClass,19,22,L9110S_DCStepperClass,21,25"}
4156#ifdef USE_WITHOUT_DEVICE_NAME
4158 else if (strcasecmp(setCmdString,
"stepperangle")==0)
4160 SerialDebug.printf(
"stepperAngle: %s\n", valCmdString);
4163 foundCommand =
true;
4169 else if (strcasecmp(setCmdString,
"stepperRPM")==0)
4171 SerialDebug.printf(
"stepperRPM: %s\n", valCmdString);
4174 foundCommand =
true;
4179 else if (strcasecmp(setCmdString,
"2feed")==0)
4181 SerialDebug.printf(
"2feed: %d\n", flag);
4184 foundCommand =
true;
4189 else if (strcasecmp(setCmdString,
"sensorPlugs")==0)
4193 SerialDebug.printf(
"sensorPlugs: %s\n", valCmdString);
4194 foundCommand =
true;
4202 else if (strcasecmp(setCmdString,
"sensors")==0)
4210 foundCommand =
true;
4213 else if (strcasecmp(setCmdString,
"M5AtomKind")==0)
4218 foundCommand =
true;
4224 else if (strcasecmp(setCmdString,
"BLEUseDeviceName")==0)
4230 foundCommand =
true;
4238#pragma mark Device Name and Not Group
4242 foundCommand =
true;
4244 if (strcasecmp(setCmdString,
"devOnlySM")==0)
4255 else if (strcasecmp(setCmdString,
"toggle")==0)
4258 if (strcasecmp(valCmdString,
"buzzer")==0)
4262 SerialDebug.printf(
"connectedBLEDeviceName = %s\n", connectedBLEDeviceName);
4264 SerialDebug.printf(
"Call Toggle Buzzer via BLE: 'F' - dev=%s\n", connectedBLEDeviceName);
4265 if (connectedBLEDeviceName)
4277 else if (strcasecmp(valCmdString,
"socket")==0)
4288 else if (strcasecmp(setCmdString,
"autoMotorDirection")==0)
4294 else if (strcasecmp(setCmdString,
"config")==0)
4304 else if (strcasecmp(setCmdString,
"includeGroups")==0)
4310 else if (strcasecmp(setCmdString,
"ble+wifi")==0)
4315 else if (strcasecmp(setCmdString,
"factoryreset")==0)
4322 else if (strcasecmp(setCmdString,
"restartmodels")==0)
4328 else if (strcasecmp(setCmdString,
"screentimeout")==0)
4333 else if (strcasecmp(setCmdString,
"stepperangle")==0)
4335 SerialDebug.printf(
"stepperAngle: %s\n", valCmdString);
4342 else if (strcasecmp(setCmdString,
"stepperRPM")==0)
4344 SerialDebug.printf(
"stepperRPM: %s\n", valCmdString);
4350 else if (strcasecmp(setCmdString,
"2feed")==0)
4352 SerialDebug.printf(
"2feed: %d\n", flag);
4356 else if (strcasecmp(setCmdString,
"noclick")==0)
4361 else if (strcasecmp(setCmdString,
"gateway")==0)
4367 else if (strcasecmp(setCmdString,
"DiscoverM5PTClicker")==0)
4372 else if (strcasecmp(setCmdString,
"usespiff")==0 && !
isGroupTopic())
4376#ifdef USE_SPIFF_MODULE
4385 else if (strcasecmp(setCmdString,
"usespiff_mqtt")==0 && !
isGroupTopic())
4390 else if (strcasecmp(setCmdString,
"usespiff_qratom")==0 && !
isGroupTopic())
4398 else if (strcasecmp(setCmdString,
"PIR_UseSM")==0 && !
isGroupTopic())
4404 else if (strcasecmp(setCmdString,
"AtomSocketGlobalOnOff")==0 && !
isGroupTopic())
4410 else if (strcasecmp(setCmdString,
"LUXdark")==0 && !
isGroupTopic())
4416 else if (strcasecmp(setCmdString,
"scannedGroup")==0 && !
isGroupTopic())
4423 else if (strcasecmp(setCmdString,
"scannedDevice")==0 && !
isGroupTopic())
4431 else if (strcasecmp(setCmdString,
"timerdelay")==0)
4433 int timerdelay = atoi(valCmdString);
4437 SerialDebug.printf(
"timerdelay: %d\n", timerdelay);
4441 else if (strcasecmp(setCmdString,
"timerdelayMax")==0)
4443 int timerdelay = atoi(valCmdString);
4447 SerialDebug.printf(
"timerdelayMax: %d\n", timerdelay);
4450 else if (strcasecmp(setCmdString,
"starttimer")==0)
4455 SerialDebug.printf(
"startTimer: %d\n", flag);
4460 else if (strcasecmp(setCmdString,
"sensorPlugs")==0)
4464 SerialDebug.printf(
"sensorPlugs: %s\n", valCmdString);
4472 else if (strcasecmp(setCmdString,
"sensors")==0)
4481 else if (strcasecmp(setCmdString,
"stepper")==0)
4485 float stepperAngle = 22.5;
4488 if (strcasecmp(valCmdString,
"mini")==0)
4492 stepperAngle = 45.0;
4495 else if (strcasecmp(valCmdString,
"tumbler")==0)
4498 stepperAngle = 200.0;
4508 SerialDebug.printf(
"stepper = %d, stepperAngle = %f\n", feederType, stepperAngle);
4519 else if (strcasecmp(setCmdString,
"factoryClockwiseMotor")==0)
4521 SerialCall.println(
" *** Setting factory clockwise motor");
4527 else if (strcasecmp(setCmdString,
"clockwiseMotor")==0)
4529 SerialCall.println(
" *** Setting clockwise motor");
4537 else if (strcasecmp(setCmdString,
"toggleMotor")==0)
4545 currentDirection = !currentDirection;
4549 else if (strcasecmp(setCmdString,
"otafile")==0)
4555 else if (strcasecmp(setCmdString,
"location")==0 && !
isGroupTopic())
4565 else if (strcasecmp(setCmdString,
"pairnow")==0)
4578 else if (strcasecmp(setCmdString,
"pairdev")==0)
4581 if (strcasecmp(valCmdString,previousName)!=0)
4605#ifdef NO_MORE_PREFERENCE_BLE_USE_DISCOVERED_PAIRED_DEVICE_SETTING
4606 if (strlen(valCmdString)==0)
4617 else if (strcasecmp(setCmdString,
"usegroups")==0)
4626 else if (strcasecmp(setCmdString,
"groups")==0)
4636 foundCommand =
false;
4638#pragma mark END of device and not group
4643 if (strcasecmp(setCmdString,
"device")==0 && !
isGroupTopic())
4655 else if (strcasecmp(setCmdString,
"screencolor")==0)
4658 int screenColor = atoi(valCmdString);
4665 else if (strcasecmp(setCmdString,
"gen3only")==0)
4677 else if (strcasecmp(setCmdString,
"BLEUsePairedDeviceName")==0)
4681#ifdef NO_MORE_PREFERENCE_BLE_USE_DISCOVERED_PAIRED_DEVICE_SETTING
4689 else if (strcasecmp(setCmdString,"BLEUseDeviceName")==0)
4705 else if (strcasecmp(setCmdString,
"minMenu")==0)
4707 SerialDebug.println(
"PREFERENCE_IS_MINIMAL_MENU_SETTING via BLE");
4722 else if (strcasecmp(setCmdString,
"addwifi")==0)
4729 strcpy(str,valCmdString);
4732 char* ssid = strtok_r(rest,
":", &rest);
4733 char* password = strtok_r(rest,
":", &rest);
4734 SerialDebug.printf(
"addwifi %s, %s\n", ssid?ssid:
"null", password?password:
"");
4741 char credentials[100];
4743 sprintf(credentials,
"{'ssid':'%s','ssidPassword':'%s'}", ssid?ssid:
"NULL", password?password:
"");
4745 SerialMin.println(credentials);
4759 else if (strcasecmp(setCmdString,
"usedocfollow")==0)
4761 SerialDebug.printf(
"PREFERENCE_USE_DOC_FOLLOW_SETTING %s\n", valCmdString);
4766 else if (strcasecmp(setCmdString,
"semanticMarker")==0)
4768 SerialDebug.printf(
"2.SemanticMarker: %s\n", valCmdString);
4772 boolean showSM =
true;
4774 showSM = deviceNameSpecified;
4780 SerialDebug.println(
"Not showing SemanticMarker ");
4784 else if (strcasecmp(setCmdString,
"blankscreen")==0)
4797 else if (strcasecmp(setCmdString,
"SubDawgpack")==0)
4801 SerialDebug.println(
"PREFERENCE_SUB_DAWGPACK_SETTING via BLE");
4815 _mqttClient.unsubscribe((
char*)
"usersP/dawgpack");
4821 else if (strcasecmp(setCmdString,
"buzz")==0 && !
isGroupTopic())
4827 SerialDebug.println(
"BUZZ:ON via BLE");
4832 SerialDebug.println(
"BUZZ:OFF via BLE");
4839 else if (strcasecmp(setCmdString,
"bleclient")==0)
4843 SerialDebug.println(
"PREFERENCE_MAIN_BLE_CLIENT_VALUE via BLE");
4851 else if (strcasecmp(setCmdString,
"bleserver")==0)
4855 SerialDebug.println(
"PREFERENCE_MAIN_BLE_SERVER_VALUE via BLE");
4861 else if (strcasecmp(setCmdString,
"tilt")==0)
4865 SerialDebug.println(
"PREFERENCE_SENSOR_TILT_VALUE via BLE");
4871 else if (strcasecmp(setCmdString,
"zoomSm")==0)
4879 SerialDebug.println(
"PREFERENCE_SEMANTIC_MARKER_ZOOMED_VALUE ON via BLE");
4894 SerialDebug.println(
"PREFERENCE_SEMANTIC_MARKER_ZOOMED_VALUE OFF via BLE");
4914 else if (strcasecmp(setCmdString,
"buttonA")==0)
4916 if (strcasecmp(valCmdString,
"longpress")==0)
4918 else if (strcasecmp(valCmdString,
"shortpress")==0)
4921 else if (strcasecmp(setCmdString,
"buttonB")==0)
4923 if (strcasecmp(valCmdString,
"longpress")==0)
4925 else if (strcasecmp(valCmdString,
"shortpress")==0)
4928 else if (strcasecmp(setCmdString,
"M5AtomKind")==0 && !
isGroupTopic())
4937 else if (strcasecmp(setCmdString,
"disk")==0)
4939 SerialDebug.printf(
"Cloud DISK space = %s\n", valCmdString);
4941 else if (strcasecmp(setCmdString,
"feedcount")==0)
4943 SerialDebug.printf(
"Global feed count = %s\n", valCmdString);
4947 SerialMin.printf(
"2.Unknown cmd: %s (isGroupTopic=%d)\n", setCmdString,
isGroupTopic());
4957 char* sendCmdString =
const_cast<char*
>(sendCmd);
4961 if (strcasecmp(sendCmdString,
"temp")==0)
4963 SerialCall.println(
"sendCmd == temp");
4967 else if (strcasecmp(sendCmdString,
"status")==0)
4969 SerialCall.println(
"sendCmd == status");
4974 else if (strcasecmp(sendCmdString,
"capture")==0)
4976 SerialCall.println(
"sendCmd == capture");
4983 else if (strcasecmp(sendCmdString,
"volume")==0)
4985 SerialCall.println(
"sendCmd == volume (not implemented)");
4992 SerialTemp.print(
"Unknown send request: ");
4993 SerialTemp.println(sendCmdString);
5002 char* setCmdString =
const_cast<char*
>(set64Cmd);
5003 char* valCmdString =
const_cast<char*
>(valCmd);
5005 char plaintext_out[200];
5006 int len = strlen(valCmdString);
5009 SerialError.println(
"Length too long to base64 decode: 200");
5013 int status = base64_decode_chars(valCmdString, len, plaintext_out);
5014 String decoded = String(plaintext_out);
5021 SerialDebug.println(decoded);
5023 if (strcasecmp(setCmdString,
"semanticMarker")==0 && !
isGroupTopic())
5029 boolean showSM =
true;
5031 showSM = deviceNameSpecified;
5042 SerialDebug.println(
"Not showing SemanticMarker ");
5044 else if (strcasecmp(setCmdString,
"PIR_SM_JSON")==0 && !
isGroupTopic())
5057 else if (strcasecmp(setCmdString,
"PIR_OFF_SM_JSON")==0 && !
isGroupTopic())
5073 else if (strcasecmp(setCmdString,
"ScannedSemanticMarker")==0)
5080 char * my_argument =
const_cast<char*
> (decoded.c_str());
5132#ifdef ONLY_NULL_IF_THERE
5133 SerialDebug.println(
" *** processMQTT .. treat like credentials");
5135 const char* a1 = myObject[
"ssid"];
5142 SerialTemp.printf(
"myObject[ssid] = '%s'\n", a1?a1:
"EMPTY");
5148 const char* a2 = myObject[
"ssidPassword"];
5157 SerialDebug.println(
" *** processMQTT .. treat like credentials");
5159 const char* a1 = myObject[
"ssid"];
5160 if (a1 && strlen(a1)>0)
5167 SerialTemp.printf(
"myObject[ssid] = '%s'\n", a1?a1:
"EMPTY");
5173 const char* a2 = myObject[
"ssidPassword"];
5174 if (a2 && strlen(a2)>0)
5191 const char* a3 = myObject[
"mqtt_server"];
5201 const char* a4 = myObject[
"mqtt_port"];
5212 const char* a5 = myObject[
"mqtt_password"];
5223 const char* a6 = myObject[
"mqtt_user"];
5234 const char* a7 = myObject[
"deviceName"];
5235 if (a7 && strlen(a7)>0)
5244 const char* a8 = myObject[
"uuid"];
5246 if (a8 && strlen(a8)>0)
5258 const char* a9 = myObject[
"mqtt_topic"];
5260 if (a9 && strlen(a9)>0)
5273 const char* a10 = myObject[
"mqtt_guestPassword"];
5275 if (a10 && strlen(a10)>0)
5288 const char* a11 = myObject[
"location"];
5289 if (a11 && strlen(a11)>0)
5301 boolean saveJSONPreferences =
true;
5305 SerialDebug.println(
"Setting WIFI from JSON parameters");
5316 SerialDebug.println(
" ***** ERROR .. no ssidString *** ");
5320 saveJSONPreferences =
false;
5325 if (!saveJSONPreferences)
5327 SerialDebug.println(
"**** Not saving JSON in preferences ***");
5357 SerialDebug.println(
"set disconnectedWIFI and stopDelay");
5372 SerialDebug.println(
"cleanMQTTpasswordsUpdateInEPROM");
5386 DynamicJsonDocument myObject(1024);
5422 serializeJson(myObject, output2);
5426 SerialDebug.print(
"MQTTNetworking.Writing EPROM JSON = '");
5427 SerialDebug.print(output2);
5428 SerialDebug.println(
"'");
5437#define NO_NEED_AND_GRU_CRASH
5438#ifdef NO_NEED_AND_GRU_CRASH
5443 SerialDebug.print(
"Reading.2 EPROM JSON = ");
5458 s.replace(
"%20",
" ");
5459 s.replace(
"+",
" ");
5460 s.replace(
"%21",
"!");
5461 s.replace(
"%22",
"\"");
5462 s.replace(
"%23",
"#");
5463 s.replace(
"%24",
"$");
5464 s.replace(
"%25",
"%");
5465 s.replace(
"%26",
"&");
5466 s.replace(
"%27",
"\'");
5467 s.replace(
"%28",
"(");
5468 s.replace(
"%29",
")");
5469 s.replace(
"%30",
"*");
5470 s.replace(
"%31",
"+");
5471 s.replace(
"%2C",
",");
5472 s.replace(
"%2E",
".");
5473 s.replace(
"%2F",
"/");
5474 s.replace(
"%2C",
",");
5475 s.replace(
"%3A",
":");
5476 s.replace(
"%3B",
";");
5477 s.replace(
"%3C",
"<");
5478 s.replace(
"%3D",
"=");
5479 s.replace(
"%3E",
">");
5480 s.replace(
"%3F",
"?");
5481 s.replace(
"%40",
"@");
5482 s.replace(
"%5B",
"[");
5483 s.replace(
"%5C",
"\\");
5484 s.replace(
"%5D",
"]");
5485 s.replace(
"%5E",
"^");
5486 s.replace(
"%5F",
"-");
5487 s.replace(
"%60",
"`");
5488 s.replace(
"%7B",
"{");
5489 s.replace(
"%7D",
"}");
boolean isConnectedBLEClient()
returns whether connected over BLE as a client to a server(like a ESP feeder)
void disconnect_BLEClientNetworking()
try to disconnect..
void sendCommandBLEClient_13orLess(String cmdString)
send a string of 13 characters or less
char * getServiceName_BLEServerNetworking()
retrieve the service name (PTFEEDER, PTFeeder:Name, PTClicker:Name, etc)
void showSemanticMarkerFunc_displayModule(String semanticMarkerAddressBase, String title, const char *(*getStatusFunc)(void))
finish the address after calling the function provided, called from MQTT for STATUS
void addToTextMessages_displayModule(String text)
void wakeupScreen_displayModule()
wakes up the screen
void showText_displayModule(String text)
void redrawSemanticMarker_displayModule(boolean startNew)
redraws the image..
void setScreenColor_displayModule(int screenColor)
cache for getting the screen color 0..n. Will reset the cache as well
void showSemanticMarker_displayModule(String semanticMarkerAddress, String title)
displays the Semantic Marker (a super QR code) on the M5 screen (with an N second display)
void blankScreen_displayModule()
blanks the screen
void resetLoopTimer_displayModule()
reset the loop timer .. useful for testing,
void blinkBlueLightMQTT()
blinks the blue light
void startDelayCheckWIFI_MQTTNetworking(int seconds)
init the delay
void publishBinaryFile(char *topic, uint8_t *buf, size_t len, String fileExtension)
boolean delayFinished_WIFI_MQTTState()
boolean bluetoothOnline()
! should be a definition that the bluetooth is ONLINE
#define MAXglobalMQTTAttempts
boolean isSuperTopic()
helper to know it's a superuser topic (and not process in most cases).
void emptyLastMessageStatus()
empty the status message
char _fullMessageIn[MAX_MESSAGE]
message received on subscription
void processBarkletMessage(String message, String topic)
process an MQTT message looking for keywords (barklet language)
void publishMQTTMessageDefaultTopic(char *message)
Wrapper of the mqttclient publish.
void printTopicType()
prints the topic on debug
boolean _delayCheckWIFIRunning_MQTTNetworking
true if still waiting for delayCheckWIFI to finish
char * _ssidPasswordString
void finishWIFI_Setup()
end of WIFI loop..
void checkAndReconnectWIFI_MQTTNetworking()
print a SPIFF timestamp..
char _fullMessageOut[MAX_MESSAGE]
message to send out
int _startTimestamp
uptime since last reboot.
void updatePreferencesInEPROM()
just update the EPROM, and send that to the WIFI_AP module as well
char * _jsonVersionString
boolean _setupMQTTNetworkingAlready
try a flag so setupMQTTnetworking only called 1 times..
void cleanEPROM_MQTTNetworking()
cleans the eprom info
char * wifiStatus_MQTT()
show the status in string form (from Library/Adruino... WiFiType.h)
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 rep...
bool stringMatch(String message, String substring)
check if the string matches
void MQTTModule_readPreferences()
setup the WIFI
void cleanSSID_EPROM_Method()
calls the method for cleaning the SSID eprom. This calls the WIFI_APModule callback
String get_WIFIInfoString()
retrieve the WIFIInfoString
boolean isTrueString(String valCmdString)
whether the string is TRUE, ON, 1
void publishMQTTMessage(char *topic, char *message)
Wrapper of the mqttclient publish. NOTE: this might need to be in the loop as well,...
boolean skipMessageProcessing()
this is sent from the backend as a message {'guest':'guest password'} .. but lets' add to the credent...
void sendMessageNoChangeMQTT_Topic(char *message, char *topic)
just send a message but without any extras
void publishSPIFFFile_MQTT(char *topic, char *path, int len)
int _delayCheckWIFISeconds_MQTTNetworking
length of delay
String _topic
the topic the new message came in on..
void setupWIFI_loop()
the loop part of WIFI
void sendMessageMQTT(char *message)
char _lastDocFollowSemanticMarker[MAX_MESSAGE_DOCFOLLOW]
storage for last doc follow semantic marker
char * _jsonLocationString
void checkDelaySinceWIFICheck_MQTTNetworking()
checks delay for the WIFI connectivity
boolean delayCheckWIFIFinished_MQTTNetworking()
if finished..
WiFiClient _espClient
The WIFI client.
#define MAX_WIFI_CONNECT_ATTEMPTS
#define MAX_MQTT_ATTEMPTS
void setupMQTT(char *mqttServerString, char *mqttPortString, char *mqttPasswordString, char *mqttUserString, char *deviceNameString, char *uuidString)
setup the MQTT server
#define ESP_EPROM_NAME
9.27.23 to decode a base64 string (a Semantic Marker)
const char * getDynamicMessageFunc()
used by the displayModule to call this for each new status
float _WIFI_MQTTStateDelays[]
the delay in seconds for each state
boolean _newMQTTMessageArrived
void callPreSetupMQTT()
called to setup the MQTT (which is really the _mqttClient setup). Done on it's own thread....
String getJSONConfigString()
retrieve the Configuration JSON string in JSON format..
void setup_MQTTNetworking()
setup the MQTT part of networking
const char * _ntpServer
define here as well.. NOTE: this could be passed is as well... TODO
void performOTAUpdateMethod()
perform the OTA update. This calls the OTAImageUpdate methods (via preformOTAUpdateSimple())
WIFI_MQTTStates
state variables
void stopDelayCheckWIFI_MQTTNetworking()
stop the delay (not called)
void sendStatusMessageMQTT(const char *semanticMarker)
sends the semantic marker as a doc follow message #remoteMe (vs STATUS, as that triggers a status rep...
void stopDelay_WIFI_MQTTState()
char * shortVersion()
return a short version of VERSION
void getChipInfo()
create a unique ID (but it needs to be stored.. otherwise it's unique each time??
boolean isGroupTopic()
helper to know it's a superuser topic (and not process in most cases).
char * _mqttPasswordString
void loop_MQTTNetworking()
called for the loop() of this plugin
char * getLastDocFollowSemanticMarker_MQTTNetworking()
char _shortVersion[30]
the short version
void classifyTopic(char *topic)
classify a topic
void setLastMessageStatus(char *token)
char * currentMessageStatusURL()
returns a string in in URL so: status?battery=84'&buzzon='off' } .. etc
int _countSinceLastChangedMessageStatus
a counter to erase the last message if not changed in N calls..
const char * getDynamicStatusFunc()
void setupWIFI(char *arg_ssid, char *arg_password)
setup the WIFI using ssid and password
void printWIFIInfo()
print the WIFI info
void startDelay_WIFI_MQTTState()
void invokeCurrentSMModePage(char *topic)
send message to ourself to change to current specifed SM Mode
enum MQTTMessageTopicType _MQTTMessageTopicType
void cleanMQTTpasswordsUpdateInEPROM()
9.18.23 LA (after Eagle Rock bike ride, Van Morrison tomorrow)
WIFI_MQTTStates _WIFI_MQTTState
the state we are in..
TimerDelayClass * _timerDelayClass_WIFI_MQTTState
3.29.25 RaiiiinIeeeeR Beer movie
int _counterLoop
CONNECTION counters.
char _lastGroupTopic[100]
saves the group topic .. to write back on ..
void initAllArrayStorage()
Put all the storage initialization here..
boolean processJSONMessageMQTT(char *ascii, char *topic)
process the JSON message (looking for FEED, etc). Note: topic can be nil, or if not,...
PubSubClient _mqttClient(_espClient)
The PubSub MQTT Client.
String get_WIFI_SSID()
3.22.24 get the WIFI SSID for the status
void sendMessageMQTT_Topic(char *message, char *topic)
for now only send if it start message starts with "#"
void sendDocFollowMessageMQTT(const char *semanticMarker)
sends the semantic marker as a doc follow message
unsigned long _delayCheckWIFIStart_MQTTNetworking
the time the delay started
#define MAX_MESSAGE_DOCFOLLOW
void restartDelayCheckWIFI_MQTTNetworking()
starts the delay for WIFI checking, called at startup, and each time the timer finished....
char _semanticMarkerString[MAX_MESSAGE]
Preferences _preferencesMQTTNetworking
8.16.25 MQTT
void setLastDocFollowSemanticMarker_MQTTNetworking(char *semanticMarker)
sets the last DocFollow SemanticMarker
String MQTT_urlDecode(String input)
Decode the URL (copied from WIFI_APModule. Easier than breaking modules)
boolean isDawgpackTopic()
helper to know it's a dawgpack topic (and not process in most cases). Only support DOCFOLLOW for now....
void sendMessageNoChangeMQTT(char *message)
just send a message but without any extras
void callbackMQTTHandler(char *topic, byte *payload, unsigned int length)
called when data on the MQTT socket
boolean isConnectedMQTT_MQTTState()
value of MQTT connected
void checkMQTTMessages_loop()
check for MQTT messages, called from the main loop()
int getDelayCheckWIFISeconds_MQTTNetworking()
get the delay values
char _lastMessageStatusURL[MAX_MESSAGE_DOCFOLLOW]
storage of the last message status
int getUptime()
returns seconds since first booted
MQTTMessageTopicType
break up the MQTT Handler 8.12.22 as per "My guess is that you have your data collection (from some I...
char * getDeviceNameMQTT()
called for things like the advertisement
void performFeedMethod(char *topic)
calls the FEED message via the callback (which calls the BLE code)
boolean isConnectedWIFI_MQTTState()
value of WIFI connected
void restartWIFI_MQTTState()
restart the WIFI and then MQTT connection
char * _mqttGuestPasswordString
#define _preferencesJSONName
Points to strings read from JSON (limited to 15 char key name)
void reconnectMQTT_loop()
String _fullJSONString
storage for the full JSON message string to send around..
void publishSMRunMessage(char *smrunMessage)
void initShortVersion()
init short version
#define MQTT_CALLBACK_TEMP
#define MQTT_CLEAN_SSID_EPROM
#define MQTT_CALLBACK_BLINK
#define MQTT_CALLBACK_FEED
8.16.25 MQTT
#define MQTT_CALLBACK_SOLID_LIGHT
void messageSend_mainModule(char *sendValue, boolean deviceNameSpecified)
TODO: have a callback regist approach.
#define CALLBACKS_MQTT
8.16.25 MQTT
void main_updateMQTTInfo(char *ssid, char *ssid_password, char *username, char *password, char *guestPassword, char *deviceName, char *host, char *port, char *locationString)
sets the WIFI and MQTT user/password. It's up to the code (below, maybe in future a register approach...
char * charSMMode_mainModule(int whichSMMode)
returns string form whichSMMode, sg "sm0", sm1 ...
char * main_getUsername()
void main_setScannedGroupName(char *groupName)
boolean connectedBLEDeviceIsGEN3_mainModule()
whether the connected is a GEN3 (so the name isn't valid)
char * semanticMarkerToJSON_mainModule(char *semanticMarker)
char * main_currentStatusURL(boolean fullStatus)
int minMenuModesMax_mainModule()
returns the current max of the MIN menu modes (using the setting of min or expanded) to determine
void main_setScannedDeviceName(char *deviceName)
set the scanned device name
void processClientCommandChar_mainModule(char cmd)
single character version of processClientCommand (since many used that already)
void setClockwiseMotorDirection_mainModule(boolean isClockwiseFlag)
8.18.24 setting this will check for the factory setting..
void main_credentialsUpdated()
moved here 4.25.22 (entirely from ESP_IOT.ino)
void restartAllMenuStates_mainModule()
restarts all the menu states to the first one .. useful for getting a clean start....
int whichSMMode_mainModule(char *cmd)
************** SM Mode Processing ***************
void main_dispatchAsyncCommandWithString(int asyncCallCommand, char *parameter)
boolean isEmptyString(char *stringA)
informs if null or empty string
void rebootDevice_mainModule()
void setConfiguration_mainModule(char *configurationName)
void buttonB_ShortPress_mainModule()
the short press of the side button
bool containsSubstring(String message, String substring)
check if the string contains the other string. This is a poor man's grammer checker
void callCallbackMain(int callbacksModuleId, int callbackType, char *message)
performs the indirect callback based on the callbackType
int getCurrentSMMode_mainModule()
returns the current SM Mode
char * main_currentStatusJSON()
status in JSON format, needs to return something as a ',' is already added before calling this....
void changeButtonColor_MainModule()
2.21.25 add a way to change the button color (if any)
int getFeederType_mainModule()
get the feeder type (Sepper 1,2,3 ...)
void buttonA_LongPress_mainModule()
long press on buttonA (top button)
boolean startsWithChar(char *str, char c)
a char* version of startsWith (after skipping spaces)
void setCurrentSMMode_mainModule(int whichSMMode)
sets the current screen mode .. which can be used by Button and Display processing
char * getPairedDevice_mainModule()
returns if the paired device is not NONE
void setLUXThreshold_mainModule(int thresholdKind, int luxVal)
set the threshold val
void main_dispatchAsyncCommand(int asyncCallCommand)
checks if any async commands are in 'dispatch' mode, and if so, invokes them, and sets their flag to ...
char * getChipIdString()
3.17.24 get the chip id as a string
char * connectedBLEDeviceName_mainModule()
returns the connected BLE Device name (the :NAME of advertisment, Address: 01:39:3f:33 part of name,...
uint32_t getChipId()
3.17.24 get the chip id
int getTimeStamp_mainModule()
void buttonB_LongPress_mainModule()
the long press of the side button
char * createCopy(char *stringA)
void messageSetVal_mainModule(char *setName, char *valValue, boolean deviceNameSpecified)
float getTemperature_mainModule()
retrieves the temperature .
void buttonA_ShortPress_mainModule()
boolean isValidPairedDevice_mainModule()
returns if the paired device is not NONE. Note, the paired Name might be an address now (see below)
char * main_nextJSONWIFICredential()
! cycle through the next WIFI saved credential
#define SM_pair_dev
guest feed device
#define THRESHOLD_KIND_DARK
#define SM_guest_feed
guest feed
#define SM_guest_page
guest page
#define SM_timer
timer .. todo
#define SM_status
//status
#define ASYNC_SET_GATEWAY_ON
sets the GATEWAY mode on
#define ASYNC_CALL_BUZZ_ON
sends a 'B' to the BLE end of the code (assuming a feeder is connected).
#define ASYNC_POWEROFF
sets the GATEWAY mode off
#define ASYNC_CALL_CLEAN_EPROM
cleans the EPROM totally, and reboots
#define ASYNC_SEND_MQTT_STATUS_URL_MESSAGE
sends the status from the main module URL
#define ASYNC_SET_GATEWAY_OFF
sets the GATEWAY mode off
#define ASYNC_CALL_OTA_FILE_UPDATE_PARAMETER
these are the async with a string parameter
#define ASYNC_CALL_OTA_UPDATE
TODO: make this a registeration approach.
#define SM_doc_follow
docfollow
#define SM_smart_clicker_homepage
//! homepage
#define SM_WIFI_ssid
WIFI ssid.
#define SM_ap_mode
AP MODE.
#define ASYNC_CALL_BUZZ_OFF
sends a 'b' to the BLE end of the code (assuming a feeder is connected).
#define ASYNC_CLICK_SOUND
5.15.25 add a BUZZ command (or CLICK)
void setTimerDelaySecondsMax_mainModule(int delaySeconds)
void invokePair_ModelController()
void setTimerDelaySeconds_mainModule(int delaySeconds)
void startStopTimer_mainModule(boolean startTimer)
void invokeUnpairNoName_ModelController()
void performOTAUpdateSimple()
retrieves from constant location
void performOTAUpdate(char *hostname, char *httpAddress)
8.16.25 MQTT
void savePreferenceInt_mainModule(int preferenceID, int val)
sets an int preference
void savePreferenceBoolean_mainModule(int preferenceID, boolean flag)
save a boolean preference
void savePreferenceATOMKind_MainModule(String value)
returned from mainModule
void appendPreference_mainModule(int preferenceID, String preferenceValue)
called to append to a a preference (which will be an identifier and a string, which can be converted ...
void setDiscoverM5PTClicker(boolean flag)
void setSensorsString_mainModule(char *sensorsString)
void resetAllPreferences_mainModule()
resets preferences.. Currently only reset all, but eventually reset(groups..)
boolean getPreferenceBoolean_mainModule(int preferenceID)
called to set a preference (which will be an identifier and a string, which can be converted to a num...
void storePreference_mainModule(int preferenceID, String preferenceValue)
called to append to a a preference (which will be an identifier and a string, which can be converted ...
void savePreferenceFloat_mainModule(int preferenceID, float val)
called to set a preference (which will be an identifier and a string, which can be converted to a num...
void savePreferenceIntFromString_mainModule(int preferenceID, char *val)
sets an int, but only if a valid integer, and no signs. If bad, then a 0 is stored
void requestChainSMARTButtons()
boolean topicInIncludeGroup(char *topic)
char * getPreference_mainModule(int preferenceID)
void setIncludeGroups(char *groups)
8.2.24 set the include group (and cache it), called from MQTT
char * getPreferenceString_mainModule(int preferenceID)
returns the preference but in it's own string buffer. As long as you use it before calling getPrefere...
void printPreferenceValues_mainModule()
print the preferences to SerialDebug
void savePreference_mainModule(int preferenceID, String preferenceValue)
called to set a preference (which will be an identifier and a string, which can be converted to a num...
#define PREFERENCE_USE_SPIFF_SETTING
8.22.22 to turn on/off SPIFF use (more below..)
#define PREFERENCE_PAIRED_DEVICE_ADDRESS_SETTING
the paired device for guest device feeding (6.6.22) .. but the Address 9.3.22
#define PREFERENCE_STEPPER_KIND_VALUE
uses STEPPER type
#define PREFERENCE_SENSOR_TILT_VALUE
Sensor preferences.
#define PREFERENCE_SUB_DAWGPACK_SETTING
8.17.22 to turn on/off subscribing to the dawgpack topic
#define PREFERENCE_SM_COMMAND_PIR_OFF_SETTING
1.11.24 The Semantic Marker command is sent on PIR, and the Command to send on OFF (or opposite)
#define PREFERENCE_SENSOR_PLUGS_SETTING
#define PREFERENCE_STEPPER_FACTORY_CLOCKWISE_MOTOR_DIRECTION_SETTING
#define PREFERENCE_BLE_SERVER_USE_DEVICE_NAME_SETTING
if set, the BLE Server (like PTFeeder) will tack on the device name (or none if not defined).
#define PREFERENCE_ONLY_GEN3_CONNECT_SETTING
if true, only BLEClient connect to GEN3 feeders..
#define PREFERENCE_SENDWIFI_WITH_BLE
sends the WIFI to all except current device if set
#define PREFERENCE_NO_BUTTON_CLICK_POWEROFF_SETTING
#define PREFERENCE_SUPPORT_GROUPS_SETTING
the preference for supporting GROUPS (default true)
#define PREFERENCE_SEMANTIC_MARKER_ZOOMED_VALUE
Display preferences (SemanticMarker etc) - boolean.
#define PREFERENCE_WIFI_CREDENTIAL_2_SETTING
#define PREFERENCE_STEPPER_RPM_SETTING
#define PREFERENCE_MAIN_BLE_SERVER_VALUE
#define PREFERENCE_PAIRED_DEVICE_SETTING
the paired device for guest device feeding (6.6.22)
#define PREFERENCE_STEPPER_BUZZER_VALUE
stepper preferences
#define PREFERENCE_DEV_ONLY_SM_SETTING
adding AP_DEBUG_MODE to let others know that DEBUG eprom is available. Turn this OFF for non dev
#define STEPPER_IS_TUMBLER
#define PREFERENCE_BLE_USE_DISCOVERED_PAIRED_DEVICE_SETTING
#define PREFERENCE_USE_DOC_FOLLOW_SETTING
for
#define PREFERENCE_ATOM_SOCKET_GLOBAL_ONOFF_SETTING
1.12.24 Whether the AtomSocket accepts global on/off messages
#define PREFERENCE_USE_SPIFF_MQTT_SETTING
#define PREFERENCE_DEBUG_INFO_SETTING
a place to put some kind of Last Will of what went wrong .. for now (> max tries)
#define PREFERENCE_FIRST_TIME_FEATURE_SETTING
a firsttime feature flag (only 1 per build) 7.12.22 defaulting to TRUE
#define PREFERENCE_DISPLAY_SCREEN_TIMEOUT_VALUE
sets the timeout value
#define PREFERENCE_IS_MINIMAL_MENU_SETTING
sets the max temp for a poweroff
#define PREFERENCE_USE_SPIFF_QRATOM_SETTING
For MQTT writing to the QRATOM.
#define PREFERENCE_DEVICE_NAME_SETTING
the device name itself (6.6.22)
#define PREFERENCE_HIGH_TEMP_POWEROFF_VALUE
sets the max temp for a poweroff
#define PREFERENCE_GROUP_NAMES_SETTING
the preference setting group names to subscribe (but empty or # go to wildcard, this also supports wi...
#define PREFERENCE_STEPPER_ANGLE_FLOAT_SETTING
#define PREFERENCE_STEPPER_2FEED_SETTING
#define PREFERENCE_STEPPER_AUTO_MOTOR_DIRECTION_SETTING
#define PREFERENCE_MAIN_GATEWAY_VALUE
#define PREFERENCE_STEPPER_CLOCKWISE_MOTOR_DIRECTION_SETTING
#define PREFERENCE_MAIN_BLE_CLIENT_VALUE
#define PREFERENCE_SM_ON_PIR_SETTING
1.10.24 Flag on whether a Semantic Marker command is sent on PIR, and the Command to send
#define PREFERENCE_ATOM_KIND_SETTING
1.4.24 What kind of ATOM plug (set, M5AtomKind, val= {M5AtomSocket, M5AtomScanner}
#define PREFERENCE_SM_COMMAND_PIR_SETTING
1.10.24 The Semantic Marker command is sent on PIR, and the Command to send
#define PREFERENCE_SENSORS_SETTING
void println_SPIFFModule(char *string)
The SPIFF module is for storing messages that are retrievable later as it stores on a folder area of ...
void sendStrings_SPIFFModule(int numberOfLines)
sends SPIFF module strings over MQTT, starting at the number back specified. This will use the curren...
void printTimestamp_SPIFFModule()
prints a timestamp time: <time> :
void printFile_SPIFFModule()
prints the spiff file to the SerialDebug output
void deleteFiles_SPIFFModule()
delete the spiff files..
void println_SPIFFModule_JSON(char *attribute, char *value)
4.4.24 output a line in JSON format adding timestamp as well
void setup_SPIFFModule()
the setup for this module
void saveScreen_SPIFFModule()
save the screen to a file on the SPIFF
boolean queryMatchesName_mainModule(char *name)
void startDelay(float delayAmountSeconds)
starts delay calculation
boolean delayFinished()
whether the currently delay is finished, false if not running at all
void stopDelay()
stops delay