Skip to content

Commit 9a581f5

Browse files
committed
Removed bond list and mouse button additions. Improved passkey request interface.
1 parent 620d2e5 commit 9a581f5

File tree

6 files changed

+8
-87
lines changed

6 files changed

+8
-87
lines changed

libraries/Bluefruit52Lib/src/BLESecurity.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ static void _passkey_display_cabllack_dfr(BLESecurity::pair_passkey_cb_t func, u
7878

7979
static void _passkey_request_callback_dfr(BLESecurity::pair_passkey_req_cb_t func, uint16_t conn_hdl)
8080
{
81-
func(conn_hdl);
81+
uint8_t passkey[6];
82+
func(conn_hdl, passkey);
83+
sd_ble_gap_auth_key_reply(conn_hdl, BLE_GAP_AUTH_KEY_TYPE_PASSKEY, passkey);
8284
}
8385

8486
BLESecurity::BLESecurity(void)
@@ -213,9 +215,10 @@ bool BLESecurity::setPairPasskeyCallback(pair_passkey_cb_t fp)
213215
return true;
214216
}
215217

216-
void BLESecurity::setPairPasskeyRequestedCallback(pair_passkey_req_cb_t fp)
218+
void BLESecurity::setPairPasskeyRequestCallback(pair_passkey_req_cb_t fp)
217219
{
218220
_passkey_req_cb = fp;
221+
_sec_param.mitm = 1;
219222
}
220223

221224
void BLESecurity::setPairCompleteCallback(pair_complete_cb_t fp)
@@ -228,12 +231,6 @@ void BLESecurity::setSecuredCallback(secured_conn_cb_t fp)
228231
_secured_cb = fp;
229232
}
230233

