Update payload.cpp
This commit is contained in:
parent
f33494b84f
commit
d818b6ecf4
@ -124,6 +124,16 @@ void PayloadConvert::addBME(bmeStatus_t value) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PayloadConvert::addSDS(sdsStatus_t sds) {
|
||||||
|
#if (HAS_SDS011)
|
||||||
|
char tempBuffer[10 + 1];
|
||||||
|
sprintf(tempBuffer, ",%5.1f", sds.pm10);
|
||||||
|
addChars(tempBuffer, strlen(tempBuffer));
|
||||||
|
sprintf(tempBuffer, ",%5.1f", sds.pm25);
|
||||||
|
addChars(tempBuffer, strlen(tempBuffer));
|
||||||
|
#endif // HAS_SDS011
|
||||||
|
}
|
||||||
|
|
||||||
void PayloadConvert::addButton(uint8_t value) {
|
void PayloadConvert::addButton(uint8_t value) {
|
||||||
#ifdef HAS_BUTTON
|
#ifdef HAS_BUTTON
|
||||||
buffer[cursor++] = value;
|
buffer[cursor++] = value;
|
||||||
@ -220,6 +230,13 @@ void PayloadConvert::addBME(bmeStatus_t value) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PayloadConvert::addSDS(sdsStatus_t sds) {
|
||||||
|
#if (HAS_SDS011)
|
||||||
|
writeUint16((uint16_t)(sds.pm10 * 10));
|
||||||
|
writeUint16((uint16_t)(sds.pm25 * 10));
|
||||||
|
#endif // HAS_SDS011
|
||||||
|
}
|
||||||
|
|
||||||
void PayloadConvert::addButton(uint8_t value) {
|
void PayloadConvert::addButton(uint8_t value) {
|
||||||
#ifdef HAS_BUTTON
|
#ifdef HAS_BUTTON
|
||||||
writeUint8(value);
|
writeUint8(value);
|
||||||
@ -242,9 +259,7 @@ void PayloadConvert::uintToBytes(uint64_t value, uint8_t byteSize) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PayloadConvert::writeUptime(uint64_t uptime) {
|
void PayloadConvert::writeUptime(uint64_t uptime) { writeUint64(uptime); }
|
||||||
writeUint64(uptime);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PayloadConvert::writeVersion(char *version) {
|
void PayloadConvert::writeVersion(char *version) {
|
||||||
memcpy(buffer + cursor, version, 10);
|
memcpy(buffer + cursor, version, 10);
|
||||||
@ -265,13 +280,9 @@ void PayloadConvert::writeUint16(uint16_t i) { uintToBytes(i, 2); }
|
|||||||
|
|
||||||
void PayloadConvert::writeUint8(uint8_t i) { uintToBytes(i, 1); }
|
void PayloadConvert::writeUint8(uint8_t i) { uintToBytes(i, 1); }
|
||||||
|
|
||||||
void PayloadConvert::writeUFloat(float value) {
|
void PayloadConvert::writeUFloat(float value) { writeUint16(value * 100); }
|
||||||
writeUint16(value * 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PayloadConvert::writePressure(float value) {
|
void PayloadConvert::writePressure(float value) { writeUint16(value * 10); }
|
||||||
writeUint16(value * 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses a 16bit two's complement with two decimals, so the range is
|
* Uses a 16bit two's complement with two decimals, so the range is
|
||||||
@ -315,7 +326,8 @@ void PayloadConvert::writeBitmap(bool a, bool b, bool c, bool d, bool e, bool f,
|
|||||||
void PayloadConvert::addByte(uint8_t value) {
|
void PayloadConvert::addByte(uint8_t value) {
|
||||||
/*
|
/*
|
||||||
not implemented
|
not implemented
|
||||||
*/ }
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
void PayloadConvert::addSDS(sdsStatus_t sds) {
|
void PayloadConvert::addSDS(sdsStatus_t sds) {
|
||||||
#if (HAS_SDS011)
|
#if (HAS_SDS011)
|
||||||
|
Loading…
Reference in New Issue
Block a user