Skip to content

Commit

Permalink
BLE: Add GapPairingNone support (#3596)
Browse files Browse the repository at this point in the history
* BLE: Add GapPairingNone support
* FuriHal: cleanup naming in ble gap, remove useless config options

Co-authored-by: あく <[email protected]>
  • Loading branch information
Willy-JL and skotopes authored Apr 18, 2024
1 parent be43e49 commit 12112e7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
6 changes: 0 additions & 6 deletions targets/f7/ble_glue/app_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
/**
* Define IO Authentication
*/
#define CFG_USED_FIXED_PIN USE_FIXED_PIN_FOR_PAIRING_FORBIDDEN
#define CFG_ENCRYPTION_KEY_SIZE_MAX (16)
#define CFG_ENCRYPTION_KEY_SIZE_MIN (8)

Expand All @@ -18,11 +17,6 @@
*/
#define CFG_IO_CAPABILITY IO_CAP_DISPLAY_YES_NO

/**
* Define MITM modes
*/
#define CFG_MITM_PROTECTION MITM_PROTECTION_REQUIRED

/**
* Define Secure Connections Support
*/
Expand Down
13 changes: 11 additions & 2 deletions targets/f7/ble_glue/gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,22 +348,31 @@ static void gap_init_svc(Gap* gap) {
// Set default PHY
hci_le_set_default_phy(ALL_PHYS_PREFERENCE, TX_2M_PREFERRED, RX_2M_PREFERRED);
// Set I/O capability
uint8_t auth_req_mitm_mode = MITM_PROTECTION_REQUIRED;
uint8_t auth_req_use_fixed_pin = USE_FIXED_PIN_FOR_PAIRING_FORBIDDEN;
bool keypress_supported = false;
if(gap->config->pairing_method == GapPairingPinCodeShow) {
aci_gap_set_io_capability(IO_CAP_DISPLAY_ONLY);
} else if(gap->config->pairing_method == GapPairingPinCodeVerifyYesNo) {
aci_gap_set_io_capability(IO_CAP_DISPLAY_YES_NO);
keypress_supported = true;
} else if(gap->config->pairing_method == GapPairingNone) {
// "Just works" pairing method (iOS accepts it, it seems Android and Linux don't)
auth_req_mitm_mode = MITM_PROTECTION_NOT_REQUIRED;
auth_req_use_fixed_pin = USE_FIXED_PIN_FOR_PAIRING_ALLOWED;
// If "just works" isn't supported, we want the numeric comparaison method
aci_gap_set_io_capability(IO_CAP_DISPLAY_YES_NO);
keypress_supported = true;
}
// Setup authentication
aci_gap_set_authentication_requirement(
gap->config->bonding_mode,
CFG_MITM_PROTECTION,
auth_req_mitm_mode,
CFG_SC_SUPPORT,
keypress_supported,
CFG_ENCRYPTION_KEY_SIZE_MIN,
CFG_ENCRYPTION_KEY_SIZE_MAX,
CFG_USED_FIXED_PIN,
auth_req_use_fixed_pin,
0,
CFG_IDENTITY_ADDRESS);
// Configure whitelist
Expand Down

0 comments on commit 12112e7

Please sign in to comment.