update connected() for bluefruit and BLEPeriph
This commit is contained in:
4 files changed
+23
-5
No files matched your search
@@ -59,6 +59,23 @@ bool BLEPeriph::begin(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BLEPeriph::connected (uint16_t conn_hdl)
|
||||
{
|
||||
BLEConnection* conn = Bluefruit.Gap.Connection(conn_hdl);
|
||||
return conn && conn->connected() && (conn->getRole() == BLE_GAP_ROLE_PERIPH);
|
||||
}
|
||||
|
||||
uint8_t BLEPeriph::connected (void)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
for (uint16_t c=0; c<BLE_MAX_CONNECTION; c++)
|
||||
{
|
||||
if ( this->connected(c) ) count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
void BLEPeriph::printInfo(void)
|
||||
{
|
||||
char const * title_fmt = "%-16s: ";
|
||||
|
||||
@@ -49,6 +49,9 @@ class BLEPeriph
|
||||
|
||||
bool begin(void);
|
||||
|
||||
bool connected(uint16_t conn_hdl); // Connected as prph to this connection
|
||||
uint8_t connected(void); // Number of connected central
|
||||
|
||||
bool setConnInterval (uint16_t min, uint16_t max);
|
||||
bool setConnIntervalMS (uint16_t min_ms, uint16_t max_ms);
|
||||
bool setConnSupervisionTimeout(uint16_t timeout);
|
||||
|
||||
@@ -527,13 +527,11 @@ uint16_t AdafruitBluefruit::getApperance(void)
|
||||
/*------------------------------------------------------------------*/
|
||||
/* GAP, Connections and Bonding
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
uint8_t AdafruitBluefruit::connected(void)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
for (uint16_t c=0; c<BLE_MAX_CONNECTION; c++)
|
||||
{
|
||||
// skip Peripheral Role handle
|
||||
if ( this->connected(c) ) count++;
|
||||
}
|
||||
|
||||
@@ -543,7 +541,7 @@ uint8_t AdafruitBluefruit::connected(void)
|
||||
bool AdafruitBluefruit::connected(uint16_t conn_hdl)
|
||||
{
|
||||
BLEConnection* conn = Gap.Connection(conn_hdl);
|
||||
return conn && conn->connected() && (conn->getRole() == BLE_GAP_ROLE_PERIPH);
|
||||
return conn && conn->connected();
|
||||
}
|
||||
|
||||
bool AdafruitBluefruit::disconnect(uint16_t conn_hdl)
|
||||
|
||||
@@ -149,9 +149,9 @@ class AdafruitBluefruit
|
||||
/*------------------------------------------------------------------*/
|
||||
/* GAP, Connections and Bonding
|
||||
*------------------------------------------------------------------*/
|
||||
uint8_t connected (void); // Number of connected central
|
||||
uint8_t connected (void); // Number of connected
|
||||
|
||||
bool connected (uint16_t conn_hdl); // connected to a specific central
|
||||
bool connected (uint16_t conn_hdl);
|
||||
bool disconnect (uint16_t conn_hdl);
|
||||
ble_gap_addr_t getPeerAddr (uint16_t conn_hdl);
|
||||
|
||||
|
||||
Reference in new issue
Block a user