Skip to content

Commit b4f6140

Browse files
committed
Unregister for notification after sending command to EQ-3
1 parent 51df6b4 commit b4f6140

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

main/eq3_main.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -567,22 +567,29 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
567567
ESP_LOGI(GATTC_TAG, "eq3 got response 0x%x, 0x%x\n", p_data->notify.value[0], p_data->notify.value[1]);
568568
}
569569

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+
}
575578

576579
break;
577580
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 */
580582
if (p_data->unreg_for_notify.status != ESP_GATT_OK){
581583
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 */
583586
}
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();
586593

587594
break;
588595
}

main/eq3_main.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define EQ3_MAIN_H
33

44
#define EQ3_MAJVER "1"
5-
#define EQ3_MINVER "63"
5+
#define EQ3_MINVER "64"
66
#define EQ3_EXTRAVER "-beta"
77

88
void eq3_log_init(void);

0 commit comments

Comments
 (0)