@@ -112,7 +112,6 @@ static void thread_bootsrap_network_discovery_failure(int8_t interface_id);
112112
113113static void thread_neighbor_remove (int8_t interface_id , mle_neigh_table_entry_t * cur );
114114static void thread_bootsrap_network_join_start (struct protocol_interface_info_entry * cur_interface , discovery_response_list_t * nwk_info );
115- static int8_t thread_child_keep_alive (int8_t interface_id , const uint8_t * mac64 );
116115
117116
118117
@@ -134,37 +133,6 @@ static void thread_neighbor_remove(int8_t interface_id, mle_neigh_table_entry_t
134133 thread_reset_neighbour_info (cur_interface , cur );
135134}
136135
137-
138- static bool thread_child_keep_alive_callback (int8_t interface_id , uint16_t msgId , bool usedAllRetries )
139- {
140- uint8_t mac64 [8 ];
141- uint8_t * ll64_ptr = mle_service_get_msg_destination_address_pointer (msgId );
142-
143- memcpy (mac64 , ll64_ptr + 8 , 8 );
144- mac64 [0 ] ^= 2 ;
145-
146- mle_neigh_table_entry_t * neig_info = mle_class_get_by_link_address (interface_id , mac64 , ADDR_802_15_4_LONG );
147-
148- if (!neig_info ) {
149- return false;//Why entry is removed before timeout??
150- }
151-
152-
153- if (neig_info -> ttl > MLE_TABLE_CHALLENGE_TIMER ) {
154- return false;
155- }
156-
157-
158- if (usedAllRetries ) {
159-
160- //GET entry
161- mle_class_remove_entry (interface_id , neig_info );
162- return false;
163- }
164-
165- return true;
166- }
167-
168136int8_t thread_mle_class_init (int8_t interface_id )
169137{
170138 protocol_interface_info_entry_t * cur = protocol_stack_interface_info_get_by_id (interface_id );
@@ -182,7 +150,7 @@ int8_t thread_mle_class_init(int8_t interface_id)
182150 return -1 ;
183151 }
184152
185- if (mle_class_init (interface_id , buffer .device_decription_table_size - 1 , & thread_neighbor_remove , & thread_child_keep_alive , & thread_interface_is_active ) != 0 ) {
153+ if (mle_class_init (interface_id , buffer .device_decription_table_size - 1 , & thread_neighbor_remove , & thread_host_bootstrap_child_update , & thread_interface_is_active ) != 0 ) {
186154 return -1 ;
187155 }
188156
@@ -231,68 +199,6 @@ uint8_t thread_mode_get_by_interface_ptr(protocol_interface_info_entry_t *cur)
231199 return mle_mode ;
232200}
233201
234- static int8_t thread_child_keep_alive (int8_t interface_id , const uint8_t * mac64 )
235- {
236- mle_message_timeout_params_t timeout ;
237- uint8_t ll64 [16 ];
238- protocol_interface_info_entry_t * cur = protocol_stack_interface_info_get_by_id (interface_id );
239- uint32_t keySequence ;
240- uint16_t bufId ;
241- uint8_t mode ;
242- if (!cur ) {
243- return -1 ;
244- }
245-
246- if (!thread_info (cur )) {
247- return -1 ;
248- }
249-
250- //routers do not send keep alive
251- if (thread_i_am_router (cur )){
252- return -1 ;
253- }
254-
255- tr_debug ("Child Keep Alive" );
256- bufId = mle_service_msg_allocate (cur -> id , 150 + 3 + 6 + 10 , false,MLE_COMMAND_CHILD_UPDATE_REQUEST );
257- if (bufId == 0 ) {
258- return -1 ;
259- }
260-
261- thread_management_get_current_keysequence (cur -> id , & keySequence );
262- mle_service_msg_update_security_params (bufId , 5 , 2 , keySequence );
263- mode = thread_mode_get_by_interface_ptr (cur );
264-
265- uint8_t * ptr = mle_service_get_data_pointer (bufId );
266- ptr = mle_general_write_source_address (ptr , cur );
267- ptr = mle_tlv_write_mode (ptr , mode );
268-
269- ptr = thread_leader_data_tlv_write (ptr , cur );
270-
271- //Set Addresss TLV
272- if ((mode & MLE_FFD_DEV ) == 0 ) {
273- ptr = thread_address_registration_tlv_write (ptr , cur );
274- }
275-
276- memcpy (ll64 , ADDR_LINK_LOCAL_PREFIX , 8 );
277- memcpy (& ll64 [8 ], mac64 , 8 );
278- ll64 [8 ] ^= 2 ;
279- if (mle_service_update_length_by_ptr (bufId ,ptr )!= 0 ) {
280- tr_debug ("Buffer overflow at message write" );
281- }
282- timeout .retrans_max = 3 ;
283- timeout .timeout_init = 1 ;
284- timeout .timeout_max = 4 ;
285- timeout .delay = MLE_NO_DELAY ;
286-
287- //SET Destination address
288- mle_service_set_msg_destination_address (bufId , ll64 );
289- //Set Callback
290- mle_service_set_packet_callback (bufId , thread_child_keep_alive_callback );
291- mle_service_set_msg_timeout_parameters (bufId , & timeout );
292- mle_service_send_message (bufId );
293- return 0 ;
294- }
295-
296202/**
297203 * Return lower (worse) of the two margins.
298204 */
@@ -1014,6 +920,7 @@ static void thread_interface_bootsrap_mode_init(protocol_interface_info_entry_t
1014920 cur -> thread_info -> thread_device_mode = THREAD_DEVICE_MODE_SLEEPY_END_DEVICE ;
1015921 //SET Sleepy Host To RX on Idle mode for bootsrap
1016922 nwk_thread_host_control (cur , NET_HOST_RX_ON_IDLE , 0 );
923+ cur -> thread_info -> childUpdateReqTimer = 0.8 * cur -> thread_info -> host_link_timeout ;
1017924 } else {
1018925 tr_debug ("Set End node Mode" );
1019926 cur -> thread_info -> thread_device_mode = THREAD_DEVICE_MODE_END_DEVICE ;
@@ -1134,7 +1041,9 @@ void thread_tasklet(arm_event_s *event)
11341041
11351042 case THREAD_CHILD_UPDATE :
11361043 tr_debug_extra ("Thread SM THREAD_CHILD_UPDATE" );
1137- thread_bootstrap_child_update (cur );
1044+ if (thread_info (cur )-> thread_endnode_parent ) {
1045+ thread_host_bootstrap_child_update (cur -> id , cur -> thread_info -> thread_endnode_parent -> mac64 );
1046+ }
11381047 break ;
11391048 case THREAD_ANNOUNCE_ACTIVE : {
11401049 tr_debug_extra ("Thread SM THREAD_ANNOUNCE_ACTIVE" );
@@ -2333,21 +2242,7 @@ void thread_bootstrap_stop(protocol_interface_info_entry_t *cur)
23332242
23342243void thread_bootstrap_child_update_trig (protocol_interface_info_entry_t * cur )
23352244{
2336- if (cur -> thread_info -> thread_attached_state == THREAD_STATE_CONNECTED ) {
2337- if (cur -> thread_info -> thread_endnode_parent == NULL ) {
2338- return ;
2339- }
2340-
2341- if (cur -> thread_info -> thread_endnode_parent -> childUpdateProcessActive ) {
2342- //Set Pending if earlier proces is already started
2343- cur -> thread_info -> thread_endnode_parent -> childUpdatePending = true;
2344- return ;
2345- }
2346- //Trig event
2347- cur -> thread_info -> thread_endnode_parent -> childUpdatePending = false;
2348- cur -> thread_info -> thread_endnode_parent -> childUpdateProcessActive = true;
2349- cur -> thread_info -> thread_endnode_parent -> childUpdateProcessStatus = false;
2350-
2245+ if (cur -> thread_info -> thread_attached_state == THREAD_STATE_CONNECTED && cur -> thread_info -> thread_endnode_parent ) {
23512246 thread_bootsrap_event_trig (THREAD_CHILD_UPDATE , cur -> bootStrapId , ARM_LIB_HIGH_PRIORITY_EVENT );
23522247 }
23532248}
0 commit comments