diff --git a/libraries/Bluefruit52Lib/src/BLEDiscovery.cpp b/libraries/Bluefruit52Lib/src/BLEDiscovery.cpp index 399ac288..15a5f2bf 100644 --- a/libraries/Bluefruit52Lib/src/BLEDiscovery.cpp +++ b/libraries/Bluefruit52Lib/src/BLEDiscovery.cpp @@ -43,22 +43,22 @@ BLEDiscovery::BLEDiscovery(void) _hdl_range.start_handle = 1; _hdl_range.end_handle = 0xffff; - _evt_sem = NULL; + _sem = NULL; _evt_buf = NULL; _evt_bufsize = 0; } void BLEDiscovery::begin(void) { - if (_evt_sem == NULL) + if (_sem == NULL) { - _evt_sem = xSemaphoreCreateBinary(); + _sem = xSemaphoreCreateBinary(); } } bool BLEDiscovery::begun(void) { - return (_evt_sem != NULL); + return (_sem != NULL); } bool BLEDiscovery::_discoverService(uint16_t conn_handle, BLECentralService& svc, uint16_t start_handle) @@ -71,7 +71,7 @@ bool BLEDiscovery::_discoverService(uint16_t conn_handle, BLECentralService& svc VERIFY_STATUS( sd_ble_gattc_primary_services_discover(conn_handle, start_handle, &svc.uuid._uuid), false ); // wait for discovery event: timeout or has no data - if ( !xSemaphoreTake(_evt_sem, BLE_CENTRAL_TIMEOUT) || (_evt_bufsize == 0) ) return false; + if ( !xSemaphoreTake(_sem, BLE_CENTRAL_TIMEOUT) || (_evt_bufsize == 0) ) return false; // Check the discovered UUID with input one if ( (disc_svc.count == 1) && (svc.uuid == disc_svc.services[0].uuid) ) @@ -103,7 +103,7 @@ uint8_t BLEDiscovery::discoverCharacteristic(uint16_t conn_handle, BLECentralCha // wait for discovery event: timeout or has no data // Assume only 1 characteristic discovered each - if ( !xSemaphoreTake(_evt_sem, BLE_CENTRAL_TIMEOUT) || (_evt_bufsize == 0) || (disc_chr.count == 0) ) break; + if ( !xSemaphoreTake(_sem, BLE_CENTRAL_TIMEOUT) || (_evt_bufsize == 0) || (disc_chr.count == 0) ) break; // increase handle range for next discovery _hdl_range.start_handle = disc_chr.chars[0].handle_value + 1; @@ -142,7 +142,7 @@ uint16_t BLEDiscovery::_discoverDescriptor(uint16_t conn_handle, ble_gattc_evt_d VERIFY_STATUS( sd_ble_gattc_descriptors_discover(conn_handle, &_hdl_range), 0 ); // wait for discovery event: timeout or has no data - if ( !xSemaphoreTake(_evt_sem, BLE_CENTRAL_TIMEOUT) || (_evt_bufsize == 0) ) return 0; + if ( !xSemaphoreTake(_sem, BLE_CENTRAL_TIMEOUT) || (_evt_bufsize == 0) ) return 0; result = min16(disc_desc->count, max_count); if (result) @@ -184,7 +184,7 @@ void BLEDiscovery::_event_handler(ble_evt_t* evt) _evt_bufsize = 0; // no data } - xSemaphoreGive(_evt_sem); + xSemaphoreGive(_sem); } break; @@ -205,7 +205,7 @@ void BLEDiscovery::_event_handler(ble_evt_t* evt) _evt_bufsize = 0; // no data } - xSemaphoreGive(_evt_sem); + xSemaphoreGive(_sem); } break; @@ -228,7 +228,7 @@ void BLEDiscovery::_event_handler(ble_evt_t* evt) _evt_bufsize = 0; // no data } - xSemaphoreGive(_evt_sem); + xSemaphoreGive(_sem); } break; diff --git a/libraries/Bluefruit52Lib/src/BLEDiscovery.h b/libraries/Bluefruit52Lib/src/BLEDiscovery.h index 2433a84d..d86824c0 100644 --- a/libraries/Bluefruit52Lib/src/BLEDiscovery.h +++ b/libraries/Bluefruit52Lib/src/BLEDiscovery.h @@ -50,7 +50,7 @@ class BLEDiscovery void* _evt_buf; uint16_t _evt_bufsize; - SemaphoreHandle_t _evt_sem; + SemaphoreHandle_t _sem; void _event_handler(ble_evt_t* evt);