Skip to content

Commit dd39de0

Browse files
[TMP] adapting ArduinoIotCloud to Cloud utils new encode/decode
1 parent 053b1c3 commit dd39de0

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Diff for: src/ArduinoIoTCloudDevice.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ int ArduinoCloudDevice::connected() {
4848
void ArduinoCloudDevice::handleMessage(Message *m) {
4949
_command = UnknownCmdId;
5050
if (m != nullptr) {
51-
_command = m->id;
51+
_command = static_cast<CommandId>(m->id);
5252
}
5353

5454
/* Run through the state machine. */

Diff for: src/ArduinoIoTCloudTCP.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -402,10 +402,10 @@ void ArduinoIoTCloudTCP::handleMessage(int length)
402402
if (_messageTopicIn == topic) {
403403
CommandDown command;
404404
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s [%d] received %d bytes", __FUNCTION__, millis(), length);
405-
CBORMessageDecoder decoder;
405+
// CBORMessageDecoder decoder;
406406

407407
size_t buffer_length = length;
408-
if (decoder.decode((Message*)&command, bytes, buffer_length) != Decoder::Status::Error) {
408+
if (CBORMessageDecoder.decode((Message*)&command, bytes, buffer_length) != Decoder::Status::Error) {
409409
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s [%d] received command id %d", __FUNCTION__, millis(), command.c.id);
410410
switch (command.c.id)
411411
{
@@ -486,7 +486,7 @@ void ArduinoIoTCloudTCP::sendMessage(Message * msg)
486486
{
487487
uint8_t data[MQTT_TRANSMIT_BUFFER_SIZE];
488488
size_t bytes_encoded = sizeof(data);
489-
CBORMessageEncoder encoder;
489+
// CBORMessageEncoder encoder;
490490

491491
switch (msg->id) {
492492
case PropertiesUpdateCmdId:
@@ -499,7 +499,7 @@ void ArduinoIoTCloudTCP::sendMessage(Message * msg)
499499
break;
500500
}
501501

502-
if (encoder.encode(msg, data, bytes_encoded) == Encoder::Status::Complete &&
502+
if (CBORMessageEncoder.encode(msg, data, bytes_encoded) == Encoder::Status::Complete &&
503503
bytes_encoded > 0) {
504504
write(_messageTopicOut, data, bytes_encoded);
505505
} else {

Diff for: src/ArduinoIoTCloudThing.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ int ArduinoCloudThing::connected() {
6969
void ArduinoCloudThing::handleMessage(Message* m) {
7070
_command = UnknownCmdId;
7171
if (m != nullptr) {
72-
_command = m->id;
72+
_command = static_cast<CommandId>(m->id);
7373
if (_command == TimezoneCommandDownId) {
7474
_utcOffset = reinterpret_cast<TimezoneCommandDown*>(m)->params.offset;
7575
_utcOffsetExpireTime = reinterpret_cast<TimezoneCommandDown*>(m)->params.until;

0 commit comments

Comments
 (0)