Skip to content

Commit b487db9

Browse files
committed
rename display callback to passkey callback
1 parent 0ee2124 commit b487db9

File tree

5 files changed

+10
-18
lines changed

5 files changed

+10
-18
lines changed

libraries/Bluefruit52Lib/examples/Peripheral/pairing_display/pairing_display.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void setup()
116116
Bluefruit.setName("Bluefruit52");
117117

118118
// Serial.println("Setting pairing PIN to: " PAIRING_PIN);
119-
Bluefruit.Pairing.setDisplayCallback(pairing_display_callback);
119+
Bluefruit.Pairing.setPasskeyCallback(pairing_display_callback);
120120
Bluefruit.Pairing.setCompleteCallback(pairing_complete_callback);
121121

122122
Bluefruit.Periph.setConnectCallback(connect_callback);

libraries/Bluefruit52Lib/src/BLEConnection.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,9 @@ void BLEConnection::_eventHandler(ble_evt_t* evt)
325325

326326
case BLE_GAP_EVT_CONN_SEC_UPDATE:
327327
{
328+
// Connection is secured, we have paired/bonded
328329
const ble_gap_conn_sec_t* conn_sec = &evt->evt.gap_evt.params.conn_sec_update.conn_sec;
330+
LOG_LV2("PAIR", "Security Mode = %d, Level = %d", conn_sec->sec_mode.sm, conn_sec->sec_mode.lv);
329331

330332
// Connection is secured (paired) if encryption level > 1
331333
if ( !( conn_sec->sec_mode.sm == 1 && conn_sec->sec_mode.lv == 1) )

libraries/Bluefruit52Lib/src/BLEPairing.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ BLEPairing::BLEPairing(void)
6666
// _sec_param.lesc = 1; // enable LESC if CryptoCell is present
6767
#endif
6868

69-
_display_cb = NULL;
69+
_passkey_cb = NULL;
7070
_complete_cb = NULL;
7171
}
7272

@@ -165,9 +165,9 @@ bool BLEPairing::setPIN(const char* pin)
165165
}
166166

167167
// Pairing using LESC with peripheral display
168-
bool BLEPairing::setDisplayCallback(pair_display_cb_t fp)
168+
bool BLEPairing::setPasskeyCallback(pair_passkey_cb_t fp)
169169
{
170-
_display_cb = fp;
170+
_passkey_cb = fp;
171171

172172
if ( fp == NULL )
173173
{
@@ -266,7 +266,7 @@ void BLEPairing::_eventHandler(ble_evt_t* evt)
266266
LOG_LV2("PAIR", "Passkey = %.6s, match request = %d", passkey_display->passkey, passkey_display->match_request);
267267

268268
// Invoke display callback
269-
if ( _display_cb ) ada_callback(passkey_display->passkey, 6, _display_cb, conn_hdl, passkey_display->passkey);
269+
if ( _passkey_cb ) ada_callback(passkey_display->passkey, 6, _passkey_cb, conn_hdl, passkey_display->passkey);
270270

271271
if (passkey_display->match_request)
272272
{
@@ -359,15 +359,6 @@ void BLEPairing::_eventHandler(ble_evt_t* evt)
359359
}
360360
break;
361361

362-
case BLE_GAP_EVT_CONN_SEC_UPDATE:
363-
{
364-
const ble_gap_conn_sec_t* conn_sec = &evt->evt.gap_evt.params.conn_sec_update.conn_sec;
365-
(void) conn_sec;
366-
LOG_LV2("PAIR", "Security Mode = %d, Level = %d", conn_sec->sec_mode.sm, conn_sec->sec_mode.lv);
367-
}
368-
break;
369-
370-
371362
default: break;
372363
}
373364
}

libraries/Bluefruit52Lib/src/BLEPairing.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
class BLEPairing
3636
{
3737
public:
38-
typedef void (*pair_display_cb_t ) (uint16_t conn_hdl, uint8_t const passkey[6]);
38+
typedef void (*pair_passkey_cb_t ) (uint16_t conn_hdl, uint8_t const passkey[6]);
3939
typedef void (*pair_complete_cb_t) (uint16_t conn_hdl, uint8_t auth_status);
4040

4141
BLEPairing(void);
@@ -49,7 +49,7 @@ class BLEPairing
4949
bool resolveAddress(ble_gap_addr_t const * p_addr, ble_gap_irk_t const * irk);
5050

5151
//------------- Callbacks -------------//
52-
bool setDisplayCallback(pair_display_cb_t fp);
52+
bool setPasskeyCallback(pair_passkey_cb_t fp);
5353
void setCompleteCallback(pair_complete_cb_t fp);
5454

5555
/*------------------------------------------------------------------*/
@@ -70,7 +70,7 @@ class BLEPairing
7070

7171
bond_keys_t _bond_keys; // Shared keys with bonded device during securing connection, size ~ 80 bytes
7272

73-
pair_display_cb_t _display_cb;
73+
pair_passkey_cb_t _passkey_cb;
7474
pair_complete_cb_t _complete_cb;
7575
};
7676

libraries/Bluefruit52Lib/src/utility/bonding.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,6 @@ void bond_clear_cntr(void)
337337

338338
// Create an empty one
339339
InternalFS.mkdir(BOND_DIR_CNTR);
340-
341340
}
342341

343342
void bond_clear_all(void)

0 commit comments

Comments
 (0)