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);
86 SerialDebug.printf(
"set_ATOM_SocketModule: %s\n",flag?
"ON":
"OFF");
139 if (strcmp(setName,
"socket")==0)
141 SerialDebug.printf(
"messageSetVal_ATOM_SocketModule(%s - global =%d, dev=%d)\n", valValue, globalOnOff, deviceNameSpecified);
142 if (globalOnOff || deviceNameSpecified)
153 SerialDebug.printf(
"messageSend_ATOM_SocketModule(%s)\n", sendValue);
154 if (strcasecmp(sendValue,
"togglesocket")==0)
182 SerialDebug.printf(
"ATOM Pref = %s\n", preference);
188 SerialDebug.println(
"setup_ATOM_SocketModule.M5.begin");
206#ifdef KEY_UNIT_SENSOR_CLASS
224 SerialDebug.println(
"BuzzerSensorClass already specified in sensors");
255#ifdef KEY_UNIT_SENSOR_CLASS
298 if (M5.BtnB.wasReleasefor(3500))
301 SerialDebug.println(
"ATOM_SocketModule **** LONG LONG PRESS ***");
304 else if (M5.BtnB.wasReleasefor(1000))
307 SerialDebug.println(
"ATOM_SocketModule **** LONG PRESS ***");
310 else if (M5.BtnB.wasReleased())
313 SerialDebug.println(
"ATOM_SocketModule **** SHORT PRESS ***");
326#ifdef read_serial_monitor
329 boolean serialData =
false;
330 while (Serial.available()) {
332 int ch = Serial.read();
334 SerialDebug.write(ch);
337 SerialDebug.println();
353 SerialDebug.println(
"*** ATOM.SerialRead == 1");
379 SerialDebug.printf(
"CLEAN CREDENTIALS and reboot to AP mode\n");
395 return (
char*)
"&socket=on&k=PWR";
397 return (
char*)
"&socket=off&k=PWR";
405 return (
char*)
"'socket':'on'";
407 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()
boolean registerPinUse_mainModule(long pin, String pinName, String moduleName, boolean isI2C)
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
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 ...
void espUpdate_mainModule(int num)
the Update aggrgate
void setLEDColor(ColorsUnified color)
uses colors.. _GREEN to be typed values
#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)