File tree Expand file tree Collapse file tree 2 files changed +81
-0
lines changed Expand file tree Collapse file tree 2 files changed +81
-0
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ This file is part of the ArduinoIoTCloud 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+ /* *****************************************************************************
14+ * INCLUDES
15+ ******************************************************************************/
16+
17+ #include < message/Commands.h>
18+ #include < stdint.h>
19+
20+ /* *****************************************************************************
21+ * CLASS DECLARATION
22+ ******************************************************************************/
23+
24+ class Decoder {
25+ public:
26+ enum Status: uint8_t {
27+ Complete,
28+ InProgress,
29+ Error
30+ };
31+
32+ /* *
33+ * Decode a buffer into a provided message structure
34+ * @param msg: the message structure that is going to be filled with data provided in the buffer
35+ * @param buf: the incoming buffer that needs to be decoded
36+ * @param len: the length of the incoming buffer, value will be updated with the used len of the buffer
37+ * @return SUCCESS: if the message is decoded correctly
38+ * ERROR: if the message wasn't decoded correctly
39+ */
40+ virtual Status decode (Message* msg, const uint8_t * const buf, size_t &len) = 0;
41+ };
Original file line number Diff line number Diff line change 1+ /*
2+ This file is part of the ArduinoIoTCloud 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+ /* *****************************************************************************
14+ * INCLUDES
15+ ******************************************************************************/
16+ #include < message/Commands.h>
17+ #include < stdint.h>
18+
19+ /* *****************************************************************************
20+ * CLASS DECLARATION
21+ ******************************************************************************/
22+
23+ class Encoder {
24+ public:
25+ enum Status: uint8_t {
26+ Complete,
27+ InProgress,
28+ Error
29+ };
30+
31+ /* *
32+ * Encode a message into a buffer in a single shot
33+ * @param msg: the message that needs to be encoded
34+ * @param buf: the buffer the message will be encoded into
35+ * @param len: the length of the provided buffer, value will be updated with the consumed len of the buffer
36+ * @return SUCCESS: if the message is encoded correctly
37+ * ERROR: error during the encoding of the message
38+ */
39+ virtual Status encode (Message* msg, uint8_t * buf, size_t & len) = 0;
40+ };
You can’t perform that action at this time.
0 commit comments