@@ -25,86 +25,114 @@ bool otDatasetIsCommissioned(otInstance *aInstance)
2525 return result ;
2626}
2727
28- otError otDatasetSetActiveTlvs ( otInstance * aInstance , const otOperationalDatasetTlvs * aDataset )
28+ static otError ot_rpc_dataset_set_tlvs ( uint8_t cmd , const otOperationalDatasetTlvs * dataset )
2929{
3030 struct nrf_rpc_cbor_ctx ctx ;
31- size_t cbor_buffer_size ;
3231 otError error ;
3332
34- ARG_UNUSED ( aInstance );
33+ __ASSERT_NO_MSG ( dataset );
3534
36- if (aDataset == NULL || aDataset -> mLength > OT_OPERATIONAL_DATASET_MAX_LENGTH ) {
35+ if (dataset -> mLength > OT_OPERATIONAL_DATASET_MAX_LENGTH ) {
3736 return OT_ERROR_INVALID_ARGS ;
3837 }
3938
40- cbor_buffer_size = aDataset -> mLength + 2 ;
41-
42- NRF_RPC_CBOR_ALLOC (& ot_group , ctx , cbor_buffer_size );
43-
44- nrf_rpc_encode_buffer (& ctx , aDataset -> mTlvs , aDataset -> mLength );
45-
46- nrf_rpc_cbor_cmd_no_err (& ot_group , OT_RPC_CMD_DATASET_SET_ACTIVE_TLVS , & ctx ,
47- ot_rpc_decode_error , & error );
39+ NRF_RPC_CBOR_ALLOC (& ot_group , ctx , 2 + dataset -> mLength );
40+ nrf_rpc_encode_buffer (& ctx , dataset -> mTlvs , dataset -> mLength );
41+ nrf_rpc_cbor_cmd_no_err (& ot_group , cmd , & ctx , ot_rpc_decode_error , & error );
4842
4943 return error ;
5044}
5145
52- otError otDatasetGetActiveTlvs ( otInstance * aInstance , otOperationalDatasetTlvs * aDataset )
46+ static otError ot_rpc_dataset_get_tlvs ( uint8_t cmd , otOperationalDatasetTlvs * dataset )
5347{
5448 struct nrf_rpc_cbor_ctx ctx ;
55- otOperationalDatasetTlvs * dataset = aDataset ;
5649
57- ARG_UNUSED (aInstance );
58-
59- if (aDataset == NULL ) {
60- return OT_ERROR_NOT_FOUND ;
61- }
50+ __ASSERT_NO_MSG (dataset );
6251
6352 NRF_RPC_CBOR_ALLOC (& ot_group , ctx , 0 );
64-
65- nrf_rpc_cbor_cmd_no_err (& ot_group , OT_RPC_CMD_DATASET_GET_ACTIVE_TLVS , & ctx ,
66- ot_rpc_decode_dataset_tlvs , & dataset );
53+ nrf_rpc_cbor_cmd_no_err (& ot_group , cmd , & ctx , ot_rpc_decode_dataset_tlvs , & dataset );
6754
6855 return dataset ? OT_ERROR_NONE : OT_ERROR_NOT_FOUND ;
6956}
7057
71- otError otDatasetSetActive ( otInstance * aInstance , const otOperationalDataset * aDataset )
58+ static otError ot_rpc_dataset_set ( uint8_t cmd , const otOperationalDataset * dataset )
7259{
7360 struct nrf_rpc_cbor_ctx ctx ;
74- size_t cbor_buffer_size ;
7561 otError error ;
7662
63+ __ASSERT_NO_MSG (dataset );
64+
65+ NRF_RPC_CBOR_ALLOC (& ot_group , ctx , OPERATIONAL_DATASET_LENGTH (dataset ));
66+ ot_rpc_encode_dataset (& ctx , dataset );
67+ nrf_rpc_cbor_cmd_no_err (& ot_group , cmd , & ctx , ot_rpc_decode_error , & error );
68+
69+ return error ;
70+ }
71+
72+ static otError ot_rpc_dataset_get (uint8_t cmd , otOperationalDataset * dataset )
73+ {
74+ struct nrf_rpc_cbor_ctx ctx ;
75+
76+ __ASSERT_NO_MSG (dataset );
77+
78+ NRF_RPC_CBOR_ALLOC (& ot_group , ctx , 0 );
79+ nrf_rpc_cbor_cmd_no_err (& ot_group , cmd , & ctx , ot_rpc_decode_dataset , & dataset );
80+
81+ return dataset ? OT_ERROR_NONE : OT_ERROR_NOT_FOUND ;
82+ }
83+
84+ otError otDatasetSetActiveTlvs (otInstance * aInstance , const otOperationalDatasetTlvs * aDataset )
85+ {
7786 ARG_UNUSED (aInstance );
7887
79- if (aDataset == NULL ) {
80- return OT_ERROR_INVALID_ARGS ;
81- }
88+ return ot_rpc_dataset_set_tlvs (OT_RPC_CMD_DATASET_SET_ACTIVE_TLVS , aDataset );
89+ }
8290
83- cbor_buffer_size = OPERATIONAL_DATASET_LENGTH (aDataset );
91+ otError otDatasetGetActiveTlvs (otInstance * aInstance , otOperationalDatasetTlvs * aDataset )
92+ {
93+ ARG_UNUSED (aInstance );
8494
85- NRF_RPC_CBOR_ALLOC (& ot_group , ctx , cbor_buffer_size );
86- ot_rpc_encode_dataset (& ctx , aDataset );
87- nrf_rpc_cbor_cmd_no_err (& ot_group , OT_RPC_CMD_DATASET_SET_ACTIVE , & ctx , ot_rpc_decode_error ,
88- & error );
95+ return ot_rpc_dataset_get_tlvs (OT_RPC_CMD_DATASET_GET_ACTIVE_TLVS , aDataset );
96+ }
8997
90- return error ;
98+ otError otDatasetSetActive (otInstance * aInstance , const otOperationalDataset * aDataset )
99+ {
100+ ARG_UNUSED (aInstance );
101+
102+ return ot_rpc_dataset_set (OT_RPC_CMD_DATASET_SET_ACTIVE , aDataset );
91103}
92104
93105otError otDatasetGetActive (otInstance * aInstance , otOperationalDataset * aDataset )
94106{
95- struct nrf_rpc_cbor_ctx ctx ;
96- otOperationalDataset * dataset = aDataset ;
107+ ARG_UNUSED (aInstance );
97108
109+ return ot_rpc_dataset_get (OT_RPC_CMD_DATASET_GET_ACTIVE , aDataset );
110+ }
111+
112+ otError otDatasetSetPendingTlvs (otInstance * aInstance , const otOperationalDatasetTlvs * aDataset )
113+ {
98114 ARG_UNUSED (aInstance );
99115
100- if (aDataset == NULL ) {
101- return OT_ERROR_NOT_FOUND ;
102- }
116+ return ot_rpc_dataset_set_tlvs (OT_RPC_CMD_DATASET_SET_PENDING_TLVS , aDataset );
117+ }
103118
104- NRF_RPC_CBOR_ALLOC (& ot_group , ctx , 0 );
119+ otError otDatasetGetPendingTlvs (otInstance * aInstance , otOperationalDatasetTlvs * aDataset )
120+ {
121+ ARG_UNUSED (aInstance );
105122
106- nrf_rpc_cbor_cmd_no_err ( & ot_group , OT_RPC_CMD_DATASET_GET_ACTIVE , & ctx ,
107- ot_rpc_decode_dataset , & dataset );
123+ return ot_rpc_dataset_get_tlvs ( OT_RPC_CMD_DATASET_GET_PENDING_TLVS , aDataset );
124+ }
108125
109- return dataset ? OT_ERROR_NONE : OT_ERROR_NOT_FOUND ;
126+ otError otDatasetSetPending (otInstance * aInstance , const otOperationalDataset * aDataset )
127+ {
128+ ARG_UNUSED (aInstance );
129+
130+ return ot_rpc_dataset_set (OT_RPC_CMD_DATASET_SET_PENDING , aDataset );
131+ }
132+
133+ otError otDatasetGetPending (otInstance * aInstance , otOperationalDataset * aDataset )
134+ {
135+ ARG_UNUSED (aInstance );
136+
137+ return ot_rpc_dataset_get (OT_RPC_CMD_DATASET_GET_PENDING , aDataset );
110138}
0 commit comments