@@ -213,6 +213,66 @@ static void ot_rpc_msg_read(const struct nrf_rpc_group *group, struct nrf_rpc_cb
213213 nrf_rpc_cbor_rsp_no_err (group , & rsp_ctx );
214214}
215215
216+ static void ot_rpc_msg_get_thread_link_info (const struct nrf_rpc_group * group ,
217+ struct nrf_rpc_cbor_ctx * ctx , void * handler_data )
218+ {
219+ ot_rpc_res_tab_key key ;
220+ otMessage * message ;
221+ otThreadLinkInfo link_info ;
222+ otError error ;
223+ size_t cbor_buffer_size ;
224+ struct nrf_rpc_cbor_ctx rsp_ctx ;
225+
226+ key = nrf_rpc_decode_uint (ctx );
227+
228+ if (!nrf_rpc_decoding_done_and_check (group , ctx )) {
229+ ot_rpc_report_cmd_decoding_error (OT_RPC_CMD_MESSAGE_GET_THREAD_LINK_INFO );
230+ return ;
231+ }
232+
233+ message = ot_res_tab_msg_get (key );
234+
235+ if (!message ) {
236+ ot_rpc_report_cmd_decoding_error (OT_RPC_CMD_MESSAGE_GET_THREAD_LINK_INFO );
237+ return ;
238+ }
239+
240+ openthread_api_mutex_lock (openthread_get_default_context ());
241+ error = otMessageGetThreadLinkInfo (message , & link_info );
242+ openthread_api_mutex_unlock (openthread_get_default_context ());
243+
244+ cbor_buffer_size = 1 ;
245+
246+ if (error == OT_ERROR_NONE ) {
247+ cbor_buffer_size += 1 + sizeof (link_info .mPanId );
248+ cbor_buffer_size += 1 + sizeof (link_info .mChannel );
249+ cbor_buffer_size += 1 + sizeof (link_info .mRss );
250+ cbor_buffer_size += 1 + sizeof (link_info .mLqi );
251+ cbor_buffer_size += 2 ; /* mLinkSecurity + mIsDstPanIdBroadcast */
252+ cbor_buffer_size += 1 + sizeof (link_info .mTimeSyncSeq );
253+ cbor_buffer_size += 1 + sizeof (link_info .mNetworkTimeOffset );
254+ cbor_buffer_size += 1 + sizeof (link_info .mRadioType );
255+ }
256+
257+ NRF_RPC_CBOR_ALLOC (group , rsp_ctx , cbor_buffer_size );
258+
259+ nrf_rpc_encode_uint (& rsp_ctx , error );
260+
261+ if (error == OT_ERROR_NONE ) {
262+ nrf_rpc_encode_uint (& rsp_ctx , link_info .mPanId );
263+ nrf_rpc_encode_uint (& rsp_ctx , link_info .mChannel );
264+ nrf_rpc_encode_int (& rsp_ctx , link_info .mRss );
265+ nrf_rpc_encode_uint (& rsp_ctx , link_info .mLqi );
266+ nrf_rpc_encode_bool (& rsp_ctx , link_info .mLinkSecurity );
267+ nrf_rpc_encode_bool (& rsp_ctx , link_info .mIsDstPanIdBroadcast );
268+ nrf_rpc_encode_uint (& rsp_ctx , link_info .mTimeSyncSeq );
269+ nrf_rpc_encode_int64 (& rsp_ctx , link_info .mNetworkTimeOffset );
270+ nrf_rpc_encode_uint (& rsp_ctx , link_info .mRadioType );
271+ }
272+
273+ nrf_rpc_cbor_rsp_no_err (group , & rsp_ctx );
274+ }
275+
216276NRF_RPC_CBOR_CMD_DECODER (ot_group , ot_rpc_msg_length , OT_RPC_CMD_MESSAGE_GET_LENGTH ,
217277 ot_rpc_msg_length , NULL );
218278
@@ -228,3 +288,7 @@ NRF_RPC_CBOR_CMD_DECODER(ot_group, ot_rpc_msg_udp_new, OT_RPC_CMD_UDP_NEW_MESSAG
228288
229289NRF_RPC_CBOR_CMD_DECODER (ot_group , ot_rpc_msg_append , OT_RPC_CMD_MESSAGE_APPEND , ot_rpc_msg_append ,
230290 NULL );
291+
292+ NRF_RPC_CBOR_CMD_DECODER (ot_group , ot_rpc_msg_get_thread_link_info ,
293+ OT_RPC_CMD_MESSAGE_GET_THREAD_LINK_INFO , ot_rpc_msg_get_thread_link_info ,
294+ NULL );
0 commit comments