Small Fix for Helper Functions

This commit is contained in:
seiichiro 2021-03-29 17:44:55 +02:00
parent 054f27ebee
commit c63132ebe0
4 changed files with 8 additions and 4 deletions

View file

@ -40,7 +40,7 @@ class AttSensor {
// Return the number of Bytes added to the Payload // Return the number of Bytes added to the Payload
virtual uint8_t numBytes(void) = 0; virtual uint8_t numBytes(void) = 0;
// Helper Functions to Put Values Into the Payload Array // Helper Functions to Put Values Into the Payload Array
static void int32ToPayload(int32_t value, char *payload, uint8_t startbyte) { static void int32ToPayload(int32_t value, char *payload, uint8_t startbyte) {
payload[startbyte] = (value) & 0XFF; payload[startbyte] = (value) & 0XFF;
payload[startbyte+1] = (value >> 8) & 0XFF; payload[startbyte+1] = (value >> 8) & 0XFF;
@ -51,6 +51,10 @@ class AttSensor {
payload[startbyte] = (value) & 0XFF; payload[startbyte] = (value) & 0XFF;
payload[startbyte+1] = (value >> 8) & 0XFF; payload[startbyte+1] = (value >> 8) & 0XFF;
} }
static void uint16ToPayload(uint16_t value, char *payload, uint8_t startbyte) {
payload[startbyte] = (value) & 0XFF;
payload[startbyte+1] = (value >> 8) & 0XFF;
}
}; };
#endif #endif

View file

@ -51,7 +51,7 @@ uint8_t MHZ19C::getSensorData(char * payload, uint8_t startbyte) {
if (readBytes > 0) { if (readBytes > 0) {
switch(buffer[1]) { switch(buffer[1]) {
case 0x86: case 0x86:
int16ToPayload((buffer[2]*256) + buffer[3], payload, startbyte); uint16ToPayload((buffer[2]*256) + buffer[3], payload, startbyte);
break; break;
} }
} }

View file

@ -44,7 +44,7 @@ uint8_t SENSAIRS8::getSensorData(char *payload, uint8_t startbyte) {
payload[startbyte] = 0x00; payload[startbyte] = 0x00;
payload[startbyte+1] = 0x00; payload[startbyte+1] = 0x00;
if (readBytes > 0) { if (readBytes > 0) {
int16ToPayload((buffer[3]*256) + buffer[4], payload, startbyte); uint16ToPayload((buffer[3]*256) + buffer[4], payload, startbyte);
} }
return startbyte+2; return startbyte+2;
} }

View file

@ -44,7 +44,7 @@ uint8_t SG112A::getSensorData(char *payload, uint8_t startbyte) {
if (readBytes > 0) { if (readBytes > 0) {
switch(buffer[2]) { switch(buffer[2]) {
case 0x15: case 0x15:
int16ToPayload((buffer[3]*256) + buffer[4], payload, startbyte); uint16ToPayload((buffer[3]*256) + buffer[4], payload, startbyte);
break; break;
} }
} }