BLEGap getPeerAddr()
This commit is contained in:
4 files changed
+29
-32
No files matched your search
@@ -168,7 +168,7 @@ bool BLEGap::requestPairing(uint16_t conn_hdl)
|
||||
// Check to see if we did bonded with current prph previously
|
||||
bond_keys_t bkeys;
|
||||
|
||||
if ( bond_find_cntr(&conn->addr, &bkeys) )
|
||||
if ( bond_find_cntr(&conn->_addr, &bkeys) )
|
||||
{
|
||||
cntr_ediv = bkeys.peer_enc.master_id.ediv;
|
||||
LOG_LV2("BOND", "Load Keys from file " BOND_FNAME_CNTR, cntr_ediv);
|
||||
@@ -212,26 +212,6 @@ uint8_t BLEGap::getRole(uint16_t conn_hdl)
|
||||
return _peers[conn_hdl].role;
|
||||
}
|
||||
|
||||
uint8_t BLEGap::getPeerAddr(uint16_t conn_hdl, uint8_t addr[6])
|
||||
{
|
||||
BLEGapConnection* conn = _connection[conn_hdl];
|
||||
if (conn)
|
||||
{
|
||||
memcpy(addr, conn->addr.addr, BLE_GAP_ADDR_LEN);
|
||||
return conn->addr.addr_type;
|
||||
}else
|
||||
{
|
||||
memclr(addr, BLE_GAP_ADDR_LEN);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
ble_gap_addr_t BLEGap::getPeerAddr(uint16_t conn_hdl)
|
||||
{
|
||||
BLEGapConnection* conn = _connection[conn_hdl];
|
||||
return conn ? conn->addr : ((ble_gap_addr_t) {0});
|
||||
}
|
||||
|
||||
uint16_t BLEGap::getPeerName(uint16_t conn_hdl, char* buf, uint16_t bufsize)
|
||||
{
|
||||
return Bluefruit.Gatt.readCharByUuid(conn_hdl, BLEUuid(BLE_UUID_GAP_CHARACTERISTIC_DEVICE_NAME), buf, bufsize);
|
||||
@@ -239,7 +219,6 @@ uint16_t BLEGap::getPeerName(uint16_t conn_hdl, char* buf, uint16_t bufsize)
|
||||
|
||||
/**
|
||||
* Event handler
|
||||
* @param evt
|
||||
*/
|
||||
void BLEGap::_eventHandler(ble_evt_t* evt)
|
||||
{
|
||||
@@ -271,7 +250,7 @@ void BLEGap::_eventHandler(ble_evt_t* evt)
|
||||
|
||||
varclr(conn);
|
||||
|
||||
conn->addr = para->peer_addr;
|
||||
conn->_addr = para->peer_addr;
|
||||
conn->att_mtu = BLE_GATT_ATT_MTU_DEFAULT;
|
||||
conn->role = para->role;
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class BLEGapConnection
|
||||
uint16_t _conn_hdl;
|
||||
|
||||
public:
|
||||
ble_gap_addr_t addr;
|
||||
ble_gap_addr_t _addr;
|
||||
uint16_t att_mtu;
|
||||
bool paired;
|
||||
uint8_t role;
|
||||
@@ -82,6 +82,17 @@ class BLEGapConnection
|
||||
return att_mtu;
|
||||
}
|
||||
|
||||
ble_gap_addr_t getPeerAddr(void)
|
||||
{
|
||||
return _addr;
|
||||
}
|
||||
|
||||
uint8_t getPeerAddr(uint8_t addr[6])
|
||||
{
|
||||
memcpy(addr, _addr.addr, BLE_GAP_ADDR_LEN);
|
||||
return _addr.addr_type;
|
||||
}
|
||||
|
||||
bool getHvnPacket (void)
|
||||
{
|
||||
VERIFY(hvn_tx_sem != NULL);
|
||||
@@ -118,9 +129,7 @@ class BLEGap
|
||||
|
||||
uint8_t getRole (uint16_t conn_hdl);
|
||||
|
||||
uint8_t getPeerAddr (uint16_t conn_hdl, uint8_t addr[6]);
|
||||
ble_gap_addr_t getPeerAddr (uint16_t conn_hdl);
|
||||
uint16_t getPeerName (uint16_t conn_hdl, char* buf, uint16_t bufsize);
|
||||
uint16_t getPeerName (uint16_t conn_hdl, char* buf, uint16_t bufsize);
|
||||
|
||||
uint16_t getMaxMtuByConnCfg (uint8_t conn_cfg);
|
||||
|
||||
@@ -150,8 +159,6 @@ class BLEGap
|
||||
uint8_t role;
|
||||
} gap_peer_t;
|
||||
|
||||
|
||||
|
||||
private:
|
||||
struct {
|
||||
// Bandwidth configuration
|
||||
|
||||
@@ -613,12 +613,21 @@ uint16_t AdafruitBluefruit::connInterval(void)
|
||||
|
||||
ble_gap_addr_t AdafruitBluefruit::getPeerAddr(void)
|
||||
{
|
||||
return Gap.getPeerAddr(_conn_hdl);
|
||||
BLEGapConnection* conn = Gap.getConnection(_conn_hdl);
|
||||
return conn ? conn->getPeerAddr() : ((ble_gap_addr_t) {0});
|
||||
}
|
||||
|
||||
uint8_t AdafruitBluefruit::getPeerAddr(uint8_t addr[6])
|
||||
{
|
||||
return Gap.getPeerAddr(_conn_hdl, addr);
|
||||
BLEGapConnection* conn = Gap.getConnection(_conn_hdl);
|
||||
if ( conn )
|
||||
{
|
||||
return conn->getPeerAddr(addr);
|
||||
}else
|
||||
{
|
||||
memclr(addr, BLE_GAP_ADDR_LEN);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
COMMENT_OUT (
|
||||
|
||||
@@ -94,6 +94,8 @@ static void bledfu_control_wr_authorize_cb(BLECharacteristic& chr, ble_gatts_evt
|
||||
{
|
||||
uint16_t conn_hdl = Bluefruit.connHandle();
|
||||
|
||||
BLEGapConnection* conn = Bluefruit.Gap.getConnection(conn_hdl);
|
||||
|
||||
ble_gatts_rw_authorize_reply_params_t reply = { .type = BLE_GATTS_AUTHORIZE_TYPE_WRITE };
|
||||
|
||||
if ( !chr.notifyEnabled() )
|
||||
@@ -135,7 +137,7 @@ static void bledfu_control_wr_authorize_cb(BLECharacteristic& chr, ble_gatts_evt
|
||||
sd_ble_gatts_sys_attr_get(conn_hdl, peer_data->sys_attr, &sysattr_len, BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS);
|
||||
|
||||
// Get Bond Data or using Address if not bonded
|
||||
peer_data->addr = Bluefruit.Gap.getPeerAddr(conn_hdl);
|
||||
peer_data->addr = conn->getPeerAddr();
|
||||
|
||||
if ( Bluefruit.Gap.paired(conn_hdl) )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user