Removes storing of bt peer key in internal flash for bad usb BLE

Co-authored-by: yocvito <nicolasmorel.dp@gmail.com>
This commit is contained in:
yocvito
2023-02-03 19:39:30 +01:00
committed by Willy-JL
parent 82f4a287cb
commit d6a1dc2e1f
4 changed files with 28 additions and 2 deletions

View File

@@ -661,6 +661,8 @@ void bad_kb_bt_init(Bt* bt) {
bt_mode_prev = bt_get_profile_pairing_method(bt);
bt_set_profile_pairing_method(bt, GapPairingNone);
furi_hal_bt_start_advertising();
// disable peer key adding to bt SRAM storage
bt_disable_peer_key_update(bad_usb->bt);
connection_mode = BadKbConnectionModeBt;
}
@@ -683,6 +685,9 @@ void bad_kb_bt_deinit(Bt* bt) {
// if it happens, maybe we should increase the delay after bt_disconnect
bt_set_profile(bt, BtProfileSerial);
// starts saving peer keys (bounded devices)
bt_enable_peer_key_update(bad_usb->bt);
connection_mode = BadKbConnectionModeNone;
}
@@ -827,7 +832,6 @@ static int32_t bad_kb_worker(void* context) {
furi_thread_flags_wait(0, FuriFlagWaitAny, 1500);
if(bad_kb->bt) {
update_bt_timeout(bad_kb->bt);
FURI_LOG_I(WORKER_TAG, "BLE Key timeout : %u", bt_timeout);
}
bad_kb_script_set_keyboard_layout(bad_kb, bad_kb->keyboard_layout);
worker_state = BadKbStateRunning;

View File

@@ -445,6 +445,15 @@ GapPairing bt_get_profile_pairing_method(Bt* bt) {
return furi_hal_bt_get_profile_pairing_method(get_hal_bt_profile(bt->profile));
}
void bt_disable_peer_key_update(Bt *bt) {
UNUSED(bt);
furi_hal_bt_set_key_storage_change_callback(NULL, NULL);
}
void bt_enable_peer_key_update(Bt *bt) {
furi_hal_bt_set_key_storage_change_callback(bt_on_key_storage_change_callback, bt);
}
int32_t bt_srv(void* p) {
UNUSED(p);
Bt* bt = bt_alloc();

View File

@@ -52,6 +52,17 @@ bool bt_remote_rssi(Bt* bt, BtRssi* rssi);
void bt_set_profile_pairing_method(Bt* bt, GapPairing pairing_method);
GapPairing bt_get_profile_pairing_method(Bt* bt);
/** Stop saving new peer key to flash (in .bt.keys file)
*
*/
void bt_disable_peer_key_update(Bt *bt);
/** Enable saving peer key to internal flash (enable by default)
*
* @note This function should be called if bt_disable_peer_key_update was called before
*/
void bt_enable_peer_key_update(Bt *bt);
/** Disconnect from Central
*
* @param bt Bt instance

View File

@@ -1,5 +1,5 @@
entry,status,name,type,params
Version,+,13.2,,
Version,v,13.4,,
Header,+,applications/services/bt/bt_service/bt.h,,
Header,+,applications/services/cli/cli.h,,
Header,+,applications/services/cli/cli_vcp.h,,
@@ -569,7 +569,9 @@ Function,+,ble_glue_start,_Bool,
Function,+,ble_glue_thread_stop,void,
Function,+,ble_glue_wait_for_c2_start,_Bool,int32_t
Function,-,bsearch,void*,"const void*, const void*, size_t, size_t, __compar_fn_t"
Function,+,bt_disable_peer_key_update,void,Bt*
Function,+,bt_disconnect,void,Bt*
Function,+,bt_enable_peer_key_update,void,Bt*
Function,+,bt_forget_bonded_devices,void,Bt*
Function,+,bt_get_profile_adv_name,const char*,Bt*
Function,+,bt_get_profile_mac_address,const uint8_t*,Bt*
1 entry status name type params
2 Version + v 13.2 13.4
3 Header + applications/services/bt/bt_service/bt.h
4 Header + applications/services/cli/cli.h
5 Header + applications/services/cli/cli_vcp.h
569 Function + ble_glue_thread_stop void
570 Function + ble_glue_wait_for_c2_start _Bool int32_t
571 Function - bsearch void* const void*, const void*, size_t, size_t, __compar_fn_t
572 Function + bt_disable_peer_key_update void Bt*
573 Function + bt_disconnect void Bt*
574 Function + bt_enable_peer_key_update void Bt*
575 Function + bt_forget_bonded_devices void Bt*
576 Function + bt_get_profile_adv_name const char* Bt*
577 Function + bt_get_profile_mac_address const uint8_t* Bt*