added support for SDS011

This commit is contained in:
August Quint authored and GitHub committed 2020-01-22 15:51:49 +01:00
1 parent c1411e5c1b
commit b5250a21ed
1 file changed
+36
+36
View File
@@ -489,5 +489,41 @@ void PayloadConvert::addTime(time_t value) {
buffer[cursor++] = (byte)((tx_period & 0x000000FF));
#endif
}
#endif // PAYLOAD_ENCODER
void PayloadConvert::addPM10( float value) {
#if (HAS_SDS011)
#if (PAYLOAD_ENCODER == 1) // plain
char tempBuffer[10+1];
sprintf( tempBuffer, ",%5.1f", value);
addChars(tempBuffer, strlen(tempBuffer));
#elif (PAYLOAD_ENCODER == 2 ) // packed
writeUint16( (uint16_t) (value*10) );
#elif (PAYLOAD_ENCODER == 3 ) // Cayenne LPP dynamic
// TODO
#elif (PAYLOAD_ENCODER == 4 ) // Cayenne LPP packed
// TODO
#endif
#endif // HAS_SDS011
}
void PayloadConvert::addPM25( float value) {
#if (HAS_SDS011)
#if (PAYLOAD_ENCODER == 1) // plain
char tempBuffer[10+1];
sprintf( tempBuffer, ",%5.1f", value);
addChars(tempBuffer, strlen(tempBuffer));
#elif (PAYLOAD_ENCODER == 2 ) // packed
writeUint16( (uint16_t) (value*10) );
#elif (PAYLOAD_ENCODER == 3 ) // Cayenne LPP dynamic
// TODO
#elif (PAYLOAD_ENCODER == 4 ) // Cayenne LPP packed
// TODO
#endif
#endif // HAS_SDS011
}
void PayloadConvert::addChars( char * string, int len) {
for (int i=0; i < len; i++)
addByte(string[i]);
}