add ClientCharacteristic disconnect()

This commit is contained in:
hathach committed 2017-07-18 21:00:58 +07:00
1 parent 32767269c1
commit f56c0dc458
4 files changed
+19 -3

No files matched your search

@@ -42,7 +42,8 @@
void BLEClientCharacteristic::_init(void)
{
varclr(&_chr);
_cccd_handle = 0;
_chr.handle_value = BLE_GATT_HANDLE_INVALID;
_cccd_handle = BLE_GATT_HANDLE_INVALID;
_notify_cb = NULL;
_use_AdaCallback = true;
@@ -88,6 +89,11 @@ void BLEClientCharacteristic::assign(ble_gattc_char_t* gattc_chr)
_chr = *gattc_chr;
}
void BLEClientCharacteristic::disconnect(void)
{
_chr.handle_value = BLE_GATT_HANDLE_INVALID;
}
void BLEClientCharacteristic::useAdaCallback(bool enabled)
{
_use_AdaCallback = enabled;
@@ -101,6 +101,8 @@ class BLEClientCharacteristic
void _init (void);
void _eventHandler (ble_evt_t* event);
void disconnect(void);
friend class BLEGatt;
};
+9 -1
View File
@@ -103,7 +103,7 @@ void BLEGatt::_eventHandler(ble_evt_t* evt)
}
}
// disconnect Client Service of the disconnected handle
// disconnect Client Services & Characteristics of the disconnected handle
if ( evt->header.evt_id == BLE_GAP_EVT_DISCONNECTED )
{
for(int i=0; i<_client.svc_count; i++)
@@ -113,6 +113,14 @@ void BLEGatt::_eventHandler(ble_evt_t* evt)
_client.svc_list[i]->disconnect();
}
}
for(int i=0; i<_client.chr_count; i++)
{
if ( evt_conn_hdl == _client.chr_list[i]->_conn_hdl )
{
_client.chr_list[i]->disconnect();
}
}
}
// GATTC Read Characteristic by UUID procedure
@@ -76,7 +76,7 @@ void BLEClientUart::setRxCallback( rx_callback_t fp)
bool BLEClientUart::discover(uint16_t conn_handle)
{
// Call BLECentralService discover
// Call Base class discover
VERIFY( BLEClientService::discover(conn_handle) );
_conn_hdl = BLE_CONN_HANDLE_INVALID; // make as invalid until we found all chars