@@ -156,12 +156,9 @@ static bool prv_find_dsc_by_uuid(ListNode *node, void *data) {
156156 return ble_uuid_cmp (& dsc_node -> descriptor .uuid .u , dsc_uuid ) == 0 ;
157157}
158158
159- static bool prv_find_dsc_uuid (GATTServiceDiscoveryContext * context ,
160- const ble_uuid_t * svc_uuid ,
161- const ble_uuid_t * chr_uuid ,
162- const ble_uuid_t * dsc_uuid ,
163- uint16_t * chr_handle ,
164- uint16_t * dsc_handle ) {
159+ static bool prv_find_dsc_uuid (GATTServiceDiscoveryContext * context , const ble_uuid_t * svc_uuid ,
160+ const ble_uuid_t * chr_uuid , const ble_uuid_t * dsc_uuid ,
161+ uint16_t * chr_handle , uint16_t * dsc_handle ) {
165162 GATTServiceDiscoveryServiceNode * service_node = (GATTServiceDiscoveryServiceNode * )list_find (
166163 context -> services , prv_find_svc_by_uuid , (void * )svc_uuid );
167164 if (service_node == NULL ) {
@@ -195,12 +192,10 @@ typedef struct {
195192static int prv_on_svc_chgd_subscribe (uint16_t conn_handle , const struct ble_gatt_error * error ,
196193 struct ble_gatt_attr * attr , void * arg ) {
197194 if (error -> status != 0 ) {
198- PBL_LOG_ERR ("Failed to subscribe to service changed: 0x%" PRIx16 ,
199- error -> status );
195+ PBL_LOG_ERR ("Failed to subscribe to service changed: 0x%" PRIx16 , error -> status );
200196 } else {
201197 GATTServiceDiscoveryDescriptorContext * ctx = arg ;
202- bt_driver_cb_gatt_client_discovery_handle_service_changed (ctx -> connection ,
203- ctx -> chr_handle );
198+ bt_driver_cb_gatt_client_discovery_handle_service_changed (ctx -> connection , ctx -> chr_handle );
204199
205200 PBL_LOG_DBG ("Subscribed to service changed" );
206201 }
@@ -210,29 +205,30 @@ static int prv_on_svc_chgd_subscribe(uint16_t conn_handle, const struct ble_gatt
210205 return 0 ;
211206}
212207
213- static void prv_convert_service_and_notify_os (uint16_t conn_handle , GATTServiceDiscoveryContext * context ) {
208+ static void prv_convert_service_and_notify_os (uint16_t conn_handle ,
209+ GATTServiceDiscoveryContext * context ) {
214210 list_foreach (context -> services , prv_convert_service_and_notify_os_cb , context -> connection );
215211 bt_driver_cb_gatt_client_discovery_complete (context -> connection , BTErrnoOK );
216212
217213 // Subscribe to service changed indications (BLE Core 6.0, part G 7.7.1)
218214 uint16_t chr_handle , dsc_handle ;
219215 if (prv_find_dsc_uuid (context , BLE_UUID16_DECLARE (BLE_GATT_SVC_UUID16 ),
220216 BLE_UUID16_DECLARE (BLE_SVC_GATT_CHR_SERVICE_CHANGED_UUID16 ),
221- BLE_UUID16_DECLARE (BLE_GATT_DSC_CLT_CFG_UUID16 ),
222- & chr_handle , & dsc_handle )) {
217+ BLE_UUID16_DECLARE (BLE_GATT_DSC_CLT_CFG_UUID16 ), & chr_handle ,
218+ & dsc_handle )) {
223219 uint16_t value ;
224220 int ret ;
225221
226- GATTServiceDiscoveryDescriptorContext * ctx = kernel_zalloc_check (
227- sizeof (GATTServiceDiscoveryDescriptorContext ));
222+ GATTServiceDiscoveryDescriptorContext * ctx =
223+ kernel_zalloc_check ( sizeof (GATTServiceDiscoveryDescriptorContext ));
228224 ctx -> connection = context -> connection ;
229225 ctx -> chr_handle = chr_handle ;
230226
231227 value = 0x0002 ;
232- ret = ble_gattc_write_flat (conn_handle , dsc_handle ,
233- & value , sizeof ( value ), prv_on_svc_chgd_subscribe , ctx );
228+ ret = ble_gattc_write_flat (conn_handle , dsc_handle , & value , sizeof ( value ),
229+ prv_on_svc_chgd_subscribe , ctx );
234230 if (ret != 0 ) {
235- PBL_LOG_ERR ("Failed to subscribe to service changed: %d" , ret );
231+ PBL_LOG_ERR ("Failed to subscribe to service changed: %d" , ret );
236232 }
237233 }
238234
@@ -264,8 +260,8 @@ static void prv_discover_next_dscs(uint16_t conn_handle, GATTServiceDiscoveryCon
264260 uint16_t end_handle = prv_get_last_dsc_handle (context );
265261 int rc = ble_gattc_disc_all_dscs (conn_handle , start_handle , end_handle , prv_find_dsc_cb , context );
266262 if (rc != 0 ) {
267- PBL_LOG_ERR ("ble_gattc_disc_all_dscs rc=0x%04x (0x%04x -> 0x%04x)" ,
268- ( uint16_t ) rc , start_handle , end_handle );
263+ PBL_LOG_ERR ("ble_gattc_disc_all_dscs rc=0x%04x (0x%04x -> 0x%04x)" , ( uint16_t ) rc , start_handle ,
264+ end_handle );
269265 }
270266}
271267
@@ -275,8 +271,8 @@ static void prv_discover_next_chrs(uint16_t conn_handle, GATTServiceDiscoveryCon
275271 int rc = ble_gattc_disc_all_chrs (conn_handle , service_node -> service .start_handle ,
276272 service_node -> service .end_handle , prv_find_chr_cb , context );
277273 if (rc != 0 ) {
278- PBL_LOG_ERR ("ble_gattc_disc_all_chrs rc=0x%04x (0x%04x -> 0x%04x)" ,
279- ( uint16_t ) rc , service_node -> service .start_handle , service_node -> service .end_handle );
274+ PBL_LOG_ERR ("ble_gattc_disc_all_chrs rc=0x%04x (0x%04x -> 0x%04x)" , ( uint16_t ) rc ,
275+ service_node -> service .start_handle , service_node -> service .end_handle );
280276 }
281277}
282278
@@ -339,8 +335,7 @@ static int prv_find_dsc_cb(uint16_t conn_handle, const struct ble_gatt_error *er
339335 case 0 :
340336 char chr_uuid_str [BLE_UUID_STR_LEN ];
341337 ble_uuid_to_str (& dsc -> uuid .u , chr_uuid_str );
342- PBL_LOG_DBG ("Found descriptor %s (hdl: 0x%" PRIx16 ")" ,
343- chr_uuid_str , dsc -> handle );
338+ PBL_LOG_DBG ("Found descriptor %s (hdl: 0x%" PRIx16 ")" , chr_uuid_str , dsc -> handle );
344339
345340 GATTServiceDiscoveryDescriptorNode * dsc_node = prv_create_descriptor_node (dsc );
346341 GATTServiceDiscoveryCharacteristicNode * chr_node = prv_get_current_chr (context );
@@ -384,8 +379,7 @@ static int prv_find_dsc_cb(uint16_t conn_handle, const struct ble_gatt_error *er
384379 break ;
385380
386381 default :
387- PBL_LOG_ERR ("Descriptor discovery error: %d" ,
388- error -> status );
382+ PBL_LOG_ERR ("Descriptor discovery error: %d" , error -> status );
389383 if (error -> status == BLE_HS_ETIMEOUT ) {
390384 errno = BTErrnoServiceDiscoveryTimeout ;
391385 } else if (error -> status == BLE_HS_ENOTCONN ) {
@@ -420,7 +414,7 @@ static int prv_find_chr_cb(uint16_t conn_handle, const struct ble_gatt_error *er
420414 char chr_uuid_str [BLE_UUID_STR_LEN ];
421415 ble_uuid_to_str (& chr -> uuid .u , chr_uuid_str );
422416 PBL_LOG_DBG ("Found characteristic %s (val hdl: 0x%" PRIx16 ", def hdl: 0x%" PRIx16 ")" ,
423- chr_uuid_str , chr -> val_handle , chr -> def_handle );
417+ chr_uuid_str , chr -> val_handle , chr -> def_handle );
424418
425419 GATTServiceDiscoveryCharacteristicNode * chr_node = prv_create_chr_node (chr );
426420 GATTServiceDiscoveryServiceNode * service_node = prv_get_current_service (context );
@@ -456,8 +450,7 @@ static int prv_find_chr_cb(uint16_t conn_handle, const struct ble_gatt_error *er
456450 break ;
457451
458452 default :
459- PBL_LOG_ERR ("Characteristic discovery error: %d" ,
460- error -> status );
453+ PBL_LOG_ERR ("Characteristic discovery error: %d" , error -> status );
461454 if (error -> status == BLE_HS_ETIMEOUT ) {
462455 errno = BTErrnoServiceDiscoveryTimeout ;
463456 } else if (error -> status == BLE_HS_ENOTCONN ) {
@@ -491,17 +484,16 @@ static int prv_find_inc_svc_cb(uint16_t conn_handle, const struct ble_gatt_error
491484 case 0 :
492485 if (service -> start_handle < context -> range .start ||
493486 service -> end_handle > context -> range .end ) {
494- return 0 ; // skip this service
487+ return 0 ; // skip this service
495488 }
496489
497490 GATTServiceDiscoveryServiceNode * service_node = prv_create_service_node (service );
498491 prv_list_append_or_set (& context -> services , & service_node -> node );
499492
500493 char service_uuid_str [BLE_UUID_STR_LEN ];
501494 ble_uuid_to_str (& service -> uuid .u , service_uuid_str );
502- PBL_LOG_DBG ("Found service %s, 0x%" PRIx16 "-0x%" PRIx16 " (total %lu)" ,
503- service_uuid_str , service -> start_handle , service -> end_handle ,
504- list_count (context -> services ));
495+ PBL_LOG_DBG ("Found service %s, 0x%" PRIx16 "-0x%" PRIx16 " (total %lu)" , service_uuid_str ,
496+ service -> start_handle , service -> end_handle , list_count (context -> services ));
505497 break ;
506498
507499 case BLE_HS_EDONE :
@@ -621,4 +613,5 @@ BTErrno bt_driver_gatt_stop_discovery(GAPLEConnection *connection) {
621613 return BTErrnoOK ;
622614}
623615
624- void bt_driver_gatt_handle_discovery_abandoned (void ) {}
616+ void bt_driver_gatt_handle_discovery_abandoned (void ) {
617+ }
0 commit comments