ESP_IOT v2.5
IOT ESP Coding
REFAcTOR.c File Reference

Go to the source code of this file.

Macros

#define REFACTOR_MSG
 

Functions

else if (strcasecmp(setCmdString,"buzz")==0)
 TODO: duplicate and depreciate these and replace with set:buzz,val:on. More...
 
else if (strcasecmp(setCmdString,"bleclient")==0)
 
else if (strcasecmp(setCmdString,"bleserver")==0)
 
else if (strcasecmp(setCmdString,"tilt")==0)
 
else if (strcasecmp(setCmdString,"zoomSm")==0)
 
else if (guestCmd)
 {'guest':'guest password'} More...
 
else if (semanticMarkerCmd)
 
else if (setCmd &&valCmd)
 5.12.22 More...
 
else if (sendCmd)
 5.24.22 send:<request> .. Note these are for cmd without an argument.. More...
 
 if (a1 &&strlen(a1)>0)
 end process commands.. More...
 
SerialTemp println (a1)
 
SerialTemp println (_ssidString)
 
 if (a2 &&strlen(a2)>0)
 
 if (a3)
 
 if (a4)
 
 if (a5)
 
 if (a6)
 
 if (a7 &&strlen(a7)>0)
 
 if (a8)
 
 if (a9)
 
 if (a10)
 
 if (a11 &&strlen(a11)>0)
 
 if (!isEmptyString(_ssidString))
 setup the WIFI if the ssid string (at least) is specified More...
 
 callCallbackMain (CALLBACKS_MQTT, MQTT_CALLBACK_SOLID_LIGHT,(char *)"solidLight")
 call the callback specified from the caller (eg. NimBLE_PetTutor_Server .. or others) More...
 
 if (!saveJSONPreferences)
 don't save the preferences, since it didn't have enough information.. More...
 
 updatePreferencesInEPROM ()
 NOTE: this writes over entire values, since it's a string vs an JSON object. More...
 
 main_credentialsUpdated ()
 new 4.8.22 .. trying to kick out of AP mode if the credentials are good.. More...
 
 startDelay_WIFI_MQTTState ()
 init the delay, this uses the array of delays so we can change easier.. More...
 
void restartWIFI_MQTTState ()
 restart the WIFI and then MQTT connection More...
 

Variables

return true
 this return is important!!! More...
 
else _ssidString = NULL
 
else _ssidPasswordString = NULL
 
 _globalMQTTAttempts = 0
 reset the MQTT attempts More...
 
boolean saveJSONPreferences = true
 
 else
 
 _WIFI_MQTTState = preSetupWIFI
 putting here .. time might have gone too fast.. More...
 

Macro Definition Documentation

◆ REFACTOR_MSG

#define REFACTOR_MSG

Definition at line 1 of file REFAcTOR.c.

Function Documentation

◆ callCallbackMain()

callCallbackMain ( CALLBACKS_MQTT  ,
MQTT_CALLBACK_SOLID_LIGHT  ,
(char *)"solidLight"   
)

call the callback specified from the caller (eg. NimBLE_PetTutor_Server .. or others)

◆ if() [1/22]

if ( isEmptyString_ssidString)

setup the WIFI if the ssid string (at least) is specified

new: go out and let the process work... set the state, then the 'loop' will call setupWIF(...)

Definition at line 527 of file REFAcTOR.c.

Here is the call graph for this function:

◆ if() [2/22]

if ( saveJSONPreferences)

don't save the preferences, since it didn't have enough information..

Definition at line 549 of file REFAcTOR.c.

◆ if() [3/22]

if ( a1 &&  strlena1,
 
)

end process commands..

