1
0
mirror of https://github.com/adafruit/Adafruit_MQTT_Library.git synced 2025-07-27 15:01:49 +03:00

Documented payload

This commit is contained in:
Stuart Feichtinger
2016-01-31 17:24:00 -06:00
parent ef573ee2b2
commit 23a4673565

View File

@ -58,6 +58,23 @@ Adafruit_MQTT_Publish photocell = Adafruit_MQTT_Publish(&mqtt, PHOTOCELL_FEED);
const char ONOFF_FEED[] PROGMEM = AIO_USERNAME "/feeds/onoff"; const char ONOFF_FEED[] PROGMEM = AIO_USERNAME "/feeds/onoff";
Adafruit_MQTT_Subscribe onoffbutton = Adafruit_MQTT_Subscribe(&mqtt, ONOFF_FEED); Adafruit_MQTT_Subscribe onoffbutton = Adafruit_MQTT_Subscribe(&mqtt, ONOFF_FEED);
// Arbitrary Payload
// Union allows for easier interaction of members in struct form with easy publishing
// of "raw" bytes
typedef union{
struct __attribute__((__packed__)){ // packed to eliminate padding for easier parsing.
char charAry[10];
int16_t val1;
unsigned long val2;
uint16_t val3;
}s;
uint8_t raw[sizeof(s)]; // For publishing
} packet_t;
/*************************** Sketch Code ************************************/ /*************************** Sketch Code ************************************/
// Bug workaround for Arduino 1.6.6, it seems to need a function declaration // Bug workaround for Arduino 1.6.6, it seems to need a function declaration