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