TRY without 1.30.22 (RAMS win) and it works.. if can talk BLE, then reboot.. 2.2.22

 {
 "ssid" : "SunnyWhiteriver",
 "ssidPassword" : "sunny2021",
 "mqtt_topic": "usersP/bark/test",
 "mqtt_user" : "test",
 "deviceName" : "HowieFeeder",
 "mqtt_password" : "password..",
 "mqtt_guestPassword" : "password",
 "uuid" : "scott",
 "mqtt_port" : "1883",
 "mqtt_server" : "idogwatch.com",
 "mqtt_status" : "Success",
 "location": "whatever to reply with, GPS, state, city, etc.."
 }

todo pass the guest password too ! Store wifi config. ␖å␖˜␖å␖¨wifi␖é␖␖ç␖®␖ä␖¡␖æ␖¯

See also
https://arduinojson.org

Definition at line 397 of file REFAcTOR.c.

Here is the call graph for this function:

◆ if() [4/22]

if ( a10  )

Definition at line 502 of file REFAcTOR.c.

Here is the call graph for this function:

◆ if() [5/22]

if ( a11 &&  strlena11,
 
)

Definition at line 513 of file REFAcTOR.c.

Here is the call graph for this function:

◆ if() [6/22]

if ( a2 &&  strlena2,
 
)

Definition at line 411 of file REFAcTOR.c.

Here is the call graph for this function:

◆ if() [7/22]

if ( a3  )

Definition at line 429 of file REFAcTOR.c.

Here is the call graph for this function:

◆ if() [8/22]

if ( a4  )

Definition at line 439 of file REFAcTOR.c.

Here is the call graph for this function:

◆ if() [9/22]

if ( a5  )

Definition at line 450 of file REFAcTOR.c.

Here is the call graph for this function:

◆ if() [10/22]

if ( a6  )

Definition at line 461 of file REFAcTOR.c.

Here is the call graph for this function:

◆ if() [11/22]

if ( a7 &&  strlena7,
 
)

Definition at line 471 of file REFAcTOR.c.

Here is the call graph for this function:

◆ if() [12/22]

if ( a8  )

Definition at line 481 of file REFAcTOR.c.

Here is the call graph for this function:

◆ if() [13/22]

if ( a9  )

Definition at line 491 of file REFAcTOR.c.

Here is the call graph for this function:

◆ if() [14/22]

else if ( guestCmd  )

{'guest':'guest password'}

Definition at line 129 of file REFAcTOR.c.

◆ if() [15/22]

else if ( semanticMarkerCmd  )

use the name/cat/uuid ..

Definition at line 135 of file REFAcTOR.c.

Here is the call graph for this function:

◆ if() [16/22]

else if ( sendCmd  )

5.24.22 send:<request> .. Note these are for cmd without an argument..

NOTE: This will be calling ourself

request a TEMP be sent.

request a STATUS be sent.

request a CAPTURE be sent.

request a VOLUME be sent.

Definition at line 326 of file REFAcTOR.c.

Here is the call graph for this function:

◆ if() [17/22]

else if ( setCmd &&  valCmd)

5.12.22

options: hightemp, feedcount, timeout

try 5.12.22 {'set':'item'},{'val':'value'} eg. set:hightemp, val:80) TODO: confirm valid integer values...

set the high temp value..

set the stepperangle.

set the timeout from no click to poweroff

called to set a preference (which will be an identifier and a string, which can be converted to a number or boolean)

add stepper type

called to set a preference (which will be an identifier and a string, which can be converted to a number or boolean)

add stepper type

set the location

rename device

since renaming, lets set a STATUS out.. request a STATUS be sent.

paireddev the paired device

saves the pair device name TODO: the feed device should use the pair as well.. (DONE..)

set the screen color 0..n

sets the gen3only flag

sets the gen3only flag

for now just reboot which will use this perference

sets the gen3only flag

sets the bleusepaireddevicename flag

sets the gen3only flag

sets the bleusedevicename flag

for now just reboot which will use this perference and re-create the service name..

send message to ourself to process the current mode..

send message to ourself to process the current mode..

store the JSON version of these credentials..

Definition at line 146 of file REFAcTOR.c.

