1818#define OT_RPC_MAX_NUM_UNICAST_ADDRESSES 8
1919#define OT_RPC_MAX_NUM_MULTICAST_ADDRESSES 8
2020
21- static otError decode_ot_error (struct nrf_rpc_cbor_ctx * ctx )
22- {
23- otError error ;
24-
25- if (!zcbor_uint_decode (ctx -> zs , & error , sizeof (error ))) {
26- error = OT_ERROR_PARSE ;
27- }
28-
29- nrf_rpc_cbor_decoding_done (& ot_group , ctx );
30-
31- return error ;
32- }
33-
3421const otNetifAddress * otIp6GetUnicastAddresses (otInstance * aInstance )
3522{
3623 struct nrf_rpc_cbor_ctx ctx ;
@@ -140,39 +127,33 @@ const otNetifMulticastAddress *otIp6GetMulticastAddresses(otInstance *aInstance)
140127otError otIp6SetEnabled (otInstance * aInstance , bool aEnabled )
141128{
142129 struct nrf_rpc_cbor_ctx ctx ;
130+ otError error ;
143131
144132 ARG_UNUSED (aInstance );
145133
146134 NRF_RPC_CBOR_ALLOC (& ot_group , ctx , 1 );
135+ nrf_rpc_encode_bool (& ctx , aEnabled );
136+ nrf_rpc_cbor_cmd_no_err (& ot_group , OT_RPC_CMD_IP6_SET_ENABLED , & ctx , ot_rpc_decode_error ,
137+ & error );
147138
148- if (!zcbor_bool_encode (ctx .zs , & aEnabled )) {
149- NRF_RPC_CBOR_DISCARD (& ot_group , ctx );
150- return OT_ERROR_INVALID_ARGS ;
151- }
152-
153- nrf_rpc_cbor_cmd_rsp_no_err (& ot_group , OT_RPC_CMD_IP6_SET_ENABLED , & ctx );
154-
155- return decode_ot_error (& ctx );
139+ return error ;
156140}
157141
158142bool otIp6IsEnabled (otInstance * aInstance )
159143{
160144 struct nrf_rpc_cbor_ctx ctx ;
161- bool enabled = false;
162- bool decoded_ok ;
145+ bool enabled ;
163146
164147 ARG_UNUSED (aInstance );
165148
166149 NRF_RPC_CBOR_ALLOC (& ot_group , ctx , 0 );
167150
168151 nrf_rpc_cbor_cmd_rsp_no_err (& ot_group , OT_RPC_CMD_IP6_IS_ENABLED , & ctx );
169152
170- decoded_ok = zcbor_bool_decode (ctx .zs , & enabled );
171- nrf_rpc_cbor_decoding_done (& ot_group , & ctx );
153+ enabled = nrf_rpc_decode_bool (& ctx );
172154
173- if (!decoded_ok ) {
174- nrf_rpc_err (- EBADMSG , NRF_RPC_ERR_SRC_RECV , & ot_group , OT_RPC_CMD_IP6_IS_ENABLED ,
175- NRF_RPC_PACKET_TYPE_RSP );
155+ if (!nrf_rpc_decoding_done_and_check (& ot_group , & ctx )) {
156+ ot_rpc_report_decoding_error (OT_RPC_CMD_IP6_IS_ENABLED );
176157 }
177158
178159 return enabled ;
@@ -181,35 +162,30 @@ bool otIp6IsEnabled(otInstance *aInstance)
181162otError otIp6SubscribeMulticastAddress (otInstance * aInstance , const otIp6Address * aAddress )
182163{
183164 struct nrf_rpc_cbor_ctx ctx ;
165+ otError error ;
184166
185167 ARG_UNUSED (aInstance );
186168
187169 NRF_RPC_CBOR_ALLOC (& ot_group , ctx , 1 + OT_IP6_ADDRESS_SIZE );
170+ nrf_rpc_encode_buffer (& ctx , (const char * )aAddress , OT_IP6_ADDRESS_SIZE );
171+ nrf_rpc_cbor_cmd_no_err (& ot_group , OT_RPC_CMD_IP6_SUBSCRIBE_MADDR , & ctx ,
172+ ot_rpc_decode_error , & error );
188173
189- if (!zcbor_bstr_encode_ptr (ctx .zs , (const char * )aAddress , OT_IP6_ADDRESS_SIZE )) {
190- NRF_RPC_CBOR_DISCARD (& ot_group , ctx );
191- return OT_ERROR_INVALID_ARGS ;
192- }
193-
194- nrf_rpc_cbor_cmd_rsp_no_err (& ot_group , OT_RPC_CMD_IP6_SUBSCRIBE_MADDR , & ctx );
195-
196- return decode_ot_error (& ctx );
174+ return error ;
197175}
198176
199177otError otIp6UnsubscribeMulticastAddress (otInstance * aInstance , const otIp6Address * aAddress )
200178{
201179 struct nrf_rpc_cbor_ctx ctx ;
180+ otError error ;
202181
203182 ARG_UNUSED (aInstance );
204183
205184 NRF_RPC_CBOR_ALLOC (& ot_group , ctx , 1 + OT_IP6_ADDRESS_SIZE );
206185
207- if (!zcbor_bstr_encode_ptr (ctx .zs , (const char * )aAddress , OT_IP6_ADDRESS_SIZE )) {
208- NRF_RPC_CBOR_DISCARD (& ot_group , ctx );
209- return OT_ERROR_INVALID_ARGS ;
210- }
211-
212- nrf_rpc_cbor_cmd_rsp_no_err (& ot_group , OT_RPC_CMD_IP6_UNSUBSCRIBE_MADDR , & ctx );
186+ nrf_rpc_encode_buffer (& ctx , (const char * )aAddress , OT_IP6_ADDRESS_SIZE );
187+ nrf_rpc_cbor_cmd_no_err (& ot_group , OT_RPC_CMD_IP6_UNSUBSCRIBE_MADDR , & ctx ,
188+ ot_rpc_decode_error , & error );
213189
214- return decode_ot_error ( & ctx ) ;
190+ return error ;
215191}
0 commit comments