User Tools

Site Tools


kits:gpio:api:events

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

kits:gpio:api:events [2021/11/01 13:44] (current)
James Sentman created
Line 1: Line 1:
 +
 +=====Server Events Stream:====
 +The device supports a Server Events Stream at the link: http://​xtgio.local/​events
 +
 +There is a limit to the number of streams the device can keep open at once. Please plan to limit the number of connected clients to at most 4. The events stream does not give you any indication of the capabilities or configuration of the device, please first hit the /api/data request to get information on all the endpoints or other info that might be sent through the endpoint. The connection event below is the only one that sends a simple value. All other events send a short JSON command using the constants below:
 +
 +====JSON Command Constants:​====
 +^Name^Constant^Description^
 +|Address|addr|The address of the endpoint or 1-wire sensor. For GPIO Endpoint 1 the address will be the string “1” for a 1-wire sensor the address might be “A429FF”|
 +|Device Type|APfx|The “Address Prefix” showing what kind of unit is being addressed. For a GPIO endpoint the value will be “xt.gpio” see below for a list of other suitable endpoints.|
 +|Command|mcmd|The command being sent. For discrete gpio it will be “ON” or “OFF” for numerical values it will be “SetValue”|
 +|Value|Valu|If the command is SetValue then the actual value will be sent with this key|
 +|Update Only|UpDt|If the command is sending data that may not have changed from the last setting this value will be set to true. If it is present and true you should only take action on the new value if it is different from the last value you received. The RSSI and CPUTEMP commands are sent every 30 seconds but with this set to true|
 +|Error|comm|If set to any value other than 0 then an error should be indicated for the endpoint or sensor being addressed. Will not always be present. Sending a 0 should cancel any error display.|
 +|Temp Format|Frmt|Temperature sensors will send the temperature format that is configured for the device here along with readings. It will be a lower case “f” or “c”|
 +
 +
 +====DeviceTypes:​====
 +^Name^Constant^Description^
 +|GPIO Endpoint|xt.gpio|Any update from a GPIO endpoint.|
 +|Register|xt.register|Values without specific handling requirements may be sent as registers. The RSSI and Cpu Temperature values are sent as registers|
 +|Temperature|xt.temp|1-wire and DHT-22 Temperature sensors will use this as their Device Type/​Address Prefix|
 +|Humidity|xt.hum|DHT-22 sensors or any other humidity sources will use this Device Type|
 +
 +
 +====Event Constants:​====
 +In general the kind of measurement or event that you are receiving should be taken from the Device Type portion of the command above, however a command string is also included that might be useful in knowing how to route or process the command.
 +
 +^Name^Constant^Content^Description^
 +|Connection Event|XTGPIO|Firmware Version number or string|Upon connection this event is sent. The value will be the firmware version of the device|
 +|GPIO Event|gpio|Json String|An event has happened for one of the GPIO endpoints. New value, or new temp/​reading etc|
 +|1-Wire Reading|1wire|Json String|A 1-wire sensor has a new reading|
 +|Wifi Strength|RSSI|Json String|The Wifi Signal strength. These are currently sent every 30 seconds but will change in future builds to only send if the value has changed.|
 +|CPU Temperature|CPUTEMP|Json String|The CPU Temperature in F as returned from the ESP32 core temp call. These are currently sent every 30 seconds but will change in future builds to only send if the value has changed|
 +
 +====Examples:​====
 +Connection Event:
 +<​code>​
 +id: 144265395
 +event: XTGPIO
 +data: 1.2.45.178.2234
 +</​code>​
 +
 +
 +GPIO #1 Changed State:
 +<​code>​
 +id: 1062735
 +event: gpio
 +data: {"​addr":"​1","​APfx":"​xt.gpio","​mcmd":"​OFF"​}
 +</​code>​
 +
 +<​code>​
 +id: 1062735
 +event: gpio
 +data: {"​addr":"​1","​APfx":"​xt.gpio","​mcmd”:"​ON"​}
 +</​code>​
 +
 +
 +1-wire Temperature Reading:
 +<​code>​
 +id: 1461490365
 +event: 1wire
 +data: {"​addr":"​FFA181","​APfx":"​xt.temp","​mcmd":"​SetValue","​Valu":​34.8125,"​comm":​0,"​Frmt":"​f"​}
 +</​code>​
 +
 +CPU Temperature Reading:
 +<​code>​
 +id: 1092236
 +event: CPUTEMP
 +data: {"​addr":"​CPUTEMP","​APfx":"​xt.register","​UpDt":​true,"​mcmd":"​SetValue","​Valu":​122}
 +</​code>​
 +
 +WiFi RSSI Reading:
 +<​code>​
 +id: 1122223
 +event: RSSI
 +data: {"​addr":"​RSSI","​APfx":"​xt.register","​UpDt":​true,"​mcmd":"​SetValue","​Valu":​-48}
 +</​code>​
 +
  
kits/gpio/api/events.txt · Last modified: 2021/11/01 13:44 by James Sentman