15#include "../../Defines.h"
17#ifdef USE_CAMERA_MODULE
18#include <HTTPClient.h>
46#define ESP_EPROM_NAME "ESP32"
49#ifdef USE_MQTT_NETWORKING
61#include <ArduinoJson.h>
64#include <Preferences.h>
79void setupWIFI(
char * arg_ssid,
char * arg_password);
84#define MAXglobalMQTTAttempts 10
86#define MAX_MQTT_ATTEMPTS 10
89#define MAX_WIFI_CONNECT_ATTEMPTS 30
96void setupMQTT(
char* mqttServerString,
char *mqttPortString,
char *mqttPasswordString,
char *mqttUserString,
char *deviceNameString,
char *uuidString);
125#define STATUS "#STATUS"
127#define REMOTE "#remoteMe"
128#define REMOTE2 "#REMOTE"
130#define FEED_2 "#feedme"
131#define ACK_FEED "#actMe"
132#define ACK_FEED2 "#ackMe"
133#define CONNECTED "#connectedMe"
134#define NOT_CONNECTED "#noconnectedMe"
135#define NO_ACK_FEED "#noactMe"
136#define PLAY_ME "#playMe"
137#define DOCFOLLOW "#docFollow"
138#define DOCFOLLOW2 "#DOCFOLLOW"
139#define DOCSYNC "#docSync"
140#define NO_CAN "#NO_CAN"
143#define FOLLOW_ME "#followMe"
182#define MAX_MESSAGE 600
191#define _preferencesJSONName "JSONPrefs"
214 boolean skip =
false;
225#define TRY_MORE_ASYNC_PROCESSING
226#ifdef TRY_MORE_ASYNC_PROCESSING
232 SerialMin.printf(
"Publish message(%s): %s\n",topic, message);
235 SerialMin.println(
" *** MQTT not connected .. message will queue until connected (hopefully)" );
253#ifdef USE_CAMERA_MODULE
263 SerialMin.printf(
"Publish binary file(%s), len=%d\n", topic, len);
269#ifdef USE_CAMERA_MODULE
274 WiFiClient postClient;
276 String serverName =
"knowledgeshark.me";
278 String serverPath =
"/examples/servlets/UploadServlet";
280 int serverPort = 8080;
281 SerialDebug.println(
"Connecting to server: " + serverName);
283 if (postClient.connect(serverName.c_str(), serverPort))
285 SerialDebug.printf(
"Connection successful! len = %d\n", len);
286 String filename =
"esp32-cam-" + String(
getDeviceNameMQTT()) +
"-" + String(random(0xffff), HEX) +
".jpg";
287 String head =
"--KonaCurrents\r\nContent-Disposition: form-data; name=\"imageFile\"; filename=\"" +
288 filename +
"\"\r\nContent-Type: image/jpeg\r\n\r\n";
289 String tail =
"\r\n--KonaCurrents--\r\n";
291 uint32_t imageLen = len;
292 uint32_t extraLen = head.length() + tail.length();
293 uint32_t totalLen = imageLen + extraLen;
295 postClient.println(
"POST " + serverPath +
" HTTP/1.1");
296 postClient.println(
"Host: " + serverName);
297 postClient.println(
"Content-Length: " + String(totalLen));
298 postClient.println(
"Content-Type: multipart/form-data; boundary=KonaCurrents");
299 postClient.println();
300 postClient.print(head);
302 uint8_t *fbBuf = buf;
304 for (
size_t n=0; n<fbLen; n=n+1024)
308 postClient.write(fbBuf, 1024);
311 else if (fbLen%1024>0)
313 size_t remainder = fbLen%1024;
314 postClient.write(fbBuf, remainder);
317 postClient.print(tail);
334 SerialDebug.printf(
"Connection NOT successful! ");
383 for (
int i = 0; i < 17; i = i + 8) {
384 _chipId |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
408 SerialLots.print(
"getDynamicStatusFunc: ");
448 SerialLots.print(
"setLastMessageStatus: ");
449 SerialLots.println(token);
457 if (strcasecmp(token,
"FEED")==0)
459 else if (strcasecmp(token,
"STATUS")==0)
498 SerialTemp.print(
"getDynamicMessageFunc: ");
505#define WIFI_MQTT_STATES
506#ifdef WIFI_MQTT_STATES
564 SerialLots.printf(
"startDelay_WIFI_MQTTState(%f)\n", seconds);
597 SerialDebug.println(
"setup_MQTTNetworking");
602 SerialDebug.println(
"setupMQTTNetworking already setup..");
610 SerialDebug.println(
" .. continue setup_MQTTNetworking");
624 SerialTemp.println();
640 SerialLots.printf(
"isConnectedWIFI_MQTTState: %s\n",
_mqttClient.connected()?
"connected":
"not connected");
645 SerialTemp.printf(
"isConnectedWIFI_MQTTState: %s\n",
_mqttClient.connected()?
"connected":
"not connected");
711 switch (WiFi.status())
713 case WL_NO_SHIELD:
return (
char*)
"WL_NO_SHIELD";
714 case WL_IDLE_STATUS:
return (
char*)
"WL_IDLE_STATUS";
715 case WL_NO_SSID_AVAIL:
return (
char*)
"WL_NO_SSID_AVAIL";
716 case WL_SCAN_COMPLETED:
return (
char*)
"WL_SCAN_COMPLETED";
717 case WL_CONNECTED :
return (
char*)
"WL_CONNECTED";
718 case WL_CONNECT_FAILED:
return (
char*)
"WL_CONNECT_FAILED";
719 case WL_CONNECTION_LOST:
return (
char*)
"WL_CONNECTION_LOST";
721 case WL_DISCONNECTED:
return (
char*)
"WL_DISCONNECTED";
739 SerialCall.printf(
"startdelayCheckWIFI_MQTTNetworking: %d\n", seconds);
765 SerialCall.println(
"delayCheckWIFIFinished_MQTTNetworking..");
775 SerialCall.println(
"stopDelayCheckWIFI_MQTTNetworking _delayRunning=false");
801 SerialMin.printf(
"checkAndReconnectWIFI_MQTTState: %s\n",
wifiStatus_MQTT());
802 boolean tryReconnect =
true;
803 switch (WiFi.status())
809 case WL_NO_SSID_AVAIL:
812 case WL_SCAN_COMPLETED:
825 tryReconnect =
false;
827 case WL_CONNECT_FAILED:
831 case WL_CONNECTION_LOST:
835 case WL_DISCONNECTED:
851 SerialMin.println(
"reconnectAttempt");
877 SerialInfo.printf(
"\nConnecting to '%s' password = '%s'\n", arg_ssid?arg_ssid:
"NULL", arg_password?arg_password:
"NULL");
885 WiFi.begin(arg_ssid, arg_password);
906 if (WiFi.status() == WL_CONNECTED)
908 SerialDebug.println(
"WiFi.status() == WL_CONNECTED()");
914 WiFi.setAutoReconnect(
true);
939 SerialInfo.println(
"WIFI **** Cannot connect .. try bluetooth update ... ");
961 SerialMin.println(
"WiFi connected");
962 SerialMin.print(
"IP Address: ");
963 SerialMin.println(WiFi.localIP());
964 SerialMin.print(
"WiFi SSID:");
965 SerialMin.println(WiFi.SSID());
966 long rssi = WiFi.RSSI();
967 SerialMin.print(
"signal strength (RSSI):");
968 SerialMin.print(rssi);
969 SerialMin.println(
" dBm");
975 SerialMin.println(
"finishWIFI_Setup()");
978 randomSeed(micros());
1000 SerialDebug.println(
"setupMQTTNetworking_WIFI done..");
1058 if (strcmp(topic,
"usersP/dawgpack")==0)
1060 else if (strcmp(topic,
"usersP/bark") == 0)
1069 SerialDebug.print(
"Topic = ");
1073 SerialDebug.println(
"userTopic");
1077 SerialDebug.println(
"dawgPackTopic");
1081 SerialDebug.println(
"superTopic");
1094 SerialLots.printf(
"callbackMQTTHandler topic: %s\n", topic);
1112 SerialDebug.printf(
"MessageArrived: '%s', onTopic=%s\n",
_fullMessageIn, topic);
1120#ifdef TRY_MORE_ASYNC_PROCESSING
1123 SerialLots.printf(
"MessageArrived: '%s', onTopic=%s\n",
_fullMessageIn, topic);
1138 SerialLots.println(
" -- DONE processsBarkletMessage ----");
1151 SerialDebug.println(
"reconnectMQTT_loop: _mqttClient.connected()");
1169 SerialInfo.println(
"FAILED MQTT .. so lets try connecting to WIFI again..");
1170 SerialInfo.println(
"Setting WIFI from JSON parameters");
1189 String clientId =
"espM5-";
1192 String clientId =
"esp32-";
1194 clientId += String(random(0xffff), HEX);
1196 SerialDebug.printf(
"attempt _mqttClient.connect(%s)\n", clientId);
1212 SerialInfo.println(
"MQTT CONNECTED");
1220 sprintf(
_fullMessageOut,
"%s {%s}{'mqttUser':'%s','location':'%s','uptime':'%d','v':'%s'}",
REMOTE,
_deviceNameString?
_deviceNameString:
"NULL",
_mqttUserString?
_mqttUserString:
"NULL",
_jsonLocationString?
_jsonLocationString:
"somewhere",
getUptime(), VERSION);
1224#ifdef TRY_MORE_ASYNC_PROCESSING
1231#ifdef NOT_NOW_ONLY_DOCFOLLOW
1232#ifdef TRY_MORE_ASYNC_PROCESSING
1270 SerialInfo.printf(
"FAILED, rc=%d, trying again in 0.2 seconds\n",
_mqttClient.state());
1281void setupMQTT(
char* mqttServerString,
char *mqttPortString,
char *mqttPasswordString,
char *mqttUserString,
char *deviceNameString,
char *uuidString)
1283 SerialTemp.println(
"**** setupMQTT *****");
1285 if (mqttServerString && mqttPortString && mqttPasswordString && mqttUserString)
1288 int port = atoi(mqttPortString);
1301 SerialInfo.println(
" *** No MQTT Server/Port Specified ** abort");
1312#ifdef TRY_MORE_ASYNC_PROCESSING
1338 return strcmp(&message[0], &substring[0]) == 0;
1350 SerialDebug.println(
"cleanEPROM_MQTTNetworking");
1372#ifdef TRY_MORE_ASYNC_PROCESSING
1395#ifdef TRY_MORE_ASYNC_PROCESSING
1407 SerialTemp.println(
"sendStatusMessageMQTT..");
1408 sprintf(
_fullMessageOut,
"#remoteMe {%s} {AVM=%s}", deviceName, semanticMarker);
1413#ifdef TRY_MORE_ASYNC_PROCESSING
1430 SerialTemp.println(
"sendDocFollowMessageMQTT..");
1439#ifdef TRY_MORE_ASYNC_PROCESSING
1457 char *messageString = &message[0];
1459 bool messageValidToSendBack =
false;
1460 SerialCall.print(
"processBarkletMessage: ");
1461 SerialCall.print(message);
1462 SerialCall.print(
" topic=");
1463 SerialCall.println(topic);
1491 char pairedDevice[100];
1499 strcpy(pairedDevice,
"none");
1500#ifdef USE_BLE_CLIENT_NETWORKING
1503 boolean isConnectedBLE =
false;
1507 if (isConnectedBLE && isGateway)
1511 sprintf(
_fullMessageOut,
"%s {%s} {%s} {I,F} {'T':'%d','dev':'%s','user':'%s','location':'%s','v':'%s','ble':'%s'}",
1520#ifdef USE_BLE_SERVER_NETWORKING
1532#ifdef TRY_MORE_ASYNC_PROCESSING
1543 SerialTemp.println(
"Sending on DawgPack too..");
1546#ifdef TRY_MORE_ASYNC_PROCESSING
1558 sprintf(
_fullMessageOut,
"%s {%s} {%s} {I,F} {'T':'%d','dev':'%s','user':'%s','location':'%s','ble':'%s','v':'%s'}",
1566#ifdef USE_BLE_SERVER_NETWORKING
1574 messageValidToSendBack =
true;
1588 boolean performFeed =
true;
1612 SerialTemp.println(
" *** Feeding via our gateway ***");
1617 SerialDebug.println(
" ** Not feeding as not our paired device either ***");
1618 performFeed =
false;
1625 SerialDebug.printf(
"**NOT Perform FEED as deviceName doesn't ours: %s\n",
_deviceNameString );
1627 performFeed =
false;
1639 messageValidToSendBack =
false;
1651 char *indexOfEqual = index(&message[0],
'=');
1652 if (strlen(indexOfEqual)>2)
1657 while (*indexOfEqual && *indexOfEqual !=
'}')
1676 messageValidToSendBack =
true;
1686#ifdef M5_CAPTURE_SCREEN
1693 messageValidToSendBack =
false;
1708 messageValidToSendBack =
true;
1755 sprintf(
_fullMessageOut,
"over the air binary image update from version: %s", VERSION);
1767 sprintf(
_fullMessageOut,
"over the air NOT updating as not matching string: %s",
1782 SerialDebug.println(
"DAWGPACK unsupported message");
1785 if (messageValidToSendBack)
1790#ifdef TRY_MORE_ASYNC_PROCESSING
1802 SerialTemp.println(
"2.Sending on DawgPack too..");
1805#ifdef TRY_MORE_ASYNC_PROCESSING
1822 sprintf(
_fullMessageOut,
"over the air binary image update, replacing our version: %s", VERSION);
1829#ifdef REALLY_DO_IT_BOMBS
1862 SerialDebug.println(
"Perform FEED internally, calling callbackFunction.. 2");
1874#define ACK_FOR_PAIR_TOO
1875 char pairedDevice[100];
1879 strcpy(pairedDevice,
"none");
1881#ifdef USE_BLE_CLIENT_NETWORKING
1884 boolean isConnectedBLE =
false;
1888 if (isConnectedBLE && isGateway)
1891 SerialTemp.print(
"PairedDevice: ");
1892 SerialTemp.println(pairedDevice);
1893 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");
1898#ifdef TRY_MORE_ASYNC_PROCESSING
1912#ifdef TRY_MORE_ASYNC_PROCESSING
1920 sprintf(
_fullMessageOut,
"%s {%s} {'T':'%d','temp':'%2.0f','topic':'%s','user':'%s','v':'%s','location':'%s','paired':'%s', 'ble':'%s','gateway':'%s'}",
ACK_FEED,
_deviceNameString, time, temp, &topic[0]?&topic[0]:
"NULL",
_mqttUserString, VERSION_SHORT,
_jsonLocationString?
_jsonLocationString:
"somewhere",pairedDevice, isConnectedBLE?
"c":
"x", isGateway?
"on":
"off");
1931#ifdef TRY_MORE_ASYNC_PROCESSING
1946#ifdef TRY_MORE_ASYNC_PROCESSING
1965 SerialDebug.println(
"MQTT.readPreferences");
1970 SerialDebug.println(
"BOOTSTRAP device with our own WIFI and MQTT");
1972 char* BOOT_mqtt_server = (
char*)
"iDogWatch.com";
1975 char* BOOT_mqtt_port = (
char*)
"1883";
1976 char* BOOT_ssid = (
char*)
"SunnyWhiteriver";
1977 char* BOOT_ssid_password = (
char*)
"sunny2021";
1978 char *BOOT_mqtt_user = (
char*)
"test";
1979 char *BOOT_mqtt_password = (
char*)
"test";
1980 char *BOOT_mqtt_guestPassword = (
char*)
"test";
1984 char *BOOT_mqtt_topic = (
char*)
"usersP/bark/test";
1986 char *BOOT_deviceName = (
char*)
"name-of-feeder";
1987 char *BOOT_uuidString = (
char*)
"unused";
1988 char *BOOT_jsonHeaderString = (
char*)
"WIFI+MQTT";
1989 char *BOOT_jsonVersionString = (
char*)
"BOOTSTRAP 1.3";
1990 char *BOOT_jsonLocationString = (
char*)
"PetLand";
2009 DynamicJsonDocument myObject(1024);
2011 myObject[
"ssid"] = BOOT_ssid;
2012 myObject[
"ssidPassword"] = BOOT_ssid_password;
2013 myObject[
"mqtt_server"] = BOOT_mqtt_server;
2014 myObject[
"mqtt_port"] = BOOT_mqtt_port;
2015 myObject[
"mqtt_password"] = BOOT_mqtt_password;
2016 myObject[
"mqtt_guestPassword"] = BOOT_mqtt_guestPassword;
2018 myObject[
"mqtt_user"] = BOOT_mqtt_user;
2019 myObject[
"mqtt_topic"] = BOOT_mqtt_topic;
2020 myObject[
"deviceName"] = BOOT_deviceName;
2021 myObject[
"uuid"] = BOOT_uuidString;
2022 myObject[
"jsonHeader"] = BOOT_jsonHeaderString;
2023 myObject[
"jsonVersion"] = BOOT_jsonVersionString;
2024 myObject[
"location"] = BOOT_jsonLocationString;
2031 SerialDebug.print(
"Writing EPROM JSON = ");
2034 serializeJson(myObject, output1);
2035 SerialDebug.println(output1);
2045 SerialDebug.print(
"Reading.3 EPROM JSON = ");
2065 SerialDebug.print(
"Reading.1 EPROM JSON = ");
2077 SerialDebug.println(
"*** no JSON in preferences, probably first time. use Bootstrap, or BLE update ***");
2083 DynamicJsonDocument myObject(1024);
2086 SerialDebug.print(
"JSON parsed.1 = ");
2088 serializeJson(myObject, output1);
2089 SerialDebug.println(output1);
2095 const char* a1 = myObject[
"ssid"];
2106 SerialDebug.println(
"ssid == NULL");
2111 SerialDebug.println(
"No SSID set, try BLE update again.. ");
2135 const char* a2 = myObject[
"ssidPassword"];
2148 const char* a3 = myObject[
"mqtt_server"];
2160 const char* a4 = myObject[
"mqtt_port"];
2171 const char* a5 = myObject[
"mqtt_password"];
2183 const char* a6 = myObject[
"mqtt_user"];
2194 const char* a7 = myObject[
"deviceName"];
2210 const char* a8 = myObject[
"uuid"];
2215 SerialDebug.print(
"UUID: ");
2224 const char* a9 = myObject[
"mqtt_topic"];
2235 const char* a10 = myObject[
"jsonHeader"];
2247 const char* a11 = myObject[
"jsonVersion"];
2258 const char* a12 = myObject[
"location"];
2269 const char* a13 = myObject[
"mqtt_guestPassword"];
2289 return valCmdString.equalsIgnoreCase(
"on") ||
2290 valCmdString.equalsIgnoreCase(
"1") ||
2291 valCmdString.equalsIgnoreCase(
"true");
2295function isFalseString(String valCmdString)
2297 return valCmdString.equalsIgnoreCase(
"off") ||
2298 valCmdString.equalsIgnoreCase(
"0") ||
2299 valCmdString.equalsIgnoreCase(
"false");
2314 SerialLots.println(
" *** processJSONMessageMQTT ***");
2334 SerialLots.printf(
"processJSONMessageMQTT(%s) -> return false, not JSON\n", ascii);
2339 SerialDebug.printf(
"processJSONMessageMQTT: '%s'\n", ascii);
2343 SerialLots.printf(
"Ascii before deserializeJson: %s\n", ascii);
2345 DynamicJsonDocument myObject(1024);
2346 deserializeJson(myObject, ascii);
2348 SerialDebug.print(
"JSON parsed = ");
2351 serializeJson(myObject, output1);
2352 SerialDebug.println(output1);
2353 SerialLots.printf(
"Ascii after deserializeJson: %s\n", ascii);
2359 const char* cmd = myObject[
"cmd"];
2360 const char* semanticMarkerCmd = myObject[
"sm"];
2361 const char* guestCmd = myObject[
"guest"];
2363 const char *setCmd = myObject[
"set"];
2364 const char *valCmd = myObject[
"val"];
2366 const char *sendCmd = myObject[
"send"];
2368 const char *devName = myObject[
"dev"];
2370 boolean processCommands =
false;
2371 if (cmd || semanticMarkerCmd || guestCmd || setCmd || sendCmd)
2372 processCommands =
true;
2378 String guestPassword =
"pettutor";
2399 if (processCommands)
2404 char* setCmdString =
const_cast<char*
>(setCmd);
2405 char* valCmdString =
const_cast<char*
>(valCmd);
2407 if (setCmd && strcasecmp(setCmd,
"semanticMarker")==0)
2409 SerialDebug.printf(
"DAWGPACK supported message: %s\n", setCmd);
2413 SerialDebug.println(
"DAWGPACK unsupported message");
2421 boolean deviceNameSpecified = devName != NULL;
2423 boolean processMessageOrGateway =
true;
2424 if (deviceNameSpecified)
2427 processMessageOrGateway =
false;
2428#ifdef WILDCARD_DEVICE_NAME_SUPPORT
2433 SerialTemp.printf(
"Query: %s *** Matches our dev name: %s\n", devName,
_deviceNameString);
2439 SerialTemp.println(
" .. our own device ..");
2440 processMessageOrGateway =
true;
2446#ifdef WILDCARD_DEVICE_NAME_SUPPORT
2455 SerialTemp.println(
" .. our paired device ..");
2456 processMessageOrGateway =
true;
2462 if (!processMessageOrGateway)
2465 SerialTemp.print(
"Disregard as Device Specified: ");
2466 SerialTemp.print(devName);
2469 SerialTemp.print(
" not ours: ");
2473#ifdef WILDCARD_DEVICE_NAME_SUPPORT
2480 SerialTemp.print(
" .. And not paired device:");
2494 SerialTemp.printf(
"BLE CMD = '%s'\n", cmd);
2497 if (whichSMMode >= 0)
2502 SerialDebug.printf(
"currentSMMode = %d whichSMMode = %d\n", currentSMMode, whichSMMode);
2510 if (currentSMMode != whichSMMode)
2512 SerialDebug.println(
" *** Not changing page as in DOCFOLLOW mode ***");
2516 SerialDebug.println(
" *** SM_doc_follow and changing to the same page ***");
2522 boolean markerAlreadyShown =
false;
2523 switch (whichSMMode)
2529 baseString = (
char*)
"https://iDogWatch.com/bot/guestpage2";
2530 title =
"MINI CLICKER";
2538 baseString = (
char*)
"https://iDogWatch.com/bot/guestpage2";
2546 baseString = (
char*)
"https://iDogWatch.com/bot/guestpage2";
2554 baseString = (
char*)
"https://iDogWatch.com/bot/guestpage2";
2568 title =
"WIFI FEED";
2578 markerAlreadyShown =
true;
2602 markerAlreadyShown =
true;
2609 baseString = (
char*)
"https://iDogWatch.com/bot/guestpage";
2610 title =
"Guest Page";
2616 baseString = (
char*)
"https://iDogWatch.com/bot/feedguest";
2617 title =
"Feed Guest";
2623 baseString = (
char*)
"https://iDogWatch.com/bot/feedguestdevice";
2654 title =
"Help Info";
2662 title =
"DOC FOLLOW";
2667 SM =
"https://SemanticMarker.org";
2692 if (!markerAlreadyShown)
2698 else if (strcasecmp(cmd,
"ota")==0)
2700 SerialDebug.println(
"OTA via BLE");
2704 else if (strcasecmp(cmd,
"clean")==0)
2706 SerialDebug.println(
"CLEAN via BLE");
2710 else if (strcasecmp(cmd,
"feed")==0)
2712 SerialDebug.printf(
"FEED via BLE (%s)\n",topic?topic:
"NULL TOPIC!!");
2715 else if (strcasecmp(cmd,
"resettimer")==0)
2719 else if (strcasecmp(cmd,
"status")==0)
2721 SerialDebug.println(
"STATUS via BLE");
2755 SerialLots.println(
"cmd == status");
2759 else if (strcasecmp(cmd,
"erase")==0)
2761 SerialDebug.println(
"ERASE via BLE");
2766 else if (strcasecmp(cmd,
"buzzon")==0)
2768 SerialDebug.println(
"BUZZON via BLE");
2771 else if (strcasecmp(cmd,
"buzzoff")==0)
2773 SerialDebug.println(
"BUZZOFF via BLE");
2778 else if (strcasecmp(cmd,
"gatewayOn")==0)
2780 if (deviceNameSpecified)
2782 SerialDebug.println(
"ASYNC_SET_GATEWAY_ON via BLE");
2786 else if (strcasecmp(cmd,
"gatewayOff")==0)
2788 if (deviceNameSpecified)
2790 SerialDebug.println(
"ASYNC_SET_GATEWAY_OFF via BLE");
2795 else if (strcasecmp(cmd,
"resetfirsttime")==0)
2797 if (deviceNameSpecified)
2799 SerialDebug.println(
"PREFERENCE_FIRST_TIME_FEATURE_SETTING ON via BLE");
2806 else if (strcasecmp(cmd,
"bleclientOn")==0)
2808 if (deviceNameSpecified)
2810 SerialDebug.println(
"PREFERENCE_MAIN_BLE_CLIENT_VALUE ON via BLE");
2816 else if (strcasecmp(cmd,
"bleclientOff")==0)
2818 if (deviceNameSpecified)
2820 SerialDebug.println(
"PREFERENCE_MAIN_BLE_CLIENT_VALUE OFF via BLE");
2826 else if (strcasecmp(cmd,
"bleserverOn")==0)
2828 if (deviceNameSpecified)
2830 SerialDebug.println(
"PREFERENCE_MAIN_BLE_SERVER_VALUE ON via BLE");
2836 else if (strcasecmp(cmd,
"bleserverOff")==0)
2838 if (deviceNameSpecified)
2840 SerialDebug.println(
"PREFERENCE_MAIN_BLE_SERVER_VALUE OFF via BLE");
2846 else if (strcasecmp(cmd,
"reboot")==0)
2848 if (deviceNameSpecified)
2850 SerialDebug.println(
"REBOOT via BLE");
2855 else if (strcasecmp(cmd,
"tiltOn")==0)
2857 SerialDebug.println(
"PREFERENCE_SENSOR_TILT_VALUE ON via BLE");
2860 else if (strcasecmp(cmd,
"tiltOff")==0)
2862 SerialDebug.println(
"PREFERENCE_SENSOR_TILT_VALUE OFF via BLE");
2866 else if (strcasecmp(cmd,
"zoomSMOn")==0)
2871 SerialDebug.println(
"PREFERENCE_SEMANTIC_MARKER_ZOOMED_VALUE ON via BLE");
2882 else if (strcasecmp(cmd,
"zoomSMOff")==0)
2886 SerialDebug.println(
"PREFERENCE_SEMANTIC_MARKER_ZOOMED_VALUE OFF via BLE");
2904 else if (strcasecmp(cmd,
"poweroff")==0)
2906 SerialDebug.println(
"ASYNC_POWEROFF OFF via BLE");
2910 else if (strcasecmp(cmd,
"wifi")==0)
2912 SerialDebug.println(
"cmd=wifi via BLE");
2915 else if (strcasecmp(cmd,
"swapwifi")==0)
2917 SerialDebug.println(
"cmd=swapwifi via BLE");
2930 else if (strcasecmp(cmd,
"readspiff")==0)
2932 SerialDebug.println(
"readspiff...");
2936 else if (strcasecmp(cmd,
"sendspiff")==0)
2940 else if (strcasecmp(cmd,
"deletespiff")==0)
2944 else if (strcasecmp(cmd,
"capture")==0)
2953 else if (strcasecmp(cmd,
"help")==0)
2958 sprintf(
_fullMessageOut,
"Syntax {\'cmd': \'[ota|clean|feed|erase|status|buzzon|buzzoff| MORE..help]\'} ");
2961#ifdef TRY_MORE_ASYNC_PROCESSING
2976 else if (semanticMarkerCmd)
2979 char* baseString = (
char*)
"https://SemanticMarker.org/bot/";
2987 else if (setCmd && valCmd)
2990 char* setCmdString =
const_cast<char*
>(setCmd);
2991 char* valCmdString =
const_cast<char*
>(valCmd);
2992 SerialTemp.print(
"Set: ");
2993 SerialTemp.print(setCmdString);
2994 SerialTemp.print(
", Val: ");
2995 SerialTemp.println(valCmdString);
3003 if (strcasecmp(setCmdString,
"hightemp")==0)
3009 else if (strcasecmp(setCmdString,
"cmd")==0)
3011 if (strcasecmp(valCmdString,
"feed")==0)
3013 SerialCall.printf(
"feed via set,cmd (%s)\n",topic?topic:
"NULL TOPIC!!");
3016 else if (strcasecmp(valCmdString,
"status")==0)
3018 SerialCall.println(
"status via set,cmd");
3022 else if (strcasecmp(valCmdString,
"resettimer")==0)
3028 SerialTemp.printf(
"Unknown cmd: %s\n", valCmdString);
3031 else if (strcasecmp(setCmdString,
"ble+wifi")==0)
3033 if (deviceNameSpecified)
3039 else if (strcasecmp(setCmdString,
"factoryreset")==0)
3041 if (deviceNameSpecified)
3048 else if (strcasecmp(setCmdString,
"restartmodels")==0)
3054 else if (strcasecmp(setCmdString,
"screentimeout")==0)
3059 else if (strcasecmp(setCmdString,
"stepperangle")==0)
3064 else if (strcasecmp(setCmdString,
"noclick")==0)
3069 else if (strcasecmp(setCmdString,
"gateway")==0)
3071 if (deviceNameSpecified)
3078 else if (strcasecmp(setCmdString,
"DiscoverM5PTClicker")==0)
3083 else if (strcasecmp(setCmdString,
"usespiff")==0)
3096 else if (strcasecmp(setCmdString,
"timerdelay")==0)
3098 if (deviceNameSpecified)
3100 int timerdelay = atoi(valCmdString);
3104 SerialDebug.printf(
"timerdelay: %d\n", timerdelay);
3108 else if (strcasecmp(setCmdString,
"starttimer")==0)
3110 if (deviceNameSpecified)
3115 SerialDebug.printf(
"startTimer: %d\n", flag);
3120 else if (strcasecmp(setCmdString,
"stepper")==0)
3123 if (strcasecmp(valCmdString,
"mini")==0)
3125 else if (strcasecmp(valCmdString,
"tumbler")==0)
3130 else if (strcasecmp(setCmdString,
"clockwiseMotor")==0)
3132 SerialCall.println(
" *** Setting clockwise motor");
3137 else if (strcasecmp(setCmdString,
"otafile")==0)
3143 else if (strcasecmp(setCmdString,
"location")==0)
3150 else if (strcasecmp(setCmdString,
"device")==0)
3163 else if (strcasecmp(setCmdString,
"pairnow")==0)
3165 if (deviceNameSpecified)
3179 else if (strcasecmp(setCmdString,
"pairdev")==0)
3181 if (deviceNameSpecified)
3184 if (strcasecmp(valCmdString,previousName)!=0)
3193#ifdef USE_BLE_CLIENT_NETWORKING
3209#ifdef NO_MORE_PREFERENCE_BLE_USE_DISCOVERED_PAIRED_DEVICE_SETTING
3210 if (strlen(valCmdString)==0)
3221 else if (strcasecmp(setCmdString,
"screencolor")==0)
3224 int screenColor = atoi(valCmdString);
3231 else if (strcasecmp(setCmdString,
"gen3only")==0)
3240 else if (strcasecmp(setCmdString,
"BLEUsePairedDeviceName")==0)
3242 if (deviceNameSpecified)
3244#ifdef NO_MORE_PREFERENCE_BLE_USE_DISCOVERED_PAIRED_DEVICE_SETTING
3251 else if (strcasecmp(setCmdString,
"BLEUseDeviceName")==0)
3253 if (deviceNameSpecified)
3261#ifdef USE_BLE_CLIENT_NETWORKING
3267 else if (strcasecmp(setCmdString,
"minMenu")==0)
3269 SerialDebug.println(
"PREFERENCE_IS_MINIMAL_MENU_SETTING via BLE");
3284 else if (strcasecmp(setCmdString,
"addwifi")==0)
3286 if (deviceNameSpecified)
3291 strcpy(str,valCmdString);
3294 char* ssid = strtok_r(rest,
":", &rest);
3295 char* password = strtok_r(rest,
":", &rest);
3296 SerialDebug.printf(
"addwifi %s, %s\n", ssid?ssid:
"null", password?password:
"");
3303 char credentials[100];
3305 sprintf(credentials,
"{'ssid':'%s','ssidPassword':'%s'}", ssid?ssid:
"NULL", password?password:
"");
3307 SerialMin.println(credentials);
3321 else if (strcasecmp(setCmdString,
"usedocfollow")==0)
3323 SerialDebug.printf(
"PREFERENCE_USE_DOC_FOLLOW_SETTING %s\n", valCmdString);
3327 else if (strcasecmp(setCmdString,
"semanticMarker")==0)
3329 SerialDebug.printf(
"SemanticMarker: %s\n", valCmdString);
3333 else if (strcasecmp(setCmdString,
"blankscreen")==0)
3345 else if (strcasecmp(setCmdString,
"SubDawgpack")==0)
3347 if (deviceNameSpecified)
3349 SerialDebug.println(
"PREFERENCE_SUB_DAWGPACK_SETTING via BLE");
3363 _mqttClient.unsubscribe((
char*)
"usersP/dawgpack");
3369 else if (strcasecmp(setCmdString,
"buzz")==0)
3375 SerialDebug.println(
"BUZZ:ON via BLE");
3380 SerialDebug.println(
"BUZZ:OFF via BLE");
3387 else if (strcasecmp(setCmdString,
"bleclient")==0)
3389 if (deviceNameSpecified)
3391 SerialDebug.println(
"PREFERENCE_MAIN_BLE_CLIENT_VALUE via BLE");
3399 else if (strcasecmp(setCmdString,
"bleserver")==0)
3401 if (deviceNameSpecified)
3403 SerialDebug.println(
"PREFERENCE_MAIN_BLE_SERVER_VALUE via BLE");
3409 else if (strcasecmp(setCmdString,
"tilt")==0)
3411 if (deviceNameSpecified)
3413 SerialDebug.println(
"PREFERENCE_SENSOR_TILT_VALUE via BLE");
3417 else if (strcasecmp(setCmdString,
"zoomSm")==0)
3425 SerialDebug.println(
"PREFERENCE_SEMANTIC_MARKER_ZOOMED_VALUE ON via BLE");
3440 SerialDebug.println(
"PREFERENCE_SEMANTIC_MARKER_ZOOMED_VALUE OFF via BLE");
3460 else if (strcasecmp(setCmdString,
"buttonA")==0)
3462 if (strcasecmp(valCmdString,
"longpress")==0)
3464 else if (strcasecmp(valCmdString,
"shortpress")==0)
3467 else if (strcasecmp(setCmdString,
"buttonB")==0)
3469 if (strcasecmp(valCmdString,
"longpress")==0)
3471 else if (strcasecmp(valCmdString,
"shortpress")==0)
3476 SerialMin.printf(
"Unknown cmd: %s\n", setCmdString);
3485 char* sendCmdString =
const_cast<char*
>(sendCmd);
3486 if (strcasecmp(sendCmdString,
"temp")==0)
3488 SerialCall.println(
"sendCmd == temp");
3492 else if (strcasecmp(sendCmdString,
"status")==0)
3494 SerialCall.println(
"sendCmd == status");
3498 else if (strcasecmp(sendCmdString,
"capture")==0)
3500 SerialCall.println(
"sendCmd == capture");
3504 else if (strcasecmp(sendCmdString,
"volume")==0)
3506 SerialCall.println(
"sendCmd == volume (not implemented)");
3512 SerialTemp.print(
"Unknown send request: ");
3513 SerialTemp.println(sendCmdString);
3551 const char* a1 = myObject[
"ssid"];
3552 if (a1 && strlen(a1)>0)
3560 SerialTemp.println(a1);
3565 const char* a2 = myObject[
"ssidPassword"];
3566 if (a2 && strlen(a2)>0)
3583 const char* a3 = myObject[
"mqtt_server"];
3593 const char* a4 = myObject[
"mqtt_port"];
3604 const char* a5 = myObject[
"mqtt_password"];
3615 const char* a6 = myObject[
"mqtt_user"];
3625 const char* a7 = myObject[
"deviceName"];
3626 if (a7 && strlen(a7)>0)
3635 const char* a8 = myObject[
"uuid"];
3645 const char* a9 = myObject[
"mqtt_topic"];
3656 const char* a10 = myObject[
"mqtt_guestPassword"];
3667 const char* a11 = myObject[
"location"];
3668 if (a11 && strlen(a11)>0)
3684 SerialDebug.println(
"Setting WIFI from JSON parameters");
3695 SerialDebug.println(
" ***** ERROR .. no ssidString *** ");
3706 SerialDebug.println(
"**** Not saving JSON in preferences ***");
3740 DynamicJsonDocument myObject(1024);
3768 serializeJson(myObject, output2);
3772 SerialDebug.print(
"MQTTNetworking.Writing EPROM JSON = '");
3773 SerialDebug.print(output2);
3774 SerialDebug.println(
"'");
3783#define NO_NEED_AND_GRU_CRASH
3784#ifdef NO_NEED_AND_GRU_CRASH
3789 SerialDebug.print(
"Reading.2 EPROM JSON = ");
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
unsigned long _delayStart_WIFI_MQTTState
the time the delay started
boolean delayFinished_WIFI_MQTTState()
if finished..
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 _delayRunning_WIFI_MQTTState
true if still waiting for delay to finish
boolean _setupMQTTNetworkingAlready
try a flag so setupMQTTnetworking only called 1 times..
void cleanEPROM_MQTTNetworking()
cleans the eprom info
char _lastDocFollowSemanticMarker[200]
storage for last doc follow semantic marker
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
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...
int _delayCheckWIFISeconds_MQTTNetworking
length of delay
String _topic
the topic the new message came in on..
char _lastMessageStatusURL[100]
storage of the last message status
void setupWIFI_loop()
the loop part of WIFI
void sendMessageMQTT(char *message)
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
Ambers 22nd birthday.. 2.20.22.
const char * getDynamicMessageFunc()
used by the displayModule to call this for each new status
float _delaySeconds_WIFI_MQTTState
length of delay
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()
stop the delay
void getChipInfo()
create a unique ID (but it needs to be stored.. otherwise it's unique each time??
char * _mqttPasswordString
void loop_MQTTNetworking()
called for the loop() of this plugin
char * getLastDocFollowSemanticMarker_MQTTNetworking()
#define MAX_MESSAGE
define this storage once, and use everwhere..
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
void publishBinaryFile(char *topic, uint8_t *buf, size_t len)
publish a binary file..
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()
init the delay, this uses the array of delays so we can change easier..
void invokeCurrentSMModePage(char *topic)
send message to ourself to change to current specifed SM Mode
enum MQTTMessageTopicType _MQTTMessageTopicType
WIFI_MQTTStates _WIFI_MQTTState
the state we are in..
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.
void sendDocFollowMessageMQTT(const char *semanticMarker)
sends the semantic marker as a doc follow message
unsigned long _delayCheckWIFIStart_MQTTNetworking
the time the delay started
void restartDelayCheckWIFI_MQTTNetworking()
starts the delay for WIFI checking, called at startup, and each time the timer finished....
char _semanticMarkerString[MAX_MESSAGE]
Preferences _preferencesMQTTNetworking
3.3.22 Using the new JSON library which is supposed to catch syntax errors without blowing up
void setLastDocFollowSemanticMarker_MQTTNetworking(char *semanticMarker)
sets the last DocFollow SemanticMarker
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
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..
#define MQTT_CALLBACK_TEMP
#define MQTT_CLEAN_SSID_EPROM
#define MQTT_CALLBACK_BLINK
#define MQTT_CALLBACK_FEED
#define MQTT_CALLBACK_SOLID_LIGHT
void takePicture_MainModule()
take a picture (calls the camera module).. what to do with picture??? TODO
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 ...
boolean connectedBLEDeviceIsGEN3_mainModule()
whether the connected is a GEN3 (so the name isn't valid)
int minMenuModesMax_mainModule()
returns the current max of the MIN menu modes (using the setting of min or expanded) to determine
char * main_currentStatusURL()
returns a string in in URL so: status?battery=84'&buzzon='off' } .. etc
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
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 main_dispatchAsyncCommand(int asyncCallCommand)
checks if any async commands are in 'dispatch' mode, and if so, invokes them, and sets their flag to ...
int getTimeStamp_mainModule()
void buttonB_LongPress_mainModule()
the long press of the side button
char * createCopy(char *stringA)
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 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).
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)
connects to host and grabs the http file and tries to update the binary (OTA)
void savePreferenceInt_mainModule(int preferenceID, int val)
sets an int preference
void savePreferenceBoolean_mainModule(int preferenceID, boolean flag)
save a boolean preference
void setDiscoverM5PTClicker(boolean flag)
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 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
char * getPreference_mainModule(int preferenceID)
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
#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_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_SEMANTIC_MARKER_ZOOMED_VALUE
Display preferences (SemanticMarker etc) - boolean.
#define PREFERENCE_WIFI_CREDENTIAL_2_SETTING
#define PREFERENCE_MAIN_BLE_SERVER_VALUE
#define PREFERENCE_PAIRED_DEVICE_SETTING
the paired device for guest device feeding (6.6.22)
#define STEPPER_IS_TUMBLER
#define PREFERENCE_BLE_USE_DISCOVERED_PAIRED_DEVICE_SETTING
#define PREFERENCE_USE_DOC_FOLLOW_SETTING
for
#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_HIGH_TEMP_POWEROFF_VALUE
sets the max temp for a poweroff
#define PREFERENCE_STEPPER_ANGLE_FLOAT_SETTING
#define PREFERENCE_MAIN_GATEWAY_VALUE
#define PREFERENCE_STEPPER_CLOCKWISE_MOTOR_DIRECTION_SETTING
#define PREFERENCE_MAIN_BLE_CLIENT_VALUE
boolean saveJSONPreferences
void println_SPIFFModule(char *string)
print a string to spiff (a new line is added)
void printInt_SPIFFModule(int val)
print a int to spiff (NO new line is added)
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
void printFile_SPIFFModule()
prints the spiff file to the SerialDebug output
void print_SPIFFModule(char *string)
print a string to spiff (NO new line is added)
void deleteFiles_SPIFFModule()
delete the spiff files..
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 parseQueryLine_mainModule(char *line)
parses a line of text, returning the number of tokens..