Skip to content

Commit a920478

Browse files
defining Message structure for encoding and decoding messages with an id specifier
1 parent 76efd85 commit a920478

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/interfaces/message.h

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
This file is part of the Arduino_CloudUtils library.
3+
4+
Copyright (c) 2024 Arduino SA
5+
6+
This Source Code Form is subject to the terms of the Mozilla Public
7+
License, v. 2.0. If a copy of the MPL was not distributed with this
8+
file, You can obtain one at http://mozilla.org/MPL/2.0/.
9+
*/
10+
11+
#pragma once
12+
13+
typedef uint32_t MessageId;
14+
15+
/**
16+
* The following struct can be used as a template to create ArduinoCloud compatible
17+
* Messages that can be handled by encoders/decoders and other Cloud related message exchange
18+
* These kind of messages are required to be identifiable by a starting uint32_t uinique identification number.
19+
*
20+
* In order to use this structure you need to embed this into another structure and
21+
* add additional parameters
22+
*/
23+
struct Message {
24+
MessageId id;
25+
};
26+
27+
/**
28+
* The following enum is defined to assign Arduino MessageIds starting values
29+
* and boundaries and avoid value clashing
30+
*/
31+
enum : MessageId {
32+
ArduinoIOTCloudStartMessageId = 0x100,
33+
ArduinoProvisioningStartMessageId = 0x200,
34+
};

0 commit comments

Comments
 (0)