move callback from BLEGap back to Bluefruit & BLECentral

This commit is contained in:
hathach committed 2017-07-15 00:38:25 +07:00
1 parent 5c4869f2a0
commit d7fe49b4c3
6 files changed
+35 -70

No files matched your search

-41
View File
@@ -39,8 +39,6 @@
BLEGap::BLEGap(void)
{
varclr(&_prph_cb);
varclr(&_central_cb);
varclr(&_peers);
}
@@ -54,28 +52,6 @@ uint8_t BLEGap::getRole(uint16_t conn_handle)
return _peers[conn_handle].role;
}
void BLEGap::setConnectCallback(connect_callback_t fp, uint8_t role)
{
if (role == BLE_GAP_ROLE_PERIPH)
{
_prph_cb.connect_cb = fp;
}else
{
_central_cb.connect_cb = fp;
}
}
void BLEGap::setDisconnectCallback(disconnect_callback_t fp, uint8_t role)
{
if (role == BLE_GAP_ROLE_PERIPH)
{
_prph_cb.disconnect_cb = fp;
}else
{
_central_cb.disconnect_cb = fp;
}
}
uint8_t BLEGap::getPeerAddr(uint16_t conn_handle, uint8_t addr[6])
{
memcpy(addr, _peers[conn_handle].addr.addr, BLE_GAP_ADDR_LEN);
@@ -124,15 +100,6 @@ void BLEGap::_eventHandler(ble_evt_t* evt)
uint8_t txbuf_max;
(void) sd_ble_tx_packet_count_get(conn_handle, &txbuf_max);
peer->txpacket_sem = xSemaphoreCreateCounting(txbuf_max, txbuf_max);
// Invoke callback according to the role
if ( peer->role == BLE_GAP_ROLE_PERIPH)
{
if (_prph_cb.connect_cb) ada_callback(NULL, _prph_cb.connect_cb, conn_handle);
}else
{
if (_central_cb.connect_cb) ada_callback(NULL, _central_cb.connect_cb, conn_handle);
}
}
break;
@@ -145,14 +112,6 @@ void BLEGap::_eventHandler(ble_evt_t* evt)
vSemaphoreDelete( peer->txpacket_sem );
peer->txpacket_sem = NULL;
if ( peer->role == BLE_GAP_ROLE_PERIPH)
{
if (_prph_cb.disconnect_cb) ada_callback(NULL, _prph_cb.disconnect_cb, conn_handle, para->reason);
}else
{
if (_central_cb.disconnect_cb) ada_callback(NULL, _central_cb.disconnect_cb, conn_handle, para->reason);
}
}
break;