Here is the call graph for this function:

◆ if() [18/22]

else if ( strcasecmp(setCmdString,"bleclient")  = =0)

for now just reboot which will use this perference

for now just reboot which will use this perference

Definition at line 20 of file REFAcTOR.c.

Here is the call graph for this function:

◆ if() [19/22]

else if ( strcasecmp(setCmdString,"bleserver")  = =0)

for now just reboot which will use this perference

for now just reboot which will use this perference

Definition at line 44 of file REFAcTOR.c.

Here is the call graph for this function:

◆ if() [20/22]

else if ( strcasecmp(setCmdString,"buzz")  = =0)

TODO: duplicate and depreciate these and replace with set:buzz,val:on.

Definition at line 4 of file REFAcTOR.c.

Here is the call graph for this function:

◆ if() [21/22]

else if ( strcasecmp(setCmdString,"tilt")  = =0)

Definition at line 68 of file REFAcTOR.c.

Here is the call graph for this function:

◆ if() [22/22]

else if ( strcasecmp(setCmdString,"zoomSm")  = =0)

zoom == the NON semantic marker version.. so min menu is true

zoom only if in the max menu set..

zoom only if in the max menu set..

send message to ourself to process the current mode..

Definition at line 83 of file REFAcTOR.c.

Here is the call graph for this function:

◆ main_credentialsUpdated()

main_credentialsUpdated ( )

new 4.8.22 .. trying to kick out of AP mode if the credentials are good..

new 4.8.22 .. trying to kick out of AP mode if the credentials are good..

April 8, 2022 set that the credentials are set. Called from the MQTT after processJSONMessage() found things were good..

Definition at line 392 of file MainModule.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ println() [1/2]

SerialTemp println ( _ssidString  )

◆ println() [2/2]

SerialTemp println ( a1  )

◆ restartWIFI_MQTTState()

void restartWIFI_MQTTState ( )

restart the WIFI and then MQTT connection

Definition at line 570 of file REFAcTOR.c.

Here is the call graph for this function:

◆ startDelay_WIFI_MQTTState()

startDelay_WIFI_MQTTState ( )

init the delay, this uses the array of delays so we can change easier..

Definition at line 561 of file MQTTNetworking.cpp.

Here is the caller graph for this function:

◆ updatePreferencesInEPROM()

updatePreferencesInEPROM ( )

NOTE: this writes over entire values, since it's a string vs an JSON object.

just update the EPROM, and send that to the WIFI_AP module as well

basically if only the ssid/pass are sent, that is all that's written to EPROM even if the other information is available.. So recreate the JSON instead.. seems c++ you cannot re-use output as it just appends to it.. unreal

JSON

open the preferences

save in EPROM

Close the Preferences

sets the MQTT user/password. It's up to the code to decide who needs to know (currently saves in the WIFI_APModule

NEW: 2.21.22 TRY: reading back..

check ... _fullMessage Close the Preferences

Definition at line 583 of file REFAcTOR.c.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ _globalMQTTAttempts

_globalMQTTAttempts = 0

reset the MQTT attempts

Definition at line 523 of file REFAcTOR.c.

◆ _ssidPasswordString

else _ssidPasswordString = NULL

Definition at line 417 of file REFAcTOR.c.

◆ _ssidString

else _ssidString = NULL

Definition at line 403 of file REFAcTOR.c.

◆ _WIFI_MQTTState

_WIFI_MQTTState = preSetupWIFI

putting here .. time might have gone too fast..

Definition at line 562 of file REFAcTOR.c.

◆ else

else
Initial value:
{
SerialDebug.println(" ***** ERROR .. no ssidString *** ")

Definition at line 538 of file REFAcTOR.c.

◆ saveJSONPreferences

saveJSONPreferences = true

Definition at line 525 of file REFAcTOR.c.

◆ true

return true

this return is important!!!

Definition at line 364 of file REFAcTOR.c.