@@ -128,6 +128,7 @@ bool common_hal_bleio_connection_get_connected(bleio_connection_obj_t *self) {
128
128
}
129
129
130
130
void common_hal_bleio_connection_disconnect (bleio_connection_internal_t * self ) {
131
+ // Second argument is an HCI reason, not an HS error code.
131
132
ble_gap_terminate (self -> conn_handle , BLE_ERR_REM_USER_CONN_TERM );
132
133
}
133
134
@@ -162,9 +163,9 @@ STATIC int _discovered_service_cb(uint16_t conn_handle,
162
163
void * arg ) {
163
164
bleio_connection_internal_t * self = (bleio_connection_internal_t * )arg ;
164
165
165
- if (error -> status != BLE_ERR_SUCCESS ) {
166
+ if (error -> status != 0 ) {
166
167
// Keep the first error in case it's due to memory.
167
- if (_last_discovery_status == BLE_ERR_SUCCESS ) {
168
+ if (_last_discovery_status == 0 ) {
168
169
_last_discovery_status = error -> status ;
169
170
xTaskNotifyGive (discovery_task );
170
171
}
@@ -173,7 +174,7 @@ STATIC int _discovered_service_cb(uint16_t conn_handle,
173
174
174
175
// If any of these memory allocations fail, we set _last_discovery_status
175
176
// and let the process continue.
176
- if (_last_discovery_status != BLE_ERR_SUCCESS ) {
177
+ if (_last_discovery_status != 0 ) {
177
178
return 0 ;
178
179
}
179
180
bleio_service_obj_t * service = mp_obj_malloc (bleio_service_obj_t , & bleio_service_type );
@@ -202,16 +203,16 @@ STATIC int _discovered_characteristic_cb(uint16_t conn_handle,
202
203
void * arg ) {
203
204
bleio_service_obj_t * service = (bleio_service_obj_t * )arg ;
204
205
205
- if (error -> status != BLE_ERR_SUCCESS ) {
206
+ if (error -> status != 0 ) {
206
207
// Keep the first error in case it's due to memory.
207
- if (_last_discovery_status == BLE_ERR_SUCCESS ) {
208
+ if (_last_discovery_status == 0 ) {
208
209
_last_discovery_status = error -> status ;
209
210
xTaskNotifyGive (discovery_task );
210
211
}
211
212
}
212
213
// If any of these memory allocations fail, we set _last_discovery_status
213
214
// and let the process continue.
214
- if (_last_discovery_status != BLE_ERR_SUCCESS ) {
215
+ if (_last_discovery_status != 0 ) {
215
216
return 0 ;
216
217
}
217
218
@@ -253,16 +254,16 @@ STATIC int _discovered_descriptor_cb(uint16_t conn_handle,
253
254
void * arg ) {
254
255
bleio_characteristic_obj_t * characteristic = (bleio_characteristic_obj_t * )arg ;
255
256
256
- if (error -> status != BLE_ERR_SUCCESS ) {
257
+ if (error -> status != 0 ) {
257
258
// Keep the first error in case it's due to memory.
258
- if (_last_discovery_status == BLE_ERR_SUCCESS ) {
259
+ if (_last_discovery_status == 0 ) {
259
260
_last_discovery_status = error -> status ;
260
261
}
261
262
xTaskNotifyGive (discovery_task );
262
263
}
263
264
// If any of these memory allocations fail, we set _last_discovery_status
264
265
// and let the process continue.
265
- if (_last_discovery_status != BLE_ERR_SUCCESS ) {
266
+ if (_last_discovery_status != 0 ) {
266
267
return 0 ;
267
268
}
268
269
@@ -306,7 +307,7 @@ STATIC void discover_remote_services(bleio_connection_internal_t *self, mp_obj_t
306
307
307
308
discovery_task = xTaskGetCurrentTaskHandle ();
308
309
if (service_uuids_whitelist == mp_const_none ) {
309
- _last_discovery_status = BLE_ERR_SUCCESS ;
310
+ _last_discovery_status = 0 ;
310
311
CHECK_NIMBLE_ERROR (ble_gattc_disc_all_svcs (self -> conn_handle , _discovered_service_cb , self ));
311
312
312
313
// Wait for sync.
@@ -324,7 +325,7 @@ STATIC void discover_remote_services(bleio_connection_internal_t *self, mp_obj_t
324
325
}
325
326
bleio_uuid_obj_t * uuid = MP_OBJ_TO_PTR (uuid_obj );
326
327
327
- _last_discovery_status = BLE_ERR_SUCCESS ;
328
+ _last_discovery_status = 0 ;
328
329
// Make sure we start with a clean notification state
329
330
ulTaskNotifyValueClear (discovery_task , 0xffffffff );
330
331
CHECK_NIMBLE_ERROR (ble_gattc_disc_svc_by_uuid (self -> conn_handle , & uuid -> nimble_ble_uuid .u ,
@@ -340,7 +341,7 @@ STATIC void discover_remote_services(bleio_connection_internal_t *self, mp_obj_t
340
341
for (size_t i = 0 ; i < self -> remote_service_list -> len ; i ++ ) {
341
342
bleio_service_obj_t * service = MP_OBJ_TO_PTR (self -> remote_service_list -> items [i ]);
342
343
343
- _last_discovery_status = BLE_ERR_SUCCESS ;
344
+ _last_discovery_status = 0 ;
344
345
CHECK_NIMBLE_ERROR (ble_gattc_disc_all_chrs (self -> conn_handle ,
345
346
service -> start_handle ,
346
347
service -> end_handle ,
@@ -375,7 +376,7 @@ STATIC void discover_remote_services(bleio_connection_internal_t *self, mp_obj_t
375
376
continue ;
376
377
}
377
378
378
- _last_discovery_status = BLE_ERR_SUCCESS ;
379
+ _last_discovery_status = 0 ;
379
380
CHECK_NIMBLE_ERROR (ble_gattc_disc_all_dscs (self -> conn_handle , characteristic -> handle ,
380
381
end_handle ,
381
382
_discovered_descriptor_cb , characteristic ));
0 commit comments