read peer Gap Device Name
This commit is contained in:
hathach committed 2017-07-08 00:29:38 +07:00
1 parent 6053993a7b
commit 226c99ab0c
4 files changed
+26 -11

No files matched your search

+10
View File
@@ -53,6 +53,16 @@ bool BLEGap::getTxPacket(uint16_t conn_handle)
return xSemaphoreTake(_txpacket_sem[conn_handle], ms2tick(BLE_GENERIC_TIMEOUT));
}
uint16_t BLEGap::getPeerDevName(char* buf, uint16_t bufsize)
{
return getPeerDevName(Bluefruit.connHandle(), buf, bufsize);
}
uint16_t BLEGap::getPeerDevName(uint16_t conn_handle, char* buf, uint16_t bufsize)
{
return Bluefruit.Gatt.readCharByUuid(conn_handle, BLEUuid(BLE_UUID_GAP_CHARACTERISTIC_DEVICE_NAME), buf, bufsize);
}
void BLEGap::_eventHandler(ble_evt_t* evt)
{
// conn handle has fixed offset regardless of event type
+3
View File
@@ -50,6 +50,9 @@ class BLEGap
bool getTxPacket(void);
bool getTxPacket(uint16_t conn_handle);
uint16_t getPeerDevName(char* buf, uint16_t bufsize);
uint16_t getPeerDevName(uint16_t conn_handle, char* buf, uint16_t bufsize);
/*------------------------------------------------------------------*/
/* INTERNAL USAGE ONLY
* Although declare as public, it is meant to be invoked by internal
+12 -10
View File
@@ -38,7 +38,7 @@
BLEGatt::BLEGatt(void)
//: _adamsg()
: _adamsg()
{
varclr(&_server);
varclr(&_client);
@@ -46,17 +46,20 @@ BLEGatt::BLEGatt(void)
uint16_t BLEGatt::readCharByUuid(uint16_t conn_hdl, BLEUuid bleuuid, void* buffer, uint16_t bufsize, uint16_t start_hdl, uint16_t end_hdl)
{
#if 0
int32_t count = 0;
ble_gattc_handle_range_t hdl_range = { .start_handle = start_hdl, .end_handle = end_hdl };
_adamsg.begin(true);
_adamsg.prepare(buffer, bufsize);
VERIFY_STATUS( sd_ble_gattc_char_value_by_uuid_read(conn_hdl, &bleuuid._uuid, &hdl_range), 0);
int32_t count = _adamsg.waitUntilComplete(BLE_GENERIC_TIMEOUT);
if( NRF_SUCCESS == sd_ble_gattc_char_value_by_uuid_read(conn_hdl, &bleuuid._uuid, &hdl_range) )
{
count = _adamsg.waitUntilComplete(BLE_GENERIC_TIMEOUT);
}
_adamsg.stop();
return (count < 0) ? 0 : count;
#endif
return 0;
}
void BLEGatt::_eventHandler(ble_evt_t* evt)
@@ -94,7 +97,6 @@ void BLEGatt::_eventHandler(ble_evt_t* evt)
for(int i=0; i<_client.svc_count; i++) _client.svc_list[i]->disconnect();
}
#if 0
// GATTC Read Characteristic by UUID procedure
if ( evt->header.evt_id == BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP )
{
@@ -104,10 +106,10 @@ void BLEGatt::_eventHandler(ble_evt_t* evt)
PRINT_INT(rd_rsp->value_len);
if (rd_rsp->count)
{
_adamsg.feed(rd_rsp->handle_value[0].p_value, rd_rsp->value_len)
_adamsg.feed(rd_rsp->handle_value[0].p_value, rd_rsp->value_len);
_adamsg.complete();
}
}
#endif
}
/*------------------------------------------------------------------*/
+1 -1
View File
@@ -89,7 +89,7 @@ class BLEGatt
BLEClientCharacteristic* chr_list[BLE_GATT_MAX_CLIENT_CHARS];
}_client;
// AdaMsg _adamsg;
AdaMsg _adamsg;
};
#endif /* BLEGATT_H_ */