Skip to content

Commit 7b0c38a

Browse files
authored
Merge pull request #12742 from LDong-Arm/gatt_sm_deprecated_cleanup
BLE: remove deprecated APIs from Gatt and SecurityManager
2 parents bb80385 + 07c25bb commit 7b0c38a

File tree

5 files changed

+1
-356
lines changed

5 files changed

+1
-356
lines changed

features/FEATURE_BLE/ble/GattCharacteristic.h

Lines changed: 0 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,32 +1426,6 @@ class GattCharacteristic {
14261426
}
14271427

14281428
public:
1429-
/**
1430-
* Set up the minimum security (mode and level) requirements for access to
1431-
* the characteristic's value attribute.
1432-
*
1433-
* @param[in] securityMode Can be one of encryption or signing, with or
1434-
* without protection for man in the middle attacks (MITM).
1435-
*
1436-
* @deprecated Fine grained security check has been added to with mbed OS
1437-
* 5.9. It is possible to set independently security requirements for read,
1438-
* write and update operations. In the meantime SecurityManager::SecurityMode_t
1439-
* is not used anymore to represent security requirements as it maps
1440-
* incorrectly the Bluetooth standard.
1441-
*/
1442-
MBED_DEPRECATED_SINCE(
1443-
"mbed-os-5.9",
1444-
"Use setWriteSecurityRequirements, setReadSecurityRequirements and "
1445-
"setUpdateSecurityRequirements"
1446-
)
1447-
void requireSecurity(SecurityManager::SecurityMode_t securityMode)
1448-
{
1449-
SecurityRequirement_t sec_requirements = SecurityModeToAttSecurity(securityMode);
1450-
1451-
_valueAttribute.setReadSecurityRequirement(sec_requirements);
1452-
_valueAttribute.setWriteSecurityRequirement(sec_requirements);
1453-
_update_security = sec_requirements.value();
1454-
}
14551429

