ESP_IOT v2.5
IOT ESP Coding
ATOM_SM.cpp File Reference
#include "ATOM_SM.h"
#include <libb64/cdecode.h>
Include dependency graph for ATOM_SM.cpp:

Go to the source code of this file.

Macros

#define DECODE_BASE64
 
#define MAX_SM   500
 
#define TRY_OPTIMIZE
 

Functions

void parseQueryArgs (char *credentialsStringInput, boolean useAnyArgs)
 9.27.23 to decode a base64 string (a Semantic Marker) More...
 
boolean ATOM_processSemanticMarker (char *semanticMarker, char *lastSemanticMarker)
 

Variables

char _copyLastSemanticMarker [MAX_SM]
 
char _lastScannedGroupName [40]
 

Macro Definition Documentation

◆ DECODE_BASE64

#define DECODE_BASE64

Definition at line 12 of file ATOM_SM.cpp.

◆ MAX_SM

#define MAX_SM   500

Definition at line 24 of file ATOM_SM.cpp.

◆ TRY_OPTIMIZE

#define TRY_OPTIMIZE

Function Documentation

◆ ATOM_processSemanticMarker()

boolean ATOM_processSemanticMarker ( char *  semanticMarker,
char *  lastSemanticMarker 
)

process the semantic marker (maybe from a click or a scan) If a SMART button, it will tack on username, password and optionally scannedDevice 12.15.23 return TRUE if this is a new SemanticMarker to save in _lastSemanticMarker return FALSE if this is a transient SM so don't override _lastSemanticMarker (eg. /scannedDevice, WIFI, credentials) Added passing lastSemanticMarker .. this is for the /scannedDevice to recursively call itself (so parms are substituded)

NOTE: The _lastSemanticMarker will be replaced with this semanticMarker .. unless

  • scannedDevice - since ethen the long press will re-run the last scanned semantic marker but with the new Device

scannedDevice is a special that is only for the scaner. Syntax: https://SemanticMarker.org/bot/scannedDevice/{deviceName}{?queryParms} if {deviceName} == "_none" then it empties it.. NOTE: 12.16.23 The scannedDevice is a temporal feature. It will not replace the last scanned SemanticMarker, instead it will be used to set the ScannedDevice (or none) That way the longPress can still be used to re-invoke the lastSemanticMarker (such as the feed) without having to re-scan it. BUT: we will send this on the MQTT network just so others can hear it and decide what to do Such as the remote Abilities monitor sees if the user scanned the device first etc.. FUTURE: decide on a remote ScannedDevice feature.. maybe called that: remoteScannedDevice which will be an MQTT message (so a remote handler can set the device..)

per issue #286, syntax has been extended to include arguments /scannedDevice/DeviceName?kind=AtomSocket&status=socket&valKind=onoff HERE we just need to search for the "?" and that will be the device name.

use the _copyLastSemanticMarker as a placeholder..

See also
https://stackoverflow.com/questions/1453876/why-does-strncpy-not-null-terminate

