Removed bond list and mouse button additions. Improved passkey request interface.
This commit is contained in:
1 parent
620d2e5543
commit
9a581f5f41
6 files changed
+8
-87
No files matched your search
@@ -78,7 +78,9 @@ static void _passkey_display_cabllack_dfr(BLESecurity::pair_passkey_cb_t func, u
|
||||
|
||||
static void _passkey_request_callback_dfr(BLESecurity::pair_passkey_req_cb_t func, uint16_t conn_hdl)
|
||||
{
|
||||
func(conn_hdl);
|
||||
uint8_t passkey[6];
|
||||
func(conn_hdl, passkey);
|
||||
sd_ble_gap_auth_key_reply(conn_hdl, BLE_GAP_AUTH_KEY_TYPE_PASSKEY, passkey);
|
||||
}
|
||||
|
||||
BLESecurity::BLESecurity(void)
|
||||
@@ -213,9 +215,10 @@ bool BLESecurity::setPairPasskeyCallback(pair_passkey_cb_t fp)
|
||||
return true;
|
||||
}
|
||||
|
||||
void BLESecurity::setPairPasskeyRequestedCallback(pair_passkey_req_cb_t fp)
|
||||
void BLESecurity::setPairPasskeyRequestCallback(pair_passkey_req_cb_t fp)
|
||||
{
|
||||
_passkey_req_cb = fp;
|
||||
_sec_param.mitm = 1;
|
||||
}
|
||||
|
||||
void BLESecurity::setPairCompleteCallback(pair_complete_cb_t fp)
|
||||
@@ -228,12 +231,6 @@ void BLESecurity::setSecuredCallback(secured_conn_cb_t fp)
|
||||
_secured_cb = fp;
|
||||
}
|
||||
|
||||
bool BLESecurity::enterRequestedPasskey(uint16_t conn_hdl, uint8_t const* passkey)
|
||||
{
|
||||
VERIFY_STATUS(sd_ble_gap_auth_key_reply(conn_hdl, BLE_GAP_AUTH_KEY_TYPE_PASSKEY, passkey), false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BLESecurity::_authenticate(uint16_t conn_hdl)
|
||||
{
|
||||
VERIFY_STATUS(sd_ble_gap_authenticate(conn_hdl, &_sec_param ), false);
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
class BLESecurity
|
||||
{
|
||||
public:
|
||||
typedef bool (*pair_passkey_cb_t ) (uint16_t conn_hdl, uint8_t const passkey[6], bool match_request);
|
||||
typedef void (*pair_passkey_req_cb_t) (uint16_t conn_hdl);
|
||||
typedef bool (*pair_passkey_cb_t) (uint16_t conn_hdl, uint8_t const passkey[6], bool match_request);
|
||||
typedef void (*pair_passkey_req_cb_t) (uint16_t conn_hdl, uint8_t passkey[6]);
|
||||
typedef void (*pair_complete_cb_t) (uint16_t conn_hdl, uint8_t auth_status);
|
||||
typedef void (*secured_conn_cb_t) (uint16_t conn_hdl);
|
||||
|
||||
@@ -58,12 +58,10 @@ class BLESecurity
|
||||
|
||||
//------------- Callbacks -------------//
|
||||
bool setPairPasskeyCallback(pair_passkey_cb_t fp);
|
||||
void setPairPasskeyRequestedCallback(pair_passkey_req_cb_t fp);
|
||||
void setPairPasskeyRequestCallback(pair_passkey_req_cb_t fp);
|
||||
void setPairCompleteCallback(pair_complete_cb_t fp);
|
||||
void setSecuredCallback(secured_conn_cb_t fp);
|
||||
|
||||
bool enterRequestedPasskey(uint16_t conn_hdl, uint8_t const* passkey);
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* INTERNAL USAGE ONLY
|
||||
* Although declare as public, it is meant to be invoked by internal
|
||||
|
||||
@@ -225,16 +225,6 @@ bool BLEHidAdafruit::mouseButtonRelease(uint16_t conn_hdl)
|
||||
return mouseReport(conn_hdl, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
bool BLEHidAdafruit::mouseButtonPressSpecific(uint16_t conn_hdl, uint8_t buttons)
|
||||
{
|
||||
return mouseReport(conn_hdl, _mse_buttons | buttons, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
bool BLEHidAdafruit::mouseButtonReleaseSpecific(uint16_t conn_hdl, uint8_t buttons)
|
||||
{
|
||||
return mouseReport(conn_hdl, _mse_buttons & ~buttons, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
bool BLEHidAdafruit::mouseMove(uint16_t conn_hdl, int8_t x, int8_t y)
|
||||
{
|
||||
return mouseReport(conn_hdl, _mse_buttons, x, y, 0, 0);
|
||||
@@ -317,16 +307,6 @@ bool BLEHidAdafruit::mouseButtonRelease(void)
|
||||
return mouseButtonRelease(BLE_CONN_HANDLE_INVALID);
|
||||
}
|
||||
|
||||
bool BLEHidAdafruit::mouseButtonPressSpecific(uint8_t buttons)
|
||||
{
|
||||
return mouseButtonPressSpecific(BLE_CONN_HANDLE_INVALID, buttons);
|
||||
}
|
||||
|
||||
bool BLEHidAdafruit::mouseButtonReleaseSpecific(uint8_t buttons)
|
||||
{
|
||||
return mouseButtonReleaseSpecific(BLE_CONN_HANDLE_INVALID, buttons);
|
||||
}
|
||||
|
||||
bool BLEHidAdafruit::mouseMove(int8_t x, int8_t y)
|
||||
{
|
||||
return mouseMove(BLE_CONN_HANDLE_INVALID, x, y);
|
||||
|
||||
@@ -90,9 +90,6 @@ class BLEHidAdafruit : public BLEHidGeneric
|
||||
|
||||
bool mouseButtonPress(uint8_t buttons);
|
||||
bool mouseButtonRelease(void);
|
||||
|
||||
bool mouseButtonPressSpecific(uint8_t buttons);
|
||||
bool mouseButtonReleaseSpecific(uint8_t buttons);
|
||||
|
||||
bool mouseMove(int8_t x, int8_t y);
|
||||
bool mouseScroll(int8_t scroll);
|
||||
@@ -104,9 +101,6 @@ class BLEHidAdafruit : public BLEHidGeneric
|
||||
|
||||
bool mouseButtonPress(uint16_t conn_hdl, uint8_t buttons);
|
||||
bool mouseButtonRelease(uint16_t conn_hdl);
|
||||
|
||||
bool mouseButtonPressSpecific(uint16_t conn_hdl, uint8_t buttons);
|
||||
bool mouseButtonReleaseSpecific(uint16_t conn_hdl, uint8_t buttons);
|
||||
|
||||
bool mouseMove(uint16_t conn_hdl, int8_t x, int8_t y);
|
||||
bool mouseScroll(uint16_t conn_hdl, int8_t scroll);
|
||||
|
||||
@@ -292,47 +292,6 @@ bool bond_load_cccd(uint8_t role, uint16_t conn_hdl, ble_gap_addr_t const* id_ad
|
||||
return loaded;
|
||||
}
|
||||
|
||||
bool bond_get_list(uint8_t role, bonded_device_info* bondedPeers, uint32_t bondedPeersSize, uint32_t* actualBondedPeersSize)
|
||||
{
|
||||
char const * dpath = (role == BLE_GAP_ROLE_PERIPH ? BOND_DIR_PRPH : BOND_DIR_CNTR);
|
||||
|
||||
File dir(dpath, FILE_O_READ, InternalFS);
|
||||
File file(InternalFS);
|
||||
|
||||
uint32_t peerIndex = 0;
|
||||
while ((file = dir.openNextFile(FILE_O_READ)) && (peerIndex < bondedPeersSize))
|
||||
{
|
||||
if (!file.isDirectory())
|
||||
{
|
||||
int len = file.read();
|
||||
bond_keys_t bondKeys{};
|
||||
if (len == sizeof(bondKeys))
|
||||
{
|
||||
file.read(&bondKeys, len);
|
||||
|
||||
bonded_device_info deviceInfo{};
|
||||
deviceInfo.address = bondKeys.peer_id.id_addr_info;
|
||||
|
||||
len = file.read();
|
||||
if (len > 0)
|
||||
{
|
||||
file.read(deviceInfo.name, min(len, sizeof(deviceInfo.name)));
|
||||
}
|
||||
|
||||
bondedPeers[peerIndex] = deviceInfo;
|
||||
peerIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
file.close();
|
||||
}
|
||||
|
||||
file.close();
|
||||
dir.close();
|
||||
*actualBondedPeersSize = peerIndex;
|
||||
return true;
|
||||
}
|
||||
|
||||
void bond_print_list(uint8_t role)
|
||||
{
|
||||
char const * dpath = (role == BLE_GAP_ROLE_PERIPH ? BOND_DIR_PRPH : BOND_DIR_CNTR);
|
||||
|
||||
@@ -52,12 +52,6 @@ typedef struct
|
||||
ble_gap_id_key_t peer_id;
|
||||
} bond_keys_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ble_gap_addr_t address;
|
||||
char name[25];
|
||||
} bonded_device_info;
|
||||
|
||||
void bond_init(void);
|
||||
void bond_clear_prph(void);
|
||||
void bond_clear_cntr(void);
|
||||
@@ -71,7 +65,6 @@ bool bond_load_keys(uint8_t role, ble_gap_addr_t* peer_addr, bond_keys_t* bkeys)
|
||||
bool bond_save_cccd (uint8_t role, uint16_t conn_hdl, ble_gap_addr_t const* id_addr);
|
||||
bool bond_load_cccd (uint8_t role, uint16_t conn_hdl, ble_gap_addr_t const* id_addr);
|
||||
|
||||
bool bond_get_list(uint8_t role, bonded_device_info* bondedPeers, uint32_t bondedPeersSize, uint32_t* actualBondedPeersSize);
|
||||
void bond_print_list(uint8_t role);
|
||||
|
||||
#endif /* BONDING_H_ */
|
||||
Reference in new issue
Block a user