Skip to content

Commit 8c4dd38

Browse files
Fabrizio Mirabitomattiabertorello
authored andcommitted
fix integer type into a double
1 parent b5c6a5f commit 8c4dd38

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

ArduinoCloudThing.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,21 @@ void ArduinoCloudThing::decode(uint8_t *payload, size_t length) {
281281
cbor_value_get_double(&propValue, &val);
282282
ArduinoCloudProperty<float>* p = (ArduinoCloudProperty<float>*) property;
283283
p->write((float)val);
284+
} else if (propValue.type == CborIntegerType) {
285+
int val;
286+
cbor_value_get_int(&propValue, &val);
287+
ArduinoCloudProperty<float>* p = (ArduinoCloudProperty<float>*) property;
288+
p->write((float)val);
289+
} else if (propValue.type == CborFloatType) {
290+
float val;
291+
cbor_value_get_float(&propValue, &val);
292+
ArduinoCloudProperty<float>* p = (ArduinoCloudProperty<float>*) property;
293+
p->write(val);
294+
} else if (propValue.type == CborHalfFloatType) {
295+
float val;
296+
cbor_value_get_half_float(&propValue, &val);
297+
ArduinoCloudProperty<float>* p = (ArduinoCloudProperty<float>*) property;
298+
p->write(val);
284299
}
285300
} else if (propType == INT && !cbor_value_map_find_value(&recursedMap, "v", &propValue)) {
286301
// if no key proper key was found, do nothing
@@ -295,6 +310,16 @@ void ArduinoCloudThing::decode(uint8_t *payload, size_t length) {
295310
cbor_value_get_double(&propValue, &val);
296311
ArduinoCloudProperty<int>* p = (ArduinoCloudProperty<int>*) property;
297312
p->write((int)val);
313+
} else if (propValue.type == CborFloatType) {
314+
float val;
315+
cbor_value_get_float(&propValue, &val);
316+
ArduinoCloudProperty<int>* p = (ArduinoCloudProperty<int>*) property;
317+
p->write((int)val);
318+
} else if (propValue.type == CborHalfFloatType) {
319+
float val;
320+
cbor_value_get_half_float(&propValue, &val);
321+
ArduinoCloudProperty<int>* p = (ArduinoCloudProperty<int>*) property;
322+
p->write((int)val);
298323
}
299324
} else if (propType == BOOL && !cbor_value_map_find_value(&recursedMap, "vb", &propValue)) {
300325
if (propValue.type == CborBooleanType) {

0 commit comments

Comments
 (0)