14561430
/**
14571431
* Set all security requirements of the characteristic.
@@ -1729,62 +1703,6 @@ class GattCharacteristic {
17291703
return _properties;
17301704
}
17311705

1732-
/**
1733-
* Get the characteristic's required security.
1734-
*
1735-
* @return The characteristic's required security.
1736-
*
1737-
* @deprecated Fine grained security check has been added to with mbed OS
1738-
* 5.9. It is possible to set independently security requirements for read,
1739-
* write and update operations. In the meantime SecurityManager::SecurityMode_t
1740-
* is not used anymore to represent security requirements as it maps
1741-
* incorrectly the Bluetooth standard.
1742-
*/
1743-
MBED_DEPRECATED_SINCE(
1744-
"mbed-os-5.9",
1745-
"Use getWriteSecurityRequirements, getReadSecurityRequirements and "
1746-
"getUpdateSecurityRequirements"
1747-
)
1748-
SecurityManager::SecurityMode_t getRequiredSecurity() const
1749-
{
1750-
SecurityRequirement_t max_sec = std::max(
1751-
std::max(
1752-
getReadSecurityRequirement(),
1753-
getWriteSecurityRequirement()
1754-
),
1755-
getUpdateSecurityRequirement()
1756-
);
1757-
1758-
bool needs_signing =
1759-
_properties & BLE_GATT_CHAR_PROPERTIES_AUTHENTICATED_SIGNED_WRITES;
1760-
1761-
switch(max_sec.value()) {
1762-
case SecurityRequirement_t::NONE:
1763-
MBED_ASSERT(needs_signing == false);
1764-
return SecurityManager::SECURITY_MODE_ENCRYPTION_OPEN_LINK;
1765-
#if BLE_FEATURE_SECURITY
1766-
case SecurityRequirement_t::UNAUTHENTICATED:
1767-
return (needs_signing) ?
1768-
SecurityManager::SECURITY_MODE_SIGNED_NO_MITM :
1769-
SecurityManager::SECURITY_MODE_ENCRYPTION_NO_MITM;
1770-
1771-
case SecurityRequirement_t::AUTHENTICATED:
1772-
return (needs_signing) ?
1773-
SecurityManager::SECURITY_MODE_SIGNED_WITH_MITM :
1774-
SecurityManager::SECURITY_MODE_ENCRYPTION_WITH_MITM;
1775-
#if BLE_FEATURE_SECURE_CONNECTIONS
1776-
case SecurityRequirement_t::SC_AUTHENTICATED:
1777-
MBED_ASSERT(needs_signing == false);
1778-
// fallback to encryption with MITM
1779-
return SecurityManager::SECURITY_MODE_ENCRYPTION_WITH_MITM;
1780-
#endif // BLE_FEATURE_SECURE_CONNECTIONS
1781-
#endif // BLE_FEATURE_SECURITY
1782-
default:
1783-
MBED_ASSERT(false);
1784-
return SecurityManager::SECURITY_MODE_NO_ACCESS;
1785-
}
1786-
}
1787-
17881706
/**
17891707
* Get the total number of descriptors within this characteristic.
17901708
*
@@ -1840,42 +1758,6 @@ class GattCharacteristic {
18401758

18411759
private:
18421760

1843-
/**
1844-
* Loosely convert a SecurityManager::SecurityMode_t into a
1845-
* SecurityRequirement_t.
1846-
*
1847-
* @param[in] mode The security mode to convert
1848-
*
1849-
* @return The security requirement equivalent to the security mode in input.
1850-
*/
1851-
SecurityRequirement_t SecurityModeToAttSecurity(
1852-
SecurityManager::SecurityMode_t mode
1853-
) {
1854-
switch(mode) {
1855-
case SecurityManager::SECURITY_MODE_ENCRYPTION_OPEN_LINK:
1856-
case SecurityManager::SECURITY_MODE_NO_ACCESS:
1857-
// assuming access is managed by property and orthogonal to
1858-
// security mode ...
1859-
return SecurityRequirement_t::NONE;
1860-
#if BLE_FEATURE_SECURITY
1861-
case SecurityManager::SECURITY_MODE_ENCRYPTION_NO_MITM:
1862-
#if BLE_FEATURE_SIGNING
1863-
case SecurityManager::SECURITY_MODE_SIGNED_NO_MITM:
1864-
#endif
1865-
return SecurityRequirement_t::UNAUTHENTICATED;
1866-
1867-
case SecurityManager::SECURITY_MODE_ENCRYPTION_WITH_MITM:
1868-
#if BLE_FEATURE_SIGNING
1869-
case SecurityManager::SECURITY_MODE_SIGNED_WITH_MITM:
1870-
#endif
1871-
return SecurityRequirement_t::AUTHENTICATED;
1872-
#endif // BLE_FEATURE_SECURITY
1873-
default:
1874-
// should not happens; makes the compiler happy.
1875-
return SecurityRequirement_t::NONE;
1876-
}
1877-
}
1878-
18791761
/**
18801762
* Attribute that contains the actual value of this characteristic.
18811763
*/

features/FEATURE_BLE/ble/GattClient.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -525,25 +525,6 @@ class GattClient : public StaticInterface<Impl, GattClient> {
525525
return onDataWriteCallbackChain;
526526
}
527527

528-
/**
529-
* Register an attribute write event handler.
530-
*
531-
* @param[in] callback Event handler being registered.
532-
*
533-
* @note It is possible to remove registered handlers using
534-
* onDataWritten().detach(callbackToRemove).
535-
*
536-
* @note Write commands (issued using writeWoResponse) don't generate a
537-
* response.
538-
*
539-
* @deprecated Use GattServer::onDataWritten().
540-
*/
541-
MBED_DEPRECATED("Use GattServer::onDataWritten()")
542-
void onDataWrite(WriteCallback_t callback)
543-
{
544-
onDataWritten(callback);
545-
}
546-
547528
/**
548529
* Register a service discovery termination event handler.
549530
*

0 commit comments

Comments
 (0)