mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #13811 from pan-/ble-conditional-compilation
Ble conditional compilationpull/13882/head
commit
c29a2e2338
|
@ -247,6 +247,7 @@ public:
|
|||
// Pairing
|
||||
//
|
||||
|
||||
#if BLE_ROLE_PERIPHERAL
|
||||
/**
|
||||
* Request application to accept or reject pairing. Application should respond by
|
||||
* calling the appropriate function: acceptPairingRequest or cancelPairingRequest
|
||||
|
@ -256,6 +257,7 @@ public:
|
|||
virtual void pairingRequest(ble::connection_handle_t connectionHandle) {
|
||||
(void)connectionHandle;
|
||||
}
|
||||
#endif // BLE_ROLE_PERIPHERAL
|
||||
|
||||
/**
|
||||
* Indicate to the application that pairing has completed.
|
||||
|
@ -327,6 +329,7 @@ public:
|
|||
(void)passkey;
|
||||
}
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
/**
|
||||
* Indicate to the application that a confirmation is required. This is used
|
||||
* when the device does not have a keyboard but has a yes/no button. The device
|
||||
|
@ -339,6 +342,7 @@ public:
|
|||
virtual void confirmationRequest(ble::connection_handle_t connectionHandle) {
|
||||
(void)connectionHandle;
|
||||
}
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
/**
|
||||
* Indicate to the application that a passkey is required. The application should
|
||||
|
@ -350,6 +354,7 @@ public:
|
|||
(void)connectionHandle;
|
||||
}
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
/**
|
||||
* Notify the application that a key was pressed by the peer during passkey entry.
|
||||
*
|
||||
|
@ -360,6 +365,7 @@ public:
|
|||
(void)connectionHandle;
|
||||
(void)keypress;
|
||||
}
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
/**
|
||||
* Indicate to the application it needs to return legacy pairing OOB to the stack.
|
||||
|
@ -402,6 +408,7 @@ public:
|
|||
// Keys
|
||||
//
|
||||
|
||||
#if BLE_FEATURE_SIGNING
|
||||
/**
|
||||
* Deliver the signing key to the application.
|
||||
*
|
||||
|
@ -414,6 +421,8 @@ public:
|
|||
(void)csrk;
|
||||
(void)authenticated;
|
||||
}
|
||||
#endif // BLE_FEATURE_SIGNING
|
||||
|
||||
/**
|
||||
* Prevent polymorphic deletion and avoid unnecessary virtual destructor
|
||||
* as the SecurityManager class will never delete the instance it contains.
|
||||
|
@ -526,6 +535,7 @@ public:
|
|||
// Pairing
|
||||
//
|
||||
|
||||
#if BLE_ROLE_CENTRAL
|
||||
/**
|
||||
* Request pairing with the peer. Called by the master.
|
||||
* @note Slave can call requestAuthentication or setLinkEncryption to achieve security.
|
||||
|
@ -534,7 +544,9 @@ public:
|
|||
* @return BLE_ERROR_NONE or appropriate error code indicating the failure reason.
|
||||
*/
|
||||
ble_error_t requestPairing(ble::connection_handle_t connectionHandle);
|
||||
#endif // BLE_ROLE_CENTRAL
|
||||
|
||||
#if BLE_ROLE_PERIPHERAL
|
||||
/**
|
||||
* Accept the pairing request. Called as a result of pairingRequest being called
|
||||
* on the event handler.
|
||||
|
@ -543,6 +555,7 @@ public:
|
|||
* @return BLE_ERROR_NONE or appropriate error code indicating the failure reason.
|
||||
*/
|
||||
ble_error_t acceptPairingRequest(ble::connection_handle_t connectionHandle);
|
||||
#endif // BLE_ROLE_PERIPHERAL
|
||||
|
||||
/**
|
||||
* Reject pairing request if the local device is the slave or cancel an outstanding
|
||||
|
@ -577,6 +590,7 @@ public:
|
|||
// Feature support
|
||||
//
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
/**
|
||||
* Allow of disallow the use of legacy pairing in case the application only wants
|
||||
* to force the use of Secure Connections. If legacy pairing is disallowed and either
|
||||
|
@ -594,6 +608,7 @@ public:
|
|||
* @return BLE_ERROR_NONE or appropriate error code indicating the failure reason.
|
||||
*/
|
||||
ble_error_t getSecureConnectionsSupport(bool *enabled);
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Security settings
|
||||
|
@ -766,6 +781,7 @@ public:
|
|||
*/
|
||||
ble_error_t setOOBDataUsage(ble::connection_handle_t connectionHandle, bool useOOB, bool OOBProvidesMITM = true);
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
/**
|
||||
* Report to the stack if the passkey matches or not. Used during pairing to provide MITM protection.
|
||||
*
|
||||
|
@ -774,6 +790,7 @@ public:
|
|||
* @return BLE_ERROR_NONE or appropriate error code indicating the failure reason.
|
||||
*/
|
||||
ble_error_t confirmationEntered(ble::connection_handle_t connectionHandle, bool confirmation);
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
/**
|
||||
* Supply the stack with the user entered passkey.
|
||||
|
@ -784,6 +801,7 @@ public:
|
|||
*/
|
||||
ble_error_t passkeyEntered(ble::connection_handle_t connectionHandle, Passkey_t passkey);
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
/**
|
||||
* Send a notification to the peer that the user pressed a key on the local device.
|
||||
* @note This will only be delivered if the keypress notifications have been enabled during pairing.
|
||||
|
@ -793,6 +811,7 @@ public:
|
|||
* @return BLE_ERROR_NONE or appropriate error code indicating the failure reason.
|
||||
*/
|
||||
ble_error_t sendKeypressNotification(ble::connection_handle_t connectionHandle, ble::Keypress_t keypress);
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
/**
|
||||
* Supply the stack with the OOB data for legacy connections.
|
||||
|
@ -803,6 +822,7 @@ public:
|
|||
*/
|
||||
ble_error_t legacyPairingOobReceived(const ble::address_t *address, const ble::oob_tk_t *tk);
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
/**
|
||||
* Supply the stack with the OOB data for secure connections.
|
||||
*
|
||||
|
@ -813,11 +833,13 @@ public:
|
|||
* @return BLE_ERROR_NONE or appropriate error code indicating the failure reason.
|
||||
*/
|
||||
ble_error_t oobReceived(const ble::address_t *address, const ble::oob_lesc_value_t *random, const ble::oob_confirm_t *confirm);
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Keys
|
||||
//
|
||||
|
||||
#if BLE_FEATURE_SIGNING
|
||||
/**
|
||||
* Retrieves a signing key through a signingKey event.
|
||||
* If a signing key is not present, pairing/authentication will be attempted.
|
||||
|
@ -830,6 +852,7 @@ public:
|
|||
* @return BLE_ERROR_NONE or appropriate error code indicating the failure reason.
|
||||
*/
|
||||
ble_error_t getSigningKey(ble::connection_handle_t connectionHandle, bool authenticated);
|
||||
#endif // BLE_FEATURE_SIGNING
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Privacy
|
||||
|
|
|
@ -217,6 +217,7 @@ static const hciEvtParse_t hciEvtParseFcnTbl[] =
|
|||
hciEvtParseLeConnCteReqEnableCmdCmpl,
|
||||
hciEvtParseLeConnCteRspEnableCmdCmpl,
|
||||
hciEvtParseLeReadAntennaInfoCmdCmpl,
|
||||
#if HCI_VER_BT >= HCI_VER_BT_CORE_SPEC_5_2
|
||||
hciEvtParseLeCisEst,
|
||||
hciEvtParseLeCisReq,
|
||||
hciEvtParseDisconnectCmpl,
|
||||
|
@ -235,6 +236,7 @@ static const hciEvtParse_t hciEvtParseFcnTbl[] =
|
|||
hciEvtParseLeBigSyncLost,
|
||||
hciEvtParseLeBigTermSyncCmpl,
|
||||
hciEvtParseLeBigInfoAdvRpt
|
||||
#endif // HCI_VER_BT_CORE_SPEC_5_2
|
||||
};
|
||||
|
||||
/* HCI event structure length table, indexed by internal callback event value */
|
||||
|
@ -308,6 +310,7 @@ static const uint8_t hciEvtCbackLen[] =
|
|||
sizeof(hciLeConnCteReqEnableCmdCmplEvt_t),
|
||||
sizeof(hciLeConnCteRspEnableCmdCmplEvt_t),
|
||||
sizeof(hciLeReadAntennaInfoCmdCmplEvt_t),
|
||||
#if HCI_VER_BT >= HCI_VER_BT_CORE_SPEC_5_2
|
||||
sizeof(HciLeCisEstEvt_t),
|
||||
sizeof(HciLeCisReqEvt_t),
|
||||
sizeof(hciDisconnectCmplEvt_t),
|
||||
|
@ -326,6 +329,7 @@ static const uint8_t hciEvtCbackLen[] =
|
|||
sizeof(HciLeBigSyncLostEvt_t),
|
||||
sizeof(HciLeBigTermSyncCmplEvt_t),
|
||||
sizeof(HciLeBigInfoAdvRptEvt_t)
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Global event statistics. */
|
||||
|
@ -2583,6 +2587,7 @@ void hciEvtProcessCmdCmpl(uint8_t *p, uint8_t len)
|
|||
cbackEvt = HCI_LE_PER_ADV_SET_INFO_TRSF_CMD_CMPL_CBACK_EVT;
|
||||
break;
|
||||
|
||||
#if HCI_VER_BT >= HCI_VER_BT_CORE_SPEC_5_2
|
||||
case HCI_OPCODE_LE_SET_CIG_PARAMS:
|
||||
cbackEvt = HCI_LE_SET_CIG_PARAMS_CMD_CMPL_CBACK_EVT;
|
||||
break;
|
||||
|
@ -2618,6 +2623,7 @@ void hciEvtProcessCmdCmpl(uint8_t *p, uint8_t len)
|
|||
case HCI_OPCODE_READ_LOCAL_SUP_CONTROLLER_DLY:
|
||||
cbackEvt = HCI_READ_LOCAL_SUP_CTR_DLY_CMD_CMPL_CBACK_EVT;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
/* test for vendor specific command completion OGF. */
|
||||
|
@ -2851,6 +2857,7 @@ void hciEvtProcessMsg(uint8_t *pEvt)
|
|||
cbackEvt = HCI_LE_CTE_REQ_FAILED_CBACK_EVT;
|
||||
break;
|
||||
|
||||
#if HCI_VER_BT >= HCI_VER_BT_CORE_SPEC_5_2
|
||||
case HCI_LE_CIS_EST_EVT:
|
||||
/* if CIS connection created successfully */
|
||||
if (*pEvt == HCI_SUCCESS)
|
||||
|
@ -2888,6 +2895,7 @@ void hciEvtProcessMsg(uint8_t *pEvt)
|
|||
case HCI_LE_BIG_INFO_ADV_REPORT_EVT:
|
||||
cbackEvt = HCI_LE_BIG_INFO_ADV_REPORT_CBACK_EVT;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
|
@ -2899,11 +2907,13 @@ void hciEvtProcessMsg(uint8_t *pEvt)
|
|||
|
||||
/* if disconnect is for CIS connection */
|
||||
BYTES_TO_UINT16(handle, (pEvt + 1));
|
||||
#if HCI_VER_BT >= HCI_VER_BT_CORE_SPEC_5_2
|
||||
if (hciCoreCisByHandle(handle) != NULL)
|
||||
{
|
||||
cbackEvt = HCI_CIS_DISCONNECT_CMPL_CBACK_EVT;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
cbackEvt = HCI_DISCONNECT_CMPL_CBACK_EVT;
|
||||
}
|
||||
|
@ -2991,11 +3001,13 @@ void hciEvtProcessMsg(uint8_t *pEvt)
|
|||
BYTES_TO_UINT16(handle, (pEvt + 1));
|
||||
hciCoreConnClose(handle);
|
||||
}
|
||||
#if HCI_VER_BT >= HCI_VER_BT_CORE_SPEC_5_2
|
||||
else if (cbackEvt == HCI_CIS_DISCONNECT_CMPL_CBACK_EVT)
|
||||
{
|
||||
BYTES_TO_UINT16(handle, (pEvt + 1));
|
||||
hciCoreCisClose(handle);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1421,6 +1421,11 @@ extern "C" {
|
|||
#define HCI_VER_BT_CORE_SPEC_5_2 0x0B /*!< Bluetooth core specification 5.2 */
|
||||
/**@}*/
|
||||
|
||||
#ifndef HCI_VER_BT
|
||||
#define HCI_VER_BT HCI_VER_BT_CORE_SPEC_5_1
|
||||
#endif
|
||||
|
||||
|
||||
/** \name Parameter lengths
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -57,15 +57,19 @@ ble_error_t SecurityManager::generateWhitelistFromBondTable(::ble::whitelist_t *
|
|||
return impl->generateWhitelistFromBondTable(whitelist);
|
||||
}
|
||||
|
||||
#if BLE_ROLE_CENTRAL
|
||||
ble_error_t SecurityManager::requestPairing(ble::connection_handle_t connectionHandle)
|
||||
{
|
||||
return impl->requestPairing(connectionHandle);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BLE_ROLE_PERIPHERAL
|
||||
ble_error_t SecurityManager::acceptPairingRequest(ble::connection_handle_t connectionHandle)
|
||||
{
|
||||
return impl->acceptPairingRequest(connectionHandle);
|
||||
}
|
||||
#endif
|
||||
|
||||
ble_error_t SecurityManager::cancelPairingRequest(ble::connection_handle_t connectionHandle)
|
||||
{
|
||||
|
@ -82,6 +86,7 @@ ble_error_t SecurityManager::getPeerIdentity(ble::connection_handle_t connection
|
|||
return impl->getPeerIdentity(connectionHandle);
|
||||
}
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
ble_error_t SecurityManager::allowLegacyPairing(bool allow)
|
||||
{
|
||||
return impl->allowLegacyPairing(allow);
|
||||
|
@ -91,6 +96,7 @@ ble_error_t SecurityManager::getSecureConnectionsSupport(bool *enabled)
|
|||
{
|
||||
return impl->getSecureConnectionsSupport(enabled);
|
||||
}
|
||||
#endif
|
||||
|
||||
ble_error_t SecurityManager::setIoCapability(SecurityIOCapabilities_t iocaps)
|
||||
{
|
||||
|
@ -162,35 +168,43 @@ ble_error_t SecurityManager::setOOBDataUsage(ble::connection_handle_t connection
|
|||
return impl->setOOBDataUsage(connectionHandle, useOOB, OOBProvidesMITM);
|
||||
}
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
ble_error_t SecurityManager::confirmationEntered(ble::connection_handle_t connectionHandle, bool confirmation)
|
||||
{
|
||||
return impl->confirmationEntered(connectionHandle, confirmation);
|
||||
}
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
ble_error_t SecurityManager::passkeyEntered(ble::connection_handle_t connectionHandle, Passkey_t passkey)
|
||||
{
|
||||
return impl->passkeyEntered(connectionHandle, passkey);
|
||||
}
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
ble_error_t SecurityManager::sendKeypressNotification(ble::connection_handle_t connectionHandle, ble::Keypress_t keypress)
|
||||
{
|
||||
return impl->sendKeypressNotification(connectionHandle, keypress);
|
||||
}
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
ble_error_t SecurityManager::legacyPairingOobReceived(const ble::address_t *address, const ble::oob_tk_t *tk)
|
||||
{
|
||||
return impl->legacyPairingOobReceived(address, tk);
|
||||
}
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
ble_error_t SecurityManager::oobReceived(const ble::address_t *address, const ble::oob_lesc_value_t *random, const ble::oob_confirm_t *confirm)
|
||||
{
|
||||
return impl->oobReceived(address, random, confirm);
|
||||
}
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
#if BLE_FEATURE_SIGNING
|
||||
ble_error_t SecurityManager::getSigningKey(ble::connection_handle_t connectionHandle, bool authenticated)
|
||||
{
|
||||
return impl->getSigningKey(connectionHandle, authenticated);
|
||||
}
|
||||
#endif // BLE_FEATURE_SIGNING
|
||||
|
||||
#if BLE_FEATURE_PRIVACY
|
||||
ble_error_t SecurityManager::setPrivateAddressTimeout(
|
||||
|
|
|
@ -414,6 +414,7 @@ void BLEInstanceBase::stack_handler(wsfEventMask_t event, wsfMsgHdr_t *msg)
|
|||
|
||||
void BLEInstanceBase::device_manager_cb(dmEvt_t *dm_event)
|
||||
{
|
||||
#if BLE_FEATURE_CONNECTABLE
|
||||
if (dm_event->hdr.status == HCI_SUCCESS && dm_event->hdr.event == DM_CONN_DATA_LEN_CHANGE_IND) {
|
||||
// this event can only happen after a connection has been established therefore gap is present
|
||||
ble::PalGapEventHandler *handler;
|
||||
|
@ -427,6 +428,7 @@ void BLEInstanceBase::device_manager_cb(dmEvt_t *dm_event)
|
|||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
BLEInstanceBase::deviceInstance().stack_handler(0, &dm_event->hdr);
|
||||
}
|
||||
|
|
|
@ -304,12 +304,14 @@ ble_error_t PalAttClient::terminate()
|
|||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
#if BLE_FEATURE_GATT_CLIENT
|
||||
// singleton of the ARM Cordio client
|
||||
PalAttClient &PalAttClient::get_client()
|
||||
{
|
||||
static PalAttClient _client;
|
||||
return _client;
|
||||
}
|
||||
#endif
|
||||
|
||||
void PalAttClient::when_server_message_received(
|
||||
mbed::Callback<void(connection_handle_t, const AttServerMessage &)> cb
|
||||
|
@ -345,12 +347,17 @@ bool PalAttClient::event_handler(const attEvt_t *event)
|
|||
|
||||
bool PalAttClient::timeout_event_handler(const attEvt_t *event)
|
||||
{
|
||||
#if BLE_FEATURE_GATT_CLIENT
|
||||
|
||||
if (event->hdr.status != ATT_ERR_TIMEOUT) {
|
||||
return false;
|
||||
}
|
||||
|
||||
get_client().on_transaction_timeout(event->hdr.param);
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -359,10 +366,12 @@ void PalAttClient::generated_handler(
|
|||
const attEvt_t *event, ResultType (*convert)(const attEvt_t *)
|
||||
)
|
||||
{
|
||||
#if BLE_FEATURE_GATT_CLIENT
|
||||
get_client().on_server_event(
|
||||
event->hdr.param,
|
||||
convert(event)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
void PalAttClient::on_server_event(
|
||||
|
@ -392,9 +401,9 @@ void PalAttClient::on_transaction_timeout(
|
|||
}
|
||||
}
|
||||
|
||||
#if BLE_FEATURE_GATT_CLIENT
|
||||
void PalAttClient::att_client_handler(const attEvt_t *event)
|
||||
{
|
||||
#if BLE_FEATURE_GATT_CLIENT
|
||||
if (event->hdr.status == ATT_SUCCESS && event->hdr.event == ATT_MTU_UPDATE_IND) {
|
||||
ble::impl::BLEInstanceBase &ble = BLEInstanceBase::deviceInstance();
|
||||
PalGattClientEventHandler *handler = ble.getPalGattClient().get_event_handler();
|
||||
|
@ -444,13 +453,13 @@ void PalAttClient::att_client_handler(const attEvt_t *event)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif // BLE_FEATURE_GATT_CLIENT
|
||||
|
||||
#if BLE_FEATURE_GATT_SERVER
|
||||
// pass events not handled to the server side
|
||||
ble::impl::GattServer::att_cb(event);
|
||||
#endif // BLE_FEATURE_GATT_SERVER
|
||||
}
|
||||
#endif // BLE_FEATURE_GATT_CLIENT
|
||||
|
||||
} // namespace impl
|
||||
} // ble
|
||||
|
|
|
@ -173,8 +173,10 @@ public:
|
|||
*/
|
||||
ble_error_t terminate() final;
|
||||
|
||||
#if BLE_FEATURE_GATT_CLIENT
|
||||
// singleton of the ARM Cordio client
|
||||
static PalAttClient &get_client();
|
||||
#endif
|
||||
|
||||
void when_server_message_received(
|
||||
mbed::Callback<void(connection_handle_t, const AttServerMessage &)> cb
|
||||
|
@ -199,7 +201,9 @@ public:
|
|||
/**
|
||||
* Callback which handle attEvt_t and forward them to on_server_event.
|
||||
*/
|
||||
#if BLE_FEATURE_GATT_CLIENT
|
||||
static void att_client_handler(const attEvt_t *event);
|
||||
#endif
|
||||
|
||||
private:
|
||||
/**
|
||||
|
|
|
@ -104,7 +104,7 @@ ble_error_t PalGap::set_random_address(const address_t &address)
|
|||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
|
||||
#if BLE_ROLE_BROADCASTER
|
||||
ble_error_t PalGap::set_advertising_parameters(
|
||||
uint16_t advertising_interval_min,
|
||||
uint16_t advertising_interval_max,
|
||||
|
@ -233,8 +233,9 @@ ble_error_t PalGap::advertising_enable(bool enable)
|
|||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
#endif // BLE_ROLE_BROADCASTER
|
||||
|
||||
|
||||
#if BLE_ROLE_OBSERVER
|
||||
ble_error_t PalGap::set_scan_parameters(
|
||||
bool active_scanning,
|
||||
uint16_t scan_interval,
|
||||
|
@ -276,8 +277,9 @@ ble_error_t PalGap::scan_enable(
|
|||
}
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
#endif // BLE_ROLE_OBSERVER
|
||||
|
||||
|
||||
#if BLE_ROLE_CENTRAL
|
||||
ble_error_t PalGap::create_connection(
|
||||
uint16_t scan_interval,
|
||||
uint16_t scan_window,
|
||||
|
@ -342,8 +344,9 @@ ble_error_t PalGap::cancel_connection_creation()
|
|||
|
||||
return error;
|
||||
}
|
||||
#endif // BLE_ROLE_CENTRAL
|
||||
|
||||
|
||||
#if BLE_FEATURE_WHITELIST
|
||||
uint8_t PalGap::read_white_list_capacity()
|
||||
{
|
||||
return HciGetWhiteListSize();
|
||||
|
@ -381,8 +384,9 @@ ble_error_t PalGap::remove_device_from_whitelist(
|
|||
);
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
#endif // BLE_FEATURE_WHITELIST
|
||||
|
||||
|
||||
#if BLE_FEATURE_CONNECTABLE
|
||||
ble_error_t PalGap::connection_parameters_update(
|
||||
connection_handle_t connection,
|
||||
uint16_t connection_interval_min,
|
||||
|
@ -463,6 +467,9 @@ ble_error_t PalGap::disconnect(
|
|||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
#endif // BLE_FEATURE_CONNECTABLE
|
||||
|
||||
#if BLE_FEATURE_PHY_MANAGEMENT
|
||||
ble_error_t PalGap::read_phy(connection_handle_t connection)
|
||||
{
|
||||
if (is_feature_supported(controller_supported_features_t::LE_2M_PHY)
|
||||
|
@ -514,6 +521,7 @@ ble_error_t PalGap::set_phy(
|
|||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
#endif // BLE_FEATURE_PHY_MANAGEMENT
|
||||
|
||||
// singleton of the ARM Cordio client
|
||||
|
||||
|
@ -766,6 +774,7 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg)
|
|||
}
|
||||
break;
|
||||
|
||||
#if BLE_ROLE_PERIPHERAL
|
||||
case DM_CONN_CLOSE_IND: {
|
||||
// Intercept connection close indication received when direct advertising timeout.
|
||||
// Leave the rest of the processing to the event handlers bellow.
|
||||
|
@ -775,16 +784,21 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg)
|
|||
get_gap().get_running_conn_direct_adv_cb(evt->hdr.param);
|
||||
if (adv_cb) {
|
||||
adv_cb->state = direct_adv_cb_t::free;
|
||||
#if BLE_ROLE_BROADCASTER
|
||||
if (handler) {
|
||||
handler->on_advertising_set_terminated(
|
||||
hci_error_code_t(evt->status),
|
||||
adv_cb->advertising_handle,
|
||||
DM_CONN_ID_NONE,
|
||||
0
|
||||
);
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
if (get_gap().is_feature_supported(controller_supported_features_t::LE_EXTENDED_ADVERTISING)) {
|
||||
handler->on_advertising_set_terminated(
|
||||
hci_error_code_t(evt->status),
|
||||
adv_cb->advertising_handle,
|
||||
DM_CONN_ID_NONE,
|
||||
0
|
||||
);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
handler->on_legacy_advertising_stopped();
|
||||
}
|
||||
}
|
||||
#endif // BLE_ROLE_BROADCASTER
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -801,6 +815,7 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg)
|
|||
}
|
||||
}
|
||||
break;
|
||||
#endif // BLE_ROLE_PERIPHERAL
|
||||
#endif // BLE_FEATURE_CONNECTABLE
|
||||
}
|
||||
|
||||
|
@ -843,7 +858,8 @@ bool PalGap::event_handler(const wsfMsgHdr_t *msg)
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
#if BLE_ROLE_BROADCASTER
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
ble_error_t PalGap::set_advertising_set_random_address(
|
||||
advertising_handle_t advertising_handle,
|
||||
const address_t &address
|
||||
|
@ -853,7 +869,6 @@ ble_error_t PalGap::set_advertising_set_random_address(
|
|||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
ble_error_t PalGap::set_extended_advertising_parameters(
|
||||
advertising_handle_t advertising_handle,
|
||||
advertising_event_properties_t event_properties,
|
||||
|
@ -995,6 +1010,7 @@ ble_error_t PalGap::set_extended_advertising_parameters(
|
|||
}
|
||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
|
||||
#if BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
ble_error_t PalGap::set_periodic_advertising_parameters(
|
||||
advertising_handle_t advertising_handle,
|
||||
periodic_advertising_interval_t periodic_advertising_min,
|
||||
|
@ -1012,8 +1028,9 @@ ble_error_t PalGap::set_periodic_advertising_parameters(
|
|||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
|
||||
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
ble_error_t PalGap::set_extended_advertising_data(
|
||||
advertising_handle_t advertising_handle,
|
||||
advertising_fragment_description_t operation,
|
||||
|
@ -1037,8 +1054,9 @@ ble_error_t PalGap::set_extended_advertising_data(
|
|||
);
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
#endif // #if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
|
||||
|
||||
#if BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
ble_error_t PalGap::set_periodic_advertising_data(
|
||||
advertising_handle_t advertising_handle,
|
||||
advertising_fragment_description_t fragment_description,
|
||||
|
@ -1054,8 +1072,9 @@ ble_error_t PalGap::set_periodic_advertising_data(
|
|||
);
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
|
||||
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
ble_error_t PalGap::set_extended_scan_response_data(
|
||||
advertising_handle_t advertising_handle,
|
||||
advertising_fragment_description_t operation,
|
||||
|
@ -1170,8 +1189,9 @@ ble_error_t PalGap::extended_advertising_enable(
|
|||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
|
||||
|
||||
#if BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
ble_error_t PalGap::periodic_advertising_enable(
|
||||
bool enable,
|
||||
advertising_handle_t advertising_handle
|
||||
|
@ -1185,7 +1205,7 @@ ble_error_t PalGap::periodic_advertising_enable(
|
|||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
uint16_t PalGap::get_maximum_advertising_data_length()
|
||||
{
|
||||
|
@ -1210,7 +1230,7 @@ uint8_t PalGap::get_max_number_of_advertising_sets()
|
|||
return std::min(HciGetNumSupAdvSets(), (uint8_t) DM_NUM_ADV_SETS);
|
||||
}
|
||||
|
||||
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
ble_error_t PalGap::remove_advertising_set(advertising_handle_t advertising_handle)
|
||||
{
|
||||
DmAdvRemoveAdvSet(advertising_handle);
|
||||
|
@ -1223,8 +1243,11 @@ ble_error_t PalGap::clear_advertising_sets()
|
|||
DmAdvClearAdvSets();
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
#endif // BLE_ROLE_BROADCASTER
|
||||
|
||||
|
||||
#if BLE_ROLE_OBSERVER
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
ble_error_t PalGap::set_extended_scan_parameters(
|
||||
own_address_type_t own_address_type,
|
||||
scanning_filter_policy_t filter_policy,
|
||||
|
@ -1287,8 +1310,9 @@ ble_error_t PalGap::extended_scan_enable(
|
|||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
|
||||
|
||||
#if BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
ble_error_t PalGap::periodic_advertising_create_sync(
|
||||
bool use_periodic_advertiser_list,
|
||||
uint8_t advertising_sid,
|
||||
|
@ -1376,8 +1400,10 @@ uint8_t PalGap::read_periodic_advertiser_list_size()
|
|||
{
|
||||
return HciGetPerAdvListSize();
|
||||
}
|
||||
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
#endif // BLE_ROLE_OBSERVER
|
||||
|
||||
|
||||
#if BLE_ROLE_CENTRAL && BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
ble_error_t PalGap::extended_create_connection(
|
||||
initiator_policy_t initiator_policy,
|
||||
own_address_type_t own_address_type,
|
||||
|
@ -1430,6 +1456,7 @@ ble_error_t PalGap::extended_create_connection(
|
|||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
#endif // BLE_ROLE_CENTRAL && BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
|
||||
|
||||
ble_error_t PalGap::update_direct_advertising_parameters(
|
||||
|
|
|
@ -50,6 +50,7 @@ public:
|
|||
|
||||
ble_error_t set_random_address(const address_t &address) final;
|
||||
|
||||
#if BLE_ROLE_BROADCASTER
|
||||
ble_error_t set_advertising_parameters(
|
||||
uint16_t advertising_interval_min,
|
||||
uint16_t advertising_interval_max,
|
||||
|
@ -72,7 +73,9 @@ public:
|
|||
) final;
|
||||
|
||||
ble_error_t advertising_enable(bool enable) final;
|
||||
#endif // BLE_ROLE_BROADCASTER
|
||||
|
||||
#if BLE_ROLE_OBSERVER
|
||||
ble_error_t set_scan_parameters(
|
||||
bool active_scanning,
|
||||
uint16_t scan_interval,
|
||||
|
@ -85,7 +88,9 @@ public:
|
|||
bool enable,
|
||||
bool filter_duplicates
|
||||
) final;
|
||||
#endif // BLE_ROLE_OBSERVER
|
||||
|
||||
#if BLE_ROLE_CENTRAL
|
||||
ble_error_t create_connection(
|
||||
uint16_t scan_interval,
|
||||
uint16_t scan_window,
|
||||
|
@ -102,7 +107,9 @@ public:
|
|||
) final;
|
||||
|
||||
ble_error_t cancel_connection_creation();
|
||||
#endif
|
||||
|
||||
#if BLE_FEATURE_WHITELIST
|
||||
uint8_t read_white_list_capacity() final;
|
||||
|
||||
ble_error_t clear_whitelist() final;
|
||||
|
@ -116,7 +123,9 @@ public:
|
|||
whitelist_address_type_t address_type,
|
||||
address_t address
|
||||
) final;
|
||||
#endif // BLE_FEATURE_WHITELIST
|
||||
|
||||
#if BLE_FEATURE_CONNECTABLE
|
||||
ble_error_t connection_parameters_update(
|
||||
connection_handle_t connection,
|
||||
uint16_t connection_interval_min,
|
||||
|
@ -146,7 +155,9 @@ public:
|
|||
connection_handle_t connection,
|
||||
local_disconnection_reason_t disconnection_reason
|
||||
) final;
|
||||
#endif // BLE_FEATURE_CONNECTABLE
|
||||
|
||||
#if BLE_FEATURE_PHY_MANAGEMENT
|
||||
ble_error_t read_phy(connection_handle_t connection) final;
|
||||
|
||||
ble_error_t set_preferred_phys(
|
||||
|
@ -160,6 +171,7 @@ public:
|
|||
const phy_set_t &rx_phys,
|
||||
coded_symbol_per_bit_t coded_symbol
|
||||
) final;
|
||||
#endif // BLE_FEATURE_PHY_MANAGEMENT
|
||||
|
||||
// singleton of the ARM Cordio client
|
||||
static PalGap &get_gap();
|
||||
|
@ -169,12 +181,13 @@ public:
|
|||
*/
|
||||
static void gap_handler(const wsfMsgHdr_t *msg);
|
||||
|
||||
#if BLE_ROLE_BROADCASTER
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
ble_error_t set_advertising_set_random_address(
|
||||
advertising_handle_t advertising_handle,
|
||||
const address_t &address
|
||||
) final;
|
||||
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
ble_error_t set_extended_advertising_parameters(
|
||||
advertising_handle_t advertising_handle,
|
||||
advertising_event_properties_t event_properties,
|
||||
|
@ -194,13 +207,17 @@ public:
|
|||
) final;
|
||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
|
||||
|
||||
#if BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
ble_error_t set_periodic_advertising_parameters(
|
||||
advertising_handle_t advertising_handle,
|
||||
periodic_advertising_interval_t periodic_advertising_min,
|
||||
periodic_advertising_interval_t periodic_advertising_max,
|
||||
bool advertise_power
|
||||
) final;
|
||||
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
ble_error_t set_extended_advertising_data(
|
||||
advertising_handle_t advertising_handle,
|
||||
advertising_fragment_description_t operation,
|
||||
|
@ -208,14 +225,18 @@ public:
|
|||
uint8_t advertising_data_size,
|
||||
const uint8_t *advertising_data
|
||||
) final;
|
||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
|
||||
#if BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
ble_error_t set_periodic_advertising_data(
|
||||
advertising_handle_t advertising_handle,
|
||||
advertising_fragment_description_t fragment_description,
|
||||
uint8_t advertising_data_size,
|
||||
const uint8_t *advertising_data
|
||||
) final;
|
||||
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
ble_error_t set_extended_scan_response_data(
|
||||
advertising_handle_t advertising_handle,
|
||||
advertising_fragment_description_t operation,
|
||||
|
@ -231,11 +252,14 @@ public:
|
|||
const uint16_t *durations,
|
||||
const uint8_t *max_extended_advertising_events
|
||||
) final;
|
||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
|
||||
#if BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
ble_error_t periodic_advertising_enable(
|
||||
bool enable,
|
||||
advertising_handle_t advertising_handle
|
||||
) final;
|
||||
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
|
||||
uint16_t get_maximum_advertising_data_length() final;
|
||||
|
||||
|
@ -245,12 +269,17 @@ public:
|
|||
|
||||
uint8_t get_max_number_of_advertising_sets() final;
|
||||
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
ble_error_t remove_advertising_set(
|
||||
advertising_handle_t advertising_handle
|
||||
) final;
|
||||
|
||||
ble_error_t clear_advertising_sets() final;
|
||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
#endif // BLE_ROLE_BROADCASTER
|
||||
|
||||
#if BLE_ROLE_OBSERVER
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
ble_error_t set_extended_scan_parameters(
|
||||
own_address_type_t own_address_type,
|
||||
scanning_filter_policy_t filter_policy,
|
||||
|
@ -266,7 +295,9 @@ public:
|
|||
uint16_t duration,
|
||||
uint16_t period
|
||||
) final;
|
||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
|
||||
#if BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
ble_error_t periodic_advertising_create_sync(
|
||||
bool use_periodic_advertiser_list,
|
||||
uint8_t advertising_sid,
|
||||
|
@ -297,7 +328,10 @@ public:
|
|||
ble_error_t clear_periodic_advertiser_list() final;
|
||||
|
||||
uint8_t read_periodic_advertiser_list_size() final;
|
||||
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
#endif // BLE_ROLE_OBSERVER
|
||||
|
||||
#if BLE_ROLE_CENTRAL && BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
ble_error_t extended_create_connection(
|
||||
initiator_policy_t initiator_policy,
|
||||
own_address_type_t own_address_type,
|
||||
|
@ -313,6 +347,7 @@ public:
|
|||
const uint16_t *minimum_connection_event_lengths,
|
||||
const uint16_t *maximum_connection_event_lengths
|
||||
) final;
|
||||
#endif // BLE_ROLE_CENTRAL && BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
|
||||
void when_gap_event_received(mbed::Callback<void(const GapEvent &)> cb) final;
|
||||
|
||||
|
|
|
@ -36,10 +36,7 @@ namespace impl {
|
|||
PalSecurityManager::PalSecurityManager() :
|
||||
_pal_event_handler(nullptr),
|
||||
_use_default_passkey(false),
|
||||
_default_passkey(0),
|
||||
_lesc_keys_generated(false),
|
||||
_public_key_x(),
|
||||
_peer_csrks()
|
||||
_default_passkey(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -57,7 +54,9 @@ ble_error_t PalSecurityManager::initialize()
|
|||
// reset local state
|
||||
_use_default_passkey = false;
|
||||
_default_passkey = 0;
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
_lesc_keys_generated = false;
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
#if BLE_FEATURE_SIGNING
|
||||
memset(_peer_csrks, 0, sizeof(_peer_csrks));
|
||||
#endif
|
||||
|
@ -116,9 +115,14 @@ ble_error_t PalSecurityManager::get_secure_connections_support(
|
|||
bool &enabled
|
||||
)
|
||||
{
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
// FIXME: should depend of the controller
|
||||
enabled = false;
|
||||
return BLE_ERROR_NONE;
|
||||
#else
|
||||
enabled = false;
|
||||
return BLE_ERROR_NONE;
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -143,7 +147,7 @@ ble_error_t PalSecurityManager::get_authentication_timeout(
|
|||
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
#if BLE_ROLE_PERIPHERAL
|
||||
ble_error_t PalSecurityManager::slave_security_request(
|
||||
connection_handle_t connection,
|
||||
AuthenticationMask authentication
|
||||
|
@ -152,12 +156,13 @@ ble_error_t PalSecurityManager::slave_security_request(
|
|||
DmSecSlaveReq(connection, authentication.value());
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
#endif // BLE_ROLE_PERIPHERAL
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Encryption
|
||||
//
|
||||
|
||||
|
||||
#if BLE_ROLE_CENTRAL
|
||||
ble_error_t PalSecurityManager::enable_encryption(
|
||||
connection_handle_t connection,
|
||||
const ltk_t <k,
|
||||
|
@ -180,7 +185,7 @@ ble_error_t PalSecurityManager::enable_encryption(
|
|||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
ble_error_t PalSecurityManager::enable_encryption(
|
||||
connection_handle_t connection,
|
||||
const ltk_t <k,
|
||||
|
@ -199,6 +204,8 @@ ble_error_t PalSecurityManager::enable_encryption(
|
|||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
#endif // BLE_ROLE_CENTRAL
|
||||
|
||||
|
||||
ble_error_t PalSecurityManager::encrypt_data(
|
||||
|
@ -275,6 +282,7 @@ ble_error_t PalSecurityManager::set_identity_address(
|
|||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
#if BLE_FEATURE_SIGNING
|
||||
ble_error_t PalSecurityManager::set_csrk(
|
||||
const csrk_t &csrk,
|
||||
sign_count_t sign_counter
|
||||
|
@ -282,8 +290,10 @@ ble_error_t PalSecurityManager::set_csrk(
|
|||
{
|
||||
_csrk = csrk;
|
||||
DmSecSetLocalCsrk(_csrk.data());
|
||||
#if BLE_FEATURE_GATT_CLIENT
|
||||
// extra set the sign counter used by the client
|
||||
impl::PalAttClient::get_client().set_sign_counter(sign_counter);
|
||||
#endif
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
@ -333,6 +343,7 @@ ble_error_t PalSecurityManager::remove_peer_csrk(connection_handle_t connection)
|
|||
AttsSetCsrk(connection, nullptr, false);
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
#endif // BLE_FEATURE_SIGNING
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Global parameters
|
||||
|
@ -378,7 +389,7 @@ ble_error_t PalSecurityManager::set_encryption_key_requirements(
|
|||
// Authentication
|
||||
//
|
||||
|
||||
|
||||
#if BLE_ROLE_CENTRAL
|
||||
ble_error_t PalSecurityManager::send_pairing_request(
|
||||
connection_handle_t connection,
|
||||
bool oob_data_flag,
|
||||
|
@ -397,8 +408,9 @@ ble_error_t PalSecurityManager::send_pairing_request(
|
|||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
#endif // BLE_ROLE_CENTRAL
|
||||
|
||||
|
||||
#if BLE_ROLE_PERIPHERAL
|
||||
ble_error_t PalSecurityManager::send_pairing_response(
|
||||
connection_handle_t connection,
|
||||
bool oob_data_flag,
|
||||
|
@ -417,6 +429,7 @@ ble_error_t PalSecurityManager::send_pairing_response(
|
|||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
#endif // BLE_ROLE_PERIPHERAL
|
||||
|
||||
|
||||
ble_error_t PalSecurityManager::cancel_pairing(
|
||||
|
@ -467,7 +480,7 @@ ble_error_t PalSecurityManager::legacy_pairing_oob_request_reply(
|
|||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
ble_error_t PalSecurityManager::confirmation_entered(
|
||||
connection_handle_t connection, bool confirmation
|
||||
)
|
||||
|
@ -518,6 +531,7 @@ ble_error_t PalSecurityManager::secure_connections_oob_request_reply(
|
|||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
|
||||
PalSecurityManager &PalSecurityManager::get_security_manager()
|
||||
|
@ -701,6 +715,7 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t *msg)
|
|||
return true;
|
||||
}
|
||||
|
||||
#if BLE_ROLE_PERIPHERAL
|
||||
case DM_SEC_PAIR_IND: {
|
||||
auto *evt = (dmSecPairIndEvt_t *) msg;
|
||||
handler->on_pairing_request(
|
||||
|
@ -712,7 +727,9 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t *msg)
|
|||
);
|
||||
return true;
|
||||
}
|
||||
#endif // BLE_ROLE_PERIPHERAL
|
||||
|
||||
#if BLE_ROLE_CENTRAL
|
||||
case DM_SEC_SLAVE_REQ_IND: {
|
||||
auto *evt = (dmSecPairIndEvt_t *) msg;
|
||||
handler->on_slave_security_request(
|
||||
|
@ -721,7 +738,9 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t *msg)
|
|||
);
|
||||
return true;
|
||||
}
|
||||
#endif // BLE_ROLE_CENTRAL
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
case DM_SEC_CALC_OOB_IND: {
|
||||
auto *evt = (dmSecOobCalcIndEvt_t *) msg;
|
||||
handler->on_secure_connections_oob_generated(
|
||||
|
@ -731,7 +750,6 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t *msg)
|
|||
return true;
|
||||
}
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
case DM_SEC_ECC_KEY_IND: {
|
||||
auto *evt = (secEccMsg_t *) msg;
|
||||
DmSecSetEccKey(&evt->data.key);
|
||||
|
@ -739,7 +757,6 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t *msg)
|
|||
self._lesc_keys_generated = true;
|
||||
return true;
|
||||
}
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
case DM_SEC_COMPARE_IND: {
|
||||
auto *evt = (dmSecCnfIndEvt_t *) msg;
|
||||
|
@ -759,6 +776,7 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t *msg)
|
|||
);
|
||||
return true;
|
||||
}
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
default:
|
||||
return false;
|
||||
|
@ -767,6 +785,7 @@ bool PalSecurityManager::sm_handler(const wsfMsgHdr_t *msg)
|
|||
|
||||
// Helper functions for privacy
|
||||
|
||||
#if BLE_FEATURE_SIGNING
|
||||
void PalSecurityManager::cleanup_peer_csrks()
|
||||
{
|
||||
for (auto & peer_csrk : _peer_csrks) {
|
||||
|
@ -776,6 +795,7 @@ void PalSecurityManager::cleanup_peer_csrks()
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif // BLE_FEATURE_SIGNING
|
||||
|
||||
void PalSecurityManager::set_event_handler(
|
||||
PalSecurityManagerEventHandler *event_handler
|
||||
|
|
|
@ -63,6 +63,7 @@ public:
|
|||
// Pairing
|
||||
//
|
||||
|
||||
#if BLE_ROLE_CENTRAL
|
||||
/**
|
||||
* @see ::ble::PalSecurityManager::send_pairing_request
|
||||
*/
|
||||
|
@ -73,7 +74,9 @@ public:
|
|||
KeyDistribution initiator_dist,
|
||||
KeyDistribution responder_dist
|
||||
) final;
|
||||
#endif // BLE_ROLE_CENTRAL
|
||||
|
||||
#if BLE_ROLE_PERIPHERAL
|
||||
/**
|
||||
* @see ::ble::PalSecurityManager::send_pairing_response
|
||||
*/
|
||||
|
@ -84,6 +87,7 @@ public:
|
|||
KeyDistribution initiator_dist,
|
||||
KeyDistribution responder_dist
|
||||
) final;
|
||||
#endif // BLE_ROLE_PERIPHERAL
|
||||
|
||||
/**
|
||||
* @see ::ble::PalSecurityManager::cancel_pairing
|
||||
|
@ -134,6 +138,7 @@ public:
|
|||
uint8_t max_encryption_key_size
|
||||
) final;
|
||||
|
||||
#if BLE_ROLE_PERIPHERAL
|
||||
/**
|
||||
* @see ::ble::PalSecurityManager::slave_security_request
|
||||
*/
|
||||
|
@ -141,11 +146,13 @@ public:
|
|||
connection_handle_t connection,
|
||||
AuthenticationMask authentication
|
||||
) final;
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Encryption
|
||||
//
|
||||
|
||||
#if BLE_ROLE_CENTRAL
|
||||
/**
|
||||
* @see ::ble::PalSecurityManager::enable_encryption
|
||||
*/
|
||||
|
@ -157,6 +164,7 @@ public:
|
|||
bool mitm
|
||||
) final;
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
/**
|
||||
* @see ::ble::PalSecurityManager::enable_encryption
|
||||
*/
|
||||
|
@ -165,6 +173,8 @@ public:
|
|||
const ltk_t <k,
|
||||
bool mitm
|
||||
) final;
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
#endif // BLE_ROLE_CENTRAL
|
||||
|
||||
/**
|
||||
* @see ::ble::PalSecurityManager::encrypt_data
|
||||
|
@ -207,6 +217,7 @@ public:
|
|||
const address_t &address, bool public_address
|
||||
) final;
|
||||
|
||||
#if BLE_FEATURE_SIGNING
|
||||
/**
|
||||
* @see ::ble::PalSecurityManager::set_csrk
|
||||
*/
|
||||
|
@ -226,6 +237,7 @@ public:
|
|||
) final;
|
||||
|
||||
ble_error_t remove_peer_csrk(connection_handle_t connection) final;
|
||||
#endif // BLE_FEATURE_SIGNING
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Authentication
|
||||
|
@ -253,6 +265,7 @@ public:
|
|||
passkey_num_t passkey
|
||||
) final;
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
/**
|
||||
* @see ::ble::PalSecurityManager::secure_connections_oob_request_reply
|
||||
*/
|
||||
|
@ -262,6 +275,7 @@ public:
|
|||
const oob_lesc_value_t &peer_random,
|
||||
const oob_confirm_t &peer_confirm
|
||||
) final;
|
||||
#endif // /BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
/**
|
||||
* @see ::ble::PalSecurityManager::legacy_pairing_oob_request_reply
|
||||
|
@ -271,6 +285,7 @@ public:
|
|||
const oob_tk_t &oob_data
|
||||
) final;
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
/**
|
||||
* @see ::ble::PalSecurityManager::confirmation_entered
|
||||
*/
|
||||
|
@ -289,6 +304,7 @@ public:
|
|||
* @see ::ble::PalSecurityManager::generate_secure_connections_oob
|
||||
*/
|
||||
ble_error_t generate_secure_connections_oob() final;
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
/**
|
||||
* @see ::ble::PalSecurityManager::set_event_handler
|
||||
|
@ -309,17 +325,23 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
#if BLE_FEATURE_SIGNING
|
||||
void cleanup_peer_csrks();
|
||||
#endif // BLE_FEATURE_SIGNING
|
||||
|
||||
PalSecurityManagerEventHandler *_pal_event_handler;
|
||||
|
||||
bool _use_default_passkey;
|
||||
passkey_num_t _default_passkey;
|
||||
bool _lesc_keys_generated;
|
||||
uint8_t _public_key_x[SEC_ECC_KEY_LEN];
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
bool _lesc_keys_generated = false;
|
||||
uint8_t _public_key_x[SEC_ECC_KEY_LEN] = {0};
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
irk_t _irk;
|
||||
#if BLE_FEATURE_SIGNING
|
||||
csrk_t _csrk;
|
||||
csrk_t *_peer_csrks[DM_CONN_MAX];
|
||||
csrk_t *_peer_csrks[DM_CONN_MAX] = {0};
|
||||
#endif // BLE_FEATURE_SIGNING
|
||||
};
|
||||
|
||||
} // namespace impl
|
||||
|
|
|
@ -494,9 +494,12 @@ ble_error_t Gap::stopScan()
|
|||
_scan_requested = false;
|
||||
|
||||
if (_scan_state == ScanState::scan) {
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
if (is_extended_advertising_available()) {
|
||||
err = _pal_gap.extended_scan_enable(false, duplicates_filter_t::DISABLE, 0, 0);
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
err = _pal_gap.scan_enable(false, false);
|
||||
}
|
||||
|
||||
|
@ -616,7 +619,9 @@ ble_error_t Gap::connect(
|
|||
connectionParams.getMaxConnectionIntervalArray()[0]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
else {
|
||||
// set the correct mac address before starting scanning.
|
||||
if (_scan_state == ScanState::idle) {
|
||||
_pal_gap.set_random_address(*address);
|
||||
|
@ -659,6 +664,7 @@ ble_error_t Gap::connect(
|
|||
);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ret == BLE_ERROR_NONE) {
|
||||
_initiating = true;
|
||||
|
@ -808,6 +814,7 @@ void Gap::on_read_phy(
|
|||
}
|
||||
#endif // BLE_FEATURE_PHY_MANAGEMENT
|
||||
|
||||
#if BLE_FEATURE_CONNECTABLE
|
||||
void Gap::on_data_length_change(
|
||||
connection_handle_t connection_handle,
|
||||
uint16_t tx_size,
|
||||
|
@ -818,6 +825,7 @@ void Gap::on_data_length_change(
|
|||
_event_handler->onDataLengthChange(connection_handle, tx_size, rx_size);
|
||||
}
|
||||
}
|
||||
#endif // BLE_FEATURE_CONNECTABLE
|
||||
|
||||
#if BLE_FEATURE_PHY_MANAGEMENT
|
||||
void Gap::on_phy_update_complete(
|
||||
|
@ -1083,17 +1091,15 @@ ble_error_t Gap::reset()
|
|||
#endif // BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION
|
||||
#endif // BLE_FEATURE_PRIVACY
|
||||
|
||||
#if BLE_ROLE_BROADCASTER
|
||||
_advertising_timeout.detach();
|
||||
#endif
|
||||
#if BLE_ROLE_OBSERVER
|
||||
_scan_timeout.detach();
|
||||
#endif
|
||||
|
||||
#if BLE_ROLE_BROADCASTER
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
if (is_extended_advertising_available()) {
|
||||
/* stop all advertising sets */
|
||||
for (size_t i = 1; i < BLE_GAP_MAX_ADVERTISING_SETS; ++i) {
|
||||
for (size_t i = 0; i < BLE_GAP_MAX_ADVERTISING_SETS; ++i) {
|
||||
if (_active_sets.get(i)) {
|
||||
_pal_gap.extended_advertising_enable(
|
||||
/* enable */ false,
|
||||
|
@ -1110,37 +1116,33 @@ ble_error_t Gap::reset()
|
|||
(advertising_handle_t) i
|
||||
);
|
||||
}
|
||||
_active_periodic_sets.clear();
|
||||
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
}
|
||||
|
||||
/* clear state of all advertising sets */
|
||||
_existing_sets.clear();
|
||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
#if BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
_active_periodic_sets.clear();
|
||||
#endif
|
||||
if (_active_sets.get(LEGACY_ADVERTISING_HANDLE)) {
|
||||
_pal_gap.extended_advertising_enable(
|
||||
/* enable */ false,
|
||||
/* number of advertising sets */ 1,
|
||||
(advertising_handle_t *) &LEGACY_ADVERTISING_HANDLE,
|
||||
nullptr,
|
||||
nullptr
|
||||
);
|
||||
}
|
||||
_active_sets.clear();
|
||||
_pending_sets.clear();
|
||||
_address_refresh_sets.clear();
|
||||
_interruptible_sets.clear();
|
||||
_connectable_payload_size_exceeded.clear();
|
||||
_set_is_connectable.clear();
|
||||
|
||||
/* clear advertising set data on the controller */
|
||||
_pal_gap.clear_advertising_sets();
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
} else
|
||||
#else // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
{
|
||||
if (_active_sets.get(LEGACY_ADVERTISING_HANDLE)) {
|
||||
_pal_gap.advertising_enable(false);
|
||||
}
|
||||
}
|
||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
|
||||
_active_sets.clear();
|
||||
_pending_sets.clear();
|
||||
_address_refresh_sets.clear();
|
||||
_interruptible_sets.clear();
|
||||
_connectable_payload_size_exceeded.clear();
|
||||
_set_is_connectable.clear();
|
||||
_advertising_timeout.detach();
|
||||
#endif // #BLE_ROLE_BROADCASTER
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
|
@ -2854,6 +2856,7 @@ void Gap::on_legacy_advertising_stopped()
|
|||
}
|
||||
}
|
||||
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
void Gap::on_advertising_set_started(const mbed::Span<const uint8_t>& handles)
|
||||
{
|
||||
for (const auto &handle : handles) {
|
||||
|
@ -2919,6 +2922,7 @@ void Gap::on_scan_request_received(
|
|||
)
|
||||
);
|
||||
}
|
||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
#endif // BLE_ROLE_BROADCASTER
|
||||
|
||||
#if BLE_FEATURE_CONNECTABLE
|
||||
|
@ -2985,6 +2989,7 @@ ble_error_t Gap::setScanParameters(const ScanParameters ¶ms)
|
|||
return BLE_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
if (is_extended_advertising_available()) {
|
||||
bool active_scanning[] = {
|
||||
params.get1mPhyConfiguration().isActiveScanningSet(),
|
||||
|
@ -3009,7 +3014,9 @@ ble_error_t Gap::setScanParameters(const ScanParameters ¶ms)
|
|||
scan_interval,
|
||||
scan_window
|
||||
);
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if (params.getPhys().get_coded()) {
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
|
|
@ -702,11 +702,13 @@ private:
|
|||
) override;
|
||||
#endif // BLE_FEATURE_PHY_MANAGEMENT
|
||||
|
||||
#if BLE_FEATURE_CONNECTABLE
|
||||
void on_data_length_change(
|
||||
connection_handle_t connection_handle,
|
||||
uint16_t tx_size,
|
||||
uint16_t rx_size
|
||||
) override;
|
||||
#endif
|
||||
|
||||
#if BLE_FEATURE_PHY_MANAGEMENT
|
||||
void on_phy_update_complete(
|
||||
|
@ -766,6 +768,7 @@ private:
|
|||
|
||||
void on_legacy_advertising_stopped() override;
|
||||
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
void on_advertising_set_started(const mbed::Span<const uint8_t>& handles) override;
|
||||
|
||||
void on_advertising_set_terminated(
|
||||
|
@ -780,6 +783,7 @@ private:
|
|||
connection_peer_address_type_t scanner_address_type,
|
||||
const ble::address_t &address
|
||||
) override;
|
||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
#endif // BLE_ROLE_BROADCASTER
|
||||
|
||||
#if BLE_FEATURE_CONNECTABLE
|
||||
|
|
|
@ -243,7 +243,7 @@ ble_error_t SecurityManager::generateWhitelistFromBondTable(::ble::whitelist_t *
|
|||
// Pairing
|
||||
//
|
||||
|
||||
|
||||
#if BLE_ROLE_CENTRAL
|
||||
ble_error_t SecurityManager::requestPairing(connection_handle_t connection)
|
||||
{
|
||||
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
|
||||
|
@ -297,8 +297,9 @@ ble_error_t SecurityManager::requestPairing(connection_handle_t connection)
|
|||
responder_distribution
|
||||
);
|
||||
}
|
||||
#endif // BLE_ROLE_CENTRAL
|
||||
|
||||
|
||||
#if BLE_ROLE_PERIPHERAL
|
||||
ble_error_t SecurityManager::acceptPairingRequest(connection_handle_t connection)
|
||||
{
|
||||
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
|
||||
|
@ -357,6 +358,7 @@ ble_error_t SecurityManager::acceptPairingRequest(connection_handle_t connection
|
|||
responder_distribution
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
ble_error_t SecurityManager::cancelPairingRequest(connection_handle_t connection)
|
||||
|
@ -405,7 +407,7 @@ ble_error_t SecurityManager::getPeerIdentity(connection_handle_t connection)
|
|||
// Feature support
|
||||
//
|
||||
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
ble_error_t SecurityManager::allowLegacyPairing(bool allow)
|
||||
{
|
||||
_legacy_pairing_allowed = allow;
|
||||
|
@ -417,6 +419,7 @@ ble_error_t SecurityManager::getSecureConnectionsSupport(bool *enabled)
|
|||
{
|
||||
return _pal.get_secure_connections_support(*enabled);
|
||||
}
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Security settings
|
||||
|
@ -485,11 +488,13 @@ ble_error_t SecurityManager::setLinkSecurity(
|
|||
case SECURITY_MODE_ENCRYPTION_WITH_MITM:
|
||||
return setLinkEncryption(connection, link_encryption_t::ENCRYPTED_WITH_MITM);
|
||||
|
||||
#if BLE_FEATURE_SIGNING
|
||||
case SECURITY_MODE_SIGNED_NO_MITM:
|
||||
return getSigningKey(connection, false);
|
||||
|
||||
case SECURITY_MODE_SIGNED_WITH_MITM:
|
||||
return getSigningKey(connection, true);
|
||||
#endif // BLE_FEATURE_SIGNING
|
||||
|
||||
default:
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
|
@ -535,9 +540,17 @@ ble_error_t SecurityManager::enableSigning(
|
|||
/* create keys if needed and exchange them */
|
||||
init_signing();
|
||||
if (cb->is_master) {
|
||||
#if BLE_ROLE_CENTRAL
|
||||
return requestPairing(connection);
|
||||
#else
|
||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||
#endif
|
||||
} else {
|
||||
#if BLE_ROLE_PERIPHERAL
|
||||
return slave_security_request(connection);
|
||||
#else
|
||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -702,6 +715,7 @@ ble_error_t SecurityManager::setEncryptionKeyRequirements(
|
|||
// Keys
|
||||
//
|
||||
|
||||
#if BLE_FEATURE_SIGNING
|
||||
ble_error_t SecurityManager::getSigningKey(connection_handle_t connection, bool authenticated)
|
||||
{
|
||||
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
|
||||
|
@ -730,12 +744,21 @@ ble_error_t SecurityManager::getSigningKey(connection_handle_t connection, bool
|
|||
if (authenticated) {
|
||||
return requestAuthentication(connection);
|
||||
} else if (cb->is_master) {
|
||||
#if BLE_ROLE_CENTRAL
|
||||
return requestPairing(connection);
|
||||
#else
|
||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||
#endif
|
||||
} else {
|
||||
#if BLE_ROLE_PERIPHERAL
|
||||
return slave_security_request(connection);
|
||||
#else
|
||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // BLE_FEATURE_SIGNING
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Privacy
|
||||
|
@ -780,9 +803,17 @@ ble_error_t SecurityManager::requestAuthentication(connection_handle_t connectio
|
|||
} else {
|
||||
cb->mitm_requested = true;
|
||||
if (cb->is_master) {
|
||||
#if BLE_ROLE_CENTRAL
|
||||
return requestPairing(connection);
|
||||
#else
|
||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||
#endif
|
||||
} else {
|
||||
#if BLE_ROLE_PERIPHERAL
|
||||
return slave_security_request(connection);
|
||||
#else
|
||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -811,6 +842,7 @@ ble_error_t SecurityManager::generateOOB(
|
|||
return status;
|
||||
}
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
/* Secure connections. Avoid generating if we're already waiting for it.
|
||||
* If a local random is set to 0 it means we're already calculating. */
|
||||
if (!is_all_zeros(_oob_local_random)) {
|
||||
|
@ -833,6 +865,7 @@ ble_error_t SecurityManager::generateOOB(
|
|||
} else {
|
||||
return BLE_STACK_BUSY;
|
||||
}
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
@ -860,7 +893,7 @@ ble_error_t SecurityManager::setOOBDataUsage(
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
ble_error_t SecurityManager::confirmationEntered(
|
||||
connection_handle_t connection,
|
||||
bool confirmation
|
||||
|
@ -869,7 +902,7 @@ ble_error_t SecurityManager::confirmationEntered(
|
|||
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
|
||||
return _pal.confirmation_entered(connection, confirmation);
|
||||
}
|
||||
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
ble_error_t SecurityManager::passkeyEntered(
|
||||
connection_handle_t connection,
|
||||
|
@ -883,7 +916,7 @@ ble_error_t SecurityManager::passkeyEntered(
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
ble_error_t SecurityManager::sendKeypressNotification(
|
||||
connection_handle_t connection,
|
||||
ble::Keypress_t keypress
|
||||
|
@ -892,6 +925,7 @@ ble_error_t SecurityManager::sendKeypressNotification(
|
|||
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
|
||||
return _pal.send_keypress_notification(connection, keypress);
|
||||
}
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
|
||||
ble_error_t SecurityManager::legacyPairingOobReceived(
|
||||
|
@ -929,7 +963,7 @@ ble_error_t SecurityManager::legacyPairingOobReceived(
|
|||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
ble_error_t SecurityManager::oobReceived(
|
||||
const address_t *address,
|
||||
const oob_lesc_value_t *random,
|
||||
|
@ -946,6 +980,7 @@ ble_error_t SecurityManager::oobReceived(
|
|||
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
}
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Helper functions
|
||||
|
@ -1104,6 +1139,7 @@ ble_error_t SecurityManager::get_random_data(uint8_t *buffer, size_t size)
|
|||
}
|
||||
|
||||
|
||||
#if BLE_ROLE_PERIPHERAL
|
||||
ble_error_t SecurityManager::slave_security_request(connection_handle_t connection)
|
||||
{
|
||||
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
|
||||
|
@ -1115,6 +1151,7 @@ ble_error_t SecurityManager::slave_security_request(connection_handle_t connecti
|
|||
link_authentication.set_mitm(cb->mitm_requested);
|
||||
return _pal.slave_security_request(connection, link_authentication);
|
||||
}
|
||||
#endif // BLE_ROLE_PERIPHERAL
|
||||
|
||||
|
||||
ble_error_t SecurityManager::enable_encryption(connection_handle_t connection)
|
||||
|
@ -1131,6 +1168,7 @@ ble_error_t SecurityManager::enable_encryption(connection_handle_t connection)
|
|||
}
|
||||
|
||||
if (cb->is_master) {
|
||||
#if BLE_ROLE_CENTRAL
|
||||
if (flags->ltk_stored) {
|
||||
_db->get_entry_peer_keys(
|
||||
mbed::callback(this, &SecurityManager::enable_encryption_cb),
|
||||
|
@ -1140,12 +1178,19 @@ ble_error_t SecurityManager::enable_encryption(connection_handle_t connection)
|
|||
} else {
|
||||
return requestPairing(connection);
|
||||
}
|
||||
#else
|
||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||
#endif // BLE_ROLE_CENTRAL
|
||||
} else {
|
||||
#if BLE_ROLE_PERIPHERAL
|
||||
return slave_security_request(connection);
|
||||
#else
|
||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||
#endif // BLE_ROLE_PERIPHERAL
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if BLE_ROLE_CENTRAL
|
||||
void SecurityManager::enable_encryption_cb(
|
||||
SecurityDb::entry_handle_t db_entry,
|
||||
const SecurityEntryKeys_t* entryKeys
|
||||
|
@ -1163,14 +1208,17 @@ void SecurityManager::enable_encryption_cb(
|
|||
}
|
||||
|
||||
if (entryKeys) {
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
if (flags->secure_connections_paired) {
|
||||
_pal.enable_encryption(cb->connection, entryKeys->ltk, flags->ltk_mitm_protected);
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
_pal.enable_encryption(cb->connection, entryKeys->ltk, entryKeys->rand, entryKeys->ediv, flags->ltk_mitm_protected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void SecurityManager::set_ltk_cb(
|
||||
SecurityDb::entry_handle_t db_entry,
|
||||
|
@ -1200,7 +1248,7 @@ void SecurityManager::set_ltk_cb(
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#if BLE_FEATURE_SIGNING
|
||||
void SecurityManager::set_peer_csrk_cb(
|
||||
SecurityDb::entry_handle_t db_entry,
|
||||
const SecurityEntrySigning_t* signing
|
||||
|
@ -1247,7 +1295,7 @@ void SecurityManager::return_csrk_cb(
|
|||
flags->csrk_mitm_protected
|
||||
);
|
||||
}
|
||||
|
||||
#endif // BLE_FEATURE_SIGNING
|
||||
|
||||
void SecurityManager::update_oob_presence(connection_handle_t connection)
|
||||
{
|
||||
|
@ -1410,7 +1458,7 @@ void SecurityManager::on_identity_list_retrieved(
|
|||
// Pairing
|
||||
//
|
||||
|
||||
|
||||
#if BLE_ROLE_PERIPHERAL
|
||||
void SecurityManager::on_pairing_request(
|
||||
connection_handle_t connection,
|
||||
bool use_oob,
|
||||
|
@ -1441,7 +1489,7 @@ void SecurityManager::on_pairing_request(
|
|||
acceptPairingRequest(connection);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // BLE_ROLE_PERIPHERAL
|
||||
|
||||
void SecurityManager::on_pairing_error(
|
||||
connection_handle_t connection,
|
||||
|
@ -1505,7 +1553,7 @@ void SecurityManager::on_valid_mic_timeout(connection_handle_t connection)
|
|||
(void)connection;
|
||||
}
|
||||
|
||||
|
||||
#if BLE_FEATURE_SIGNING
|
||||
void SecurityManager::on_signed_write_received(
|
||||
connection_handle_t connection,
|
||||
sign_count_t sign_counter
|
||||
|
@ -1538,9 +1586,13 @@ void SecurityManager::on_signed_write_verification_failure(
|
|||
if (cb->csrk_failures == 3) {
|
||||
cb->csrk_failures = 0;
|
||||
if (cb->is_master) {
|
||||
#if BLE_ROLE_CENTRAL
|
||||
requestPairing(connection);
|
||||
#endif
|
||||
} else {
|
||||
#if BLE_ROLE_PERIPHERAL
|
||||
slave_security_request(connection);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1552,8 +1604,9 @@ void SecurityManager::on_signed_write()
|
|||
MBED_ASSERT(_db);
|
||||
_db->set_local_sign_counter(_db->get_local_sign_counter() + 1);
|
||||
}
|
||||
#endif // BLE_FEATURE_SIGNING
|
||||
|
||||
|
||||
#if BLE_ROLE_CENTRAL
|
||||
void SecurityManager::on_slave_security_request(
|
||||
connection_handle_t connection,
|
||||
AuthenticationMask authentication
|
||||
|
@ -1589,6 +1642,7 @@ void SecurityManager::on_slave_security_request(
|
|||
enable_encryption(connection);
|
||||
}
|
||||
}
|
||||
#endif // BLE_ROLE_CENTRAL
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Encryption
|
||||
|
@ -1622,7 +1676,9 @@ void SecurityManager::on_link_encryption_result(
|
|||
cb->authenticated = true;
|
||||
cb->encrypted = true;
|
||||
|
||||
} else if (result == link_encryption_t::NOT_ENCRYPTED
|
||||
}
|
||||
#if BLE_ROLE_CENTRAL
|
||||
else if (result == link_encryption_t::NOT_ENCRYPTED
|
||||
&& cb->encryption_requested
|
||||
&& !cb->encryption_failed) {
|
||||
|
||||
|
@ -1633,6 +1689,7 @@ void SecurityManager::on_link_encryption_result(
|
|||
/* don't return an event yet since we are retrying */
|
||||
return;
|
||||
}
|
||||
#endif // BLE_ROLE_CENTRAL
|
||||
|
||||
eventHandler->linkEncryptionResult(connection, result);
|
||||
}
|
||||
|
@ -1662,55 +1719,12 @@ void SecurityManager::on_passkey_display(
|
|||
eventHandler->passkeyDisplay(connection, PasskeyAscii(passkey).value());
|
||||
}
|
||||
|
||||
|
||||
void SecurityManager::on_keypress_notification(
|
||||
connection_handle_t connection,
|
||||
ble::Keypress_t keypress
|
||||
)
|
||||
{
|
||||
set_mitm_performed(connection);
|
||||
eventHandler->keypressNotification(connection, keypress);
|
||||
}
|
||||
|
||||
|
||||
void SecurityManager::on_passkey_request(connection_handle_t connection)
|
||||
{
|
||||
set_mitm_performed(connection);
|
||||
eventHandler->passkeyRequest(connection);
|
||||
}
|
||||
|
||||
|
||||
void SecurityManager::on_confirmation_request(connection_handle_t connection)
|
||||
{
|
||||
set_mitm_performed(connection);
|
||||
eventHandler->confirmationRequest(connection);
|
||||
}
|
||||
|
||||
|
||||
void SecurityManager::on_secure_connections_oob_request(connection_handle_t connection)
|
||||
{
|
||||
set_mitm_performed(connection);
|
||||
|
||||
ControlBlock_t *cb = get_control_block(connection);
|
||||
if (!cb) {
|
||||
return;
|
||||
}
|
||||
|
||||
SecurityDistributionFlags_t* flags = _db->get_distribution_flags(cb->db_entry);
|
||||
if (!flags) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (flags->peer_address == _oob_peer_address) {
|
||||
_pal.secure_connections_oob_request_reply(connection, _oob_local_random, _oob_peer_random, _oob_peer_confirm);
|
||||
/* do not re-use peer OOB */
|
||||
set_all_zeros(_oob_peer_address);
|
||||
} else {
|
||||
_pal.cancel_pairing(connection, pairing_failure_t::OOB_NOT_AVAILABLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SecurityManager::on_legacy_pairing_oob_request(connection_handle_t connection)
|
||||
{
|
||||
MBED_ASSERT(_db);
|
||||
|
@ -1743,6 +1757,44 @@ void SecurityManager::on_legacy_pairing_oob_request(connection_handle_t connecti
|
|||
}
|
||||
}
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
void SecurityManager::on_keypress_notification(
|
||||
connection_handle_t connection,
|
||||
ble::Keypress_t keypress
|
||||
)
|
||||
{
|
||||
set_mitm_performed(connection);
|
||||
eventHandler->keypressNotification(connection, keypress);
|
||||
}
|
||||
|
||||
void SecurityManager::on_confirmation_request(connection_handle_t connection)
|
||||
{
|
||||
set_mitm_performed(connection);
|
||||
eventHandler->confirmationRequest(connection);
|
||||
}
|
||||
|
||||
void SecurityManager::on_secure_connections_oob_request(connection_handle_t connection)
|
||||
{
|
||||
set_mitm_performed(connection);
|
||||
|
||||
ControlBlock_t *cb = get_control_block(connection);
|
||||
if (!cb) {
|
||||
return;
|
||||
}
|
||||
|
||||
SecurityDistributionFlags_t* flags = _db->get_distribution_flags(cb->db_entry);
|
||||
if (!flags) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (flags->peer_address == _oob_peer_address) {
|
||||
_pal.secure_connections_oob_request_reply(connection, _oob_local_random, _oob_peer_random, _oob_peer_confirm);
|
||||
/* do not re-use peer OOB */
|
||||
set_all_zeros(_oob_peer_address);
|
||||
} else {
|
||||
_pal.cancel_pairing(connection, pairing_failure_t::OOB_NOT_AVAILABLE);
|
||||
}
|
||||
}
|
||||
|
||||
void SecurityManager::on_secure_connections_oob_generated(
|
||||
const oob_lesc_value_t &random,
|
||||
|
@ -1752,12 +1804,13 @@ void SecurityManager::on_secure_connections_oob_generated(
|
|||
eventHandler->oobGenerated(&_oob_local_address, &random, &confirm);
|
||||
_oob_local_random = random;
|
||||
}
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Keys
|
||||
//
|
||||
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
void SecurityManager::on_secure_connections_ltk_generated(
|
||||
connection_handle_t connection,
|
||||
const ltk_t <k
|
||||
|
@ -1780,6 +1833,7 @@ void SecurityManager::on_secure_connections_ltk_generated(
|
|||
_db->set_entry_peer_ltk(cb->db_entry, ltk);
|
||||
_db->set_entry_local_ltk(cb->db_entry, ltk);
|
||||
}
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
|
||||
void SecurityManager::on_keys_distributed_ltk(
|
||||
|
@ -1895,7 +1949,7 @@ void SecurityManager::on_keys_distributed_bdaddr(
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
#if BLE_FEATURE_SIGNING
|
||||
void SecurityManager::on_keys_distributed_csrk(
|
||||
connection_handle_t connection,
|
||||
const csrk_t &csrk
|
||||
|
@ -1921,6 +1975,7 @@ void SecurityManager::on_keys_distributed_csrk(
|
|||
flags->csrk_mitm_protected
|
||||
);
|
||||
}
|
||||
#endif // BLE_FEATURE_SIGNING
|
||||
|
||||
|
||||
void SecurityManager::on_ltk_request(
|
||||
|
|
|
@ -46,8 +46,11 @@ namespace impl {
|
|||
|
||||
class SecurityManager :
|
||||
public ble::PalSecurityManagerEventHandler,
|
||||
public ble::PalConnectionMonitorEventHandler,
|
||||
public ble::PalSigningMonitorEventHandler {
|
||||
public ble::PalConnectionMonitorEventHandler
|
||||
#if BLE_FEATURE_SIGNING
|
||||
, public ble::PalSigningMonitorEventHandler
|
||||
#endif // BLE_FEATURE_SIGNING
|
||||
{
|
||||
friend class ble::PalConnectionMonitorEventHandler;
|
||||
|
||||
friend PalGenericAccessService;
|
||||
|
@ -94,9 +97,13 @@ public:
|
|||
// Pairing
|
||||
//
|
||||
|
||||
#if BLE_ROLE_CENTRAL
|
||||
ble_error_t requestPairing(ble::connection_handle_t connectionHandle);
|
||||
#endif // BLE_ROLE_CENTRAL
|
||||
|
||||
#if BLE_ROLE_PERIPHERAL
|
||||
ble_error_t acceptPairingRequest(ble::connection_handle_t connectionHandle);
|
||||
#endif // BLE_ROLE_PERIPHERAL
|
||||
|
||||
ble_error_t cancelPairingRequest(ble::connection_handle_t connectionHandle);
|
||||
|
||||
|
@ -107,10 +114,11 @@ public:
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
// Feature support
|
||||
//
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
ble_error_t allowLegacyPairing(bool allow = true);
|
||||
|
||||
ble_error_t getSecureConnectionsSupport(bool *enabled);
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Security settings
|
||||
|
@ -161,26 +169,27 @@ public:
|
|||
|
||||
ble_error_t setOOBDataUsage(ble::connection_handle_t connectionHandle, bool useOOB, bool OOBProvidesMITM = true);
|
||||
|
||||
ble_error_t confirmationEntered(ble::connection_handle_t connectionHandle, bool confirmation);
|
||||
|
||||
ble_error_t passkeyEntered(ble::connection_handle_t connectionHandle, Passkey_t passkey);
|
||||
|
||||
ble_error_t sendKeypressNotification(ble::connection_handle_t connectionHandle, ble::Keypress_t keypress);
|
||||
|
||||
ble_error_t legacyPairingOobReceived(const ble::address_t *address, const ble::oob_tk_t *tk);
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
ble_error_t confirmationEntered(ble::connection_handle_t connectionHandle, bool confirmation);
|
||||
|
||||
ble_error_t sendKeypressNotification(ble::connection_handle_t connectionHandle, ble::Keypress_t keypress);
|
||||
|
||||
ble_error_t oobReceived(
|
||||
const ble::address_t *address,
|
||||
const ble::oob_lesc_value_t *random,
|
||||
const ble::oob_confirm_t *confirm
|
||||
);
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Keys
|
||||
//
|
||||
|
||||
#if BLE_FEATURE_SIGNING
|
||||
ble_error_t getSigningKey(ble::connection_handle_t connectionHandle, bool authenticated);
|
||||
|
||||
#endif // BLE_FEATURE_SIGNING
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Privacy
|
||||
//
|
||||
|
@ -241,6 +250,7 @@ private:
|
|||
// Pairing
|
||||
//
|
||||
|
||||
#if BLE_ROLE_PERIPHERAL
|
||||
/** @copydoc PalSecurityManager::on_pairing_request
|
||||
*/
|
||||
void on_pairing_request(
|
||||
|
@ -250,6 +260,7 @@ private:
|
|||
KeyDistribution initiator_dist,
|
||||
KeyDistribution responder_dist
|
||||
) override;
|
||||
#endif
|
||||
|
||||
/** @copydoc PalSecurityManager::on_pairing_error
|
||||
*/
|
||||
|
@ -280,6 +291,7 @@ private:
|
|||
connection_handle_t connection
|
||||
) override;
|
||||
|
||||
#if BLE_FEATURE_SIGNING
|
||||
/** @copydoc PalSecurityManager::on_signed_write_received
|
||||
*/
|
||||
void on_signed_write_received(
|
||||
|
@ -296,13 +308,16 @@ private:
|
|||
/** @copydoc PalSecurityManager::on_signed_write
|
||||
*/
|
||||
void on_signed_write() override;
|
||||
#endif // BLE_FEATURE_SIGNING
|
||||
|
||||
#if BLE_ROLE_CENTRAL
|
||||
/** @copydoc PalSecurityManager::on_slave_security_request
|
||||
*/
|
||||
void on_slave_security_request(
|
||||
connection_handle_t connection,
|
||||
AuthenticationMask authentication
|
||||
) override;
|
||||
#endif // BLE_ROLE_CENTRAL
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Encryption
|
||||
|
@ -332,12 +347,14 @@ private:
|
|||
passkey_num_t passkey
|
||||
) override;
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
/** @copydoc PalSecurityManager::on_keypress_notification
|
||||
*/
|
||||
void on_keypress_notification(
|
||||
connection_handle_t connection,
|
||||
ble::Keypress_t keypress
|
||||
) override;
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
/** @copydoc PalSecurityManager::on_passkey_request
|
||||
*/
|
||||
|
@ -345,6 +362,7 @@ private:
|
|||
connection_handle_t connection
|
||||
) override;
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
/** @copydoc PalSecurityManager::on_confirmation_request
|
||||
*/
|
||||
void on_confirmation_request(
|
||||
|
@ -356,6 +374,7 @@ private:
|
|||
void on_secure_connections_oob_request(
|
||||
connection_handle_t connection
|
||||
) override;
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
/** @copydoc PalSecurityManager::on_legacy_pairing_oob_request
|
||||
*/
|
||||
|
@ -363,23 +382,27 @@ private:
|
|||
connection_handle_t connection
|
||||
) override;
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
/** @copydoc PalSecurityManager::on_secure_connections_oob_generated
|
||||
*/
|
||||
void on_secure_connections_oob_generated(
|
||||
const oob_lesc_value_t &random,
|
||||
const oob_confirm_t &confirm
|
||||
) override;
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Keys
|
||||
//
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
/** @copydoc PalSecurityManager::on_secure_connections_ltk_generated
|
||||
*/
|
||||
void on_secure_connections_ltk_generated(
|
||||
connection_handle_t connection,
|
||||
const ltk_t <k
|
||||
) override;
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
/** @copydoc PalSecurityManager::on_keys_distributed_ltk
|
||||
*/
|
||||
|
@ -426,12 +449,14 @@ private:
|
|||
const address_t &peer_identity_address
|
||||
) override;
|
||||
|
||||
#if BLE_FEATURE_SIGNING
|
||||
/** @copydoc PalSecurityManager::on_keys_distributed_csrk
|
||||
*/
|
||||
void on_keys_distributed_csrk(
|
||||
connection_handle_t connection,
|
||||
const csrk_t &csrk
|
||||
) override;
|
||||
#endif // BLE_FEATURE_SIGNING
|
||||
|
||||
/** @copydoc PalSecurityManager::on_ltk_requeston_ltk_request
|
||||
*/
|
||||
|
@ -516,9 +541,11 @@ private:
|
|||
size_t size
|
||||
);
|
||||
|
||||
#if BLE_ROLE_PERIPHERAL
|
||||
ble_error_t slave_security_request(
|
||||
connection_handle_t connection
|
||||
);
|
||||
#endif
|
||||
|
||||
ble_error_t enable_encryption(
|
||||
connection_handle_t connection
|
||||
|
@ -534,6 +561,7 @@ private:
|
|||
const SecurityEntryKeys_t *entryKeys
|
||||
);
|
||||
|
||||
#if BLE_FEATURE_SIGNING
|
||||
void return_csrk_cb(
|
||||
SecurityDb::entry_handle_t connection,
|
||||
const SecurityEntrySigning_t *signing
|
||||
|
@ -543,6 +571,7 @@ private:
|
|||
SecurityDb::entry_handle_t connection,
|
||||
const SecurityEntrySigning_t *signing
|
||||
);
|
||||
#endif
|
||||
|
||||
void update_oob_presence(
|
||||
connection_handle_t connection
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
) = 0;
|
||||
#endif // BLE_FEATURE_PHY_MANAGEMENT
|
||||
|
||||
#if BLE_FEATURE_CONNECTABLE
|
||||
/**
|
||||
* @copydoc PalGap::EventHandler::onDataLengthChange
|
||||
*/
|
||||
|
@ -51,6 +52,7 @@ public:
|
|||
uint16_t tx_size,
|
||||
uint16_t rx_size
|
||||
) = 0;
|
||||
#endif
|
||||
|
||||
#if BLE_FEATURE_PHY_MANAGEMENT
|
||||
/**
|
||||
|
@ -183,6 +185,7 @@ public:
|
|||
*/
|
||||
virtual void on_legacy_advertising_stopped() = 0;
|
||||
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
/**
|
||||
* Called when extended advertising has been started.
|
||||
*/
|
||||
|
@ -213,6 +216,7 @@ public:
|
|||
connection_peer_address_type_t scanner_address_type,
|
||||
const address_t &address
|
||||
) = 0;
|
||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
#endif // BLE_ROLE_BROADCASTER
|
||||
|
||||
#if BLE_FEATURE_CONNECTABLE
|
||||
|
@ -302,6 +306,8 @@ public:
|
|||
*/
|
||||
virtual ble_error_t set_random_address(const address_t &address) = 0;
|
||||
|
||||
#if BLE_ROLE_BROADCASTER
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
/**
|
||||
* Set the random device address used by an advertising set.
|
||||
*
|
||||
|
@ -326,6 +332,7 @@ public:
|
|||
advertising_handle_t advertising_handle,
|
||||
const address_t &address
|
||||
) = 0;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Set the advertising parameters which will be used during the advertising
|
||||
|
@ -474,6 +481,7 @@ public:
|
|||
) = 0;
|
||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
|
||||
#if BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
/**
|
||||
* Configure periodic advertising parameters of an advertising set.
|
||||
*
|
||||
|
@ -506,6 +514,7 @@ public:
|
|||
periodic_advertising_interval_t periodic_advertising_max,
|
||||
bool advertise_power
|
||||
) = 0;
|
||||
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
|
||||
/**
|
||||
* Set the data sends in advertising packet. If the advertising is
|
||||
|
@ -529,6 +538,7 @@ public:
|
|||
const advertising_data_t &advertising_data
|
||||
) = 0;
|
||||
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
/**
|
||||
* Set data in advertising PDUs.
|
||||
*
|
||||
|
@ -567,7 +577,9 @@ public:
|
|||
uint8_t advertising_data_size,
|
||||
const uint8_t *advertising_data
|
||||
) = 0;
|
||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
|
||||
#if BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
/**
|
||||
* Set the data used in periodic advertising PDUs.
|
||||
*
|
||||
|
@ -599,6 +611,7 @@ public:
|
|||
uint8_t advertising_data_size,
|
||||
const uint8_t *advertising_data
|
||||
) = 0;
|
||||
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
|
||||
/**
|
||||
* Set the data sends in scan response packets. If the advertising is
|
||||
|
@ -622,6 +635,7 @@ public:
|
|||
const advertising_data_t &scan_response_data
|
||||
) = 0;
|
||||
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
/**
|
||||
* Set the data sends in extended scan response packets. If the advertising
|
||||
* is currently enabled, the data shall be used when a new extended scan
|
||||
|
@ -654,6 +668,7 @@ public:
|
|||
uint8_t scan_response_data_size,
|
||||
const uint8_t *scan_response_data
|
||||
) = 0;
|
||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
|
||||
/**
|
||||
* Start or stop advertising.
|
||||
|
@ -697,6 +712,7 @@ public:
|
|||
*/
|
||||
virtual ble_error_t advertising_enable(bool enable) = 0;
|
||||
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
/**
|
||||
* Start of stop advertising of extended advertising sets.
|
||||
*
|
||||
|
@ -739,7 +755,9 @@ public:
|
|||
const uint16_t *durations,
|
||||
const uint8_t *max_extended_advertising_events
|
||||
) = 0;
|
||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
|
||||
#if BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
/**
|
||||
* Enable or disable periodic advertising of an advertising set.
|
||||
*
|
||||
|
@ -759,6 +777,7 @@ public:
|
|||
bool enable,
|
||||
advertising_handle_t advertising_handle
|
||||
) = 0;
|
||||
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
|
||||
/**
|
||||
* Query the maximum data length the controller supports in an advertising
|
||||
|
@ -801,6 +820,7 @@ public:
|
|||
*/
|
||||
virtual uint8_t get_max_number_of_advertising_sets() = 0;
|
||||
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
/**
|
||||
* Remove an advertising set from the controller.
|
||||
*
|
||||
|
@ -835,8 +855,10 @@ public:
|
|||
* command.
|
||||
*/
|
||||
virtual ble_error_t clear_advertising_sets() = 0;
|
||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
#endif // BLE_ROLE_BROADCASTER
|
||||
|
||||
|
||||
#if BLE_ROLE_OBSERVER
|
||||
/**
|
||||
* Set the parameter of the scan process.
|
||||
*
|
||||
|
@ -872,6 +894,7 @@ public:
|
|||
scanning_filter_policy_t filter_policy
|
||||
) = 0;
|
||||
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
/**
|
||||
* Set extended scan parameters to be used on advertising channels.
|
||||
*
|
||||
|
@ -908,6 +931,7 @@ public:
|
|||
const uint16_t *scan_interval,
|
||||
const uint16_t *scan_window
|
||||
) = 0;
|
||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
|
||||
/**
|
||||
* Start/stop scanning process.
|
||||
|
@ -935,6 +959,7 @@ public:
|
|||
bool filter_duplicates
|
||||
) = 0;
|
||||
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
/**
|
||||
* Enable or disable extended scanning.
|
||||
*
|
||||
|
@ -962,7 +987,9 @@ public:
|
|||
uint16_t duration,
|
||||
uint16_t period
|
||||
) = 0;
|
||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
|
||||
#if BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
/**
|
||||
* Synchronize an observer with a periodic advertising broadcaster.
|
||||
*
|
||||
|
@ -1107,7 +1134,10 @@ public:
|
|||
* @note We (wrongfully) assume that value doesn't change over time.
|
||||
*/
|
||||
virtual uint8_t read_periodic_advertiser_list_size() = 0;
|
||||
#endif // BLE_FEATURE_PERIODIC_ADVERTISING
|
||||
#endif // BLE_ROLE_OBSERVER
|
||||
|
||||
#if BLE_ROLE_CENTRAL
|
||||
/**
|
||||
* Create a new le connection to a connectable advertiser.
|
||||
*
|
||||
|
@ -1194,6 +1224,7 @@ public:
|
|||
uint16_t maximum_connection_event_length
|
||||
) = 0;
|
||||
|
||||
#if BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
/**
|
||||
* Create a new le connection to a connectable advertiser.
|
||||
*
|
||||
|
@ -1286,6 +1317,7 @@ public:
|
|||
const uint16_t *minimum_connection_event_lengths,
|
||||
const uint16_t *maximum_connection_event_lengths
|
||||
) = 0;
|
||||
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
|
||||
|
||||
/**
|
||||
* Cancel the ongoing connection creation process.
|
||||
|
@ -1297,7 +1329,9 @@ public:
|
|||
* command.
|
||||
*/
|
||||
virtual ble_error_t cancel_connection_creation() = 0;
|
||||
#endif // BLE_ROLE_CENTRAL
|
||||
|
||||
#if BLE_FEATURE_WHITELIST
|
||||
/**
|
||||
* Return the number of total whitelist entries that can be stored in the
|
||||
* le subsystem.
|
||||
|
@ -1368,7 +1402,9 @@ public:
|
|||
whitelist_address_type_t address_type,
|
||||
address_t address
|
||||
) = 0;
|
||||
#endif // BLE_FEATURE_WHITELIST
|
||||
|
||||
#if BLE_FEATURE_CONNECTABLE
|
||||
/**
|
||||
* Start a connection update procedure.
|
||||
*
|
||||
|
@ -1543,6 +1579,7 @@ public:
|
|||
connection_handle_t connection,
|
||||
local_disconnection_reason_t disconnection_reason
|
||||
) = 0;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Checked support for a feature in the link controller.
|
||||
|
@ -1554,6 +1591,7 @@ public:
|
|||
controller_supported_features_t feature
|
||||
) = 0;
|
||||
|
||||
#if BLE_FEATURE_PHY_MANAGEMENT
|
||||
/**
|
||||
* @see PalGap::readPhy
|
||||
*/
|
||||
|
@ -1576,6 +1614,7 @@ public:
|
|||
const phy_set_t &rx_phys,
|
||||
coded_symbol_per_bit_t coded_symbol
|
||||
) = 0;
|
||||
#endif // BLE_FEATURE_PHY_MANAGEMENT
|
||||
|
||||
/**
|
||||
* Register a callback which will handle PalGap events.
|
||||
|
|
|
@ -212,6 +212,7 @@ public:
|
|||
// Pairing
|
||||
//
|
||||
|
||||
#if BLE_ROLE_PERIPHERAL
|
||||
/**
|
||||
* Request pairing. This is called on the slave in response to a request from the master.
|
||||
* Upper layer shall either send a pairing response (send_pairing_response)
|
||||
|
@ -230,6 +231,7 @@ public:
|
|||
KeyDistribution initiator_dist,
|
||||
KeyDistribution responder_dist
|
||||
) = 0;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Indicate that the pairing has failed.
|
||||
|
@ -277,6 +279,7 @@ public:
|
|||
connection_handle_t connection
|
||||
) = 0;
|
||||
|
||||
#if BLE_ROLE_CENTRAL
|
||||
/**
|
||||
* Ask the stack to evaluate the security request received from the slave.
|
||||
* This might result in the stack enabling encryption, or pairing/re-pairing.
|
||||
|
@ -288,6 +291,7 @@ public:
|
|||
connection_handle_t connection,
|
||||
AuthenticationMask authentication
|
||||
) = 0;
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Encryption
|
||||
|
@ -330,6 +334,7 @@ public:
|
|||
passkey_num_t passkey
|
||||
) = 0;
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
/**
|
||||
* Indicate that user confirmation is required to confirm matching
|
||||
* passkeys displayed on devices.
|
||||
|
@ -340,6 +345,7 @@ public:
|
|||
virtual void on_confirmation_request(
|
||||
connection_handle_t connection
|
||||
) = 0;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Request the passkey entered during pairing.
|
||||
|
@ -352,6 +358,7 @@ public:
|
|||
connection_handle_t connection
|
||||
) = 0;
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
/**
|
||||
* Indicate that a key has been pressed by the peer.
|
||||
*
|
||||
|
@ -374,6 +381,7 @@ public:
|
|||
virtual void on_secure_connections_oob_request(
|
||||
connection_handle_t connection
|
||||
) = 0;
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
/**
|
||||
* Request OOB data from the user application.
|
||||
|
@ -386,6 +394,7 @@ public:
|
|||
connection_handle_t connection
|
||||
) = 0;
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
/**
|
||||
* Send OOB data to the application for transport to the peer.
|
||||
*
|
||||
|
@ -399,11 +408,13 @@ public:
|
|||
const oob_lesc_value_t &random,
|
||||
const oob_confirm_t &confirm
|
||||
) = 0;
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Keys
|
||||
//
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
/**
|
||||
* Store the results of key generation of the stage 2 of secure connections pairing
|
||||
* @see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part H - 2.3.5.6.5
|
||||
|
@ -415,6 +426,7 @@ public:
|
|||
connection_handle_t connection,
|
||||
const ltk_t <k
|
||||
) = 0;
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
/**
|
||||
* Store the results of key distribution after LTK has been received.
|
||||
|
@ -491,6 +503,7 @@ public:
|
|||
const address_t &peer_identity_address
|
||||
) = 0;
|
||||
|
||||
#if BLE_FEATURE_SIGNING
|
||||
/**
|
||||
* Store the peer's CSRK after it has been distributed.
|
||||
*
|
||||
|
@ -501,6 +514,7 @@ public:
|
|||
connection_handle_t connection,
|
||||
const csrk_t &csrk
|
||||
) = 0;
|
||||
#endif // BLE_FEATURE_SIGNING
|
||||
|
||||
/**
|
||||
* Request the LTK since the peer is asking us to encrypt the link. We need to
|
||||
|
@ -563,6 +577,7 @@ public:
|
|||
// Pairing
|
||||
//
|
||||
|
||||
#if BLE_ROLE_CENTRAL
|
||||
/**
|
||||
* Send a pairing request to a slave.
|
||||
*
|
||||
|
@ -581,7 +596,9 @@ public:
|
|||
KeyDistribution initiator_dist,
|
||||
KeyDistribution responder_dist
|
||||
) = 0;
|
||||
#endif // BLE_ROLE_CENTRAL
|
||||
|
||||
#if BLE_ROLE_PERIPHERAL
|
||||
/**
|
||||
* Send a pairing response to a master.
|
||||
*
|
||||
|
@ -600,6 +617,7 @@ public:
|
|||
KeyDistribution initiator_dist,
|
||||
KeyDistribution responder_dist
|
||||
) = 0;
|
||||
#endif // BLE_ROLE_PERIPHERAL
|
||||
|
||||
/**
|
||||
* Cancel an ongoing pairing.
|
||||
|
@ -686,6 +704,7 @@ public:
|
|||
uint8_t max_encryption_key_size
|
||||
) = 0;
|
||||
|
||||
#if BLE_ROLE_PERIPHERAL
|
||||
/**
|
||||
* Request change of security level from the master. This is called by the slave when
|
||||
* it needs to elevate the security level as it can't change it itself. This will be
|
||||
|
@ -700,11 +719,13 @@ public:
|
|||
connection_handle_t connection,
|
||||
AuthenticationMask authentication
|
||||
) = 0;
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Encryption
|
||||
//
|
||||
|
||||
#if BLE_ROLE_CENTRAL
|
||||
/**
|
||||
* Enabled encryption using the LTK given. The EDIV and RAND will be sent to the peer and
|
||||
* used to identify the LTK. This is called by the master. This will refresh the key if
|
||||
|
@ -725,6 +746,7 @@ public:
|
|||
bool mitm
|
||||
) = 0;
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
/**
|
||||
* Enabled encryption using the LTK given on a connection established with secure
|
||||
* connections pairing.
|
||||
|
@ -739,6 +761,8 @@ public:
|
|||
const ltk_t <k,
|
||||
bool mitm
|
||||
) = 0;
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
#endif // BLE_ROLE_CENTRAL
|
||||
|
||||
/**
|
||||
* Encrypt data with a given key. This uses the facility on the controller to
|
||||
|
@ -804,6 +828,7 @@ public:
|
|||
const address_t &address, bool public_address
|
||||
) = 0;
|
||||
|
||||
#if BLE_FEATURE_SIGNING
|
||||
/**
|
||||
* Set the local CSRK.
|
||||
*
|
||||
|
@ -833,6 +858,7 @@ public:
|
|||
) = 0;
|
||||
|
||||
virtual ble_error_t remove_peer_csrk(connection_handle_t connection) = 0;
|
||||
#endif // BLE_FEATURE_SIGNING
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Authentication
|
||||
|
@ -887,6 +913,7 @@ public:
|
|||
passkey_num_t passkey
|
||||
) = 0;
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
/**
|
||||
* Reply to a Secure Connections oob data request received from the EventHandler.
|
||||
*
|
||||
|
@ -903,6 +930,7 @@ public:
|
|||
const oob_lesc_value_t &peer_random,
|
||||
const oob_confirm_t &peer_confirm
|
||||
) = 0;
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
/**
|
||||
* Reply to a legacy pairing oob data request received from the EventHandler.
|
||||
|
@ -916,6 +944,7 @@ public:
|
|||
const oob_tk_t &oob_data
|
||||
) = 0;
|
||||
|
||||
#if BLE_FEATURE_SECURE_CONNECTIONS
|
||||
/**
|
||||
* Notify the stack that the user has confirmed the values during numerical
|
||||
* comparison stage of pairing.
|
||||
|
@ -942,11 +971,13 @@ public:
|
|||
ble::Keypress_t keypress
|
||||
) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Generate local OOB data to be sent to the application which sends it to the peer.
|
||||
* @return BLE_ERROR_NONE On success, else an error code indicating reason for failure
|
||||
*/
|
||||
virtual ble_error_t generate_secure_connections_oob() = 0;
|
||||
#endif // BLE_FEATURE_SECURE_CONNECTIONS
|
||||
|
||||
/* Entry points for the underlying stack to report events back to the user. */
|
||||
|
||||
|
|
Loading…
Reference in New Issue