11#include "gap.h"
22
33uint16_t conn_handle = 0 ;
4- bool notify_state = false;
4+ bool notify_state_report_data = false;
5+ bool notify_state_battery_status = false;
56
67/*
78 * Enables advertising with parameters:
@@ -119,6 +120,9 @@ int bleGAPEevent(struct ble_gap_event *event, void *arg) {
119120 //517 = Authentication Failure
120121 //573 = Connection Terminated due to MIC Failure
121122
123+ notify_state_report_data = false;
124+ notify_state_battery_status = false;
125+
122126 /* Connection terminated; resume advertising */
123127 bleAdvertise ();
124128 break ;
@@ -144,10 +148,14 @@ int bleGAPEevent(struct ble_gap_event *event, void *arg) {
144148 }
145149
146150 if (event -> subscribe .attr_handle == report_data_handle ) {
147- notify_state = event -> subscribe .cur_notify ;
148- } else if (event -> subscribe .attr_handle != report_data_handle ) {
149- notify_state = event -> subscribe .cur_notify ;
151+ //check if the device subscribed to the report data notifies
152+ notify_state_report_data = event -> subscribe .cur_notify ;
153+ } else if (event -> subscribe .attr_handle == battery_status_handle ) {
154+ //check if the device subscribed to the battery status notifies
155+ notify_state_battery_status = event -> subscribe .cur_notify ;
150156 }
157+
158+
151159 ESP_LOGI (tag_GAP , "conn_handle from subscribe=%d" , conn_handle );
152160 break ;
153161
@@ -226,7 +234,6 @@ int bleGAPEevent(struct ble_gap_event *event, void *arg) {
226234 case BLE_GAP_EVENT_NOTIFY_TX :
227235 //Represents a transmitted ATT notification or indication, or a
228236 //completed indication transaction.
229- ESP_LOGI (tag_GAP , "notify tx event occured" );
230237 return 0 ;
231238 default :
232239 ESP_LOGI (tag_GAP , "GAP EVENT ID: %d\n" ,event -> type );
0 commit comments