@@ -567,22 +567,29 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
567
567
ESP_LOGI (GATTC_TAG , "eq3 got response 0x%x, 0x%x\n" , p_data -> notify .value [0 ], p_data -> notify .value [1 ]);
568
568
}
569
569
570
- /* Notify the successful command */
571
- command_complete (true);
572
- /* 2 second delay until disconnect to allow any background GATTC stuff to complete */
573
- setnextcmd (EQ3_DISCONNECT , 2 );
574
- runtimer ();
570
+ if (ESP_OK != esp_ble_gattc_unregister_for_notify (gattc_if , gl_profile_tab [PROFILE_A_APP_ID ].remote_bda , gl_profile_tab [PROFILE_A_APP_ID ].resp_char_handle )){
571
+ ESP_LOGI (GATTC_TAG , "eq3 failed to unreg for notify\n" );
572
+ /* Notify the successful command */
573
+ command_complete (true);
574
+ /* 2 second delay until disconnect to allow any background GATTC stuff to complete */
575
+ setnextcmd (EQ3_DISCONNECT , 2 );
576
+ runtimer ();
577
+ }
575
578
576
579
break ;
577
580
case ESP_GATTC_UNREG_FOR_NOTIFY_EVT : {
578
- /* Oops - this won't happen
579
- * forgot to call unregister-for-notify before disconnecting - may need to revisit if it causes problems */
581
+ /* We should now be unregistered for notification */
580
582
if (p_data -> unreg_for_notify .status != ESP_GATT_OK ){
581
583
ESP_LOGE (GATTC_TAG , "UNREG FOR NOTIFY failed: error status = %d" , p_data -> unreg_for_notify .status );
582
- break ;
584
+ //break;
585
+ /* Continue to disconnect */
583
586
}
584
-
585
- esp_ble_gattc_close (gl_profile_tab [PROFILE_A_APP_ID ].gattc_if , gl_profile_tab [PROFILE_A_APP_ID ].conn_id );
587
+ ESP_LOGI (GATTC_TAG , "eq3 unregistered for notification\n" );
588
+ /* Notify the successful command */
589
+ command_complete (true);
590
+ /* 2 second delay until disconnect to allow any background GATTC stuff to complete */
591
+ setnextcmd (EQ3_DISCONNECT , 2 );
592
+ runtimer ();
586
593
587
594
break ;
588
595
}
0 commit comments