rename display callback to passkey callback

This commit is contained in:
hathach committed 2020-03-16 13:22:13 +07:00
1 parent 0ee2124e06
commit b487db9603
5 files changed
+10 -18

No files matched your search

@@ -116,7 +116,7 @@ void setup()
Bluefruit.setName("Bluefruit52");
// Serial.println("Setting pairing PIN to: " PAIRING_PIN);
Bluefruit.Pairing.setDisplayCallback(pairing_display_callback);
Bluefruit.Pairing.setPasskeyCallback(pairing_display_callback);
Bluefruit.Pairing.setCompleteCallback(pairing_complete_callback);
Bluefruit.Periph.setConnectCallback(connect_callback);
@@ -325,7 +325,9 @@ void BLEConnection::_eventHandler(ble_evt_t* evt)
case BLE_GAP_EVT_CONN_SEC_UPDATE:
{
// Connection is secured, we have paired/bonded
const ble_gap_conn_sec_t* conn_sec = &evt->evt.gap_evt.params.conn_sec_update.conn_sec;
LOG_LV2("PAIR", "Security Mode = %d, Level = %d", conn_sec->sec_mode.sm, conn_sec->sec_mode.lv);
// Connection is secured (paired) if encryption level > 1
if ( !( conn_sec->sec_mode.sm == 1 && conn_sec->sec_mode.lv == 1) )
+4 -13
View File
@@ -66,7 +66,7 @@ BLEPairing::BLEPairing(void)
// _sec_param.lesc = 1; // enable LESC if CryptoCell is present
#endif
_display_cb = NULL;
_passkey_cb = NULL;
_complete_cb = NULL;
}
@@ -165,9 +165,9 @@ bool BLEPairing::setPIN(const char* pin)
}
// Pairing using LESC with peripheral display
bool BLEPairing::setDisplayCallback(pair_display_cb_t fp)
bool BLEPairing::setPasskeyCallback(pair_passkey_cb_t fp)
{
_display_cb = fp;
_passkey_cb = fp;
if ( fp == NULL )
{
@@ -266,7 +266,7 @@ void BLEPairing::_eventHandler(ble_evt_t* evt)
LOG_LV2("PAIR", "Passkey = %.6s, match request = %d", passkey_display->passkey, passkey_display->match_request);
// Invoke display callback
if ( _display_cb ) ada_callback(passkey_display->passkey, 6, _display_cb, conn_hdl, passkey_display->passkey);
if ( _passkey_cb ) ada_callback(passkey_display->passkey, 6, _passkey_cb, conn_hdl, passkey_display->passkey);
if (passkey_display->match_request)
{
@@ -359,15 +359,6 @@ void BLEPairing::_eventHandler(ble_evt_t* evt)
}
break;
case BLE_GAP_EVT_CONN_SEC_UPDATE:
{
const ble_gap_conn_sec_t* conn_sec = &evt->evt.gap_evt.params.conn_sec_update.conn_sec;
(void) conn_sec;
LOG_LV2("PAIR", "Security Mode = %d, Level = %d", conn_sec->sec_mode.sm, conn_sec->sec_mode.lv);
}
break;
default: break;
}
}
+3 -3
View File
@@ -35,7 +35,7 @@
class BLEPairing
{
public:
typedef void (*pair_display_cb_t ) (uint16_t conn_hdl, uint8_t const passkey[6]);
typedef void (*pair_passkey_cb_t ) (uint16_t conn_hdl, uint8_t const passkey[6]);
typedef void (*pair_complete_cb_t) (uint16_t conn_hdl, uint8_t auth_status);
BLEPairing(void);
@@ -49,7 +49,7 @@ class BLEPairing
bool resolveAddress(ble_gap_addr_t const * p_addr, ble_gap_irk_t const * irk);
//------------- Callbacks -------------//
bool setDisplayCallback(pair_display_cb_t fp);
bool setPasskeyCallback(pair_passkey_cb_t fp);
void setCompleteCallback(pair_complete_cb_t fp);
/*------------------------------------------------------------------*/
@@ -70,7 +70,7 @@ class BLEPairing
bond_keys_t _bond_keys; // Shared keys with bonded device during securing connection, size ~ 80 bytes
pair_display_cb_t _display_cb;
pair_passkey_cb_t _passkey_cb;
pair_complete_cb_t _complete_cb;
};
@@ -337,7 +337,6 @@ void bond_clear_cntr(void)
// Create an empty one
InternalFS.mkdir(BOND_DIR_CNTR);
}
void bond_clear_all(void)