properly escape values in json payload
This commit is contained in:
parent
a6b4c9645a
commit
ffd4d96539
@ -114,19 +114,19 @@ namespace radio {
|
||||
uBit.serial.send("{");
|
||||
if (length >= 4) {
|
||||
memcpy(&value, bytes, 4);
|
||||
uBit.serial.send("v:"); uBit.serial.send(value);
|
||||
uBit.serial.send("\"v\":"); uBit.serial.send(value);
|
||||
if(length >= 8) {
|
||||
memcpy(&value, bytes + 4, 4);
|
||||
uBit.serial.send(",t:"); uBit.serial.send(value);
|
||||
uBit.serial.send(",\"t\":"); uBit.serial.send(value);
|
||||
if (length >= 12) {
|
||||
memcpy(&value, bytes + 8, 4);
|
||||
uBit.serial.send(",s:"); uBit.serial.send(value);
|
||||
uBit.serial.send(",\"s\":"); uBit.serial.send(value);
|
||||
if (length >= 13) {
|
||||
char name[MAX_FIELD_NAME_LENGTH+1];
|
||||
uint8_t len = min(MAX_FIELD_NAME_LENGTH, bytes[12]);
|
||||
memcpy(name, bytes + 13, len);
|
||||
name[len] = 0;
|
||||
uBit.serial.send(",n:\""); uBit.serial.send(name); uBit.serial.send("\"");
|
||||
uBit.serial.send(",\"n\":\""); uBit.serial.send(name); uBit.serial.send("\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user