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"
72#include <ArduinoJson.h>
75#include <Preferences.h>
77#ifdef USE_REST_MESSAGING
78#include <WiFiClientSecure.h>
82#include <PubSubClient.h>
94void setupWIFI(
char * arg_ssid,
char * arg_password);
99#define MAXglobalMQTTAttempts 10
101#define MAX_MQTT_ATTEMPTS 10
104#define MAX_WIFI_CONNECT_ATTEMPTS 30
111void setupMQTT(
char* mqttServerString,
char *mqttPortString,
char *mqttPasswordString,
char *mqttUserString,
char *deviceNameString,
char *uuidString);
140#define STATUS "#STATUS"
142#define REMOTEME "#remoteMe"
143#define REMOTE2 "#REMOTE"
145#define FEED_2 "#feedme"
146#define ACK_FEED "#actMe"
147#define ACK_FEED2 "#ackMe"
148#define CONNECTED "#connectedMe"
149#define NOT_CONNECTED "#noconnectedMe"
150#define NO_ACK_FEED "#noactMe"
151#define PLAY_ME "#playMe"
152#define DOCFOLLOW "#docFollow"
153#define DOCFOLLOW2 "#DOCFOLLOW"
154#define DOCSYNC "#docSync"
155#define NO_CAN "#NO_CAN"
158#define FOLLOW_ME "#followMe"
200 int len = strlen(
"Version-(3.7)-3.22.24")+3;
222#ifdef PROCESS_SMART_BUTTON_JSON
224#define MAX_MESSAGE 2024
227#define MAX_MESSAGE 1024
229#define MAX_MESSAGE 600
234#define MAX_MESSAGE_DOCFOLLOW 300
248#define _preferencesJSONName "JSONPrefs"
277 boolean skip =
false;
296#define TRY_MORE_ASYNC_PROCESSING
297#ifdef TRY_MORE_ASYNC_PROCESSING
303 SerialMin.printf(
"Publish message(%s): %s\n",topic, message);
306 SerialMin.println(
" *** MQTT not connected .. message will queue until connected (hopefully)" );
329 SerialMin.printf(
"publishSMRunMessage: %s\n", smrunMessage);
330#ifdef ATOM_QRCODE_MODULE
338 WiFiClient postClient;
340 String serverName =
"knowledgeshark.me";
342 String serverPath =
"/examples/servlets/servlet/RequestParamExample";
344 int serverPort = 8080;
345 SerialDebug.println(
"2. Connecting to server: " + serverName);
349 if (postClient.connect(serverName.c_str(), serverPort))
351 String firstname = smrunMessage;
353 firstname.replace(
"&",
"%26");
356 firstname.replace(
"smart",
"smrun");
357 firstname.replace(
"smflowinfo",
"smrun");
361 SerialDebug.printf(
"RequstParamExample Connection successful! \n");
362 String head =
"--KonaCurrents\r\nContent-Disposition: form-data; name=\"firstname\"\r\nContent-Type: image/jpeg\r\n\r\n";
363 String tail =
"\r\n--KonaCurrents--\r\n";
366 head =
"firstname=" + firstname;
368 uint32_t imageLen = 0;
369 uint32_t extraLen = head.length() + tail.length();
370 uint32_t totalLen = imageLen + extraLen;
372 postClient.println(
"POST " + serverPath +
" HTTP/1.1");
373 postClient.println(
"Host: " + serverName);
375 postClient.println(
"Content-Type: application/x-www-form-urlencoded");
376 postClient.println(
"Content-Length: " + String(totalLen));
378 postClient.println();
379 postClient.print(head);
380 postClient.print(tail);
387 SerialTemp.println(
"POST " + serverPath +
" HTTP/1.1");
388 SerialTemp.println(
"Host: " + serverName);
389 SerialTemp.println(
"Content-Type: application/x-www-form-urlencoded");
390 SerialTemp.println(
"Content-Length: " + String(totalLen));
391 SerialTemp.println();
392 SerialTemp.print(head);
393 SerialTemp.println(tail);
398 SerialDebug.printf(
"Connection NOT successful! ");
406#ifdef USE_CAMERA_MODULE_XXX
409#include "esp_camera.h"
417 SerialMin.printf(
"Publish binary file(%s), len=%d\n", topic, len);
429 WiFiClient postClient;
431 String serverName =
"knowledgeshark.me";
433 String serverPath =
"/examples/servlets/UploadServlet";
435 int serverPort = 8080;
436 SerialDebug.println(
"2. Connecting to server: " + serverName);
438 if (postClient.connect(serverName.c_str(), serverPort))
440 SerialDebug.printf(
"Connection successful! len = %d\n", len);
442 String head =
"--KonaCurrents\r\nContent-Disposition: form-data; name=\"imageFile\"; filename=\"" +
443 filename +
"\"\r\nContent-Type: image/jpeg\r\n\r\n";
444 String tail =
"\r\n--KonaCurrents--\r\n";
446 uint32_t imageLen = len;
447 uint32_t extraLen = head.length() + tail.length();
448 uint32_t totalLen = imageLen + extraLen;
450 postClient.println(
"POST " + serverPath +
" HTTP/1.1");
451 postClient.println(
"Host: " + serverName);
452 postClient.println(
"Content-Length: " + String(totalLen));
453 postClient.println(
"Content-Type: multipart/form-data; boundary=KonaCurrents");
454 postClient.println();
455 postClient.print(head);
457 uint8_t *fbBuf = buf;
459 for (
size_t n=0; n<fbLen; n=n+1024)
463 postClient.write(fbBuf, 1024);
466 else if (fbLen%1024>0)
468 size_t remainder = fbLen%1024;
469 postClient.write(fbBuf, remainder);
472 postClient.print(tail);
494 SerialDebug.printf(
"Connection NOT successful! ");
505#ifdef USE_SPIFF_MODULE
514 char *fileExtension = (
char*)
"json";
516 SerialMin.printf(
"publishSPIFFFile topic=%s, file(%s) len = %d\n", topic, path, len);
524 WiFiClient postClient;
526 String serverName =
"knowledgeshark.me";
528 String serverPath =
"/examples/servlets/UploadServlet";
530 int serverPort = 8080;
531 SerialDebug.println(
"2. Connecting to server: " + serverName);
534 char *addFront = (
char*)
"[";
535 char *addBack = (
char*)
"{}]";
536 len = len + strlen(addFront) + strlen(addBack);
538 if (postClient.connect(serverName.c_str(), serverPort))
540 SerialDebug.printf(
"Connection successful! len = %d\n", len);
542 String head =
"--KonaCurrents\r\nContent-Disposition: form-data; name=\"imageFile\"; filename=\"" +
543 filename +
"\"\r\nContent-Type: file/JSON\r\n\r\n";
544 String tail =
"\r\n--KonaCurrents--\r\n";
546 uint32_t imageLen = len;
547 uint32_t extraLen = head.length() + tail.length();
548 uint32_t totalLen = imageLen + extraLen;
550 postClient.println(
"POST " + serverPath +
" HTTP/1.1");
551 postClient.println(
"Host: " + serverName);
552 postClient.println(
"Content-Length: " + String(totalLen));
553 postClient.println(
"Content-Type: multipart/form-data; boundary=KonaCurrents");
554 postClient.println();
555 postClient.print(head);
563 File file =
fs.open(path);
564 if(!file || file.isDirectory()){
565 SerialDebug.println(
"- failed to open file for reading");
570 postClient.write(addFront, strlen(addFront));
572 SerialDebug.println(head);
575 while(file.available())
577 String line = file.readString();
582 line.replace(
"'",
"\"");
584 SerialDebug.println(line);
588 postClient.write(line.c_str(), line.length());
591 SerialDebug.println(tail);
594 postClient.write(addBack, strlen(addBack));
599 postClient.print(tail);
618 SerialDebug.printf(
"Connection NOT successful! ");
639#define TRY_READING_BACK
640#ifdef TRY_READING_BACK
645 SerialDebug.print(
"Reading.12 EPROM JSON = ");
667 if (!savedDeviceName)
668 savedDeviceName = NOTSET_STRING;
686 for (
int i = 0; i < 17; i = i + 8) {
687 _chipId |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
695 Serial.printf(
"ESP32 Chip model = %s Rev %d\n", ESP.getChipModel(), ESP.getChipRevision());
696 Serial.printf(
"This chip has %d cores\n", ESP.getChipCores());
698 Serial.print(
"Chip Name: "); Serial.println(
_chipName);
717 SerialLots.print(
"getDynamicStatusFunc: ");
761 SerialLots.print(
"setLastMessageStatus: ");
762 SerialLots.println(token);
774 if (strcasecmp(token,
"FEED")==0)
776 else if (strcasecmp(token,
"STATUS")==0)
816 SerialTemp.print(
"getDynamicMessageFunc: ");
823#define WIFI_MQTT_STATES
824#ifdef WIFI_MQTT_STATES
870#define USE_TIMER_DELAY_CLASS
872#ifdef USE_TIMER_DELAY_CLASS
893unsigned long _delayStart_WIFI_MQTTState;
895boolean _delayRunning_WIFI_MQTTState =
false;
897float _delaySeconds_WIFI_MQTTState;
902 SerialLots.printf(
"startDelay_WIFI_MQTTState(%f)\n", seconds);
903 _delayStart_WIFI_MQTTState =
millis();
904 _delayRunning_WIFI_MQTTState =
true;
905 _delaySeconds_WIFI_MQTTState = seconds;
911 if (_delayRunning_WIFI_MQTTState && ((
millis() - _delayStart_WIFI_MQTTState) >= (_delaySeconds_WIFI_MQTTState * 1000)))
913 _delayRunning_WIFI_MQTTState =
false;
922 _delayRunning_WIFI_MQTTState =
false;
934#ifdef USE_SPIFF_MODULE
935#ifdef USE_SPIFF_MQTT_SETTING_NOT_NOW
975#ifdef ESP_M5_TOO_MUCH
992 SerialDebug.println(
"setup_MQTTNetworking");
997 SerialDebug.println(
"setupMQTTNetworking already setup..");
1005 SerialDebug.println(
" .. continue setup_MQTTNetworking");
1019 SerialTemp.println();
1035 SerialLots.printf(
"isConnectedWIFI_MQTTState: %s\n",
_mqttClient.connected()?
"connected":
"not connected");
1040 SerialTemp.printf(
"isConnectedWIFI_MQTTState: %s\n",
_mqttClient.connected()?
"connected":
"not connected");
1064 SerialDebug.println(
"loop_MQTTNetworking .. null ssid");
1117 switch (WiFi.status())
1119 case WL_NO_SHIELD:
return (
char*)
"WL_NO_SHIELD";
1120 case WL_IDLE_STATUS:
return (
char*)
"WL_IDLE_STATUS";
1121 case WL_NO_SSID_AVAIL:
return (
char*)
"WL_NO_SSID_AVAIL";
1122 case WL_SCAN_COMPLETED:
return (
char*)
"WL_SCAN_COMPLETED";
1123 case WL_CONNECTED :
return (
char*)
"WL_CONNECTED";
1124 case WL_CONNECT_FAILED:
return (
char*)
"WL_CONNECT_FAILED";
1125 case WL_CONNECTION_LOST:
return (
char*)
"WL_CONNECTION_LOST";
1127 case WL_DISCONNECTED:
return (
char*)
"WL_DISCONNECTED";
1145 SerialCall.printf(
"startdelayCheckWIFI_MQTTNetworking: %d\n", seconds);
1172 SerialCall.println(
"delayCheckWIFIFinished_MQTTNetworking..");
1182 SerialCall.println(
"stopDelayCheckWIFI_MQTTNetworking _delayRunning=false");
1208 SerialMin.printf(
"checkAndReconnectWIFI_MQTTState: %s\n",
wifiStatus_MQTT());
1209 boolean tryReconnect =
true;
1210 switch (WiFi.status())
1214 case WL_IDLE_STATUS:
1216 case WL_NO_SSID_AVAIL:
1219 case WL_SCAN_COMPLETED:
1230 tryReconnect =
true;
1232 tryReconnect =
false;
1234 case WL_CONNECT_FAILED:
1241 case WL_CONNECTION_LOST:
1249 case WL_DISCONNECTED:
1276 SerialMin.println(
"reconnectAttempt");
1302 SerialDebug.printf(
"1. Connecting to '%s' password = '%s'\n", arg_ssid?arg_ssid:
"NULL", arg_password?arg_password:
"NULL");
1319 if (!arg_ssid || (arg_ssid && strlen(arg_ssid)==0))
1321 SerialDebug.println(
" NULL SSID in setupWIFI .. so leaving");
1340 WiFi.mode(WIFI_STA);
1341 WiFi.begin(arg_ssid, arg_password);
1343 SerialDebug.println(
"WIF_STA mode..");
1364 if (WiFi.status() == WL_CONNECTED)
1366 SerialDebug.println(
"WiFi.status() == WL_CONNECTED()");
1367#ifdef STORE_DEBUG_INFO
1375 WiFi.setAutoReconnect(
true);
1382#ifdef STORE_DEBUG_INFO
1405 SerialDebug.println(
"WIFI **** Cannot connect .. try bluetooth update ... ");
1407#ifdef STORE_DEBUG_INFO
1409 SerialTemp.println(
"Before storePref");
1413 SerialTemp.println(
"after 1. storePref");
1416 SerialTemp.println(
"After storePref");
1425#ifdef GO_BACK_TO_ORIGINAL
1448String _WIFIInfoString;
1452 long rssi = WiFi.RSSI();
1454 _WIFIInfoString =
"IP Address: " + WiFi.localIP();
1455 _WIFIInfoString +=
"\n WIFI SSID" + String(WiFi.SSID());
1456 _WIFIInfoString +=
"\n RSSI" + rssi;
1459 SerialDebug.println(_WIFIInfoString.c_str());
1460 return _WIFIInfoString;
1466 sprintf(buf,
"%s",WiFi.SSID());
1467 return "\n WIFI SSID: " + String(WiFi.SSID());
1480 SerialMin.println(
"WiFi connected");
1481 SerialMin.print(
"IP Address: ");
1482 SerialMin.println(WiFi.localIP());
1483 SerialMin.print(
"WiFi SSID:");
1484 SerialMin.println(WiFi.SSID());
1485 long rssi = WiFi.RSSI();
1486 SerialMin.print(
"signal strength (RSSI):");
1487 SerialMin.print(rssi);
1488 SerialMin.println(
" dBm");
1496 SerialMin.println(
"finishWIFI_Setup()");
1499 randomSeed(micros());
1523 SerialDebug.println(
"setupMQTTNetworking_WIFI done..");
1589 if (strcmp(topic,
"usersP/dawgpack")==0)
1591 else if (strcmp(topic,
"usersP/bark") == 0)
1597 SerialDebug.printf(
"Group Topic: %s\n", topic);
1606 SerialDebug.print(
"Topic = ");
1610 SerialDebug.println(
"userTopic");
1614 SerialDebug.println(
"dawgPackTopic");
1618 SerialDebug.println(
"superTopic");
1622 SerialDebug.println(
"groupTopic");
1635 SerialLots.printf(
"callbackMQTTHandler topic: %s\n", topic);
1653 SerialDebug.printf(
"MessageArrived: '%s', onTopic=%s\n",
_fullMessageIn, topic);
1665 SerialDebug.printf(
"NOT PRocessing as PREFERENCE_SUPPORT_GROUPS_SETTING not set");
1672 SerialDebug.printf(
"2.NOT Processing as topic not in Include Group: %s", topic);
1683#ifdef TRY_MORE_ASYNC_PROCESSING
1686 SerialLots.printf(
"MessageArrived: '%s', onTopic=%s\n",
_fullMessageIn, topic);
1701 SerialLots.println(
" -- DONE processsBarkletMessage ----");
1715 SerialDebug.println(
" *** No ssid or password");
1727 SerialDebug.println(
"reconnectMQTT_loop: _mqttClient.connected()");
1728#ifdef STORE_DEBUG_INFO
1738#ifdef STORE_DEBUG_INFO
1756#ifdef NOT_IN_ORIGINAL
1768 SerialInfo.println(
"FAILED MQTT .. so lets try connecting to WIFI again..");
1769 SerialInfo.println(
"Setting WIFI from JSON parameters");
1771#ifdef STORE_DEBUG_INFO
1781#ifdef USE_REST_MESSAGING
1791#ifdef STORE_DEBUG_INFO
1801 String clientId =
"espM5-";
1804 String clientId =
"esp32-";
1806 clientId += String(random(0xffff), HEX);
1808 SerialDebug.printf(
"attempt _mqttClient.connect(%s)\n", clientId);
1823#ifdef STORE_DEBUG_INFO
1828 SerialInfo.println(
"MQTT CONNECTED");
1836 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());
1840#ifdef TRY_MORE_ASYNC_PROCESSING
1847#ifdef NOT_NOW_ONLY_DOCFOLLOW
1848#ifdef TRY_MORE_ASYNC_PROCESSING
1866 SerialDebug.printf(
"Subscribing to groups as PREFERENCE_SUPPORT_GROUPS_SETTING was set: %s\n", groupNames);
1868 if (strlen(groupNames)==0 || strcmp(groupNames,
"#")== 0)
1873 SerialTemp.printf(
"Subscribe usersP/groups/#\n");
1891 char *str = groupNames;
1894 for (token = strtok_r(str,
",",&rest); token != NULL; token = strtok_r(NULL,
",", &rest))
1896 sprintf(groupSub,
"usersP/groups/%s", token);
1898 SerialTemp.printf(
"Subscribe %s\n", groupSub);
1931#ifdef STORE_DEBUG_INFO
1940 SerialTemp.printf(
"FAILED, rc=%d, trying again in 0.2 seconds\n",
_mqttClient.state());
1951void setupMQTT(
char* mqttServerString,
char *mqttPortString,
char *mqttPasswordString,
char *mqttUserString,
char *deviceNameString,
char *uuidString)
1953 SerialTemp.println(
"**** setupMQTT *****");
1954#ifdef STORE_DEBUG_INFO
1963 if (mqttServerString && mqttPortString && mqttPasswordString && mqttUserString)
1966 int port = atoi(mqttPortString);
1991#ifdef STORE_DEBUG_INFO
1996 SerialInfo.println(
" *** No MQTT Server/Port Specified ** abort");
2000#ifdef STORE_DEBUG_INFO
2002 SerialTemp.println(
"done setupMQTT");
2014#ifdef TRY_MORE_ASYNC_PROCESSING
2040 return strcmp(&message[0], &substring[0]) == 0;
2052 SerialDebug.println(
"cleanEPROM_MQTTNetworking");
2077#ifdef TRY_MORE_ASYNC_PROCESSING
2102#ifdef TRY_MORE_ASYNC_PROCESSING
2125#ifdef TRY_MORE_ASYNC_PROCESSING
2150#ifdef TRY_MORE_ASYNC_PROCESSING
2162 SerialTemp.println(
"sendStatusMessageMQTT..");
2164 sprintf(
_fullMessageOut,
"#remoteMe {%s} {AVM=%s}", deviceName, semanticMarker);
2170#ifdef TRY_MORE_ASYNC_PROCESSING
2187 SerialCall.println(
"sendDocFollowMessageMQTT..");
2191#ifdef ESP_M5_ATOM_LITE
2202#ifdef TRY_MORE_ASYNC_PROCESSING
2220 char *messageString = &message[0];
2222 bool messageValidToSendBack =
false;
2223 SerialCall.print(
"processBarkletMessage: ");
2224 SerialCall.print(message);
2225 SerialCall.print(
" topic=");
2226 SerialCall.println(topic);
2254 char pairedDevice[100];
2262 strcpy(pairedDevice,
"none");
2268 if (isConnectedBLE && isGateway)
2272 sprintf(
_fullMessageOut,
"%s {%s} {%s} {I,F} {'T':'%d','dev':'%s','user':'%s','location':'%s','v':'%s','ble':'%s,%s}",
2293#ifdef TRY_MORE_ASYNC_PROCESSING
2304 SerialTemp.println(
"Sending on DawgPack too..");
2307#ifdef TRY_MORE_ASYNC_PROCESSING
2323 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",
2325 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'}",
2384 messageValidToSendBack =
true;
2402 boolean performFeed =
true;
2404 performFeed =
false;
2429 SerialTemp.println(
" *** Feeding via our gateway ***");
2434 SerialDebug.println(
" ** Not feeding as not our paired device either ***");
2435 performFeed =
false;
2442 SerialDebug.printf(
"**NOT Perform FEED as deviceName doesn't ours: %s\n",
_deviceNameString );
2444 performFeed =
false;
2456 messageValidToSendBack =
false;
2469 char *indexOfEqual = index(&message[0],
'=');
2470 if (strlen(indexOfEqual)>2)
2475 while (*indexOfEqual && *indexOfEqual !=
'}')
2493 if (strlen(JSON_String) > 0)
2496 char * my_argument =
const_cast<char*
> (topic.c_str());
2506 messageValidToSendBack =
true;
2508#ifdef PASS_ONTO_PLUGS
2512#ifdef ESP_M5_CAMERA_not_here
2514 takePicture_MainModule();
2517#ifdef M5_CAPTURE_SCREEN
2524 messageValidToSendBack =
false;
2541 messageValidToSendBack =
true;
2586 sprintf(
_fullMessageOut,
"over the air binary image update from version: %s", VERSION);
2598 sprintf(
_fullMessageOut,
"over the air NOT updating as not matching string: %s",
2613 SerialDebug.println(
"DAWGPACK unsupported message");
2616 if (messageValidToSendBack)
2621#ifdef TRY_MORE_ASYNC_PROCESSING
2633 SerialTemp.println(
"2.Sending on DawgPack too..");
2636#ifdef TRY_MORE_ASYNC_PROCESSING
2648#ifdef TRY_MORE_ASYNC_PROCESSING
2665 sprintf(
_fullMessageOut,
"over the air binary image update, replacing our version: %s", VERSION);
2672#ifdef REALLY_DO_IT_BOMBS
2705 SerialDebug.println(
"Perform FEED internally, calling callbackFunction.. 2");
2720#define ACK_FOR_PAIR_TOO
2721 char pairedDevice[100];
2725 strcpy(pairedDevice,
"none");
2736 if (isConnectedBLE && isGateway)
2739 SerialTemp.print(
"PairedDevice: ");
2740 SerialTemp.println(pairedDevice);
2741 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");
2746#ifdef TRY_MORE_ASYNC_PROCESSING
2760#ifdef TRY_MORE_ASYNC_PROCESSING
2772#ifdef TRY_MORE_ASYNC_PROCESSING
2782 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());
2790 if (moreStatus && strlen(moreStatus) > 0)
2808#ifdef TRY_MORE_ASYNC_PROCESSING
2823#ifdef TRY_MORE_ASYNC_PROCESSING
2835#ifdef TRY_MORE_ASYNC_PROCESSING
2854 SerialDebug.println(
"MQTT.readPreferences");
2859 SerialDebug.println(
"BOOTSTRAP device with our own WIFI and MQTT");
2861 char* BOOT_mqtt_server = (
char*)
"iDogWatch.com";
2864 char* BOOT_mqtt_port = (
char*)
"1883";
2865 char* BOOT_ssid = (
char*)
"SunnyWhiteriver";
2866 char* BOOT_ssid_password = (
char*)
"sunny2021";
2867 char *BOOT_mqtt_user = (
char*)
"test";
2868 char *BOOT_mqtt_password = (
char*)
"test";
2869 char *BOOT_mqtt_guestPassword = (
char*)
"test";
2873 char *BOOT_mqtt_topic = (
char*)
"usersP/bark/test";
2875 char *BOOT_deviceName = (
char*)
"name-of-feeder";
2876 char *BOOT_uuidString = (
char*)
"unused";
2877 char *BOOT_jsonHeaderString = (
char*)
"WIFI+MQTT";
2878 char *BOOT_jsonVersionString = (
char*)
"BOOTSTRAP 1.3";
2879 char *BOOT_jsonLocationString = (
char*)
"PetLand";
2898 DynamicJsonDocument myObject(1024);
2900 myObject[
"ssid"] = BOOT_ssid;
2901 myObject[
"ssidPassword"] = BOOT_ssid_password;
2902 myObject[
"mqtt_server"] = BOOT_mqtt_server;
2903 myObject[
"mqtt_port"] = BOOT_mqtt_port;
2904 myObject[
"mqtt_password"] = BOOT_mqtt_password;
2905 myObject[
"mqtt_guestPassword"] = BOOT_mqtt_guestPassword;
2907 myObject[
"mqtt_user"] = BOOT_mqtt_user;
2908 myObject[
"mqtt_topic"] = BOOT_mqtt_topic;
2909 myObject[
"deviceName"] = BOOT_deviceName;
2910 myObject[
"uuid"] = BOOT_uuidString;
2911 myObject[
"jsonHeader"] = BOOT_jsonHeaderString;
2912 myObject[
"jsonVersion"] = BOOT_jsonVersionString;
2913 myObject[
"location"] = BOOT_jsonLocationString;
2920 SerialDebug.print(
"Writing EPROM JSON = ");
2923 serializeJson(myObject, output1);
2924 SerialDebug.println(output1);
2934 SerialDebug.print(
"Reading.3 EPROM JSON = ");
2946#ifdef BOOTSTRAP_AP_MODE_STARTUP
2947 SerialDebug.println(
"*** STARTUP in AP MODE ***");
2960 SerialDebug.print(
"Reading.1 EPROM JSON = ");
2972 SerialDebug.println(
"*** no JSON in preferences, probably first time. use Bootstrap, or BLE update ***");
2978 DynamicJsonDocument myObject(1024);
2981 SerialDebug.print(
"JSON parsed.1 = ");
2983 serializeJson(myObject, output1);
2984 SerialDebug.println(output1);
2995 const char* a1 = myObject[
"ssid"];
2997 if (a1 && strlen(a1)>0)
3010 SerialDebug.println(
"ssid == NULL");
3015 SerialDebug.println(
"No SSID set, try BLE update again.. ");
3043 const char* a2 = myObject[
"ssidPassword"];
3056 const char* a3 = myObject[
"mqtt_server"];
3068 const char* a4 = myObject[
"mqtt_port"];
3079 const char* a5 = myObject[
"mqtt_password"];
3091 const char* a6 = myObject[
"mqtt_user"];
3102 const char* a7 = myObject[
"deviceName"];
3118 const char* a8 = myObject[
"uuid"];
3123 SerialDebug.print(
"UUID: ");
3132 const char* a9 = myObject[
"mqtt_topic"];
3143 const char* a10 = myObject[
"jsonHeader"];
3155 const char* a11 = myObject[
"jsonVersion"];
3166 const char* a12 = myObject[
"location"];
3177 const char* a13 = myObject[
"mqtt_guestPassword"];
3197 return valCmdString.equalsIgnoreCase(
"on") ||
3198 valCmdString.equalsIgnoreCase(
"1") ||
3199 valCmdString.equalsIgnoreCase(
"true");
3203function isFalseString(String valCmdString)
3205 return valCmdString.equalsIgnoreCase(
"off") ||
3206 valCmdString.equalsIgnoreCase(
"0") ||
3207 valCmdString.equalsIgnoreCase(
"false");
3228 SerialTemp.println(
" *** processJSONMessageMQTT ***");
3233 boolean foundCommand;
3255 SerialDebug.printf(
"NOT Processing as PREFERENCE_SUPPORT_GROUPS_SETTING not set");
3262 SerialDebug.printf(
"NOT Processing as topic not in Include Group: %s", topic);
3274 SerialLots.printf(
"processJSONMessageMQTT(%s) -> return false, not JSON\n", ascii);
3279 SerialDebug.printf(
"processJSONMessageMQTT: '%s'\n", ascii);
3283 SerialLots.printf(
"Ascii before deserializeJson: %s\n", ascii);
3285#ifdef PROCESS_SMART_BUTTON_JSON
3286 DynamicJsonDocument myObject(2024);
3289 DynamicJsonDocument myObject(1024);
3291 DynamicJsonDocument myObject(1024);
3295 deserializeJson(myObject, ascii);
3296 serializeJsonPretty(myObject, Serial);
3299 SerialDebug.print(
"\nJSON parsed = ");
3302 serializeJson(myObject, output1);
3303 SerialDebug.println(output1);
3304 SerialLots.printf(
"Ascii after deserializeJson: %s\n", ascii);
3310 const char* cmd = myObject[
"cmd"];
3311 const char* semanticMarkerCmd = myObject[
"sm"];
3312 const char* guestCmd = myObject[
"guest"];
3315 const char *set64Cmd = myObject[
"set64"];
3317 const char *setCmd = myObject[
"set"];
3318 const char *valCmd = myObject[
"val"];
3320 const char *sendCmd = myObject[
"send"];
3322 const char *devName = myObject[
"dev"];
3324 boolean processCommands =
false;
3325 if (cmd || semanticMarkerCmd || guestCmd || setCmd || sendCmd || set64Cmd)
3326 processCommands =
true;
3328#ifdef PROCESS_SMART_BUTTON_JSON
3333 SerialTemp.printf(
"SMARTButton = %d\n", processSMARTButton);
3335 if (processSMARTButton)
3336 processCommands =
true;
3344 String guestPassword =
"pettutor";
3365 if (processCommands)
3370 char* setCmdString =
const_cast<char*
>(setCmd);
3371 char* valCmdString =
const_cast<char*
>(valCmd);
3373 if (setCmd && strcasecmp(setCmd,
"semanticMarker")==0)
3375 SerialDebug.printf(
"DAWGPACK supported message: %s\n", setCmd);
3379 SerialDebug.println(
"DAWGPACK unsupported message");
3387 boolean deviceNameSpecified = devName != NULL;
3389 boolean processMessageOrGateway =
true;
3390 if (deviceNameSpecified)
3393 processMessageOrGateway =
false;
3394#ifdef WILDCARD_DEVICE_NAME_SUPPORT
3396 parseQueryLine_mainModule((char*)devName);
3399 SerialTemp.printf(
"Query: %s *** Matches our dev name: %s\n", devName,
_deviceNameString);
3400 processMessageOrGateway =
true;
3406 SerialTemp.printf(
"ChipID: %s *** Matches our ChipID name: %s\n", devName,
getChipIdString());
3407 processMessageOrGateway =
true;
3414 SerialTemp.println(
" .. our own device ..");
3415 processMessageOrGateway =
true;
3423#ifdef WILDCARD_DEVICE_NAME_SUPPORT
3427 processMessageOrGateway =
true;
3432 SerialTemp.println(
" .. our paired device ..");
3433 processMessageOrGateway =
true;
3446#ifdef PROCESS_SMART_BUTTON_JSON
3450 if (processMessageOrGateway && processSMARTButton)
3452 StaticJsonDocument<2024> smartButtonObject;
3454 deserializeJson(smartButtonObject, myObject[
"SMARTButton"]);
3456 return processJSONSMARTButton(smartButtonObject);
3460 if (!processMessageOrGateway)
3463 SerialTemp.print(
"Disregard as Device Specified: ");
3464 SerialTemp.print(devName);
3467 SerialTemp.print(
" not ours: ");
3471#ifdef WILDCARD_DEVICE_NAME_SUPPORT
3477 SerialTemp.print(
" .. And not paired device:");
3492 SerialTemp.printf(
"MQTT or BLE CMD = '%s'\n", cmd);
3495 if (whichSMMode >= 0)
3501 SerialDebug.printf(
"currentSMMode = %d whichSMMode = %d\n", currentSMMode, whichSMMode);
3509 if (currentSMMode != whichSMMode)
3511 SerialDebug.println(
" *** Not changing page as in DOCFOLLOW mode ***");
3515 SerialDebug.println(
" *** SM_doc_follow and changing to the same page ***");
3521 boolean markerAlreadyShown =
false;
3522 switch (whichSMMode)
3528 baseString = (
char*)
"https://iDogWatch.com/bot/guestpage2";
3529 title =
"MINI CLICKER";
3537 baseString = (
char*)
"https://iDogWatch.com/bot/guestpage2";
3545 baseString = (
char*)
"https://iDogWatch.com/bot/guestpage2";
3553 baseString = (
char*)
"https://iDogWatch.com/bot/guestpage2";
3567 title =
"WIFI FEED";
3577 markerAlreadyShown =
true;
3601 markerAlreadyShown =
true;
3608 baseString = (
char*)
"https://iDogWatch.com/bot/guestpage";
3609 title =
"Guest Page";
3615 baseString = (
char*)
"https://iDogWatch.com/bot/feedguest";
3616 title =
"Feed Guest";
3622 baseString = (
char*)
"https://iDogWatch.com/bot/feedguestdevice";
3653 title =
"Help Info";
3661 title =
"DOC FOLLOW";
3666 SM =
"https://SemanticMarker.org";
3692 if (!markerAlreadyShown)
3702 SerialDebug.println(
"OTA via BLE");
3708 else if (strcasecmp(cmd,
"click")==0)
3713 else if (strcasecmp(cmd,
"clean")==0 && !
isGroupTopic())
3715 SerialDebug.println(
"CLEAN via BLE");
3719 else if (strcasecmp(cmd,
"feed")==0)
3721 SerialDebug.printf(
"FEED via BLE (%s)\n",topic?topic:
"NULL TOPIC!!");
3724 else if (strcasecmp(cmd,
"resettimer")==0)
3728 else if (strcasecmp(cmd,
"status")==0)
3730 SerialDebug.println(
"STATUS via BLE");
3749 SerialLots.println(
"cmd == status");
3753 else if (strcasecmp(cmd,
"erase")==0 && !
isGroupTopic())
3755 SerialDebug.println(
"ERASE via BLE");
3760 else if (strcasecmp(cmd,
"buzzon")==0)
3762 SerialDebug.println(
"BUZZON via BLE");
3765 else if (strcasecmp(cmd,
"buzzoff")==0)
3767 SerialDebug.println(
"BUZZOFF via BLE");
3772 else if (strcasecmp(cmd,
"gatewayOn")==0)
3774 if (deviceNameSpecified)
3776 SerialDebug.println(
"ASYNC_SET_GATEWAY_ON via BLE");
3780 else if (strcasecmp(cmd,
"gatewayOff")==0)
3782 if (deviceNameSpecified)
3784 SerialDebug.println(
"ASYNC_SET_GATEWAY_OFF via BLE");
3789 else if (strcasecmp(cmd,
"resetfirsttime")==0)
3791 if (deviceNameSpecified)
3793 SerialDebug.println(
"PREFERENCE_FIRST_TIME_FEATURE_SETTING ON via BLE");
3800 else if (strcasecmp(cmd,
"bleclientOn")==0 && !
isGroupTopic())
3802 if (deviceNameSpecified)
3804 SerialDebug.println(
"PREFERENCE_MAIN_BLE_CLIENT_VALUE ON via BLE");
3810 else if (strcasecmp(cmd,
"bleclientOff")==0 && !
isGroupTopic())
3812 if (deviceNameSpecified)
3814 SerialDebug.println(
"PREFERENCE_MAIN_BLE_CLIENT_VALUE OFF via BLE");
3820 else if (strcasecmp(cmd,
"bleserverOn")==0 && !
isGroupTopic())
3822 if (deviceNameSpecified)
3824 SerialDebug.println(
"PREFERENCE_MAIN_BLE_SERVER_VALUE ON via BLE");
3830 else if (strcasecmp(cmd,
"bleserverOff")==0 && !
isGroupTopic())
3832 if (deviceNameSpecified)
3834 SerialDebug.println(
"PREFERENCE_MAIN_BLE_SERVER_VALUE OFF via BLE");
3840 else if (strcasecmp(cmd,
"reboot")==0 && !
isGroupTopic())
3842 if (deviceNameSpecified)
3844 SerialDebug.println(
"REBOOT via BLE");
3849 else if (strcasecmp(cmd,
"tiltOn")==0)
3851 SerialDebug.println(
"PREFERENCE_SENSOR_TILT_VALUE ON via BLE");
3854 else if (strcasecmp(cmd,
"tiltOff")==0)
3856 SerialDebug.println(
"PREFERENCE_SENSOR_TILT_VALUE OFF via BLE");
3860 else if (strcasecmp(cmd,
"zoomSMOn")==0)
3865 SerialDebug.println(
"PREFERENCE_SEMANTIC_MARKER_ZOOMED_VALUE ON via BLE");
3876 else if (strcasecmp(cmd,
"zoomSMOff")==0)
3880 SerialDebug.println(
"PREFERENCE_SEMANTIC_MARKER_ZOOMED_VALUE OFF via BLE");
3898 else if (strcasecmp(cmd,
"poweroff")==0 && !
isGroupTopic())
3900 SerialDebug.println(
"ASYNC_POWEROFF OFF via BLE");
3904 else if (strcasecmp(cmd,
"wifi")==0)
3906 SerialDebug.println(
"cmd=wifi via BLE");
3909 else if (strcasecmp(cmd,
"swapwifi")==0)
3911 SerialDebug.println(
"cmd=swapwifi via BLE");
3922#ifdef USE_SPIFF_MODULE
3924 else if (strcasecmp(cmd,
"readspiff")==0)
3926 SerialDebug.println(
"readspiff...");
3930 else if (strcasecmp(cmd,
"sendspiff")==0)
3934 else if (strcasecmp(cmd,
"deletespiff")==0 && !
isGroupTopic())
3939 else if (strcasecmp(cmd,
"capture")==0)
3948 else if (strcasecmp(cmd,
"help")==0)
3953 sprintf(
_fullMessageOut,
"Syntax {\'cmd': \'[ota|clean|feed|erase|status|buzzon|buzzoff| MORE..help]\'} ");
3956#ifdef TRY_MORE_ASYNC_PROCESSING
3970 char* sendCmdString =
const_cast<char*
>(cmd);
3984 else if (semanticMarkerCmd)
3987 char* baseString = (
char*)
"https://SemanticMarker.org/bot/";
3991 boolean showSM =
true;
3993 showSM = deviceNameSpecified;
3999 SerialDebug.println(
"Not showing SemanticMarker ");
4004 else if (setCmd && valCmd)
4007 char* setCmdString =
const_cast<char*
>(setCmd);
4008 char* valCmdString =
const_cast<char*
>(valCmd);
4009 SerialTemp.print(
"Set: ");
4010 SerialTemp.print(setCmdString);
4011 SerialTemp.print(
", Val: ");
4012 SerialTemp.println(valCmdString);
4027 if (strcasecmp(setCmdString,
"hightemp")==0)
4033 else if (strcasecmp(setCmdString,
"cmd")==0)
4035 if (strcasecmp(valCmdString,
"feed")==0)
4037 SerialCall.printf(
"feed via set,cmd (%s)\n",topic?topic:
"NULL TOPIC!!");
4040 else if (strcasecmp(valCmdString,
"status")==0)
4042 SerialCall.println(
"status via set,cmd");
4046 else if (strcasecmp(valCmdString,
"resettimer")==0)
4053 SerialTemp.printf(
"1.Unknown cmd: %s\n", valCmdString);
4056#pragma mark COPIED FROM BELOW .. so can set without DEVICE name
4057#define USE_WITHOUT_DEVICE_NAME
4068#ifdef USE_WITHOUT_DEVICE_NAME
4070 else if (strcasecmp(setCmdString,
"stepperangle")==0)
4072 SerialDebug.printf(
"stepperAngle: %s\n", valCmdString);
4075 foundCommand =
true;
4081 else if (strcasecmp(setCmdString,
"stepperRPM")==0)
4083 SerialDebug.printf(
"stepperRPM: %s\n", valCmdString);
4086 foundCommand =
true;
4091 else if (strcasecmp(setCmdString,
"sensorPlugs")==0)
4095 SerialDebug.printf(
"sensorPlugs: %s\n", valCmdString);
4096 foundCommand =
true;
4104 else if (strcasecmp(setCmdString,
"sensors")==0)
4112 foundCommand =
true;
4115 else if (strcasecmp(setCmdString,
"M5AtomKind")==0)
4120 foundCommand =
true;
4127#pragma mark Device Name and Not Group
4131 foundCommand =
true;
4133 if (strcasecmp(setCmdString,
"devOnlySM")==0)
4143 else if (strcasecmp(setCmdString,
"autoMotorDirection")==0)
4152 else if (strcasecmp(setCmdString,
"includeGroups")==0)
4158 else if (strcasecmp(setCmdString,
"ble+wifi")==0)
4163 else if (strcasecmp(setCmdString,
"factoryreset")==0)
4170 else if (strcasecmp(setCmdString,
"restartmodels")==0)
4176 else if (strcasecmp(setCmdString,
"screentimeout")==0)
4181 else if (strcasecmp(setCmdString,
"stepperangle")==0)
4183 SerialDebug.printf(
"stepperAngle: %s\n", valCmdString);
4190 else if (strcasecmp(setCmdString,
"stepperRPM")==0)
4192 SerialDebug.printf(
"stepperRPM: %s\n", valCmdString);
4197 else if (strcasecmp(setCmdString,
"noclick")==0)
4202 else if (strcasecmp(setCmdString,
"gateway")==0)
4208 else if (strcasecmp(setCmdString,
"DiscoverM5PTClicker")==0)
4213 else if (strcasecmp(setCmdString,
"usespiff")==0 && !
isGroupTopic())
4217#ifdef USE_SPIFF_MODULE
4226 else if (strcasecmp(setCmdString,
"usespiff_mqtt")==0 && !
isGroupTopic())
4231 else if (strcasecmp(setCmdString,
"usespiff_qratom")==0 && !
isGroupTopic())
4239 else if (strcasecmp(setCmdString,
"PIR_UseSM")==0 && !
isGroupTopic())
4245 else if (strcasecmp(setCmdString,
"AtomSocketGlobalOnOff")==0 && !
isGroupTopic())
4251 else if (strcasecmp(setCmdString,
"LUXdark")==0 && !
isGroupTopic())
4257 else if (strcasecmp(setCmdString,
"scannedGroup")==0 && !
isGroupTopic())
4264 else if (strcasecmp(setCmdString,
"scannedDevice")==0 && !
isGroupTopic())
4272 else if (strcasecmp(setCmdString,
"timerdelay")==0)
4274 int timerdelay = atoi(valCmdString);
4278 SerialDebug.printf(
"timerdelay: %d\n", timerdelay);
4282 else if (strcasecmp(setCmdString,
"timerdelayMax")==0)
4284 int timerdelay = atoi(valCmdString);
4288 SerialDebug.printf(
"timerdelayMax: %d\n", timerdelay);
4291 else if (strcasecmp(setCmdString,
"starttimer")==0)
4296 SerialDebug.printf(
"startTimer: %d\n", flag);
4301 else if (strcasecmp(setCmdString,
"sensorPlugs")==0)
4305 SerialDebug.printf(
"sensorPlugs: %s\n", valCmdString);
4313 else if (strcasecmp(setCmdString,
"sensors")==0)
4322 else if (strcasecmp(setCmdString,
"stepper")==0)
4326 float stepperAngle = 22.5;
4329 if (strcasecmp(valCmdString,
"mini")==0)
4333 stepperAngle = 45.0;
4336 else if (strcasecmp(valCmdString,
"tumbler")==0)
4339 stepperAngle = 200.0;
4349 SerialDebug.printf(
"stepper = %d, stepperAngle = %f\n", feederType, stepperAngle);
4360 else if (strcasecmp(setCmdString,
"factoryClockwiseMotor")==0)
4362 SerialCall.println(
" *** Setting factory clockwise motor");
4368 else if (strcasecmp(setCmdString,
"clockwiseMotor")==0)
4370 SerialCall.println(
" *** Setting clockwise motor");
4378 else if (strcasecmp(setCmdString,
"toggleMotor")==0)
4386 currentDirection = !currentDirection;
4390 else if (strcasecmp(setCmdString,
"otafile")==0)
4396 else if (strcasecmp(setCmdString,
"location")==0 && !
isGroupTopic())
4406 else if (strcasecmp(setCmdString,
"pairnow")==0)
4419 else if (strcasecmp(setCmdString,
"pairdev")==0)
4422 if (strcasecmp(valCmdString,previousName)!=0)
4446#ifdef NO_MORE_PREFERENCE_BLE_USE_DISCOVERED_PAIRED_DEVICE_SETTING
4447 if (strlen(valCmdString)==0)
4458 else if (strcasecmp(setCmdString,
"usegroups")==0)
4467 else if (strcasecmp(setCmdString,
"groups")==0)
4477 foundCommand =
false;
4479#pragma mark END of device and not group
4484 if (strcasecmp(setCmdString,
"device")==0 && !
isGroupTopic())
4496 else if (strcasecmp(setCmdString,
"screencolor")==0)
4499 int screenColor = atoi(valCmdString);
4506 else if (strcasecmp(setCmdString,
"gen3only")==0)
4518 else if (strcasecmp(setCmdString,
"BLEUsePairedDeviceName")==0)
4522#ifdef NO_MORE_PREFERENCE_BLE_USE_DISCOVERED_PAIRED_DEVICE_SETTING
4530 else if (strcasecmp(setCmdString,"BLEUseDeviceName")==0)
4546 else if (strcasecmp(setCmdString,
"minMenu")==0)
4548 SerialDebug.println(
"PREFERENCE_IS_MINIMAL_MENU_SETTING via BLE");
4563 else if (strcasecmp(setCmdString,
"addwifi")==0)
4570 strcpy(str,valCmdString);
4573 char* ssid = strtok_r(rest,
":", &rest);
4574 char* password = strtok_r(rest,
":", &rest);
4575 SerialDebug.printf(
"addwifi %s, %s\n", ssid?ssid:
"null", password?password:
"");
4582 char credentials[100];
4584 sprintf(credentials,
"{'ssid':'%s','ssidPassword':'%s'}", ssid?ssid:
"NULL", password?password:
"");
4586 SerialMin.println(credentials);
4600 else if (strcasecmp(setCmdString,
"usedocfollow")==0)
4602 SerialDebug.printf(
"PREFERENCE_USE_DOC_FOLLOW_SETTING %s\n", valCmdString);
4607 else if (strcasecmp(setCmdString,
"semanticMarker")==0)
4609 SerialDebug.printf(
"SemanticMarker: %s\n", valCmdString);
4613 boolean showSM =
true;
4615 showSM = deviceNameSpecified;
4621 SerialDebug.println(
"Not showing SemanticMarker ");
4625 else if (strcasecmp(setCmdString,
"blankscreen")==0)
4638 else if (strcasecmp(setCmdString,
"SubDawgpack")==0)
4642 SerialDebug.println(
"PREFERENCE_SUB_DAWGPACK_SETTING via BLE");
4656 _mqttClient.unsubscribe((
char*)
"usersP/dawgpack");
4662 else if (strcasecmp(setCmdString,
"buzz")==0 && !
isGroupTopic())
4668 SerialDebug.println(
"BUZZ:ON via BLE");
4673 SerialDebug.println(
"BUZZ:OFF via BLE");
4680 else if (strcasecmp(setCmdString,
"bleclient")==0)
4684 SerialDebug.println(
"PREFERENCE_MAIN_BLE_CLIENT_VALUE via BLE");
4692 else if (strcasecmp(setCmdString,
"bleserver")==0)
4696 SerialDebug.println(
"PREFERENCE_MAIN_BLE_SERVER_VALUE via BLE");
4702 else if (strcasecmp(setCmdString,
"tilt")==0)
4706 SerialDebug.println(
"PREFERENCE_SENSOR_TILT_VALUE via BLE");
4712 else if (strcasecmp(setCmdString,
"zoomSm")==0)
4720 SerialDebug.println(
"PREFERENCE_SEMANTIC_MARKER_ZOOMED_VALUE ON via BLE");
4735 SerialDebug.println(
"PREFERENCE_SEMANTIC_MARKER_ZOOMED_VALUE OFF via BLE");
4755 else if (strcasecmp(setCmdString,
"buttonA")==0)
4757 if (strcasecmp(valCmdString,
"longpress")==0)
4759 else if (strcasecmp(valCmdString,
"shortpress")==0)
4762 else if (strcasecmp(setCmdString,
"buttonB")==0)
4764 if (strcasecmp(valCmdString,
"longpress")==0)
4766 else if (strcasecmp(valCmdString,
"shortpress")==0)
4769 else if (strcasecmp(setCmdString,
"M5AtomKind")==0 && !
isGroupTopic())
4778 else if (strcasecmp(setCmdString,
"disk")==0)
4780 SerialDebug.printf(
"Cloud DISK space = %s\n", valCmdString);
4782 else if (strcasecmp(setCmdString,
"feedcount")==0)
4784 SerialDebug.printf(
"Global feed count = %s\n", valCmdString);
4788 SerialMin.printf(
"2.Unknown cmd: %s (isGroupTopic=%d)\n", setCmdString,
isGroupTopic());
4798 char* sendCmdString =
const_cast<char*
>(sendCmd);
4802 if (strcasecmp(sendCmdString,
"temp")==0)
4804 SerialCall.println(
"sendCmd == temp");
4808 else if (strcasecmp(sendCmdString,
"status")==0)
4810 SerialCall.println(
"sendCmd == status");
4815 else if (strcasecmp(sendCmdString,
"capture")==0)
4817 SerialCall.println(
"sendCmd == capture");
4824 else if (strcasecmp(sendCmdString,
"volume")==0)
4826 SerialCall.println(
"sendCmd == volume (not implemented)");
4833 SerialTemp.print(
"Unknown send request: ");
4834 SerialTemp.println(sendCmdString);
4843 char* setCmdString =
const_cast<char*
>(set64Cmd);
4844 char* valCmdString =
const_cast<char*
>(valCmd);
4846 char plaintext_out[200];
4847 int len = strlen(valCmdString);
4850 SerialError.println(
"Length too long to base64 decode: 200");
4854 int status = base64_decode_chars(valCmdString, len, plaintext_out);
4855 String decoded = String(plaintext_out);
4862 SerialDebug.println(decoded);
4864 if (strcasecmp(setCmdString,
"semanticMarker")==0 && !
isGroupTopic())
4870 boolean showSM =
true;
4872 showSM = deviceNameSpecified;
4883 SerialDebug.println(
"Not showing SemanticMarker ");
4885 else if (strcasecmp(setCmdString,
"PIR_SM_JSON")==0 && !
isGroupTopic())
4898 else if (strcasecmp(setCmdString,
"PIR_OFF_SM_JSON")==0 && !
isGroupTopic())
4914 else if (strcasecmp(setCmdString,
"ScannedSemanticMarker")==0)
4921 char * my_argument =
const_cast<char*
> (decoded.c_str());
4973#ifdef ONLY_NULL_IF_THERE
4974 SerialDebug.println(
" *** processMQTT .. treat like credentials");
4976 const char* a1 = myObject[
"ssid"];
4983 SerialTemp.printf(
"myObject[ssid] = '%s'\n", a1?a1:
"EMPTY");
4989 const char* a2 = myObject[
"ssidPassword"];
4998 SerialDebug.println(
" *** processMQTT .. treat like credentials");
5000 const char* a1 = myObject[
"ssid"];
5001 if (a1 && strlen(a1)>0)
5008 SerialTemp.printf(
"myObject[ssid] = '%s'\n", a1?a1:
"EMPTY");
5014 const char* a2 = myObject[
"ssidPassword"];
5015 if (a2 && strlen(a2)>0)
5032 const char* a3 = myObject[
"mqtt_server"];
5042 const char* a4 = myObject[
"mqtt_port"];
5053 const char* a5 = myObject[
"mqtt_password"];
5064 const char* a6 = myObject[
"mqtt_user"];
5075 const char* a7 = myObject[
"deviceName"];
5076 if (a7 && strlen(a7)>0)
5085 const char* a8 = myObject[
"uuid"];
5087 if (a8 && strlen(a8)>0)
5099 const char* a9 = myObject[
"mqtt_topic"];
5101 if (a9 && strlen(a9)>0)
5114 const char* a10 = myObject[
"mqtt_guestPassword"];
5116 if (a10 && strlen(a10)>0)
5129 const char* a11 = myObject[
"location"];
5130 if (a11 && strlen(a11)>0)
5142 boolean saveJSONPreferences =
true;
5146 SerialDebug.println(
"Setting WIFI from JSON parameters");
5157 SerialDebug.println(
" ***** ERROR .. no ssidString *** ");
5161 saveJSONPreferences =
false;
5166 if (!saveJSONPreferences)
5168 SerialDebug.println(
"**** Not saving JSON in preferences ***");
5198 SerialDebug.println(
"set disconnectedWIFI and stopDelay");
5213 SerialDebug.println(
"cleanMQTTpasswordsUpdateInEPROM");
5227 DynamicJsonDocument myObject(1024);
5263 serializeJson(myObject, output2);
5267 SerialDebug.print(
"MQTTNetworking.Writing EPROM JSON = '");
5268 SerialDebug.print(output2);
5269 SerialDebug.println(
"'");
5278#define NO_NEED_AND_GRU_CRASH
5279#ifdef NO_NEED_AND_GRU_CRASH
5284 SerialDebug.print(
"Reading.2 EPROM JSON = ");
5299 s.replace(
"%20",
" ");
5300 s.replace(
"+",
" ");
5301 s.replace(
"%21",
"!");
5302 s.replace(
"%22",
"\"");
5303 s.replace(
"%23",
"#");
5304 s.replace(
"%24",
"$");
5305 s.replace(
"%25",
"%");
5306 s.replace(
"%26",
"&");
5307 s.replace(
"%27",
"\'");
5308 s.replace(
"%28",
"(");
5309 s.replace(
"%29",
")");
5310 s.replace(
"%30",
"*");
5311 s.replace(
"%31",
"+");
5312 s.replace(
"%2C",
",");
5313 s.replace(
"%2E",
".");
5314 s.replace(
"%2F",
"/");
5315 s.replace(
"%2C",
",");
5316 s.replace(
"%3A",
":");
5317 s.replace(
"%3B",
";");
5318 s.replace(
"%3C",
"<");
5319 s.replace(
"%3D",
"=");
5320 s.replace(
"%3E",
">");
5321 s.replace(
"%3F",
"?");
5322 s.replace(
"%40",
"@");
5323 s.replace(
"%5B",
"[");
5324 s.replace(
"%5C",
"\\");
5325 s.replace(
"%5D",
"]");
5326 s.replace(
"%5E",
"^");
5327 s.replace(
"%5F",
"-");
5328 s.replace(
"%60",
"`");
5329 s.replace(
"%7B",
"{");
5330 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..
char * getServiceName_BLEServerNetworking()
retrieve the service name (PTFEEDER, PTFeeder:Name, PTClicker:Name, etc)
void showSemanticMarkerFunc_displayModule(String semanticMarkerAddressBase, String title, const char *(*getStatusFunc)(void))
the function to call to get the 'status', return char*
void addToTextMessages_displayModule(String text)
void wakeupScreen_displayModule()
wakes up the screen
void showText_displayModule(String text)
void redrawSemanticMarker_displayModule(boolean startNew)
redraws the Semantic Marker 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 (title = to 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 ...
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 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
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_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_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