mirror of https://github.com/ARMmbed/mbed-os.git
Added get/set method for GAP connection handle
parent
fff7a0fe60
commit
348e2de6c8
|
@ -94,13 +94,13 @@ static void btle_handler(ble_evt_t * p_ble_evt)
|
||||||
switch (p_ble_evt->header.evt_id)
|
switch (p_ble_evt->header.evt_id)
|
||||||
{
|
{
|
||||||
case BLE_GAP_EVT_CONNECTED:
|
case BLE_GAP_EVT_CONNECTED:
|
||||||
nRF51Gap::getInstance().m_connectionHandle = p_ble_evt->evt.gap_evt.conn_handle;
|
nRF51Gap::getInstance().setConnectionHandle( p_ble_evt->evt.gap_evt.conn_handle );
|
||||||
nRF51Gap::getInstance().handleEvent(GapEvents::GAP_EVENT_CONNECTED);
|
nRF51Gap::getInstance().handleEvent(GapEvents::GAP_EVENT_CONNECTED);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BLE_GAP_EVT_DISCONNECTED:
|
case BLE_GAP_EVT_DISCONNECTED:
|
||||||
// Since we are not in a connection and have not started advertising, store bonds
|
// Since we are not in a connection and have not started advertising, store bonds
|
||||||
nRF51Gap::getInstance().m_connectionHandle = BLE_CONN_HANDLE_INVALID;
|
nRF51Gap::getInstance().setConnectionHandle (BLE_CONN_HANDLE_INVALID);
|
||||||
ASSERT_STATUS_RET_VOID ( ble_bondmngr_bonded_centrals_store() );
|
ASSERT_STATUS_RET_VOID ( ble_bondmngr_bonded_centrals_store() );
|
||||||
nRF51Gap::getInstance().handleEvent(GapEvents::GAP_EVENT_DISCONNECTED);
|
nRF51Gap::getInstance().handleEvent(GapEvents::GAP_EVENT_DISCONNECTED);
|
||||||
break;
|
break;
|
||||||
|
@ -117,7 +117,7 @@ static void btle_handler(ble_evt_t * p_ble_evt)
|
||||||
sec_params.min_key_size = CFG_BLE_SEC_PARAM_MIN_KEY_SIZE ;
|
sec_params.min_key_size = CFG_BLE_SEC_PARAM_MIN_KEY_SIZE ;
|
||||||
sec_params.max_key_size = CFG_BLE_SEC_PARAM_MAX_KEY_SIZE ;
|
sec_params.max_key_size = CFG_BLE_SEC_PARAM_MAX_KEY_SIZE ;
|
||||||
|
|
||||||
ASSERT_STATUS_RET_VOID ( sd_ble_gap_sec_params_reply(nRF51Gap::getInstance().m_connectionHandle, BLE_GAP_SEC_STATUS_SUCCESS, &sec_params) );
|
ASSERT_STATUS_RET_VOID ( sd_ble_gap_sec_params_reply(nRF51Gap::getInstance().getConnectionHandle(), BLE_GAP_SEC_STATUS_SUCCESS, &sec_params) );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -234,6 +234,26 @@ ble_error_t nRF51Gap::disconnect(void)
|
||||||
return BLE_ERROR_NONE;
|
return BLE_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Sets the 16-bit connection handle
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
void nRF51Gap::setConnectionHandle(uint16_t con_handle)
|
||||||
|
{
|
||||||
|
m_connectionHandle = con_handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@brief Gets the 16-bit connection handle
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
uint16_t nRF51Gap::getConnectionHandle(void)
|
||||||
|
{
|
||||||
|
return m_connectionHandle;
|
||||||
|
}
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@brief Sets the BLE device address
|
@brief Sets the BLE device address
|
||||||
|
|
|
@ -46,9 +46,11 @@ class nRF51Gap : public Gap
|
||||||
virtual ble_error_t stopAdvertising(void);
|
virtual ble_error_t stopAdvertising(void);
|
||||||
virtual ble_error_t disconnect(void);
|
virtual ble_error_t disconnect(void);
|
||||||
|
|
||||||
uint16_t m_connectionHandle; // TODO move to private
|
void setConnectionHandle(uint16_t con_handle);
|
||||||
|
uint16_t getConnectionHandle(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
uint16_t m_connectionHandle;
|
||||||
nRF51Gap() { m_connectionHandle = BLE_CONN_HANDLE_INVALID; };
|
nRF51Gap() { m_connectionHandle = BLE_CONN_HANDLE_INVALID; };
|
||||||
nRF51Gap(nRF51Gap const&);
|
nRF51Gap(nRF51Gap const&);
|
||||||
void operator=(nRF51Gap const&);
|
void operator=(nRF51Gap const&);
|
||||||
|
|
|
@ -140,7 +140,7 @@ ble_error_t nRF51GattServer::readValue(uint16_t charHandle, uint8_t buffer[], ui
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
ble_error_t nRF51GattServer::updateValue(uint16_t charHandle, uint8_t buffer[], uint16_t len, bool localOnly)
|
ble_error_t nRF51GattServer::updateValue(uint16_t charHandle, uint8_t buffer[], uint16_t len, bool localOnly)
|
||||||
{
|
{
|
||||||
uint16_t gapConnectionHandle = nRF51Gap::getInstance().m_connectionHandle;
|
uint16_t gapConnectionHandle = nRF51Gap::getInstance().getConnectionHandle();
|
||||||
|
|
||||||
if (localOnly)
|
if (localOnly)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue