This commit is contained in:
hathach committed 2017-04-08 18:02:34 +07:00
1 parent 249a355584
commit 6c4ae55c03
4 files changed
+6 -12

No files matched your search

@@ -41,7 +41,6 @@ BLECentralService* BLECentralService::lastService = NULL;
void BLECentralService::_init(void)
{
_discovered = false;
_conn_hdl = BLE_CONN_HANDLE_INVALID;
}
@@ -71,15 +70,14 @@ bool BLECentralService::begin(void)
bool BLECentralService::discover(uint16_t conn_handle)
{
_conn_hdl = conn_handle;
VERIFY( Bluefruit.Discovery._discoverService(conn_handle, *this) );
_discovered = true;
_conn_hdl = conn_handle;
return true;
}
bool BLECentralService::discovered(void)
{
return _discovered;
return _conn_hdl != BLE_CONN_HANDLE_INVALID;
}
uint16_t BLECentralService::connHandle(void)
@@ -89,7 +87,6 @@ uint16_t BLECentralService::connHandle(void)
void BLECentralService::disconnect(void)
{
_discovered = false;
_conn_hdl = BLE_CONN_HANDLE_INVALID;
// inherited service may want to clean up its own characteristic
}
@@ -42,7 +42,6 @@
class BLECentralService
{
protected:
bool _discovered;
uint16_t _conn_hdl;
void _init(void);
@@ -78,14 +78,13 @@ bool BLECentralUart::discover(uint16_t conn_handle)
{
// Call BLECentralService discover
VERIFY( BLECentralService::discover(conn_handle) );
_discovered = false;
_conn_hdl = BLE_CONN_HANDLE_INVALID; // make as invalid until we found all chars
// Discover TXD, RXD characteristics
BLECentralCharacteristic* chr_arr[] = { &_rxd, &_txd };
VERIFY( 2 == Bluefruit.Discovery.discoverCharacteristic(conn_handle, chr_arr, 2) );
_discovered = true;
_conn_hdl = conn_handle;
return true;
}
@@ -110,15 +110,14 @@ bool BLEAncs::discover(uint16_t conn_handle)
{
// Call BLECentralService discover
VERIFY( BLECentralService::discover(conn_handle) );
_discovered = false;
_conn_hdl = BLE_CONN_HANDLE_INVALID; // make as invalid until we found all chars
// Discover characteristics
BLECentralCharacteristic* chr_arr[] = { &_control, &_notification, &_data };
VERIFY( 3 == Bluefruit.Discovery.discoverCharacteristic(conn_handle, chr_arr, 3) );
_discovered = true;
_conn_hdl = conn_handle;
return true;
}