231-
bool BLESecurity::enterRequestedPasskey(uint16_t conn_hdl, uint8_t const* passkey)
232-
{
233-
VERIFY_STATUS(sd_ble_gap_auth_key_reply(conn_hdl, BLE_GAP_AUTH_KEY_TYPE_PASSKEY, passkey), false);
234-
return true;
235-
}
236-
237234
bool BLESecurity::_authenticate(uint16_t conn_hdl)
238235
{
239236
VERIFY_STATUS(sd_ble_gap_authenticate(conn_hdl, &_sec_param ), false);

libraries/Bluefruit52Lib/src/BLESecurity.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
class BLESecurity
3636
{
3737
public:
38-
typedef bool (*pair_passkey_cb_t ) (uint16_t conn_hdl, uint8_t const passkey[6], bool match_request);
39-
typedef void (*pair_passkey_req_cb_t) (uint16_t conn_hdl);
38+
typedef bool (*pair_passkey_cb_t) (uint16_t conn_hdl, uint8_t const passkey[6], bool match_request);
39+
typedef void (*pair_passkey_req_cb_t) (uint16_t conn_hdl, uint8_t passkey[6]);
4040
typedef void (*pair_complete_cb_t) (uint16_t conn_hdl, uint8_t auth_status);
4141
typedef void (*secured_conn_cb_t) (uint16_t conn_hdl);
4242

@@ -58,12 +58,10 @@ class BLESecurity
5858

5959
//------------- Callbacks -------------//
6060
bool setPairPasskeyCallback(pair_passkey_cb_t fp);
61-
void setPairPasskeyRequestedCallback(pair_passkey_req_cb_t fp);
61+
void setPairPasskeyRequestCallback(pair_passkey_req_cb_t fp);
6262
void setPairCompleteCallback(pair_complete_cb_t fp);
6363
void setSecuredCallback(secured_conn_cb_t fp);
6464

65-
bool enterRequestedPasskey(uint16_t conn_hdl, uint8_t const* passkey);
66-
6765
/*------------------------------------------------------------------*/
6866
/* INTERNAL USAGE ONLY
6967
* Although declare as public, it is meant to be invoked by internal

libraries/Bluefruit52Lib/src/services/BLEHidAdafruit.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -225,16 +225,6 @@ bool BLEHidAdafruit::mouseButtonRelease(uint16_t conn_hdl)
225225
return mouseReport(conn_hdl, 0, 0, 0, 0, 0);
226226
}
227227

228-
bool BLEHidAdafruit::mouseButtonPressSpecific(uint16_t conn_hdl, uint8_t buttons)
229-
{
230-
return mouseReport(conn_hdl, _mse_buttons | buttons, 0, 0, 0, 0);
231-
}
232-
233-
bool BLEHidAdafruit::mouseButtonReleaseSpecific(uint16_t conn_hdl, uint8_t buttons)
234-
{
235-
return mouseReport(conn_hdl, _mse_buttons & ~buttons, 0, 0, 0, 0);
236-
}
237-
238228
bool BLEHidAdafruit::mouseMove(uint16_t conn_hdl, int8_t x, int8_t y)
239229
{
240230
return mouseReport(conn_hdl, _mse_buttons, x, y, 0, 0);
@@ -317,16 +307,6 @@ bool BLEHidAdafruit::mouseButtonRelease(void)
317307
return mouseButtonRelease(BLE_CONN_HANDLE_INVALID);
318308
}
319309

320-
bool BLEHidAdafruit::mouseButtonPressSpecific(uint8_t buttons)
321-
{
322-
return mouseButtonPressSpecific(BLE_CONN_HANDLE_INVALID, buttons);
323-
}
324-
325-
bool BLEHidAdafruit::mouseButtonReleaseSpecific(uint8_t buttons)
326-
{
327-
return mouseButtonReleaseSpecific(BLE_CONN_HANDLE_INVALID, buttons);
328-
}
329-
330310
bool BLEHidAdafruit::mouseMove(int8_t x, int8_t y)
331311
{
332312
return mouseMove(BLE_CONN_HANDLE_INVALID, x, y);

libraries/Bluefruit52Lib/src/services/BLEHidAdafruit.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,6 @@ class BLEHidAdafruit : public BLEHidGeneric
9090

9191
bool mouseButtonPress(uint8_t buttons);
9292
bool mouseButtonRelease(void);
93-
94-
bool mouseButtonPressSpecific(uint8_t buttons);
95-
bool mouseButtonReleaseSpecific(uint8_t buttons);
9693

9794
bool mouseMove(int8_t x, int8_t y);
9895
bool mouseScroll(int8_t scroll);
@@ -104,9 +101,6 @@ class BLEHidAdafruit : public BLEHidGeneric
104101

105102
bool mouseButtonPress(uint16_t conn_hdl, uint8_t buttons);
106103
bool mouseButtonRelease(uint16_t conn_hdl);
107-
108-
bool mouseButtonPressSpecific(uint16_t conn_hdl, uint8_t buttons);
109-
bool mouseButtonReleaseSpecific(uint16_t conn_hdl, uint8_t buttons);
110104

111105
bool mouseMove(uint16_t conn_hdl, int8_t x, int8_t y);
112106
bool mouseScroll(uint16_t conn_hdl, int8_t scroll);

libraries/Bluefruit52Lib/src/utility/bonding.cpp

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -292,47 +292,6 @@ bool bond_load_cccd(uint8_t role, uint16_t conn_hdl, ble_gap_addr_t const* id_ad
292292
return loaded;
293293
}
294294

295-
bool bond_get_list(uint8_t role, bonded_device_info* bondedPeers, uint32_t bondedPeersSize, uint32_t* actualBondedPeersSize)
296-
{
297-
char const * dpath = (role == BLE_GAP_ROLE_PERIPH ? BOND_DIR_PRPH : BOND_DIR_CNTR);
298-
299-
File dir(dpath, FILE_O_READ, InternalFS);
300-
File file(InternalFS);
301-
302-
uint32_t peerIndex = 0;
303-
while ((file = dir.openNextFile(FILE_O_READ)) && (peerIndex < bondedPeersSize))
304-
{
305-
if (!file.isDirectory())
306-
{
307-
int len = file.read();
308-
bond_keys_t bondKeys{};
309-
if (len == sizeof(bondKeys))
310-
{
311-
file.read(&bondKeys, len);
312-
313-
bonded_device_info deviceInfo{};
314-
deviceInfo.address = bondKeys.peer_id.id_addr_info;
315-
316-
len = file.read();
317-
if (len > 0)
318-
{
319-
file.read(deviceInfo.name, min(len, sizeof(deviceInfo.name)));
320-
}
321-
322-
bondedPeers[peerIndex] = deviceInfo;
323-
peerIndex++;
324-
}
325-
}
326-
327-
file.close();
328-
}
329-
330-
file.close();
331-
dir.close();
332-
*actualBondedPeersSize = peerIndex;
333-
return true;
334-
}
335-
336295
void bond_print_list(uint8_t role)
337296
{
338297
char const * dpath = (role == BLE_GAP_ROLE_PERIPH ? BOND_DIR_PRPH : BOND_DIR_CNTR);

libraries/Bluefruit52Lib/src/utility/bonding.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ typedef struct
5252
ble_gap_id_key_t peer_id;
5353
} bond_keys_t;
5454

55-
typedef struct
56-
{
57-
ble_gap_addr_t address;
58-
char name[25];
59-
} bonded_device_info;
60-
6155
void bond_init(void);
6256
void bond_clear_prph(void);
6357
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)
7165
bool bond_save_cccd (uint8_t role, uint16_t conn_hdl, ble_gap_addr_t const* id_addr);
7266
bool bond_load_cccd (uint8_t role, uint16_t conn_hdl, ble_gap_addr_t const* id_addr);
7367

74-
bool bond_get_list(uint8_t role, bonded_device_info* bondedPeers, uint32_t bondedPeersSize, uint32_t* actualBondedPeersSize);
7568
void bond_print_list(uint8_t role);
7669

7770
#endif /* BONDING_H_ */

0 commit comments

Comments
 (0)