14
14
15
15
#include " CBOREncoder.h"
16
16
17
- #include " MessageEncoder .h"
17
+ #include " IoTCloudMessageEncoder .h"
18
18
19
19
/* *****************************************************************************
20
20
* PUBLIC MEMBER FUNCTIONS
25
25
PRIVATE MEMBER FUNCTIONS
26
26
******************************************************************************/
27
27
28
- Encoder ::Status OtaBeginCommandEncoder::encode (CborEncoder* encoder, Message *msg) {
28
+ MessageEncoder ::Status OtaBeginCommandEncoder::encode (CborEncoder* encoder, Message *msg) {
29
29
OtaBeginUp * otaBeginUp = (OtaBeginUp*) msg;
30
30
CborEncoder array_encoder;
31
31
32
32
if (cbor_encoder_create_array (encoder, &array_encoder, 1 ) != CborNoError) {
33
- return Encoder ::Status::Error;
33
+ return MessageEncoder ::Status::Error;
34
34
}
35
35
36
36
if (cbor_encode_byte_string (&array_encoder, otaBeginUp->params .sha , SHA256_SIZE) != CborNoError) {
37
- return Encoder ::Status::Error;
37
+ return MessageEncoder ::Status::Error;
38
38
}
39
39
40
40
if (cbor_encoder_close_container (encoder, &array_encoder) != CborNoError) {
41
- return Encoder ::Status::Error;
41
+ return MessageEncoder ::Status::Error;
42
42
}
43
43
44
- return Encoder ::Status::Complete;
44
+ return MessageEncoder ::Status::Complete;
45
45
}
46
46
47
- Encoder ::Status ThingBeginCommandEncoder::encode (CborEncoder* encoder, Message *msg) {
47
+ MessageEncoder ::Status ThingBeginCommandEncoder::encode (CborEncoder* encoder, Message *msg) {
48
48
ThingBeginCmd * thingBeginCmd = (ThingBeginCmd*) msg;
49
49
CborEncoder array_encoder;
50
50
51
51
if (cbor_encoder_create_array (encoder, &array_encoder, 1 ) != CborNoError) {
52
- return Encoder ::Status::Error;
52
+ return MessageEncoder ::Status::Error;
53
53
}
54
54
55
55
if (cbor_encode_text_stringz (&array_encoder, thingBeginCmd->params .thing_id ) != CborNoError) {
56
- return Encoder ::Status::Error;
56
+ return MessageEncoder ::Status::Error;
57
57
}
58
58
59
59
if (cbor_encoder_close_container (encoder, &array_encoder) != CborNoError) {
60
- return Encoder ::Status::Error;
60
+ return MessageEncoder ::Status::Error;
61
61
}
62
62
63
- return Encoder ::Status::Complete;
63
+ return MessageEncoder ::Status::Complete;
64
64
}
65
65
66
- Encoder ::Status LastValuesBeginCommandEncoder::encode (CborEncoder* encoder, Message *msg) {
66
+ MessageEncoder ::Status LastValuesBeginCommandEncoder::encode (CborEncoder* encoder, Message *msg) {
67
67
// This command contains no parameters, it contains just the id of the message
68
68
// nothing to perform here
69
69
// (void)(encoder);
@@ -72,67 +72,67 @@ Encoder::Status LastValuesBeginCommandEncoder::encode(CborEncoder* encoder, Mess
72
72
73
73
// FIXME we are encoiding an empty array, this could be avoided
74
74
if (cbor_encoder_create_array (encoder, &array_encoder, 0 ) != CborNoError){
75
- return Encoder ::Status::Error;
75
+ return MessageEncoder ::Status::Error;
76
76
}
77
77
78
78
if (cbor_encoder_close_container (encoder, &array_encoder) != CborNoError) {
79
- return Encoder ::Status::Error;
79
+ return MessageEncoder ::Status::Error;
80
80
}
81
81
82
- return Encoder ::Status::Complete;
82
+ return MessageEncoder ::Status::Complete;
83
83
}
84
84
85
- Encoder ::Status DeviceBeginCommandEncoder::encode (CborEncoder* encoder, Message *msg) {
85
+ MessageEncoder ::Status DeviceBeginCommandEncoder::encode (CborEncoder* encoder, Message *msg) {
86
86
DeviceBeginCmd * deviceBeginCmd = (DeviceBeginCmd*) msg;
87
87
CborEncoder array_encoder;
88
88
89
89
if (cbor_encoder_create_array (encoder, &array_encoder, 1 ) != CborNoError) {
90
- return Encoder ::Status::Error;
90
+ return MessageEncoder ::Status::Error;
91
91
}
92
92
93
93
if (cbor_encode_text_stringz (&array_encoder, deviceBeginCmd->params .lib_version ) != CborNoError) {
94
- return Encoder ::Status::Error;
94
+ return MessageEncoder ::Status::Error;
95
95
}
96
96
97
97
if (cbor_encoder_close_container (encoder, &array_encoder) != CborNoError) {
98
- return Encoder ::Status::Error;
98
+ return MessageEncoder ::Status::Error;
99
99
}
100
100
101
- return Encoder ::Status::Complete;
101
+ return MessageEncoder ::Status::Complete;
102
102
}
103
103
104
- Encoder ::Status OtaProgressCommandUpEncoder::encode (CborEncoder* encoder, Message *msg) {
104
+ MessageEncoder ::Status OtaProgressCommandUpEncoder::encode (CborEncoder* encoder, Message *msg) {
105
105
OtaProgressCmdUp * ota = (OtaProgressCmdUp*) msg;
106
106
CborEncoder array_encoder;
107
107
108
108
if (cbor_encoder_create_array (encoder, &array_encoder, 4 ) != CborNoError) {
109
- return Encoder ::Status::Error;
109
+ return MessageEncoder ::Status::Error;
110
110
}
111
111
112
112
if (cbor_encode_byte_string (&array_encoder, ota->params .id , ID_SIZE) != CborNoError) {
113
- return Encoder ::Status::Error;
113
+ return MessageEncoder ::Status::Error;
114
114
}
115
115
116
116
if (cbor_encode_simple_value (&array_encoder, ota->params .state ) != CborNoError) {
117
- return Encoder ::Status::Error;
117
+ return MessageEncoder ::Status::Error;
118
118
}
119
119
120
120
if (cbor_encode_int (&array_encoder, ota->params .state_data ) != CborNoError) {
121
- return Encoder ::Status::Error;
121
+ return MessageEncoder ::Status::Error;
122
122
}
123
123
124
124
if (cbor_encode_uint (&array_encoder, ota->params .time ) != CborNoError) {
125
- return Encoder ::Status::Error;
125
+ return MessageEncoder ::Status::Error;
126
126
}
127
127
128
128
if (cbor_encoder_close_container (encoder, &array_encoder) != CborNoError) {
129
- return Encoder ::Status::Error;
129
+ return MessageEncoder ::Status::Error;
130
130
}
131
131
132
- return Encoder ::Status::Complete;
132
+ return MessageEncoder ::Status::Complete;
133
133
}
134
134
135
- Encoder ::Status TimezoneCommandUpEncoder::encode (CborEncoder* encoder, Message *msg) {
135
+ MessageEncoder ::Status TimezoneCommandUpEncoder::encode (CborEncoder* encoder, Message *msg) {
136
136
// This command contains no parameters, it contains just the id of the message
137
137
// nothing to perform here
138
138
// (void)(encoder);
@@ -141,14 +141,14 @@ Encoder::Status TimezoneCommandUpEncoder::encode(CborEncoder* encoder, Message *
141
141
142
142
// FIXME we are encoiding an empty array, this could be avoided
143
143
if (cbor_encoder_create_array (encoder, &array_encoder, 0 ) != CborNoError){
144
- return Encoder ::Status::Error;
144
+ return MessageEncoder ::Status::Error;
145
145
}
146
146
147
147
if (cbor_encoder_close_container (encoder, &array_encoder) != CborNoError) {
148
- return Encoder ::Status::Error;
148
+ return MessageEncoder ::Status::Error;
149
149
}
150
150
151
- return Encoder ::Status::Complete;
151
+ return MessageEncoder ::Status::Complete;
152
152
}
153
153
154
154
static OtaBeginCommandEncoder otaBeginCommandEncoder;
0 commit comments