Skip to content

Commit 0e74a76

Browse files
committed
more clean up
1 parent c4e2529 commit 0e74a76

File tree

4 files changed

+2
-113
lines changed

4 files changed

+2
-113
lines changed

libraries/Bluefruit52Lib/src/BLEGap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class BLEGap
100100
ble_gap_addr_t addr;
101101

102102
uint16_t ediv;
103-
bond_data_t* bond_data;
103+
bond_data_t* bond_data; // Shared keys with bonded device, size ~ 80 bytes
104104

105105
SemaphoreHandle_t hvn_tx_sem;
106106
SemaphoreHandle_t wrcmd_tx_sem;

libraries/Bluefruit52Lib/src/BLEGatt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ void BLEGatt::_eventHandler(ble_evt_t* evt)
146146
// Save CCCD if paired
147147
if ( Bluefruit.connPaired() && (evt_id == BLE_GATTS_EVT_WRITE) && (req_handle == chr->handles().cccd_handle) )
148148
{
149-
bond_save_cccd(evt_conn_hdl, Bluefruit._bond_data.own_enc.master_id.ediv);
149+
bond_save_cccd(evt_conn_hdl, Bluefruit.Gap._get_peer(evt_conn_hdl)->ediv);
150150
}
151151
}
152152
}

libraries/Bluefruit52Lib/src/bluefruit.cpp

Lines changed: 0 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,6 @@ COMMENT_OUT(
121121
_auth_type = BLE_GAP_AUTH_KEY_TYPE_NONE;
122122
varclr(_pin);
123123
)
124-
125-
varclr(&_bond_data);
126-
_bond_data.own_enc.master_id.ediv = 0xFFFF; // invalid value for ediv
127124
}
128125

129126
void AdafruitBluefruit::configServiceChanged(bool changed)
@@ -930,93 +927,6 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
930927
_conn_hdl = BLE_CONN_HANDLE_INVALID;
931928
break;
932929

933-
// case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
934-
// // Pairing in progress
935-
// varclr(&_bond_data);
936-
// _bond_data.own_enc.master_id.ediv = 0xFFFF; // invalid value for ediv
937-
//
938-
// /* Step 1: Pairing/Bonding
939-
// * - Central supplies its parameters
940-
// * - We replies with our security parameters
941-
// */
942-
// // ble_gap_sec_params_t* peer = &evt->evt.gap_evt.params.sec_params_request.peer_params;
943-
// COMMENT_OUT(
944-
// // Change security parameter according to authentication type
945-
// if ( _auth_type == BLE_GAP_AUTH_KEY_TYPE_PASSKEY)
946-
// {
947-
// sec_para.mitm = 1;
948-
// sec_para.io_caps = BLE_GAP_IO_CAPS_DISPLAY_ONLY;
949-
// }
950-
// )
951-
//
952-
// ble_gap_sec_keyset_t keyset =
953-
// {
954-
// .keys_own = {
955-
// .p_enc_key = &_bond_data.own_enc,
956-
// .p_id_key = NULL,
957-
// .p_sign_key = NULL,
958-
// .p_pk = NULL
959-
// },
960-
//
961-
// .keys_peer = {
962-
// .p_enc_key = &_bond_data.peer_enc,
963-
// .p_id_key = &_bond_data.peer_id,
964-
// .p_sign_key = NULL,
965-
// .p_pk = NULL
966-
// }
967-
// };
968-
//
969-
// VERIFY_STATUS(sd_ble_gap_sec_params_reply(evt->evt.gap_evt.conn_handle, BLE_GAP_SEC_STATUS_SUCCESS, &_sec_param, &keyset), RETURN_VOID);
970-
// break;
971-
972-
// case BLE_GAP_EVT_SEC_INFO_REQUEST:
973-
// {
974-
// // Reconnection. If bonded previously, Central will ask for stored keys.
975-
// // return security information. Otherwise NULL
976-
// ble_gap_evt_sec_info_request_t* sec_request = (ble_gap_evt_sec_info_request_t*) &evt->evt.gap_evt.params.sec_info_request;
977-
//
978-
// if ( bond_load_keys(sec_request->master_id.ediv, &_bond_data) )
979-
// {
980-
// sd_ble_gap_sec_info_reply(evt->evt.gap_evt.conn_handle, &_bond_data.own_enc.enc_info, &_bond_data.peer_id.id_info, NULL);
981-
// } else
982-
// {
983-
// sd_ble_gap_sec_info_reply(evt->evt.gap_evt.conn_handle, NULL, NULL, NULL);
984-
// }
985-
// }
986-
// break;
987-
988-
// case BLE_GAP_EVT_CONN_SEC_UPDATE:
989-
// {
990-
// // Connection is secured aka Paired
991-
// COMMENT_OUT( ble_gap_conn_sec_t* conn_sec = (ble_gap_conn_sec_t*) &evt->evt.gap_evt.params.conn_sec_update.conn_sec; )
992-
//
993-
// // Previously bonded --> secure by re-connection process
994-
// // --> Load & Set Sys Attr (Apply Service Context)
995-
// // Else Init Sys Attr
996-
// bond_load_cccd(evt_conn_hdl, _bond_data.own_enc.master_id.ediv);
997-
//
998-
// // Consider Paired as Bonded
999-
// _bonded = true;
1000-
// }
1001-
// break;
1002-
//
1003-
// case BLE_GAP_EVT_AUTH_STATUS:
1004-
// {
1005-
// // Bonding process completed
1006-
// ble_gap_evt_auth_status_t* status = &evt->evt.gap_evt.params.auth_status;
1007-
//
1008-
// // Pairing/Bonding succeeded --> save encryption keys
1009-
// if (BLE_GAP_SEC_STATUS_SUCCESS == status->auth_status)
1010-
// {
1011-
// _bonded = true;
1012-
// bond_save_keys(evt_conn_hdl, &_bond_data);
1013-
// }else
1014-
// {
1015-
// PRINT_HEX(status->auth_status);
1016-
// }
1017-
// }
1018-
// break;
1019-
1020930
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
1021931
sd_ble_gatts_sys_attr_set(_conn_hdl, NULL, 0, 0);
1022932
break;
@@ -1077,20 +987,3 @@ void AdafruitBluefruit::clearBonds(void)
1077987
bond_clear();
1078988
}
1079989

1080-
void AdafruitBluefruit::_bledfu_get_bond_data(ble_gap_addr_t* addr, ble_gap_irk_t* irk, ble_gap_enc_key_t* enc_key)
1081-
{
1082-
(*addr) = getPeerAddr();
1083-
1084-
if ( connPaired() )
1085-
{
1086-
bond_data_t bdata;
1087-
1088-
if ( bond_load_keys( Gap._get_peer(_conn_hdl)->ediv, &bdata ) )
1089-
{
1090-
(*addr) = _bond_data.peer_id.id_addr_info;
1091-
(*irk) = _bond_data.peer_id.id_info;
1092-
1093-
(*enc_key) = _bond_data.own_enc;
1094-
}
1095-
}
1096-
}

libraries/Bluefruit52Lib/src/bluefruit.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,6 @@ class AdafruitBluefruit
192192
void _startConnLed (void);
193193
void _stopConnLed (void);
194194
void _setConnLed (bool on_off);
195-
void _bledfu_get_bond_data(ble_gap_addr_t* addr, ble_gap_irk_t* irk, ble_gap_enc_key_t* enc_key);
196-
197-
// Shared keys with bonded device, size = 80 bytes
198-
bond_data_t _bond_data;
199195

200196
private:
201197
/*------------- SoftDevice Configuration -------------*/

0 commit comments

Comments
 (0)