diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/bleuart/bleuart.ino b/libraries/Bluefruit52Lib/examples/Peripheral/bleuart/bleuart.ino index 9bf7f277..2dcefa3b 100644 --- a/libraries/Bluefruit52Lib/examples/Peripheral/bleuart/bleuart.ino +++ b/libraries/Bluefruit52Lib/examples/Peripheral/bleuart/bleuart.ino @@ -28,7 +28,7 @@ void setup() // Initialize blinkTimer for 1000 ms and start it blinkTimer.begin(1000, blink_timer_callback); - //blinkTimer.start(); + blinkTimer.start(); // Setup the BLE LED to be enabled on CONNECT // Note: This is actually the default behaviour, but provided @@ -102,7 +102,11 @@ void loop() void connect_callback(void) { - Serial.println("Connected"); + char central_name[32] = { 0 }; + Bluefruit.Gap.getPeerDevName(central_name, sizeof(central_name)); + + Serial.print("Connected to "); + Serial.println(central_name); } void disconnect_callback(uint8_t reason) diff --git a/libraries/Bluefruit52Lib/src/BLEGatt.cpp b/libraries/Bluefruit52Lib/src/BLEGatt.cpp index a2a57032..c8a4c474 100644 --- a/libraries/Bluefruit52Lib/src/BLEGatt.cpp +++ b/libraries/Bluefruit52Lib/src/BLEGatt.cpp @@ -52,13 +52,19 @@ uint16_t BLEGatt::readCharByUuid(uint16_t conn_hdl, BLEUuid bleuuid, void* buffe _adamsg.begin(true); _adamsg.prepare(buffer, bufsize); - if( NRF_SUCCESS == sd_ble_gattc_char_value_by_uuid_read(conn_hdl, &bleuuid._uuid, &hdl_range) ) - { - count = _adamsg.waitUntilComplete(BLE_GENERIC_TIMEOUT); - } + err_t err = sd_ble_gattc_char_value_by_uuid_read(conn_hdl, &bleuuid._uuid, &hdl_range); + if( NRF_SUCCESS == err ) + { + // Read by uuid could take long if the uuid handle is far from start handle + count = _adamsg.waitUntilComplete(5*BLE_GENERIC_TIMEOUT); + }else + { + VERIFY_MESS(err); + } _adamsg.stop(); + return (count < 0) ? 0 : count; } @@ -102,8 +108,6 @@ void BLEGatt::_eventHandler(ble_evt_t* evt) { ble_gattc_evt_char_val_by_uuid_read_rsp_t* rd_rsp = &evt->evt.gattc_evt.params.char_val_by_uuid_read_rsp; - PRINT_INT(rd_rsp->count); - PRINT_INT(rd_rsp->value_len); if (rd_rsp->count) { _adamsg.feed(rd_rsp->handle_value[0].p_value, rd_rsp->value_len);