1#include "../../Defines.h"
7#define MenusModel_Help 0
8#define MenusModel_Settings 1
9#define MenusModel_Pairing 2
10#define MenusModel_APMode 3
11#define MenusModel_Timer 4
12#define MenusModel_Status 5
13#define MenusModel_Advanced 6
14#define MenusModel_WIFIShare 7
15#define MenusModel_GuestFeed 8
16#define MenusModel_GuestPage 9
17#define MenusModel_DocFollow 10
18#define MenusModel_Max 11
67 SerialMin.println(
" *** invalid menu item");
75ModelStateStruct _modelStateStructs[ModelKindEnumMax];
129 SerialCall.printf(
"initTimer: sec = %d\n",
_modelStateStructs[i].currentCounterSeconds);
130#if defined(ESP_M5_CAMERA) || defined(ESP_32)
147 SerialDebug.printf(
"setTimerDelaySeconds_mainModule(%d)\n", delaySeconds);
161 SerialDebug.printf(
"setTimerDelaySecondsMax_mainModule(%d)\n", delaySeconds);
186 SerialCall.printf(
"nextRandomTimeSeconds(%d,%d) = %d\n", timerModelStruct->
delaySeconds, timerModelStruct->
delaySecondsMax, nextRandomTimeSeconds);
200 SerialDebug.printf(
"startStopTimer_mainModule(%d, %d)\n", startTimer, timerModelStruct->
currentCounterSeconds);
215 SerialTemp.print(
"deviceState->pairedDeviceStateEnum: ");
220 SerialLots.println(
"pairedButNotConnectedEnum");
224 SerialLots.println(
"pairedAndConnectedEnum");
228 SerialLots.println(
"pairableAndConnectedEnum");
232 SerialLots.println(
"notConnectedEnum");
239 SerialTemp.println(
"deviceState = rebootModel ");
257 SerialTemp.println(
"deviceState = menusModel ");
262 SerialTemp.println(
"deviceState = timerModel ");
266 SerialTemp.printf(
"deviceState->maxItems (%d) \n", deviceState->
maxItems );
267 SerialTemp.printf(
"deviceState->currentItem (%d) \n", deviceState->
currentItem );
276 SerialCall.printf(
"getModel(%d) = %d\n", modelKind, model);
289 SerialCall.printf(
"hasModelForSM_Mode(%d) == yes\n", SM_Mode);
295 SerialCall.printf(
"hasModelForSM_Mode(%d) == NO\n", SM_Mode);
308 item = (item + 1) % max;
311 SerialCall.printf(
"incrementMenuState(%d) = %d \n", modelKind, item);;
318 SerialDebug.println(
"restartAllMenuStates");
339 char _smMessage_ModelController[30];
360#ifdef NO_MORE_PREFERENCE_BLE_USE_DISCOVERED_PAIRED_DEVICE_SETTING
397 SerialLots.printf(
"invokePair(%s, gen3=%d)\n", deviceName, isGEN3);
410#ifdef NO_MORE_PREFERENCE_BLE_USE_DISCOVERED_PAIRED_DEVICE_SETTING
435 SerialTemp.println(
" *** GEN3 only but connected to a non GEN3 .. so unpair **");
446#pragma mark DEBUG_7_12
447 SerialCall.printf(
"updateMenuState(%d) \n", modelKind);
454 char pairedDeviceString[50];
455 char pairedDeviceAddressString[50];
463 SerialLots.printf(
"\nPAIRED_DEVICE_MODEL\n");
464 SerialLots.printf(
"isConnectedBLE(%d)\n", isConnectedBLE);
468 SerialLots.printf(
"gen3Only(%d)\n", gen3Only);
473 SerialLots.printf(
"gatewayOn(%d)\n", gatewayOn);
477 strcpy(pairedDeviceString, pairedDeviceTemp);
478 SerialLots.printf(
"pairedDevice(%s)\n", pairedDeviceString);
481 strcpy(pairedDeviceAddressString, pairedDeviceAddressTemp);
483 SerialLots.printf(
"pairedDeviceAddress(%s)\n", pairedDeviceAddressString);
487 SerialLots.printf(
"connectedBLEDeviceName(%s)\n", connectedBLEDeviceName);
490 SerialLots.printf(
"connectedBLEDeviceNameAddress(%s)\n", connectedBLEDeviceNameAddress);
493 boolean pairedAndConnected =
false;
494 boolean pairedButNotConnected =
false;
495 boolean pairableAndConnected =
false;
496 boolean unpaired =
false;
502 if (strcmp(pairedDeviceString,connectedBLEDeviceName)==0 ||
503 strcmp(pairedDeviceAddressString,connectedBLEDeviceNameAddress)==0)
505 pairedAndConnected =
true;
507 pairableAndConnected =
true;
510 else if (strlen(pairedDeviceString) > 0 || strlen(pairedDeviceAddressString) > 0)
512 if (strlen(pairedDeviceString) > 0 && strcmp(pairedDeviceString,(
char*)
"NONE")==0)
514 else if (strlen(pairedDeviceAddressString) > 0 && strcmp(pairedDeviceAddressString,(
char*)
"NONE")==0)
518 pairedButNotConnected =
true;
526 if (pairedButNotConnected)
527 SerialLots.printf(
"pairedButNotConnected(%d)\n", pairedButNotConnected);
528 if (pairedAndConnected)
529 SerialLots.printf(
"pairedAndConnected(%d)\n", pairedAndConnected);
530 if (pairableAndConnected)
531 SerialLots.printf(
"pairableAndConnected(%d)\n", pairableAndConnected);
533 SerialLots.printf(
"unpaired(%d)\n", unpaired);
535 if (pairedButNotConnected)
541 else if (pairedAndConnected)
547 else if (pairableAndConnected)
590 SerialCall.printf(
"updateMenuState timerRunning(%d)\n", deviceState->
delayRunning);
611 long currentTimeMillis =
millis();
612 SerialCall.printf(
"currentTimeMillis = %d\n", currentTimeMillis);
613 SerialCall.printf(
"delayStartMillis = %d\n", deviceState->
delayStartMillis);
624 SerialCall.printf(
"delayFinished \n");
668 SerialCall.printf(
"menuForState(%d,%d)\n", modelKind, item);
686 menu = (
char*)
"scan..";
690 menu = (
char*)
"unpair";
694 menu = (
char*)
"Gen3";
696 menu = (
char*)
"AnyBLE";
699 SerialMin.printf(
"a.**** Invalid item: %d\n",item);
707 menu = (
char*)
"feed";
710 menu = (
char*)
"unpair";
714 menu = (
char*)
"Gen3";
716 menu = (
char*)
"AnyBLE";
719 SerialMin.printf(
"b. **** Invalid item: %d\n",item);
727 menu = (
char*)
"feed";
730 menu = (
char*)
"skip";
733 menu = (
char*)
"pair";
737 menu = (
char*)
"Gen3";
739 menu = (
char*)
"AnyBLE";
742 SerialMin.printf(
"c. **** Invalid item: %d\n",item);
750 menu = (
char*)
"scan..";
754 menu = (
char*)
"Gen3";
756 menu = (
char*)
"AnyBLE";
759 SerialMin.printf(
"d. **** Invalid item: %d\n",item);
772 menu = (
char*)
"reboot";
775 menu = (
char*)
"poweroff";
779 menu = (
char*)
"blankscrn";
783 menu = (
char *)
"Set Uno";
786 menu = (
char *)
"Tumbler";
790 menu = (
char*)
"colorscrn";
793 menu = (
char*)
"SemMarker";
797 menu = (
char*)
"BLE+WIFI";
799 menu = (
char*)
"BLEOnly";
803 menu = (
char*)
"CycleScrn";
807 menu = (
char*)
"Wave+Page";
811 menu = (
char*)
"Wave+Strm";
816 menu = (
char*)
"PTClicker";
818 menu = (
char*)
"PTFeeder";
822 SerialMin.printf(
"e. **** Invalid item: %d\n",item);
849 menu = (
char*)
"BLEPair";
852 menu = (
char*)
"APMode";
855 menu = (
char*)
"WIFIShare";
858 menu = (
char*)
"Timer";
861 menu = (
char*)
"Advanced";
864 menu = (
char*)
"Status";
867 menu = (
char*)
"GuestPage";
870 menu = (
char*)
"GuestFeed";
873 menu = (
char*)
"Settings";
876 menu = (
char*)
"DocFollow";
879 menu = (
char*)
"Help";
883 SerialMin.printf(
"f. **** Invalid item: %d\n",item);
899 menu = (
char*)
"Stop";
901 menu = (
char*)
"Start";
926 menu = (
char*)
"Delay";
930 SerialMin.printf(
"g. **** Invalid item: %d\n",item);
944 boolean modelChanged =
false;
956 SerialCall.printf(
"pairedDeviceModel");
1011 modelChanged =
true;
1016 modelChanged =
true;
1021 modelChanged =
true;
1035 modelChanged =
true;
1045 SerialCall.println(
"*** rebootModel ***");
1074 modelChanged =
true;
1078 modelChanged =
true;
1109 char pubString[100];
1111 sprintf(pubString,(
char*)
"#followMe {AVM=https://SemanticMarker.org/bot/wave/%s?action=next}", deviceState->
waveName);
1128 char pubString[100];
1131 sprintf(pubString,(
char*)
"#followMe {AVM=https://SemanticMarker.org/bot/wave/%s?stream=%0d&page=0}", deviceState->
waveName, deviceState->
currentStreamNum+1);
1149 SerialMin.println(
"h, *** invalid item ***");
1156 modelChanged =
true;
1157 SerialCall.println(
"*** menusModel ***");
1180 SerialTemp.printf(
"*** timerModel (%d) *** %d\n", item, deviceState->
delayRunning);
1215 if (currentDelay == 5)
1217 else if (currentDelay == 30)
1219 else if (currentDelay == 60)
1221 else if (currentDelay == 120)
1225 SerialTemp.printf(
".. change delay = %d\n", currentDelay);
1243 if (currentDelay < deviceState->delaySeconds)
1260 SerialMin.println(
"i2. *** invalid item ***");
1266 return modelChanged;
1273 boolean modelChanged =
false;
1278 char *semanticMarker = NULL;
1280#ifdef NOTHING_YET_SAVE_SOME_MEMORY
1313 return semanticMarker;
boolean isConnectedBLEClient()
returns whether connected over BLE as a client to a server(like a ESP feeder)
void disconnect_BLEClientNetworking()
try to disconnect..
void skipNameOrAddress_BLEClientNetworking(char *nameOrAddress)
an address or name to skip (for at least 1 time)
void sendCommandBLEClient_13orLess(String cmdString)
send a string of 13 characters or less
void incrementScreenColor_displayModule()
void publishMQTTMessageDefaultTopic(char *message)
Wrapper of the mqttclient publish.
void sendMessageMQTT(char *message)
boolean processJSONMessageMQTT(char *ascii, char *topic)
process the JSON message (looking for FEED, etc). Note: topic can be nil, or if not,...
void setConnectedBLEDevice_mainModule(char *deviceName, boolean isGEN3)
char * connectedBLEDeviceNameAddress_mainModule()
returns address part of name.
char * charSMMode_mainModule(int whichSMMode)
returns string form whichSMMode, sg "sm0", sm1 ...
char * deviceName_mainModule()
gets the device name
boolean connectedBLEDeviceIsGEN3_mainModule()
whether the connected is a GEN3 (so the name isn't valid)
void processClientCommandChar_mainModule(char cmd)
single character version of processClientCommand (since many used that already)
int getCurrentSMMode_mainModule()
returns the current SM Mode
char * getFullBLEDeviceName_mainModule()
full: ""Name: PTFeeder:HowieFeeder, Address: 7c:9e:bd:48:af:92, serviceUUID: 0xdead"
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 ...
char * connectedBLEDeviceName_mainModule()
returns the connected BLE Device name (the :NAME of advertisment, Address: 01:39:3f:33 part of name,...
#define SM_pair_dev
guest feed device
#define ASYNC_REBOOT
sets the GATEWAY mode off
#define SM_guest_feed
guest feed
#define SM_guest_page
guest page
#define ASYNC_SEND_MQTT_FEED_MESSAGE
sends a message (like FEED) on the users topic
#define SM_timer
timer .. todo
#define SM_status
//status
#define MAX_SM_EXPANDED_MODES
#define ASYNC_POWEROFF
sets the GATEWAY mode off
#define ASYNC_BLANKSCREEN
blank the screen
#define SM_doc_follow
docfollow
#define SM_smart_clicker_homepage
//! homepage
#define SM_WIFI_ssid
WIFI ssid.
#define SM_ap_mode
AP MODE.
void updateMenuState(ModelKindEnum modelKind)
updates the model for the menu state, this sets max etc
void invokeUnpairNoNameBASE_ModelController()
void incrementMenuState(ModelKindEnum modelKind)
increments the device states deviceState (wrapping around)
boolean invokeMenuState(ModelKindEnum modelKind)
invokes the menu state, return true if the model state has change enough to refreesh your View (such ...
void initMenuToSMMode()
init the mapping
void setTimerDelaySecondsMax_mainModule(int delaySeconds)
void invokeUnpair_ModelController(char *nameOrAddress)
performs the unpairing
void invokeFeed_ModelController()
performs the BLE feed
void invokePair_ModelController()
#define MenusModel_WIFIShare
void setTimerDelaySeconds_mainModule(int delaySeconds)
void invokeSkip_ModelController(char *nameOrAddress)
performs skip
void printDeviceState(ModelStateStruct *deviceState)
print it out..
#define MenusModel_Help
a pseudo Class
void startStopTimer_mainModule(boolean startTimer)
#define MenusModel_Status
char * menuForState(ModelKindEnum modelKind, int item)
returns the menu string for the deviceState's item number (use woudl go 0..maxItems -1
#define MenusModel_DocFollow
#define MenusModel_GuestFeed
#define MenusModel_Settings
void invokeUnpairNoName_ModelController()
ModelStateStruct * hasModelForSM_Mode(int SM_Mode)
retrieves the state model for the SM_Mode (SM_0 .. SM_LAST) null if none
#define MenusModel_Advanced
int _menuToSMMode[MenusModel_Max]
storage of mapping
char * getModelSemanticMarker(ModelKindEnum modelKind)
retrieves a semantic marker for the current selected item
ModelStateStruct * getModel(ModelKindEnum modelKind)
retrieves the state model for the modelKind
void initModelStructs_ModelController()
initialize the objects
void invokeFeedLocally()
storage..
#define MenusModel_APMode
#define MenusModel_GuestPage
#define MenusModel_Pairing
void invokeToggleGen3_ModelController()
toggles the GEN3 setting
void restartAllMenuStates_ModelController()
restarts all the menu states to the first one .. useful for getting a clean start....
ModelStateStruct _modelStateStructs[ModelKindEnumMax]
ModelKindEnum
a pseudo Class
@ pairedButNotConnectedEnum
@ notConnectedEnum
factory default but not connecte to anything..
@ pairableAndConnectedEnum
void savePreferenceInt_mainModule(int preferenceID, int val)
sets an int preference
boolean getDiscoverM5PTClicker()
get option
void savePreferenceBoolean_mainModule(int preferenceID, boolean flag)
save a boolean preference
void setDiscoverM5PTClicker(boolean flag)
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 togglePreferenceBoolean_mainModule(int preferenceID)
toggles a preference boolean
int getPreferenceInt_mainModule(int preferenceID)
called to set a preference (which will be an identifier and a string, which can be converted to a num...
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_PAIRED_DEVICE_ADDRESS_SETTING
the paired device for guest device feeding (6.6.22) .. but the Address 9.3.22
#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_SEMANTIC_MARKER_ZOOMED_VALUE
Display preferences (SemanticMarker etc) - boolean.
#define PREFERENCE_PAIRED_DEVICE_SETTING
the paired device for guest device feeding (6.6.22)
#define PREFERENCE_BLE_USE_DISCOVERED_PAIRED_DEVICE_SETTING
#define PREFERENCE_TIMER_MAX_INT_SETTING
the preference timer MAX (pairs with PREFERENCE_TIMER_INT_SETTING)
#define PREFERENCE_MAIN_GATEWAY_VALUE
#define PREFERENCE_TIMER_INT_SETTING
the preference timer
the struct for the models. Since this isn't straight OO, we are overlaying information....
ModelKindEnum modelKindEnum
What kind of model.
int currentCounterSeconds
current seconds (<= delaySeconds)
int currentPageState
for the next page state 0..n
boolean feedLocalOnly
feed local instead of MQTT or BLE..
int delaySecondsMax
11.29.23 max Delay Seconds .. if different than delay then next delay will be random() * (max-min) + ...
int delayStartMillis
Timer info - When the timer was started.
int counterLoopAbsoluteSeconds
int currentItem
the current item
int currentStreamNum
the stream number
char * waveName
which wave
int SM_Mode
which SM mode 0.. SM_LAST
boolean perfersBigText
a preference to the View that big text is desired
PairedDeviceStateEnum pairedDeviceStateEnum
boolean delayRunning
true if still waiting for delay to finish
int delaySeconds
length of delay (changable..)
int maxItems
the number of items in the model