complete get peer name

This commit is contained in:
hathach committed 2017-07-10 12:47:10 +07:00
1 parent 226c99ab0c
commit 5bd0b4dd87
2 files changed
+16 -8

No files matched your search

@@ -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)
+10 -6
View File
@@ -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);