TODO: send MQTT message is it {"scannedDevice",device} TODO: implement the remoteScannedDevice MQTT message (or is {set:remoteScannedDevice, val:device} or {device:D, set:remoteScannedDevice, val:device} – only to specified device (in the multicast world)

this is 2 in one. So call ourself but using the lastSemanticMarker

1.7.24 (snow in mountains and down low .. ski monday)

per issue #286, syntax has been extended to include arguments /scannedGroup/GroupName?kind=AtomSocket&status=socket&valKind=onoff HERE we just need to search for the "?" and that will be the Group name.

see if any arguments (which we aren't using yet ..)

save the group name (withoiut topic path) for use in the smrun below

TODO.. parse this, create a JSON { "ssid" then call processJSONMessageMQTT ..

NOTE: the idea of sending this around is kinda catch 22. How can I tell you the SSID if you aren't connected to the internet.. 1.1.24 NOTE: these can be in any order.. so start with semanticMarker each time..

start over 1.1.24

!put together into JSON. case sensitive..

8.16.25 MQTT

Set the credentials for the WIFI using this format

./bot/credentials?ssid=X&ssidpass=Y....

currently 9.28.23 no reason for feeder to decode base64 messages. That could change if a stored procedure.. 12.30.23 .. changing to query parameters

parse .. creating JSON and send it onto the parseJSON

1.1.24 support setJSON as well.. ./bot/setJSON?ssid=X&ssidpass=Y.... currently 9.28.23 no reason for feeder to decode base64 messages. That could change if a stored procedure.. 12.30.23 .. changing to query parameters

parse .. creating JSON and send it onto the parseJSON

see if connected to a BLE device..

8.16.25 BLE CLIENT send a BLE feed command as we are connected

perform ACK too 8.16.25 MQTT

send WIFI feed to only the device decoded..

this should work ..

8.16.25 MQTT

feed always (done after the code below..)

feed always (done after the code below..)

feed always (done after the code below..)

feed always (done after the code below..)

1.7.24 if non null then valid group topic eg. /usersP/group/GROUP_NAME

TODO: syntax for an /optimize?uuid=x&flow=y&cmd=feed The MQTT is much faster.. Lets only use MQTT for the 'device' specified (to see this difference)

this will be a cache of commands to try.. cmd:feed, cmddevice,feed,device

dev: <dev>, cmd: feed cmd: feed

1.7.24 For now only SMART buttons will use the GROUP feature (and only if local) not the smrun

try a call.. call 'smrun' with URL query parameters, like username/password/device /bot/smrun?uuid=x&flownum=y&username=X&password=y&device=z HERE .. we add the Username, Password and Device name.. parameters

this is the cached (in code) SMART buton for feed. @See https://SemanticMarker.org/bot/smart?uuid=QHmwUurxC3&flow=1674517131429

this will be a cache of commands to try.. cmd:feed, cmddevice,feed,device

dev: <dev>, cmd: feed cmd: feed

this is the cached (in code) SMART buton for toggle socket power. @See https://SemanticMarker.org/bot/smart?uuid=QHmwUurxC3&flow=1703806697279

SMART_ToggleSocket_Device

this is the togglesocket command (versus turn on/off) https://iDogWatch.com/bot/cmddevice/USERNAME/PASSWORD/DEVICE_1/togglesocket this will be a cache of commands to try.. cmd:feed, cmddevice,feed,device

dev: <dev>, cmd: feed cmd: feed

only here if not optimized

NOTE: this assumes smartIndex has parameters like: " /smart?uuid=x&flownum=y" WITHOUT the smart/ it's smart?uuid...

tack on the raw group name, not the groupTopic which is full path: usersP/group/NAME

REST is not working, so now sending to TOMCAT on KnowledgeShark.me:8080 (as HTTP not HTTPS)

right now it shows smart of smflowinfo ..

8.16.25 MQTT

3.25.24 try the http to tomcat, then it sends https to node-red

already an /smrun so call is..

3.25.24 try the http to tomcat, then it sends https to node-red

Definition at line 35 of file ATOM_SM.cpp.

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

◆ parseQueryArgs()

void parseQueryArgs ( char *  credentialsStringInput,
boolean  useAnyArgs 
)

9.27.23 to decode a base64 string (a Semantic Marker)

parse the query args .. ?<arg>=<val>{&<arg>=<val>} 1.1.24 if useAnyArgs then just create JSON from all the arg-val without remapping

init the JSON

parse the query args .. ?<arg>=<val>{&<arg>=<val>}

mapping to the JSON needed. NOTE: Case sensitive ssidPassword

decode the URL (removing %20 etc)

8.16.25 MQTT

keep going while &<arg>

look for value (to end of line, or next '&')

eat the '&'

done.. so null

if useAnyArgs then

tack on mqtt_server and mqtt_port

8.16.25 MQTT send whatever credentials were created

Definition at line 510 of file ATOM_SM.cpp.

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

Variable Documentation

◆ _copyLastSemanticMarker

char _copyLastSemanticMarker[MAX_SM]

Definition at line 25 of file ATOM_SM.cpp.

◆ _lastScannedGroupName

char _lastScannedGroupName[40]

Definition at line 26 of file ATOM_SM.cpp.