diff --git a/include/payload.h b/include/payload.h index a7de4ddd..889c164d 100644 --- a/include/payload.h +++ b/include/payload.h @@ -23,6 +23,8 @@ #define LPP_HUMIDITY_CHANNEL 29 #define LPP_BAROMETER_CHANNEL 30 #define LPP_AIR_CHANNEL 31 +#define LPP_PARTMATTER10_CHANNEL 32 // particular matter for PM 10 +#define LPP_PARTMATTER25_CHANNEL 33 // particular matter for PM 2.5 // MyDevices CayenneLPP 2.0 types for Packed Sensor Payload, not using channels, // but different FPorts diff --git a/src/payload.cpp b/src/payload.cpp index b3291348..10c04ddc 100644 --- a/src/payload.cpp +++ b/src/payload.cpp @@ -331,17 +331,21 @@ void PayloadConvert::addByte(uint8_t value) { void PayloadConvert::addSDS(sdsStatus_t sds) { #if (HAS_SDS011) - +// value of PM10 #if (PAYLOAD_ENCODER == 3) // Cayenne LPP dynamic -#error not implemented yet + buffer[cursor++] = LPP_PARTMATTER10_CHANNEL; // for PM10 #endif - -#if (PAYLOAD_ENCODER == 4) // Cayenne LPP packed -#error not implemented yet + buffer[cursor++] = LPP_LUMINOSITY; // workaround since cayenne has no data type meter + buffer[cursor++] = highByte((uint16_t)(sds.pm10 * 10)); + buffer[cursor++] = lowByte((uint16_t)(sds.pm10 * 10)); +// value of PM2.5 +#if (PAYLOAD_ENCODER == 3) // Cayenne LPP dynamic + buffer[cursor++] = LPP_PARTMATTER25_CHANNEL; // for PM2.5 #endif - -#endif // HAS_SDS011 -} + buffer[cursor++] = LPP_LUMINOSITY; // workaround since cayenne has no data type meter + buffer[cursor++] = highByte((uint16_t)(sds.pm25 * 10)); + buffer[cursor++] = lowByte((uint16_t)(sds.pm25 * 10)); +#endif // HAS_SDS011 void PayloadConvert::addCount(uint16_t value, uint8_t snifftype) { switch (snifftype) { @@ -520,4 +524,4 @@ void PayloadConvert::addTime(time_t value) { void PayloadConvert::addChars(char *string, int len) { for (int i = 0; i < len; i++) addByte(string[i]); -} \ No newline at end of file +}