Skip to content

Internal Events

doomke edited this page Jul 20, 2023 · 14 revisions

Internal Events are used to propagate state changes of a module to other modules on the same hardware. Every event includes the following 2 pieces of information:

  1. eventId -- integer, identifies category of the condition that occurred
  2. sourceId -- String, ID of the module issuing the event. Internal events do not get forwarded to the socket server and are therefore only available to modules that share the same ESP32. However, Custom event Hooks can be created to execute commands when events occur.

Due to the eventId being somewhat limited in the information it can carry, internal events are used for syncing major information with other modules on the same hardware. For more structured/verbose information socket events should be used.

Event IDs

ID event type source module
0 socket disconnected socket
1 socket connected socket
2 socket authed socket
3 wifi disconnected WiFi
4 wifi connected WiFi
5 busy all[1]
6 ready all[1]
7 time synced socket
8 debug on core[2]
9 debug off core[2]
10 input trigger low input
11 input trigger high input
  1. modules can signal busy on timed actions or while moving to indicate they are not ready to receive the next command. Followed by ready once the module is available again.
  2. used by the module manager to sync the debug state across all modules

Custom Event Hooks

In order to automate tasks on certain conditions, every ESP32 can hold up to 16 custom event hooks that each hold a single command. In order for a command to be activated, 2 conditions that constitute the event hook must be met:

  1. listeningId: the event hook only reacts if the module issuing the event matches this exactly (wildcard * allows for any sourceId to satisfy this check)
  2. eventId: the event type of the occurring event

Managing Event Hooks

In order to edit, add or delete event hooks, connect the ESP32 via serial interface and start the setup routine by sending the text setup over the interface. The firmware will then list the currently initialized modules and some management options. Choose the option to manage internal events by sending i over the interface. The listed event hooks can then be edited or removed or entirely new ones created. The following information is needed for every event hook:

Name Type Description
eventId integer specifies what type of event to listen for
listeningId String controlId of the event issuing module to listen for
controlId String controlId of the module to receive the attached command
controlKey String command key of the receiving module[3]
valueType integer defines what type the value can take[3]
controlValue boolean
integer
float
String
value accompanying the controlKey[4]
  1. both the available controlKeys and the corresponding type of controlValue depend on the type of module addressed, see the individual modules for further information
  2. only 4 types of controlValue are available (check module in question for permitted type), identified by number:
# Type
0 bool
1 integer
2 float
3 String

General

Guides

Principle of Operation

Modules

Software Hardware
camera camera
infoLED infoLED
input input
macro macro
output output
servo servo
socket socket
stepper stepper
WiFi wifi

Clone this wiki locally