Merge pull request #557 from AugustQu/SDS011

Sds011
This commit is contained in:
Verkehrsrot 2020-03-14 07:39:08 +01:00 committed by GitHub
commit 5e9d69966b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 9 deletions

View File

@ -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

View File

@ -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]);
}
}