@@ -4301,7 +4301,7 @@ static uint8_t get_adv_props(uint8_t evt_type)
43014301static void le_adv_recv (bt_addr_le_t * addr , struct bt_le_scan_recv_info * info ,
43024302 struct net_buf * buf , uint8_t len )
43034303{
4304- struct bt_le_scan_cb * listener ;
4304+ struct bt_le_scan_cb * listener , * next ;
43054305 struct net_buf_simple_state state ;
43064306 bt_addr_le_t id_addr ;
43074307
@@ -4339,8 +4339,7 @@ static void le_adv_recv(bt_addr_le_t *addr, struct bt_le_scan_recv_info *info,
43394339 net_buf_simple_restore (& buf -> b , & state );
43404340 }
43414341
4342-
4343- SYS_SLIST_FOR_EACH_CONTAINER (& scan_cbs , listener , node ) {
4342+ SYS_SLIST_FOR_EACH_CONTAINER_SAFE (& scan_cbs , listener , next , node ) {
43444343 if (listener -> recv ) {
43454344 net_buf_simple_save (& buf -> b , & state );
43464345
@@ -4359,7 +4358,7 @@ static void le_adv_recv(bt_addr_le_t *addr, struct bt_le_scan_recv_info *info,
43594358#if defined(CONFIG_BT_EXT_ADV )
43604359static void le_scan_timeout (struct net_buf * buf )
43614360{
4362- struct bt_le_scan_cb * listener ;
4361+ struct bt_le_scan_cb * listener , * next ;
43634362
43644363 atomic_clear_bit (bt_dev .flags , BT_DEV_SCANNING );
43654364 atomic_clear_bit (bt_dev .flags , BT_DEV_EXPLICIT_SCAN );
@@ -4371,7 +4370,7 @@ static void le_scan_timeout(struct net_buf *buf)
43714370 pending_id_keys_update ();
43724371#endif
43734372
4374- SYS_SLIST_FOR_EACH_CONTAINER (& scan_cbs , listener , node ) {
4373+ SYS_SLIST_FOR_EACH_CONTAINER_SAFE (& scan_cbs , listener , next , node ) {
43754374 if (listener -> timeout ) {
43764375 listener -> timeout ();
43774376 }
@@ -8996,6 +8995,11 @@ void bt_le_scan_cb_register(struct bt_le_scan_cb *cb)
89968995{
89978996 sys_slist_append (& scan_cbs , & cb -> node );
89988997}
8998+
8999+ void bt_le_scan_cb_unregister (struct bt_le_scan_cb * cb )
9000+ {
9001+ sys_slist_find_and_remove (& scan_cbs , & cb -> node );
9002+ }
89999003#endif /* CONFIG_BT_OBSERVER */
90009004
90019005#if defined(CONFIG_BT_WHITELIST )
0 commit comments