Skip to content

Commit

Permalink
Unregister for notification after sending command to EQ-3
Browse files Browse the repository at this point in the history
  • Loading branch information
softypit committed Jan 16, 2022
1 parent 51df6b4 commit b4f6140
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
27 changes: 17 additions & 10 deletions main/eq3_main.c
Expand Up @@ -567,22 +567,29 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
ESP_LOGI(GATTC_TAG, "eq3 got response 0x%x, 0x%x\n", p_data->notify.value[0], p_data->notify.value[1]);
}

/* Notify the successful command */
command_complete(true);
/* 2 second delay until disconnect to allow any background GATTC stuff to complete */
setnextcmd(EQ3_DISCONNECT, 2);
runtimer();
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)){
ESP_LOGI(GATTC_TAG, "eq3 failed to unreg for notify\n");
/* Notify the successful command */
command_complete(true);
/* 2 second delay until disconnect to allow any background GATTC stuff to complete */
setnextcmd(EQ3_DISCONNECT, 2);
runtimer();
}

break;
case ESP_GATTC_UNREG_FOR_NOTIFY_EVT: {
/* Oops - this won't happen
* forgot to call unregister-for-notify before disconnecting - may need to revisit if it causes problems */
/* We should now be unregistered for notification */
if (p_data->unreg_for_notify.status != ESP_GATT_OK){
ESP_LOGE(GATTC_TAG, "UNREG FOR NOTIFY failed: error status = %d", p_data->unreg_for_notify.status);
break;
//break;
/* Continue to disconnect */
}

esp_ble_gattc_close (gl_profile_tab[PROFILE_A_APP_ID].gattc_if, gl_profile_tab[PROFILE_A_APP_ID].conn_id);
ESP_LOGI(GATTC_TAG, "eq3 unregistered for notification\n");
/* Notify the successful command */
command_complete(true);
/* 2 second delay until disconnect to allow any background GATTC stuff to complete */
setnextcmd(EQ3_DISCONNECT, 2);
runtimer();

break;
}
Expand Down
2 changes: 1 addition & 1 deletion main/eq3_main.h
Expand Up @@ -2,7 +2,7 @@
#define EQ3_MAIN_H

#define EQ3_MAJVER "1"
#define EQ3_MINVER "63"
#define EQ3_MINVER "64"
#define EQ3_EXTRAVER "-beta"

void eq3_log_init(void);
Expand Down

0 comments on commit b4f6140

Please sign in to comment.