mirror of https://github.com/ARMmbed/mbed-os.git
braces on newlines
parent
8bdd6bca93
commit
6aac3acefb
|
|
@ -156,7 +156,8 @@ struct attribute_handle_range_t {
|
|||
static inline attribute_handle_range_t attribute_handle_range(
|
||||
attribute_handle_t begin,
|
||||
attribute_handle_t end
|
||||
) {
|
||||
)
|
||||
{
|
||||
attribute_handle_range_t result = {
|
||||
begin,
|
||||
end
|
||||
|
|
|
|||
|
|
@ -351,7 +351,8 @@ template<typename T, typename ContextType>
|
|||
FunctionPointerWithContext<ContextType> makeFunctionPointer(
|
||||
T *object,
|
||||
void (T::*member)(ContextType context)
|
||||
) {
|
||||
)
|
||||
{
|
||||
return FunctionPointerWithContext<ContextType>(object, member);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@ ble_error_t PalAttClient::exchange_mtu_request(connection_handle_t connection)
|
|||
ble_error_t PalAttClient::get_mtu_size(
|
||||
connection_handle_t connection_handle,
|
||||
uint16_t &mtu_size
|
||||
) {
|
||||
)
|
||||
{
|
||||
mtu_size = AttGetMtu(connection_handle);
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
|
@ -58,7 +59,8 @@ ble_error_t PalAttClient::get_mtu_size(
|
|||
ble_error_t PalAttClient::find_information_request(
|
||||
connection_handle_t connection_handle,
|
||||
attribute_handle_range_t discovery_range
|
||||
) {
|
||||
)
|
||||
{
|
||||
AttcFindInfoReq(
|
||||
connection_handle,
|
||||
discovery_range.begin,
|
||||
|
|
@ -76,7 +78,8 @@ ble_error_t PalAttClient::find_by_type_value_request(
|
|||
attribute_handle_range_t discovery_range,
|
||||
uint16_t type,
|
||||
const Span<const uint8_t> &value
|
||||
) {
|
||||
)
|
||||
{
|
||||
AttcFindByTypeValueReq(
|
||||
connection_handle,
|
||||
discovery_range.begin,
|
||||
|
|
@ -96,7 +99,8 @@ ble_error_t PalAttClient::read_by_type_request(
|
|||
connection_handle_t connection_handle,
|
||||
attribute_handle_range_t read_range,
|
||||
const UUID &type
|
||||
) {
|
||||
)
|
||||
{
|
||||
AttcReadByTypeReq(
|
||||
connection_handle,
|
||||
read_range.begin,
|
||||
|
|
@ -114,7 +118,8 @@ ble_error_t PalAttClient::read_by_type_request(
|
|||
ble_error_t PalAttClient::read_request(
|
||||
connection_handle_t connection_handle,
|
||||
attribute_handle_t attribute_handle
|
||||
) {
|
||||
)
|
||||
{
|
||||
AttcReadReq(connection_handle, attribute_handle);
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
|
@ -126,7 +131,8 @@ ble_error_t PalAttClient::read_blob_request(
|
|||
connection_handle_t connection_handle,
|
||||
attribute_handle_t attribute_handle,
|
||||
uint16_t offset
|
||||
) {
|
||||
)
|
||||
{
|
||||
AttcReadLongReq(
|
||||
connection_handle,
|
||||
attribute_handle,
|
||||
|
|
@ -142,7 +148,8 @@ ble_error_t PalAttClient::read_blob_request(
|
|||
ble_error_t PalAttClient::read_multiple_request(
|
||||
connection_handle_t connection_handle,
|
||||
const Span<const attribute_handle_t> &attribute_handles
|
||||
) {
|
||||
)
|
||||
{
|
||||
AttcReadMultipleReq(
|
||||
connection_handle,
|
||||
attribute_handles.size(),
|
||||
|
|
@ -158,7 +165,8 @@ ble_error_t PalAttClient::read_by_group_type_request(
|
|||
connection_handle_t connection_handle,
|
||||
attribute_handle_range_t read_range,
|
||||
const UUID &group_type
|
||||
) {
|
||||
)
|
||||
{
|
||||
AttcReadByGroupTypeReq(
|
||||
connection_handle,
|
||||
read_range.begin,
|
||||
|
|
@ -177,7 +185,8 @@ ble_error_t PalAttClient::write_request(
|
|||
connection_handle_t connection_handle,
|
||||
attribute_handle_t attribute_handle,
|
||||
const Span<const uint8_t> &value
|
||||
) {
|
||||
)
|
||||
{
|
||||
AttcWriteReq(
|
||||
connection_handle,
|
||||
attribute_handle,
|
||||
|
|
@ -194,7 +203,8 @@ ble_error_t PalAttClient::write_command(
|
|||
connection_handle_t connection_handle,
|
||||
attribute_handle_t attribute_handle,
|
||||
const Span<const uint8_t> &value
|
||||
) {
|
||||
)
|
||||
{
|
||||
AttcWriteCmd(
|
||||
connection_handle,
|
||||
attribute_handle,
|
||||
|
|
@ -211,7 +221,8 @@ ble_error_t PalAttClient::signed_write_command(
|
|||
connection_handle_t connection_handle,
|
||||
attribute_handle_t attribute_handle,
|
||||
const Span<const uint8_t> &value
|
||||
) {
|
||||
)
|
||||
{
|
||||
AttcSignedWriteCmd(
|
||||
connection_handle,
|
||||
attribute_handle,
|
||||
|
|
@ -231,7 +242,8 @@ ble_error_t PalAttClient::signed_write_command(
|
|||
*/
|
||||
void PalAttClient::set_sign_counter(
|
||||
sign_count_t sign_counter
|
||||
) {
|
||||
)
|
||||
{
|
||||
_local_sign_counter = sign_counter;
|
||||
}
|
||||
|
||||
|
|
@ -243,7 +255,8 @@ ble_error_t PalAttClient::prepare_write_request(
|
|||
attribute_handle_t attribute_handle,
|
||||
uint16_t offset,
|
||||
const Span<const uint8_t> &value
|
||||
) {
|
||||
)
|
||||
{
|
||||
AttcPrepareWriteReq(
|
||||
connection_handle,
|
||||
attribute_handle,
|
||||
|
|
@ -262,7 +275,8 @@ ble_error_t PalAttClient::prepare_write_request(
|
|||
ble_error_t PalAttClient::execute_write_request(
|
||||
connection_handle_t connection_handle,
|
||||
bool execute
|
||||
) {
|
||||
)
|
||||
{
|
||||
AttcExecuteWriteReq(
|
||||
connection_handle,
|
||||
execute
|
||||
|
|
@ -295,13 +309,15 @@ PalAttClient &PalAttClient::get_client()
|
|||
|
||||
void PalAttClient::when_server_message_received(
|
||||
mbed::Callback<void(connection_handle_t, const AttServerMessage &)> cb
|
||||
) {
|
||||
)
|
||||
{
|
||||
_server_message_cb = cb;
|
||||
}
|
||||
|
||||
void PalAttClient::when_transaction_timeout(
|
||||
mbed::Callback<void(connection_handle_t)> cb
|
||||
) {
|
||||
)
|
||||
{
|
||||
_transaction_timeout_cb = cb;
|
||||
}
|
||||
|
||||
|
|
@ -337,7 +353,8 @@ bool PalAttClient::timeout_event_handler(const attEvt_t *event)
|
|||
template<typename ResultType>
|
||||
void PalAttClient::generated_handler(
|
||||
const attEvt_t *event, ResultType (*convert)(const attEvt_t *)
|
||||
) {
|
||||
)
|
||||
{
|
||||
get_client().on_server_event(
|
||||
event->hdr.param,
|
||||
convert(event)
|
||||
|
|
@ -347,7 +364,8 @@ void PalAttClient::generated_handler(
|
|||
void PalAttClient::on_server_event(
|
||||
connection_handle_t connection_handle,
|
||||
const AttServerMessage &server_message
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (_server_message_cb) {
|
||||
_server_message_cb(connection_handle, server_message);
|
||||
}
|
||||
|
|
@ -363,7 +381,8 @@ void PalAttClient::on_server_event(
|
|||
*/
|
||||
void PalAttClient::on_transaction_timeout(
|
||||
connection_handle_t connection_handle
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (_transaction_timeout_cb) {
|
||||
_transaction_timeout_cb(connection_handle);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,8 @@ ble_error_t PalGattClient::exchange_mtu(connection_handle_t connection)
|
|||
ble_error_t PalGattClient::get_mtu_size(
|
||||
connection_handle_t connection_handle,
|
||||
uint16_t& mtu_size
|
||||
) {
|
||||
)
|
||||
{
|
||||
return _client.get_mtu_size(connection_handle, mtu_size);
|
||||
}
|
||||
|
||||
|
|
@ -51,7 +52,8 @@ ble_error_t PalGattClient::get_mtu_size(
|
|||
ble_error_t PalGattClient::discover_primary_service(
|
||||
connection_handle_t connection,
|
||||
attribute_handle_t discovery_range_begining
|
||||
) {
|
||||
)
|
||||
{
|
||||
return _client.read_by_group_type_request(
|
||||
connection,
|
||||
attribute_handle_range(discovery_range_begining, END_ATTRIBUTE_HANDLE),
|
||||
|
|
@ -64,7 +66,8 @@ ble_error_t PalGattClient::discover_primary_service_by_service_uuid(
|
|||
connection_handle_t connection_handle,
|
||||
attribute_handle_t discovery_range_begining,
|
||||
const UUID& uuid
|
||||
) {
|
||||
)
|
||||
{
|
||||
return _client.find_by_type_value_request(
|
||||
connection_handle,
|
||||
attribute_handle_range(discovery_range_begining, END_ATTRIBUTE_HANDLE),
|
||||
|
|
@ -80,7 +83,8 @@ ble_error_t PalGattClient::discover_primary_service_by_service_uuid(
|
|||
ble_error_t PalGattClient::find_included_service(
|
||||
connection_handle_t connection_handle,
|
||||
attribute_handle_range_t service_range
|
||||
) {
|
||||
)
|
||||
{
|
||||
return _client.read_by_type_request(
|
||||
connection_handle,
|
||||
service_range,
|
||||
|
|
@ -92,7 +96,8 @@ ble_error_t PalGattClient::find_included_service(
|
|||
ble_error_t PalGattClient::discover_characteristics_of_a_service(
|
||||
connection_handle_t connection_handle,
|
||||
attribute_handle_range_t discovery_range
|
||||
) {
|
||||
)
|
||||
{
|
||||
return _client.read_by_type_request(
|
||||
connection_handle,
|
||||
discovery_range,
|
||||
|
|
@ -104,7 +109,8 @@ ble_error_t PalGattClient::discover_characteristics_of_a_service(
|
|||
ble_error_t PalGattClient::discover_characteristics_descriptors(
|
||||
connection_handle_t connection_handle,
|
||||
attribute_handle_range_t descriptors_discovery_range
|
||||
) {
|
||||
)
|
||||
{
|
||||
return _client.find_information_request(
|
||||
connection_handle,
|
||||
descriptors_discovery_range
|
||||
|
|
@ -115,7 +121,8 @@ ble_error_t PalGattClient::discover_characteristics_descriptors(
|
|||
ble_error_t PalGattClient::read_attribute_value(
|
||||
connection_handle_t connection_handle,
|
||||
attribute_handle_t attribute_handle
|
||||
) {
|
||||
)
|
||||
{
|
||||
return _client.read_request(
|
||||
connection_handle,
|
||||
attribute_handle
|
||||
|
|
@ -127,7 +134,8 @@ ble_error_t PalGattClient::read_using_characteristic_uuid(
|
|||
connection_handle_t connection_handle,
|
||||
attribute_handle_range_t read_range,
|
||||
const UUID& uuid
|
||||
) {
|
||||
)
|
||||
{
|
||||
return _client.read_by_type_request(
|
||||
connection_handle,
|
||||
read_range,
|
||||
|
|
@ -140,7 +148,8 @@ ble_error_t PalGattClient::read_attribute_blob(
|
|||
connection_handle_t connection_handle,
|
||||
attribute_handle_t attribute_handle,
|
||||
uint16_t offset
|
||||
) {
|
||||
)
|
||||
{
|
||||
return _client.read_blob_request(
|
||||
connection_handle,
|
||||
attribute_handle,
|
||||
|
|
@ -152,7 +161,8 @@ ble_error_t PalGattClient::read_attribute_blob(
|
|||
ble_error_t PalGattClient::read_multiple_characteristic_values(
|
||||
connection_handle_t connection_handle,
|
||||
const Span<const attribute_handle_t>& characteristic_value_handles
|
||||
) {
|
||||
)
|
||||
{
|
||||
return _client.read_multiple_request(
|
||||
connection_handle,
|
||||
characteristic_value_handles
|
||||
|
|
@ -164,7 +174,8 @@ ble_error_t PalGattClient::write_without_response(
|
|||
connection_handle_t connection_handle,
|
||||
attribute_handle_t characteristic_value_handle,
|
||||
const Span<const uint8_t>& value
|
||||
) {
|
||||
)
|
||||
{
|
||||
return _client.write_command(
|
||||
connection_handle,
|
||||
characteristic_value_handle,
|
||||
|
|
@ -177,7 +188,8 @@ ble_error_t PalGattClient::signed_write_without_response(
|
|||
connection_handle_t connection_handle,
|
||||
attribute_handle_t characteristic_value_handle,
|
||||
const Span<const uint8_t>& value
|
||||
) {
|
||||
)
|
||||
{
|
||||
return _client.signed_write_command(
|
||||
connection_handle,
|
||||
characteristic_value_handle,
|
||||
|
|
@ -190,7 +202,8 @@ ble_error_t PalGattClient::write_attribute(
|
|||
connection_handle_t connection_handle,
|
||||
attribute_handle_t attribute_handle,
|
||||
const Span<const uint8_t>& value
|
||||
) {
|
||||
)
|
||||
{
|
||||
return _client.write_request(
|
||||
connection_handle,
|
||||
attribute_handle,
|
||||
|
|
@ -204,7 +217,8 @@ ble_error_t PalGattClient::queue_prepare_write(
|
|||
attribute_handle_t characteristic_value_handle,
|
||||
const Span<const uint8_t>& value,
|
||||
uint16_t offset
|
||||
) {
|
||||
)
|
||||
{
|
||||
return _client.prepare_write_request(
|
||||
connection_handle,
|
||||
characteristic_value_handle,
|
||||
|
|
@ -217,7 +231,8 @@ ble_error_t PalGattClient::queue_prepare_write(
|
|||
ble_error_t PalGattClient::execute_write_queue(
|
||||
connection_handle_t connection_handle,
|
||||
bool execute
|
||||
) {
|
||||
)
|
||||
{
|
||||
return _client.execute_write_request(connection_handle, execute);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,8 @@ virtual ble_error_t PalGenericAccessService::get_device_name_length(uint8_t& len
|
|||
|
||||
ble_error_t PalGenericAccessService::get_peripheral_preferred_connection_parameters(
|
||||
ble::Gap::PreferredConnectionParams_t& parameters
|
||||
) {
|
||||
)
|
||||
{
|
||||
#if BLE_FEATURE_GATT_SERVER
|
||||
parameters = gatt_server().getPreferredConnectionParams();
|
||||
return BLE_ERROR_NONE;
|
||||
|
|
@ -102,7 +103,8 @@ ble_error_t PalGenericAccessService::get_peripheral_preferred_connection_paramet
|
|||
|
||||
ble_error_t PalGenericAccessService::set_peripheral_preferred_connection_parameters(
|
||||
const ble::Gap::PreferredConnectionParams_t& parameters
|
||||
) {
|
||||
)
|
||||
{
|
||||
#if BLE_FEATURE_GATT_SERVER
|
||||
gatt_server().setPreferredConnectionParams(parameters);
|
||||
return BLE_ERROR_NONE;
|
||||
|
|
|
|||
|
|
@ -111,7 +111,8 @@ ble_error_t PalSecurityManager::add_device_to_resolving_list(
|
|||
advertising_peer_address_type_t peer_identity_address_type,
|
||||
const address_t &peer_identity_address,
|
||||
const irk_t &peer_irk
|
||||
) {
|
||||
)
|
||||
{
|
||||
if( read_resolving_list_capacity() == 0 )
|
||||
{
|
||||
// If 0 is returned as capacity, it means the controller does not support resolving addresses
|
||||
|
|
@ -128,7 +129,8 @@ ble_error_t PalSecurityManager::add_device_to_resolving_list(
|
|||
ble_error_t PalSecurityManager::remove_device_from_resolving_list(
|
||||
advertising_peer_address_type_t peer_identity_address_type,
|
||||
const address_t& peer_identity_address
|
||||
) {
|
||||
)
|
||||
{
|
||||
if( read_resolving_list_capacity() == 0 )
|
||||
{
|
||||
// If 0 is returned as capacity, it means the controller does not support resolving addresses
|
||||
|
|
@ -165,7 +167,8 @@ ble_error_t PalSecurityManager::clear_resolving_list()
|
|||
|
||||
ble_error_t PalSecurityManager::set_secure_connections_support(
|
||||
bool enabled, bool secure_connections_only
|
||||
) {
|
||||
)
|
||||
{
|
||||
// secure connection support is enabled automatically at the stack level.
|
||||
if (secure_connections_only) {
|
||||
pSmpCfg->auth |= SMP_AUTH_SC_FLAG;
|
||||
|
|
@ -179,7 +182,8 @@ ble_error_t PalSecurityManager::set_secure_connections_support(
|
|||
|
||||
ble_error_t PalSecurityManager::get_secure_connections_support(
|
||||
bool &enabled
|
||||
) {
|
||||
)
|
||||
{
|
||||
// FIXME: should depend of the controller
|
||||
enabled = false;
|
||||
return BLE_ERROR_NONE;
|
||||
|
|
@ -192,7 +196,8 @@ ble_error_t PalSecurityManager::get_secure_connections_support(
|
|||
|
||||
ble_error_t PalSecurityManager::set_authentication_timeout(
|
||||
connection_handle_t connection, uint16_t timeout_in_10ms
|
||||
) {
|
||||
)
|
||||
{
|
||||
DmWriteAuthPayloadTimeout(connection, timeout_in_10ms);
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
|
@ -200,7 +205,8 @@ ble_error_t PalSecurityManager::set_authentication_timeout(
|
|||
|
||||
ble_error_t PalSecurityManager::get_authentication_timeout(
|
||||
connection_handle_t connection, uint16_t &timeout_in_10ms
|
||||
) {
|
||||
)
|
||||
{
|
||||
// FIXME: Is it usefull to add dynamic timeout management for all connections ?
|
||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -209,7 +215,8 @@ ble_error_t PalSecurityManager::get_authentication_timeout(
|
|||
ble_error_t PalSecurityManager::slave_security_request(
|
||||
connection_handle_t connection,
|
||||
AuthenticationMask authentication
|
||||
) {
|
||||
)
|
||||
{
|
||||
DmSecSlaveReq(connection, authentication.value());
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
|
@ -225,7 +232,8 @@ ble_error_t PalSecurityManager::enable_encryption(
|
|||
const rand_t &rand,
|
||||
const ediv_t &ediv,
|
||||
bool mitm
|
||||
) {
|
||||
)
|
||||
{
|
||||
dmSecLtk_t sec_ltk;
|
||||
memcpy(sec_ltk.key, ltk.data(), ltk.size());
|
||||
memcpy(sec_ltk.rand, rand.data(), rand.size());
|
||||
|
|
@ -245,7 +253,8 @@ ble_error_t PalSecurityManager::enable_encryption(
|
|||
connection_handle_t connection,
|
||||
const ltk_t <k,
|
||||
bool mitm
|
||||
) {
|
||||
)
|
||||
{
|
||||
dmSecLtk_t sec_ltk = { 0 };
|
||||
memcpy(sec_ltk.key, ltk.data(), ltk.size());
|
||||
|
||||
|
|
@ -263,7 +272,8 @@ ble_error_t PalSecurityManager::enable_encryption(
|
|||
ble_error_t PalSecurityManager::encrypt_data(
|
||||
const byte_array_t<16> &key,
|
||||
encryption_block_t &data
|
||||
) {
|
||||
)
|
||||
{
|
||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
|
@ -274,7 +284,8 @@ ble_error_t PalSecurityManager::encrypt_data(
|
|||
|
||||
ble_error_t PalSecurityManager::set_private_address_timeout(
|
||||
uint16_t timeout_in_seconds
|
||||
) {
|
||||
)
|
||||
{
|
||||
DmPrivSetResolvablePrivateAddrTimeout(timeout_in_seconds);
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
|
@ -286,7 +297,8 @@ ble_error_t PalSecurityManager::set_private_address_timeout(
|
|||
ble_error_t PalSecurityManager::get_identity_address(
|
||||
address_t& address,
|
||||
bool& public_address
|
||||
) {
|
||||
)
|
||||
{
|
||||
// On cordio, the public address is hardcoded as the identity address.
|
||||
address = address_t(HciGetBdAddr());
|
||||
public_address = true;
|
||||
|
|
@ -303,7 +315,8 @@ ble_error_t PalSecurityManager::set_ltk(
|
|||
const ltk_t& ltk,
|
||||
bool mitm,
|
||||
bool secure_connections
|
||||
) {
|
||||
)
|
||||
{
|
||||
uint8_t security_level = DM_SEC_LEVEL_NONE;
|
||||
if (secure_connections) {
|
||||
security_level = DM_SEC_LEVEL_ENC_LESC;
|
||||
|
|
@ -325,7 +338,8 @@ ble_error_t PalSecurityManager::set_ltk(
|
|||
|
||||
ble_error_t PalSecurityManager::set_ltk_not_found(
|
||||
connection_handle_t connection
|
||||
) {
|
||||
)
|
||||
{
|
||||
DmSecLtkRsp(
|
||||
connection,
|
||||
/* key found */ false,
|
||||
|
|
@ -348,7 +362,8 @@ ble_error_t PalSecurityManager::set_irk(const irk_t& irk)
|
|||
ble_error_t PalSecurityManager::set_csrk(
|
||||
const csrk_t& csrk,
|
||||
sign_count_t sign_counter
|
||||
) {
|
||||
)
|
||||
{
|
||||
_csrk = csrk;
|
||||
DmSecSetLocalCsrk(_csrk.data());
|
||||
// extra set the sign counter used by the client
|
||||
|
|
@ -363,7 +378,8 @@ ble_error_t PalSecurityManager::set_peer_csrk(
|
|||
const csrk_t &csrk,
|
||||
bool authenticated,
|
||||
sign_count_t sign_counter
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (connection == 0 || connection > DM_CONN_MAX) {
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
|
@ -429,7 +445,8 @@ ble_error_t PalSecurityManager::set_io_capability(io_capability_t io_capability)
|
|||
ble_error_t PalSecurityManager::set_encryption_key_requirements(
|
||||
uint8_t min_encryption_key_size,
|
||||
uint8_t max_encryption_key_size
|
||||
) {
|
||||
)
|
||||
{
|
||||
if ((min_encryption_key_size < 7) || (min_encryption_key_size > 16) ||
|
||||
(min_encryption_key_size > max_encryption_key_size)) {
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
|
|
@ -452,7 +469,8 @@ ble_error_t PalSecurityManager::send_pairing_request(
|
|||
AuthenticationMask authentication_requirements,
|
||||
KeyDistribution initiator_dist,
|
||||
KeyDistribution responder_dist
|
||||
) {
|
||||
)
|
||||
{
|
||||
DmSecPairReq(
|
||||
connection,
|
||||
oob_data_flag,
|
||||
|
|
@ -471,7 +489,8 @@ ble_error_t PalSecurityManager::send_pairing_response(
|
|||
AuthenticationMask authentication_requirements,
|
||||
KeyDistribution initiator_dist,
|
||||
KeyDistribution responder_dist
|
||||
) {
|
||||
)
|
||||
{
|
||||
DmSecPairRsp(
|
||||
connection,
|
||||
oob_data_flag,
|
||||
|
|
@ -486,7 +505,8 @@ ble_error_t PalSecurityManager::send_pairing_response(
|
|||
|
||||
ble_error_t PalSecurityManager::cancel_pairing(
|
||||
connection_handle_t connection, pairing_failure_t reason
|
||||
) {
|
||||
)
|
||||
{
|
||||
DmSecCancelReq(connection, reason.value());
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
|
@ -505,7 +525,8 @@ ble_error_t PalSecurityManager::get_random_data(byte_array_t<8> &random_data)
|
|||
|
||||
ble_error_t PalSecurityManager::passkey_request_reply(
|
||||
connection_handle_t connection, passkey_num_t passkey
|
||||
) {
|
||||
)
|
||||
{
|
||||
DmSecAuthRsp(
|
||||
connection,
|
||||
/* datalength */ 3,
|
||||
|
|
@ -519,7 +540,8 @@ ble_error_t PalSecurityManager::passkey_request_reply(
|
|||
ble_error_t PalSecurityManager::legacy_pairing_oob_request_reply(
|
||||
connection_handle_t connection,
|
||||
const oob_tk_t &oob_data
|
||||
) {
|
||||
)
|
||||
{
|
||||
DmSecAuthRsp(
|
||||
connection,
|
||||
/* data length */16,
|
||||
|
|
@ -532,7 +554,8 @@ ble_error_t PalSecurityManager::legacy_pairing_oob_request_reply(
|
|||
|
||||
ble_error_t PalSecurityManager::confirmation_entered(
|
||||
connection_handle_t connection, bool confirmation
|
||||
) {
|
||||
)
|
||||
{
|
||||
DmSecCompareRsp(connection, confirmation);
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
|
@ -543,7 +566,8 @@ extern "C" void DmSecKeypressReq(dmConnId_t connId, uint8_t keypressType);
|
|||
|
||||
ble_error_t PalSecurityManager::send_keypress_notification(
|
||||
connection_handle_t connection, ble::Keypress_t keypress
|
||||
) {
|
||||
)
|
||||
{
|
||||
DmSecKeypressReq(connection, keypress);
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
|
@ -564,7 +588,8 @@ ble_error_t PalSecurityManager::secure_connections_oob_request_reply(
|
|||
const oob_lesc_value_t &local_random,
|
||||
const oob_lesc_value_t &peer_random,
|
||||
const oob_confirm_t &peer_confirm
|
||||
) {
|
||||
)
|
||||
{
|
||||
dmSecLescOobCfg_t oob_config = { 0 };
|
||||
|
||||
memcpy(oob_config.localRandom, local_random.data(), local_random.size());
|
||||
|
|
@ -1041,7 +1066,8 @@ void PalSecurityManager::cleanup_peer_csrks()
|
|||
}
|
||||
|
||||
void PalSecurityManager::set_event_handler(PalSecurityManagerEventHandler *event_handler
|
||||
) {
|
||||
)
|
||||
{
|
||||
_pal_event_handler = event_handler;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -424,7 +424,8 @@ ble_error_t Gap::getAddress(
|
|||
ble_error_t Gap::getRandomAddressType(
|
||||
const address_t address,
|
||||
ble::random_address_type_t* type
|
||||
) {
|
||||
)
|
||||
{
|
||||
// see section Device address in Bluetooth Link Layer specification
|
||||
// (Vol 6 - Part B)
|
||||
switch (address[5] >> 6) {
|
||||
|
|
|
|||
|
|
@ -976,7 +976,8 @@ ble_error_t GattClient::launchServiceDiscovery(
|
|||
ServiceDiscovery::CharacteristicCallback_t characteristic_callback,
|
||||
const UUID& matching_service_uuid,
|
||||
const UUID& matching_characteristic_uuid
|
||||
) {
|
||||
)
|
||||
{
|
||||
// verify that there is no other procedures going on this connection
|
||||
if (_is_reseting || get_control_block(connection_handle)) {
|
||||
return BLE_ERROR_INVALID_STATE;
|
||||
|
|
@ -1031,7 +1032,8 @@ ble_error_t GattClient::discoverServices(
|
|||
ble::connection_handle_t connectionHandle,
|
||||
ServiceDiscovery::ServiceCallback_t callback,
|
||||
const UUID &matchingServiceUUID
|
||||
) {
|
||||
)
|
||||
{
|
||||
/* We take advantage of the property
|
||||
* that providing nullptr for the characteristic callback results in
|
||||
* characteristic discovery being skipped for each matching
|
||||
|
|
@ -1222,7 +1224,8 @@ ble_error_t GattClient::write(
|
|||
|
||||
void GattClient::onServiceDiscoveryTermination(
|
||||
ServiceDiscovery::TerminationCallback_t callback
|
||||
) {
|
||||
)
|
||||
{
|
||||
_termination_callback = callback;
|
||||
}
|
||||
|
||||
|
|
@ -1231,7 +1234,8 @@ ble_error_t GattClient::discoverCharacteristicDescriptors(
|
|||
const DiscoveredCharacteristic& characteristic,
|
||||
const CharacteristicDescriptorDiscovery::DiscoveryCallback_t& discoveryCallback,
|
||||
const CharacteristicDescriptorDiscovery::TerminationCallback_t& terminationCallback
|
||||
) {
|
||||
)
|
||||
{
|
||||
// verify that there is no other procedures going on this connection
|
||||
if (_is_reseting || get_control_block(characteristic.getConnectionHandle())) {
|
||||
return BLE_ERROR_INVALID_STATE;
|
||||
|
|
@ -1291,7 +1295,8 @@ bool GattClient::isCharacteristicDescriptorDiscoveryActive(
|
|||
|
||||
void GattClient::terminateCharacteristicDescriptorDiscovery(
|
||||
const DiscoveredCharacteristic& characteristic
|
||||
) {
|
||||
)
|
||||
{
|
||||
ProcedureControlBlock* pcb = control_blocks;
|
||||
|
||||
while (pcb) {
|
||||
|
|
@ -1312,7 +1317,8 @@ void GattClient::terminateCharacteristicDescriptorDiscovery(
|
|||
|
||||
ble_error_t GattClient::negotiateAttMtu(
|
||||
connection_handle_t connection
|
||||
) {
|
||||
)
|
||||
{
|
||||
return _pal_client.exchange_mtu(connection);
|
||||
}
|
||||
|
||||
|
|
@ -1343,7 +1349,8 @@ ble_error_t GattClient::reset(void)
|
|||
|
||||
void GattClient::set_signing_event_handler(
|
||||
PalSigningMonitorEventHandler *signing_event_handler
|
||||
) {
|
||||
)
|
||||
{
|
||||
_signing_event_handler = signing_event_handler;
|
||||
}
|
||||
#endif // BLE_FEATURE_SIGNING
|
||||
|
|
@ -1364,7 +1371,8 @@ void GattClient::on_write_command_sent(
|
|||
ble::connection_handle_t connection_handle,
|
||||
ble::attribute_handle_t attribute_handle,
|
||||
uint8_t status
|
||||
) {
|
||||
)
|
||||
{
|
||||
GattWriteCallbackParams response = {
|
||||
connection_handle,
|
||||
attribute_handle,
|
||||
|
|
@ -1389,7 +1397,8 @@ void GattClient::on_termination(connection_handle_t connection_handle)
|
|||
void GattClient::on_server_message_received(
|
||||
connection_handle_t connection_handle,
|
||||
const AttServerMessage& message
|
||||
) {
|
||||
)
|
||||
{
|
||||
switch(message.opcode) {
|
||||
case AttributeOpcode::ERROR_RESPONSE:
|
||||
case AttributeOpcode::EXCHANGE_MTU_RESPONSE:
|
||||
|
|
@ -1421,7 +1430,8 @@ void GattClient::on_server_message_received(
|
|||
void GattClient::on_server_response(
|
||||
connection_handle_t connection,
|
||||
const AttServerMessage& message
|
||||
) {
|
||||
)
|
||||
{
|
||||
ProcedureControlBlock* pcb = get_control_block(connection);
|
||||
if (pcb == nullptr) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -169,7 +169,8 @@ uint16_t GattServer::compute_attributes_count(GattService& service)
|
|||
void GattServer::insert_service_attribute(
|
||||
GattService& service,
|
||||
attsAttr_t *&attribute_it
|
||||
) {
|
||||
)
|
||||
{
|
||||
++currentHandle;
|
||||
const UUID& service_uuid = service.getUUID();
|
||||
|
||||
|
|
@ -191,7 +192,8 @@ void GattServer::insert_service_attribute(
|
|||
ble_error_t GattServer::insert_characteristic(
|
||||
GattCharacteristic *characteristic,
|
||||
attsAttr_t *&attribute_it
|
||||
) {
|
||||
)
|
||||
{
|
||||
bool valid = is_characteristic_valid(characteristic);
|
||||
if (!valid) {
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
|
|
@ -274,7 +276,8 @@ bool GattServer::is_characteristic_valid(GattCharacteristic *characteristic)
|
|||
void GattServer::insert_characteristic_declaration_attribute(
|
||||
GattCharacteristic *characteristic,
|
||||
attsAttr_t *&attribute_it
|
||||
) {
|
||||
)
|
||||
{
|
||||
const UUID& value_uuid = characteristic->getValueAttribute().getUUID();
|
||||
|
||||
// move the current handle to point to the value handle
|
||||
|
|
@ -302,7 +305,8 @@ void GattServer::insert_characteristic_declaration_attribute(
|
|||
ble_error_t GattServer::insert_characteristic_value_attribute(
|
||||
GattCharacteristic *characteristic,
|
||||
attsAttr_t *&attribute_it
|
||||
) {
|
||||
)
|
||||
{
|
||||
GattAttribute &value_attribute = characteristic->getValueAttribute();
|
||||
uint8_t properties = characteristic->getProperties();
|
||||
|
||||
|
|
@ -424,7 +428,8 @@ ble_error_t GattServer::insert_descriptor(
|
|||
GattAttribute* descriptor,
|
||||
attsAttr_t *&attribute_it,
|
||||
bool& cccd_created
|
||||
) {
|
||||
)
|
||||
{
|
||||
uint8_t properties = characteristic->getProperties();
|
||||
|
||||
currentHandle++;
|
||||
|
|
@ -552,7 +557,8 @@ ble_error_t GattServer::insert_descriptor(
|
|||
ble_error_t GattServer::insert_cccd(
|
||||
GattCharacteristic *characteristic,
|
||||
attsAttr_t *&attribute_it
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (cccd_cnt >= MBED_CONF_BLE_API_IMPLEMENTATION_MAX_CCCD_COUNT) {
|
||||
return BLE_ERROR_NO_MEM;
|
||||
}
|
||||
|
|
@ -589,7 +595,8 @@ ble_error_t GattServer::read(
|
|||
GattAttribute::Handle_t att_handle,
|
||||
uint8_t buffer[],
|
||||
uint16_t * buffer_length
|
||||
) {
|
||||
)
|
||||
{
|
||||
uint16_t att_length = 0;
|
||||
uint8_t* att_value = nullptr;
|
||||
|
||||
|
|
@ -611,7 +618,8 @@ ble_error_t GattServer::read(
|
|||
GattAttribute::Handle_t att_handle,
|
||||
uint8_t buffer[],
|
||||
uint16_t *buffer_length
|
||||
) {
|
||||
)
|
||||
{
|
||||
// Check to see if this is a CCCD
|
||||
uint8_t cccd_index;
|
||||
if (get_cccd_index_by_cccd_handle(att_handle, cccd_index)) {
|
||||
|
|
@ -638,7 +646,8 @@ ble_error_t GattServer::write(
|
|||
const uint8_t buffer[],
|
||||
uint16_t len,
|
||||
bool local_only
|
||||
) {
|
||||
)
|
||||
{
|
||||
// Check to see if this is a CCCD, if it is the case update the value for all
|
||||
// connections
|
||||
uint8_t cccd_index;
|
||||
|
|
@ -701,7 +710,8 @@ ble_error_t GattServer::write(
|
|||
const uint8_t buffer[],
|
||||
uint16_t len,
|
||||
bool local_only
|
||||
) {
|
||||
)
|
||||
{
|
||||
// Check to see if this is a CCCD
|
||||
uint8_t cccd_index;
|
||||
if (get_cccd_index_by_cccd_handle(att_handle, cccd_index)) {
|
||||
|
|
@ -748,7 +758,8 @@ ble_error_t GattServer::write(
|
|||
ble_error_t GattServer::areUpdatesEnabled(
|
||||
const GattCharacteristic &characteristic,
|
||||
bool *enabled
|
||||
) {
|
||||
)
|
||||
{
|
||||
for (size_t idx = 0; idx < cccd_cnt; idx++) {
|
||||
if (characteristic.getValueHandle() == cccd_handles[idx]) {
|
||||
for (dmConnId_t conn_id = DM_CONN_MAX; conn_id > DM_CONN_ID_NONE; --conn_id) {
|
||||
|
|
@ -773,7 +784,8 @@ ble_error_t GattServer::areUpdatesEnabled(
|
|||
connection_handle_t connectionHandle,
|
||||
const GattCharacteristic &characteristic,
|
||||
bool *enabled
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (connectionHandle == DM_CONN_ID_NONE) {
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
|
@ -931,7 +943,8 @@ uint8_t GattServer::atts_read_cb(
|
|||
uint8_t operation,
|
||||
uint16_t offset,
|
||||
attsAttr_t *pAttr
|
||||
) {
|
||||
)
|
||||
{
|
||||
GattCharacteristic* auth_char = getInstance().get_auth_char(handle);
|
||||
if (auth_char && auth_char->isReadAuthorizationEnabled()) {
|
||||
GattReadAuthCallbackParams read_auth_params = {
|
||||
|
|
@ -973,7 +986,8 @@ uint8_t GattServer::atts_write_cb(
|
|||
uint16_t len,
|
||||
uint8_t *pValue,
|
||||
attsAttr_t *pAttr
|
||||
) {
|
||||
)
|
||||
{
|
||||
uint8_t err;
|
||||
|
||||
/* TODO: offset is not handled properly */
|
||||
|
|
@ -1301,7 +1315,8 @@ bool GattServer::get_cccd_index_by_value_handle(GattAttribute::Handle_t char_han
|
|||
bool GattServer::is_update_authorized(
|
||||
connection_handle_t connection,
|
||||
GattAttribute::Handle_t value_handle
|
||||
) {
|
||||
)
|
||||
{
|
||||
GattCharacteristic* auth_char = get_auth_char(value_handle);
|
||||
if (!auth_char) {
|
||||
return true;
|
||||
|
|
@ -1377,7 +1392,8 @@ GattServer::GattServer() :
|
|||
|
||||
void GattServer::set_signing_event_handler(
|
||||
PalSigningMonitorEventHandler *signing_event_handler
|
||||
) {
|
||||
)
|
||||
{
|
||||
_signing_event_handler = signing_event_handler;
|
||||
}
|
||||
|
||||
|
|
@ -1416,7 +1432,8 @@ template <typename T>
|
|||
ble_error_t GattServer::onDataRead(
|
||||
T *objPtr,
|
||||
void (T::*memberPtr)(const GattReadCallbackParams *context)
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (!isOnDataReadAvailable()) {
|
||||
return BLE_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -1484,7 +1501,8 @@ void GattServer::handleDataReadEvent(const GattReadCallbackParams *params)
|
|||
void GattServer::handleEvent(
|
||||
GattServerEvents::gattEvent_e type,
|
||||
GattAttribute::Handle_t attributeHandle
|
||||
) {
|
||||
)
|
||||
{
|
||||
switch (type) {
|
||||
case GattServerEvents::GATT_EVENT_UPDATES_ENABLED:
|
||||
if (updatesEnabledCallback) {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,8 @@ ble_error_t SecurityManager::init(
|
|||
const uint8_t* passkey,
|
||||
bool signing,
|
||||
const char* db_path
|
||||
) {
|
||||
)
|
||||
{
|
||||
#if !(BLE_FEATURE_SIGNING)
|
||||
if (signing) {
|
||||
return BLE_ERROR_INVALID_PARAM;
|
||||
|
|
@ -120,7 +121,8 @@ ble_error_t SecurityManager::init(
|
|||
|
||||
ble_error_t SecurityManager::setDatabaseFilepath(
|
||||
const char *db_path
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
|
||||
|
||||
/* operation only allowed with no connections active */
|
||||
|
|
@ -407,7 +409,8 @@ ble_error_t SecurityManager::setDisplayPasskey(const uint8_t* passkey)
|
|||
ble_error_t SecurityManager::setAuthenticationTimeout(
|
||||
connection_handle_t connection,
|
||||
uint32_t timeout_in_ms
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
|
||||
return _pal.set_authentication_timeout(connection, timeout_in_ms / 10);
|
||||
}
|
||||
|
|
@ -416,7 +419,8 @@ ble_error_t SecurityManager::setAuthenticationTimeout(
|
|||
ble_error_t SecurityManager::getAuthenticationTimeout(
|
||||
connection_handle_t connection,
|
||||
uint32_t *timeout_in_ms
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
|
||||
uint16_t timeout_in_10ms;
|
||||
ble_error_t status = _pal.get_authentication_timeout(connection, timeout_in_10ms);
|
||||
|
|
@ -428,7 +432,8 @@ ble_error_t SecurityManager::getAuthenticationTimeout(
|
|||
ble_error_t SecurityManager::setLinkSecurity(
|
||||
connection_handle_t connection,
|
||||
SecurityMode_t securityMode
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
|
||||
ControlBlock_t *cb = get_control_block(connection);
|
||||
if (!cb) {
|
||||
|
|
@ -472,7 +477,8 @@ ble_error_t SecurityManager::setKeypressNotification(bool enabled)
|
|||
ble_error_t SecurityManager::enableSigning(
|
||||
connection_handle_t connection,
|
||||
bool enabled
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
|
||||
ControlBlock_t *cb = get_control_block(connection);
|
||||
if (!cb) {
|
||||
|
|
@ -525,7 +531,8 @@ ble_error_t SecurityManager::setHintFutureRoleReversal(bool enable)
|
|||
ble_error_t SecurityManager::getLinkEncryption(
|
||||
connection_handle_t connection,
|
||||
link_encryption_t *encryption
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
|
||||
ControlBlock_t *cb = get_control_block(connection);
|
||||
if (!cb) {
|
||||
|
|
@ -560,7 +567,8 @@ ble_error_t SecurityManager::getLinkEncryption(
|
|||
ble_error_t SecurityManager::setLinkEncryption(
|
||||
connection_handle_t connection,
|
||||
link_encryption_t encryption
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
|
||||
ControlBlock_t *cb = get_control_block(connection);
|
||||
if (!cb) {
|
||||
|
|
@ -632,7 +640,8 @@ ble_error_t SecurityManager::setLinkEncryption(
|
|||
ble_error_t SecurityManager::getEncryptionKeySize(
|
||||
connection_handle_t connectionHandle,
|
||||
uint8_t *size
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
|
||||
ControlBlock_t *cb = get_control_block(connectionHandle);
|
||||
if (!cb) {
|
||||
|
|
@ -652,7 +661,8 @@ ble_error_t SecurityManager::getEncryptionKeySize(
|
|||
ble_error_t SecurityManager::setEncryptionKeyRequirements(
|
||||
uint8_t minimumByteSize,
|
||||
uint8_t maximumByteSize
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
|
||||
return _pal.set_encryption_key_requirements(minimumByteSize, maximumByteSize);
|
||||
}
|
||||
|
|
@ -749,7 +759,8 @@ ble_error_t SecurityManager::requestAuthentication(connection_handle_t connectio
|
|||
|
||||
ble_error_t SecurityManager::generateOOB(
|
||||
const address_t *address
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
|
||||
/* legacy pairing */
|
||||
ble_error_t status = get_random_data(_oob_temporary_key.data(), 16);
|
||||
|
|
@ -796,7 +807,8 @@ ble_error_t SecurityManager::setOOBDataUsage(
|
|||
connection_handle_t connection,
|
||||
bool useOOB,
|
||||
bool OOBProvidesMITM
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
|
||||
ControlBlock_t *cb = get_control_block(connection);
|
||||
if (!cb) {
|
||||
|
|
@ -817,7 +829,8 @@ ble_error_t SecurityManager::setOOBDataUsage(
|
|||
ble_error_t SecurityManager::confirmationEntered(
|
||||
connection_handle_t connection,
|
||||
bool confirmation
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
|
||||
return _pal.confirmation_entered(connection, confirmation);
|
||||
}
|
||||
|
|
@ -826,7 +839,8 @@ ble_error_t SecurityManager::confirmationEntered(
|
|||
ble_error_t SecurityManager::passkeyEntered(
|
||||
connection_handle_t connection,
|
||||
Passkey_t passkey
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
|
||||
return _pal.passkey_request_reply(
|
||||
connection,
|
||||
|
|
@ -838,7 +852,8 @@ ble_error_t SecurityManager::passkeyEntered(
|
|||
ble_error_t SecurityManager::sendKeypressNotification(
|
||||
connection_handle_t connection,
|
||||
ble::Keypress_t keypress
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
|
||||
return _pal.send_keypress_notification(connection, keypress);
|
||||
}
|
||||
|
|
@ -847,7 +862,8 @@ ble_error_t SecurityManager::sendKeypressNotification(
|
|||
ble_error_t SecurityManager::legacyPairingOobReceived(
|
||||
const address_t *address,
|
||||
const oob_tk_t *tk
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
|
||||
if (address && tk) {
|
||||
ControlBlock_t *cb = get_control_block(*address);
|
||||
|
|
@ -883,7 +899,8 @@ ble_error_t SecurityManager::oobReceived(
|
|||
const address_t *address,
|
||||
const oob_lesc_value_t *random,
|
||||
const oob_confirm_t *confirm
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
|
||||
if (address && random && confirm) {
|
||||
_oob_peer_address = *address;
|
||||
|
|
@ -902,7 +919,8 @@ ble_error_t SecurityManager::oobReceived(
|
|||
|
||||
ble_error_t SecurityManager::init_database(
|
||||
const char *db_path
|
||||
) {
|
||||
)
|
||||
{
|
||||
delete _db;
|
||||
|
||||
#if BLE_SECURITY_DATABASE_FILESYSTEM
|
||||
|
|
@ -1074,7 +1092,8 @@ ble_error_t SecurityManager::enable_encryption(connection_handle_t connection)
|
|||
void SecurityManager::enable_encryption_cb(
|
||||
SecurityDb::entry_handle_t db_entry,
|
||||
const SecurityEntryKeys_t* entryKeys
|
||||
) {
|
||||
)
|
||||
{
|
||||
MBED_ASSERT(_db);
|
||||
ControlBlock_t *cb = get_control_block(db_entry);
|
||||
if (!cb) {
|
||||
|
|
@ -1099,7 +1118,8 @@ void SecurityManager::enable_encryption_cb(
|
|||
void SecurityManager::set_ltk_cb(
|
||||
SecurityDb::entry_handle_t db_entry,
|
||||
const SecurityEntryKeys_t* entryKeys
|
||||
) {
|
||||
)
|
||||
{
|
||||
MBED_ASSERT(_db);
|
||||
ControlBlock_t *cb = get_control_block(db_entry);
|
||||
if (!cb) {
|
||||
|
|
@ -1127,7 +1147,8 @@ void SecurityManager::set_ltk_cb(
|
|||
void SecurityManager::set_peer_csrk_cb(
|
||||
SecurityDb::entry_handle_t db_entry,
|
||||
const SecurityEntrySigning_t* signing
|
||||
) {
|
||||
)
|
||||
{
|
||||
ControlBlock_t *cb = get_control_block(db_entry);
|
||||
if (!cb || !signing) {
|
||||
return;
|
||||
|
|
@ -1150,7 +1171,8 @@ void SecurityManager::set_peer_csrk_cb(
|
|||
void SecurityManager::return_csrk_cb(
|
||||
SecurityDb::entry_handle_t db_entry,
|
||||
const SecurityEntrySigning_t *signing
|
||||
) {
|
||||
)
|
||||
{
|
||||
MBED_ASSERT(_db);
|
||||
ControlBlock_t *cb = get_control_block(db_entry);
|
||||
if (!cb || !signing) {
|
||||
|
|
@ -1220,7 +1242,8 @@ void SecurityManager::on_connected(
|
|||
address_t peer_address,
|
||||
own_address_type_t local_address_type,
|
||||
address_t local_address
|
||||
) {
|
||||
)
|
||||
{
|
||||
#if BLE_FEATURE_SECURITY
|
||||
MBED_ASSERT(_db);
|
||||
ControlBlock_t *cb = acquire_control_block(connection);
|
||||
|
|
@ -1261,7 +1284,8 @@ void SecurityManager::on_connected(
|
|||
void SecurityManager::on_disconnected(
|
||||
connection_handle_t connection,
|
||||
disconnection_reason_t reason
|
||||
) {
|
||||
)
|
||||
{
|
||||
#if BLE_FEATURE_SECURITY
|
||||
MBED_ASSERT(_db);
|
||||
ControlBlock_t *cb = get_control_block(connection);
|
||||
|
|
@ -1281,7 +1305,8 @@ void SecurityManager::on_disconnected(
|
|||
void SecurityManager::on_security_entry_retrieved(
|
||||
SecurityDb::entry_handle_t entry,
|
||||
const SecurityEntryIdentity_t* identity
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (!identity) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -1302,7 +1327,8 @@ void SecurityManager::on_security_entry_retrieved(
|
|||
void SecurityManager::on_identity_list_retrieved(
|
||||
Span<SecurityEntryIdentity_t>& identity_list,
|
||||
size_t count
|
||||
) {
|
||||
)
|
||||
{
|
||||
typedef advertising_peer_address_type_t address_type_t;
|
||||
|
||||
_pal.clear_resolving_list();
|
||||
|
|
@ -1332,7 +1358,8 @@ void SecurityManager::on_pairing_request(
|
|||
AuthenticationMask authentication,
|
||||
KeyDistribution initiator_dist,
|
||||
KeyDistribution responder_dist
|
||||
) {
|
||||
)
|
||||
{
|
||||
/* cancel pairing if secure connection paring is not possible */
|
||||
if (!_legacy_pairing_allowed && !authentication.get_secure_connections()) {
|
||||
cancelPairingRequest(connection);
|
||||
|
|
@ -1360,7 +1387,8 @@ void SecurityManager::on_pairing_request(
|
|||
void SecurityManager::on_pairing_error(
|
||||
connection_handle_t connection,
|
||||
pairing_failure_t error
|
||||
) {
|
||||
)
|
||||
{
|
||||
set_mitm_performed(connection, false);
|
||||
|
||||
eventHandler->pairingResult(
|
||||
|
|
@ -1422,7 +1450,8 @@ void SecurityManager::on_valid_mic_timeout(connection_handle_t connection)
|
|||
void SecurityManager::on_signed_write_received(
|
||||
connection_handle_t connection,
|
||||
sign_count_t sign_counter
|
||||
) {
|
||||
)
|
||||
{
|
||||
MBED_ASSERT(_db);
|
||||
ControlBlock_t *cb = get_control_block(connection);
|
||||
if (!cb) {
|
||||
|
|
@ -1434,7 +1463,8 @@ void SecurityManager::on_signed_write_received(
|
|||
|
||||
void SecurityManager::on_signed_write_verification_failure(
|
||||
connection_handle_t connection
|
||||
) {
|
||||
)
|
||||
{
|
||||
ControlBlock_t *cb = get_control_block(connection);
|
||||
if (!cb) {
|
||||
return;
|
||||
|
|
@ -1468,7 +1498,8 @@ void SecurityManager::on_signed_write()
|
|||
void SecurityManager::on_slave_security_request(
|
||||
connection_handle_t connection,
|
||||
AuthenticationMask authentication
|
||||
) {
|
||||
)
|
||||
{
|
||||
MBED_ASSERT(_db);
|
||||
ControlBlock_t *cb = get_control_block(connection);
|
||||
if (!cb) {
|
||||
|
|
@ -1508,7 +1539,8 @@ void SecurityManager::on_slave_security_request(
|
|||
void SecurityManager::on_link_encryption_result(
|
||||
connection_handle_t connection,
|
||||
link_encryption_t result
|
||||
) {
|
||||
)
|
||||
{
|
||||
|
||||
ControlBlock_t *cb = get_control_block(connection);
|
||||
if (!cb) {
|
||||
|
|
@ -1549,7 +1581,8 @@ void SecurityManager::on_link_encryption_result(
|
|||
|
||||
void SecurityManager::on_link_encryption_request_timed_out(
|
||||
connection_handle_t connection
|
||||
) {
|
||||
)
|
||||
{
|
||||
eventHandler->linkEncryptionResult(
|
||||
connection,
|
||||
link_encryption_t::NOT_ENCRYPTED
|
||||
|
|
@ -1564,7 +1597,8 @@ void SecurityManager::on_link_encryption_request_timed_out(
|
|||
void SecurityManager::on_passkey_display(
|
||||
connection_handle_t connection,
|
||||
passkey_num_t passkey
|
||||
) {
|
||||
)
|
||||
{
|
||||
set_mitm_performed(connection);
|
||||
eventHandler->passkeyDisplay(connection, PasskeyAscii(passkey).value());
|
||||
}
|
||||
|
|
@ -1573,7 +1607,8 @@ void SecurityManager::on_passkey_display(
|
|||
void SecurityManager::on_keypress_notification(
|
||||
connection_handle_t connection,
|
||||
ble::Keypress_t keypress
|
||||
) {
|
||||
)
|
||||
{
|
||||
set_mitm_performed(connection);
|
||||
eventHandler->keypressNotification(connection, keypress);
|
||||
}
|
||||
|
|
@ -1653,7 +1688,8 @@ void SecurityManager::on_legacy_pairing_oob_request(connection_handle_t connecti
|
|||
void SecurityManager::on_secure_connections_oob_generated(
|
||||
const oob_lesc_value_t &random,
|
||||
const oob_confirm_t &confirm
|
||||
) {
|
||||
)
|
||||
{
|
||||
eventHandler->oobGenerated(&_oob_local_address, &random, &confirm);
|
||||
_oob_local_random = random;
|
||||
}
|
||||
|
|
@ -1666,7 +1702,8 @@ void SecurityManager::on_secure_connections_oob_generated(
|
|||
void SecurityManager::on_secure_connections_ltk_generated(
|
||||
connection_handle_t connection,
|
||||
const ltk_t <k
|
||||
) {
|
||||
)
|
||||
{
|
||||
MBED_ASSERT(_db);
|
||||
ControlBlock_t *cb = get_control_block(connection);
|
||||
if (!cb) {
|
||||
|
|
@ -1689,7 +1726,8 @@ void SecurityManager::on_secure_connections_ltk_generated(
|
|||
void SecurityManager::on_keys_distributed_ltk(
|
||||
connection_handle_t connection,
|
||||
const ltk_t <k
|
||||
) {
|
||||
)
|
||||
{
|
||||
MBED_ASSERT(_db);
|
||||
ControlBlock_t *cb = get_control_block(connection);
|
||||
if (!cb) {
|
||||
|
|
@ -1711,7 +1749,8 @@ void SecurityManager::on_keys_distributed_ediv_rand(
|
|||
connection_handle_t connection,
|
||||
const ediv_t &ediv,
|
||||
const rand_t &rand
|
||||
) {
|
||||
)
|
||||
{
|
||||
MBED_ASSERT(_db);
|
||||
ControlBlock_t *cb = get_control_block(connection);
|
||||
if (!cb) {
|
||||
|
|
@ -1725,7 +1764,8 @@ void SecurityManager::on_keys_distributed_ediv_rand(
|
|||
void SecurityManager::on_keys_distributed_local_ltk(
|
||||
connection_handle_t connection,
|
||||
const ltk_t <k
|
||||
) {
|
||||
)
|
||||
{
|
||||
MBED_ASSERT(_db);
|
||||
ControlBlock_t *cb = get_control_block(connection);
|
||||
if (!cb) {
|
||||
|
|
@ -1745,7 +1785,8 @@ void SecurityManager::on_keys_distributed_local_ediv_rand(
|
|||
connection_handle_t connection,
|
||||
const ediv_t &ediv,
|
||||
const rand_t &rand
|
||||
) {
|
||||
)
|
||||
{
|
||||
MBED_ASSERT(_db);
|
||||
ControlBlock_t *cb = get_control_block(connection);
|
||||
if (!cb) {
|
||||
|
|
@ -1759,7 +1800,8 @@ void SecurityManager::on_keys_distributed_local_ediv_rand(
|
|||
void SecurityManager::on_keys_distributed_irk(
|
||||
connection_handle_t connection,
|
||||
const irk_t &irk
|
||||
) {
|
||||
)
|
||||
{
|
||||
MBED_ASSERT(_db);
|
||||
ControlBlock_t *cb = get_control_block(connection);
|
||||
if (!cb) {
|
||||
|
|
@ -1779,7 +1821,8 @@ void SecurityManager::on_keys_distributed_bdaddr(
|
|||
connection_handle_t connection,
|
||||
advertising_peer_address_type_t peer_address_type,
|
||||
const address_t &peer_identity_address
|
||||
) {
|
||||
)
|
||||
{
|
||||
MBED_ASSERT(_db);
|
||||
ControlBlock_t *cb = get_control_block(connection);
|
||||
if (!cb) {
|
||||
|
|
@ -1797,7 +1840,8 @@ void SecurityManager::on_keys_distributed_bdaddr(
|
|||
void SecurityManager::on_keys_distributed_csrk(
|
||||
connection_handle_t connection,
|
||||
const csrk_t &csrk
|
||||
) {
|
||||
)
|
||||
{
|
||||
MBED_ASSERT(_db);
|
||||
ControlBlock_t *cb = get_control_block(connection);
|
||||
if (!cb) {
|
||||
|
|
@ -1824,7 +1868,8 @@ void SecurityManager::on_ltk_request(
|
|||
connection_handle_t connection,
|
||||
const ediv_t &ediv,
|
||||
const rand_t &rand
|
||||
) {
|
||||
)
|
||||
{
|
||||
MBED_ASSERT(_db);
|
||||
ControlBlock_t *cb = get_control_block(connection);
|
||||
if (!cb) {
|
||||
|
|
@ -1903,7 +1948,8 @@ SecurityManager::acquire_control_block(connection_handle_t connection)
|
|||
typename SecurityManager::ControlBlock_t*
|
||||
SecurityManager::get_control_block(
|
||||
connection_handle_t connection
|
||||
) {
|
||||
)
|
||||
{
|
||||
for (size_t i = 0; i < MAX_CONTROL_BLOCKS; i++) {
|
||||
if (!_control_blocks[i].connected) {
|
||||
continue;
|
||||
|
|
@ -1918,7 +1964,8 @@ SecurityManager::get_control_block(
|
|||
typename SecurityManager::ControlBlock_t*
|
||||
SecurityManager::get_control_block(
|
||||
const address_t &peer_address
|
||||
) {
|
||||
)
|
||||
{
|
||||
MBED_ASSERT(_db);
|
||||
for (size_t i = 0; i < MAX_CONTROL_BLOCKS; i++) {
|
||||
ControlBlock_t *cb = &_control_blocks[i];
|
||||
|
|
@ -1936,7 +1983,8 @@ SecurityManager::get_control_block(
|
|||
typename SecurityManager::ControlBlock_t*
|
||||
SecurityManager::get_control_block(
|
||||
SecurityDb::entry_handle_t db_entry
|
||||
) {
|
||||
)
|
||||
{
|
||||
for (size_t i = 0; i < MAX_CONTROL_BLOCKS; i++) {
|
||||
if (!_control_blocks[i].connected) {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -152,7 +152,8 @@ FILE* FileSecurityDb::erase_db_file(FILE* db_file)
|
|||
|
||||
SecurityDistributionFlags_t* FileSecurityDb::get_distribution_flags(
|
||||
entry_handle_t db_handle
|
||||
) {
|
||||
)
|
||||
{
|
||||
return reinterpret_cast<SecurityDistributionFlags_t*>(db_handle);
|
||||
}
|
||||
|
||||
|
|
@ -162,7 +163,8 @@ SecurityDistributionFlags_t* FileSecurityDb::get_distribution_flags(
|
|||
void FileSecurityDb::set_entry_local_ltk(
|
||||
entry_handle_t db_handle,
|
||||
const ltk_t <k
|
||||
) {
|
||||
)
|
||||
{
|
||||
entry_t *entry = as_entry(db_handle);
|
||||
if (!entry) {
|
||||
return;
|
||||
|
|
@ -177,7 +179,8 @@ void FileSecurityDb::set_entry_local_ediv_rand(
|
|||
entry_handle_t db_handle,
|
||||
const ediv_t &ediv,
|
||||
const rand_t &rand
|
||||
) {
|
||||
)
|
||||
{
|
||||
entry_t *entry = as_entry(db_handle);
|
||||
if (!entry) {
|
||||
return;
|
||||
|
|
@ -194,7 +197,8 @@ void FileSecurityDb::set_entry_local_ediv_rand(
|
|||
void FileSecurityDb::set_entry_peer_ltk(
|
||||
entry_handle_t db_handle,
|
||||
const ltk_t <k
|
||||
) {
|
||||
)
|
||||
{
|
||||
entry_t *entry = as_entry(db_handle);
|
||||
if (!entry) {
|
||||
return;
|
||||
|
|
@ -209,7 +213,8 @@ void FileSecurityDb::set_entry_peer_ediv_rand(
|
|||
entry_handle_t db_handle,
|
||||
const ediv_t &ediv,
|
||||
const rand_t &rand
|
||||
) {
|
||||
)
|
||||
{
|
||||
entry_t *entry = as_entry(db_handle);
|
||||
if (!entry) {
|
||||
return;
|
||||
|
|
@ -222,7 +227,8 @@ void FileSecurityDb::set_entry_peer_ediv_rand(
|
|||
void FileSecurityDb::set_entry_peer_irk(
|
||||
entry_handle_t db_handle,
|
||||
const irk_t &irk
|
||||
) {
|
||||
)
|
||||
{
|
||||
entry_t *entry = as_entry(db_handle);
|
||||
if (!entry) {
|
||||
return;
|
||||
|
|
@ -237,7 +243,8 @@ void FileSecurityDb::set_entry_peer_bdaddr(
|
|||
entry_handle_t db_handle,
|
||||
bool address_is_public,
|
||||
const address_t &peer_address
|
||||
) {
|
||||
)
|
||||
{
|
||||
entry_t *entry = as_entry(db_handle);
|
||||
if (!entry) {
|
||||
return;
|
||||
|
|
@ -250,7 +257,8 @@ void FileSecurityDb::set_entry_peer_bdaddr(
|
|||
void FileSecurityDb::set_entry_peer_csrk(
|
||||
entry_handle_t db_handle,
|
||||
const csrk_t &csrk
|
||||
) {
|
||||
)
|
||||
{
|
||||
entry_t *entry = as_entry(db_handle);
|
||||
if (!entry) {
|
||||
return;
|
||||
|
|
@ -264,7 +272,8 @@ void FileSecurityDb::set_entry_peer_csrk(
|
|||
void FileSecurityDb::set_entry_peer_sign_counter(
|
||||
entry_handle_t db_handle,
|
||||
sign_count_t sign_counter
|
||||
) {
|
||||
)
|
||||
{
|
||||
entry_t *entry = as_entry(db_handle);
|
||||
if (entry) {
|
||||
entry->peer_sign_counter = sign_counter;
|
||||
|
|
@ -273,7 +282,8 @@ void FileSecurityDb::set_entry_peer_sign_counter(
|
|||
|
||||
void FileSecurityDb::set_local_csrk(
|
||||
const csrk_t &csrk
|
||||
) {
|
||||
)
|
||||
{
|
||||
this->SecurityDb::set_local_csrk(csrk);
|
||||
db_write(&_local_csrk, DB_OFFSET_LOCAL_CSRK);
|
||||
}
|
||||
|
|
@ -282,7 +292,8 @@ void FileSecurityDb::set_local_identity(
|
|||
const irk_t &irk,
|
||||
const address_t &identity_address,
|
||||
bool public_address
|
||||
) {
|
||||
)
|
||||
{
|
||||
this->SecurityDb::set_local_identity(irk, identity_address, public_address);
|
||||
db_write(&_local_identity, DB_OFFSET_LOCAL_IDENTITY);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,7 +121,8 @@ bool KVStoreSecurityDb::erase_db()
|
|||
|
||||
SecurityDistributionFlags_t* KVStoreSecurityDb::get_distribution_flags(
|
||||
entry_handle_t db_handle
|
||||
) {
|
||||
)
|
||||
{
|
||||
return reinterpret_cast<SecurityDistributionFlags_t*>(db_handle);
|
||||
}
|
||||
|
||||
|
|
@ -131,7 +132,8 @@ SecurityDistributionFlags_t* KVStoreSecurityDb::get_distribution_flags(
|
|||
void KVStoreSecurityDb::set_entry_local_ltk(
|
||||
entry_handle_t db_handle,
|
||||
const ltk_t <k
|
||||
) {
|
||||
)
|
||||
{
|
||||
entry_t *entry = as_entry(db_handle);
|
||||
if (!entry) {
|
||||
return;
|
||||
|
|
@ -149,7 +151,8 @@ void KVStoreSecurityDb::set_entry_local_ediv_rand(
|
|||
entry_handle_t db_handle,
|
||||
const ediv_t &ediv,
|
||||
const rand_t &rand
|
||||
) {
|
||||
)
|
||||
{
|
||||
entry_t *entry = as_entry(db_handle);
|
||||
if (!entry) {
|
||||
return;
|
||||
|
|
@ -169,7 +172,8 @@ void KVStoreSecurityDb::set_entry_local_ediv_rand(
|
|||
void KVStoreSecurityDb::set_entry_peer_ltk(
|
||||
entry_handle_t db_handle,
|
||||
const ltk_t <k
|
||||
) {
|
||||
)
|
||||
{
|
||||
entry_t *entry = as_entry(db_handle);
|
||||
if (!entry) {
|
||||
return;
|
||||
|
|
@ -187,7 +191,8 @@ void KVStoreSecurityDb::set_entry_peer_ediv_rand(
|
|||
entry_handle_t db_handle,
|
||||
const ediv_t &ediv,
|
||||
const rand_t &rand
|
||||
) {
|
||||
)
|
||||
{
|
||||
entry_t *entry = as_entry(db_handle);
|
||||
if (!entry) {
|
||||
return;
|
||||
|
|
@ -203,7 +208,8 @@ void KVStoreSecurityDb::set_entry_peer_ediv_rand(
|
|||
void KVStoreSecurityDb::set_entry_peer_irk(
|
||||
entry_handle_t db_handle,
|
||||
const irk_t &irk
|
||||
) {
|
||||
)
|
||||
{
|
||||
entry_t *entry = as_entry(db_handle);
|
||||
if (!entry) {
|
||||
return;
|
||||
|
|
@ -221,7 +227,8 @@ void KVStoreSecurityDb::set_entry_peer_bdaddr(
|
|||
entry_handle_t db_handle,
|
||||
bool address_is_public,
|
||||
const address_t &peer_address
|
||||
) {
|
||||
)
|
||||
{
|
||||
entry_t *entry = as_entry(db_handle);
|
||||
if (!entry) {
|
||||
return;
|
||||
|
|
@ -237,7 +244,8 @@ void KVStoreSecurityDb::set_entry_peer_bdaddr(
|
|||
void KVStoreSecurityDb::set_entry_peer_csrk(
|
||||
entry_handle_t db_handle,
|
||||
const csrk_t &csrk
|
||||
) {
|
||||
)
|
||||
{
|
||||
entry_t *entry = as_entry(db_handle);
|
||||
if (!entry) {
|
||||
return;
|
||||
|
|
@ -254,7 +262,8 @@ void KVStoreSecurityDb::set_entry_peer_csrk(
|
|||
void KVStoreSecurityDb::set_entry_peer_sign_counter(
|
||||
entry_handle_t db_handle,
|
||||
sign_count_t sign_counter
|
||||
) {
|
||||
)
|
||||
{
|
||||
entry_t *entry = as_entry(db_handle);
|
||||
if (entry) {
|
||||
entry->peer_sign_counter = sign_counter;
|
||||
|
|
@ -263,7 +272,8 @@ void KVStoreSecurityDb::set_entry_peer_sign_counter(
|
|||
|
||||
void KVStoreSecurityDb::set_local_csrk(
|
||||
const csrk_t &csrk
|
||||
) {
|
||||
)
|
||||
{
|
||||
this->SecurityDb::set_local_csrk(csrk);
|
||||
db_write(&_local_csrk, DB_LOCAL_CSRK);
|
||||
}
|
||||
|
|
@ -272,7 +282,8 @@ void KVStoreSecurityDb::set_local_identity(
|
|||
const irk_t &irk,
|
||||
const address_t &identity_address,
|
||||
bool public_address
|
||||
) {
|
||||
)
|
||||
{
|
||||
this->SecurityDb::set_local_identity(irk, identity_address, public_address);
|
||||
db_write(&_local_identity, DB_LOCAL_IDENTITY);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue