11#include "../../Defines.h"
12#ifdef ATOM_SOCKET_MODULE
19#include "../ATOM_LED_Module/M5Display.h"
55#ifdef KEY_UNIT_SENSOR_CLASS
57#include "../SensorClass/SensorClassType.h"
58#include "../SensorClass/KeyUnitSensorClass.h"
66 SerialDebug.printf(
"M5AtomSocket.sensorCallbackSignature(%s,%d)\n", parameter, flag);
83 SerialDebug.printf(
"set_ATOM_SocketModule: %s\n",flag?
"ON":
"OFF");
130 if (strcmp(setName,
"socket")==0)
132 SerialDebug.printf(
"messageSetVal_ATOM_SocketModule(%s - global =%d, dev=%d)\n", valValue, globalOnOff, deviceNameSpecified);
133 if (globalOnOff || deviceNameSpecified)
144 SerialDebug.printf(
"messageSend_ATOM_SocketModule(%s)\n", sendValue);
145 if (strcasecmp(sendValue,
"togglesocket")==0)
173 SerialDebug.printf(
"ATOM Pref = %s\n", preference);
183 SerialDebug.println(
"setup_ATOM_SocketModule.M5.begin");
185 M5.begin(
true,
false,
true);
201#ifdef KEY_UNIT_SENSOR_CLASS
219 SerialDebug.println(
"BuzzerSensorClass already specified in sensors");
250#ifdef KEY_UNIT_SENSOR_CLASS
293 if (M5.BtnB.wasReleasefor(3500))
296 SerialDebug.println(
"ATOM_SocketModule **** LONG LONG PRESS ***");
299 else if (M5.BtnB.wasReleasefor(1000))
302 SerialDebug.println(
"ATOM_SocketModule **** LONG PRESS ***");
305 else if (M5.BtnB.wasReleased())
308 SerialDebug.println(
"ATOM_SocketModule **** SHORT PRESS ***");
321#ifdef read_serial_monitor
324 boolean serialData =
false;
325 while (Serial.available()) {
327 int ch = Serial.read();
329 SerialDebug.write(ch);
332 SerialDebug.println();
348 SerialDebug.println(
"*** ATOM.SerialRead == 1");
371 SerialDebug.printf(
"CLEAN CREDENTIALS and reboot to AP mode\n");
387 return (
char*)
"&socket=on&k=PWR";
389 return (
char*)
"&socket=off&k=PWR";
397 return (
char*)
"'socket':'on'";
399 return (
char*)
"'socket':'off'";
boolean _longLongPress_ATOM_SocketModule
void checkButtonB_ATOM_SocketModule()
big button on front of M5StickC Plus
void set_ATOM_SocketModule(boolean flag)
turn on/off the socket
void M5AtomSocketCallback(char *parameter, boolean flag)
char * currentStatusURL_ATOM_SocketModule()
returns a string in in URL so: status&battery=84'&buzzon='off' } .. etc
boolean _shortPress_ATOM_SocketModule
not beware of linking another ATOM these names will overload..
void buttonA_LongPress_ATOM_SocketModule()
long press on buttonA (top button)
void setup_ATOM_SocketModule()
void loopCode_ATOM_SocketModule()
LOOP code.. refactored so it's also called when a buttonPress message arrives.
ATOMSOCKET ATOM
create the ATOMSOCKET connection to the power socket
void loop_ATOM_SocketModule()
called for the loop() of this plugin
void messageSend_ATOM_SocketModule(char *sendValue)
void messageSetVal_ATOM_SocketModule(char *setName, char *valValue, boolean deviceNameSpecified)
char * currentStatusJSON_ATOM_SocketModule()
boolean _longPress_ATOM_SocketModule
void toggle_ATOM_SocketModule()
turn on/off the socket
void buttonA_ShortPress_ATOM_SocketModule()
int _Voltage
info from the socket power
boolean _isOn_ATOM_SocketModule
void initGlobals_ATOM_SocketModule()
HardwareSerial AtomSerial(2)
interface to the hardware
KeyUnitSensorClass * _KeyUnitSensorClass_ATOMSocketModule
void setup_M5Display()
the setup() no loop()
void fillpix(CRGB Color)
color the button light
void sendStatusMQTT_mainModule()
1.1.24 send status of this device after events..
boolean isTrueString_mainModule(String valCmdString)
whether the string is TRUE, ON, 1
void registerPinUse_mainModule(long pin, String pinName, String moduleName, boolean isI2C)
bool containsSubstring(String message, String substring)
check if the string contains the other string. This is a poor man's grammer checker
void sendMessageString_mainModule(char *messageString)
adding a synchronous call to send a message over the network (assuming MQTT but not specified),...
void main_dispatchAsyncCommand(int asyncCallCommand)
checks if any async commands are in 'dispatch' mode, and if so, invokes them, and sets their flag to ...
#define ASYNC_CALL_CLEAN_CREDENTIALS
cleans out the credentials and restarts in AP (Access Point) mode.
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 ...
char * getPreference_mainModule(int preferenceID)
SensorStruct * getSensor_mainModule(char *sensorName)
return the sensor specified or null
#define PREFERENCE_ATOMS_SETTING
1.1.24 the preference for all the ATOM plugs (format: atomType:value} .. for now just use socket:on
#define PREFERENCE_ATOM_SOCKET_GLOBAL_ONOFF_SETTING
1.12.24 Whether the AtomSocket accepts global on/off messages
void Init(HardwareSerial &SerialData, int _RelayIO, int _RXD)
from: https://github.com/m5stack/M5Atom/blob/master/examples/ATOM_BASE/ATOM_Socket/AtomSocket....
void setup()
Pure Virtual Function.
void loop()
Pure Virtual Function.
void registerCallback(sensorCallbackSignature *callback)