Skip to content

Commit acd4abe

Browse files
committed
clean up
1 parent cf3132b commit acd4abe

File tree

2 files changed

+0
-162
lines changed

2 files changed

+0
-162
lines changed

libraries/Bluefruit52Lib/src/bluefruit.cpp

Lines changed: 0 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
#include <Nffs.h>
3939
#include "utility/bonding.h"
4040

41-
#define SVC_CONTEXT_FLAG (BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS | BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS)
42-
4341
#define CFG_BLE_TX_POWER_LEVEL 0
4442
#define CFG_DEFAULT_NAME "Bluefruit52"
4543

@@ -1053,7 +1051,6 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
10531051
if (BLE_GAP_SEC_STATUS_SUCCESS == status->auth_status)
10541052
{
10551053
_bonded = true;
1056-
// ada_callback(NULL, _adafruit_save_bond_key_dfr, _conn_hdl);
10571054
bond_save_keys(evt_conn_hdl, &_bond_data);
10581055
}else
10591056
{
@@ -1140,160 +1137,6 @@ void AdafruitBluefruit::clearBonds(void)
11401137
printBondDir();
11411138
}
11421139

1143-
/*------------------------------------------------------------------*/
1144-
/* Saving Bond Data to Nffs in following layout
1145-
* - _bond_data 80 bytes
1146-
* - Name 32 bytes
1147-
* - CCCD variable
1148-
*------------------------------------------------------------------*/
1149-
//void _adafruit_save_bond_key_dfr(uint32_t conn_handle)
1150-
//{
1151-
// (void) conn_handle;
1152-
// Bluefruit._saveBondKeys();
1153-
//}
1154-
1155-
//void _adafruit_save_bond_cccd_dfr(uint32_t conn_handle)
1156-
//{
1157-
// (void) conn_handle;
1158-
// Bluefruit._saveBondCCCD();
1159-
//}
1160-
1161-
//void AdafruitBluefruit::_saveBondKeys(void)
1162-
//{
1163-
// char filename[BOND_FILENAME_LEN];
1164-
// sprintf(filename, BOND_FILENAME, _bond_data.own_enc.master_id.ediv);
1165-
//
1166-
// char devname[CFG_MAX_DEVNAME_LEN] = { 0 };
1167-
// Gap.getPeerName(_conn_hdl, devname, CFG_MAX_DEVNAME_LEN);
1168-
//
1169-
// NffsFile file(filename, FS_ACCESS_WRITE);
1170-
//
1171-
// VERIFY( file.exists(), );
1172-
//
1173-
// bool result = true;
1174-
//
1175-
// // write keys
1176-
// if ( !file.write((uint8_t*)&_bond_data, sizeof(_bond_data)) )
1177-
// {
1178-
// result = false;
1179-
// }
1180-
//
1181-
// // write device name
1182-
// if ( strlen(devname) && !file.write((uint8_t*) devname, CFG_MAX_DEVNAME_LEN) )
1183-
// {
1184-
// result = false;
1185-
// }
1186-
//
1187-
// file.close();
1188-
//
1189-
// if (result)
1190-
// {
1191-
// LOG_LV2("BOND", "Keys for \"%s\" is saved to file %s", devname, filename);
1192-
// }else
1193-
// {
1194-
// LOG_LV1("BOND", "Failed to save keys for \"%s\"", devname);
1195-
// }
1196-
// printBondDir();
1197-
//}
1198-
1199-
//bool AdafruitBluefruit::_loadBondKeys(uint16_t ediv)
1200-
//{
1201-
// VERIFY_STATIC(sizeof(_bond_data) == 80 );
1202-
//
1203-
// char filename[BOND_FILENAME_LEN];
1204-
// sprintf(filename, BOND_FILENAME, ediv);
1205-
//
1206-
// bool result = (Nffs.readFile(filename, &_bond_data, sizeof(_bond_data)) > 0);
1207-
//
1208-
// if ( result )
1209-
// {
1210-
// LOG_LV2("BOND", "Load Keys from file %s", filename);
1211-
// }else
1212-
// {
1213-
// LOG_LV1("BOND", "Keys not found");
1214-
// }
1215-
//
1216-
// return result;
1217-
//}
1218-
1219-
//void AdafruitBluefruit::_saveBondCCCD(void)
1220-
//{
1221-
// VERIFY( _bond_data.own_enc.master_id.ediv != 0xFFFF, );
1222-
//
1223-
// uint16_t len=0;
1224-
// sd_ble_gatts_sys_attr_get(_conn_hdl, NULL, &len, SVC_CONTEXT_FLAG);
1225-
//
1226-
// uint8_t* sys_attr = (uint8_t*) rtos_malloc( len );
1227-
// VERIFY( sys_attr, );
1228-
//
1229-
// if ( ERROR_NONE == sd_ble_gatts_sys_attr_get(_conn_hdl, sys_attr, &len, SVC_CONTEXT_FLAG) )
1230-
// {
1231-
// // save to file
1232-
// char filename[BOND_FILENAME_LEN];
1233-
// sprintf(filename, BOND_FILENAME, _bond_data.own_enc.master_id.ediv);
1234-
//
1235-
// if ( Nffs.writeFile(filename, sys_attr, len, BOND_FILE_CCCD_OFFSET) )
1236-
// {
1237-
// LOG_LV2("BOND", "CCCD setting is saved to file %s", filename);
1238-
// }else
1239-
// {
1240-
// LOG_LV1("BOND", "Failed to save CCCD setting");
1241-
// }
1242-
//
1243-
// }
1244-
//
1245-
// printBondDir();
1246-
//
1247-
// rtos_free(sys_attr);
1248-
//}
1249-
1250-
//void AdafruitBluefruit::_loadBondCCCD(uint16_t ediv)
1251-
//{
1252-
// bool loaded = false;
1253-
//
1254-
// char filename[BOND_FILENAME_LEN];
1255-
// sprintf(filename, BOND_FILENAME, ediv);
1256-
//
1257-
// NffsFile file(filename, FS_ACCESS_READ);
1258-
//
1259-
// if ( file.exists() )
1260-
// {
1261-
// int32_t len = file.size() - BOND_FILE_CCCD_OFFSET;
1262-
//
1263-
// if ( len )
1264-
// {
1265-
// uint8_t* sys_attr = (uint8_t*) rtos_malloc( len );
1266-
//
1267-
// if (sys_attr)
1268-
// {
1269-
// file.seek(BOND_FILE_CCCD_OFFSET);
1270-
//
1271-
// if ( file.read(sys_attr, len ) )
1272-
// {
1273-
// if (ERROR_NONE == sd_ble_gatts_sys_attr_set(_conn_hdl, sys_attr, len, SVC_CONTEXT_FLAG) )
1274-
// {
1275-
// loaded = true;
1276-
//
1277-
// LOG_LV2("BOND", "Load CCCD from file %s", filename);
1278-
// }else
1279-
// {
1280-
// LOG_LV1("BOND", "CCCD setting not found");
1281-
// }
1282-
// }
1283-
//
1284-
// rtos_free(sys_attr);
1285-
// }
1286-
// }
1287-
// }
1288-
//
1289-
// file.close();
1290-
//
1291-
// if ( !loaded )
1292-
// {
1293-
// sd_ble_gatts_sys_attr_set(_conn_hdl, NULL, 0, 0);
1294-
// }
1295-
//}
1296-
12971140
void AdafruitBluefruit::_bledfu_get_bond_data(ble_gap_addr_t* addr, ble_gap_irk_t* irk, ble_gap_enc_key_t* enc_key)
12981141
{
12991142
if (!_bonded)

libraries/Bluefruit52Lib/src/bluefruit.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,6 @@ class AdafruitBluefruit
196196
void _setConnLed (bool on_off);
197197
void _bledfu_get_bond_data(ble_gap_addr_t* addr, ble_gap_irk_t* irk, ble_gap_enc_key_t* enc_key);
198198

199-
// void _saveBondKeys(void);
200-
// void _saveBondCCCD(void);
201-
202199
// Shared keys with bonded device, size = 80 bytes
203200
bond_data_t _bond_data;
204201
enum
@@ -251,8 +248,6 @@ COMMENT_OUT(
251248
/*------------------------------------------------------------------*/
252249
/* INTERNAL USAGE ONLY
253250
*------------------------------------------------------------------*/
254-
// bool _loadBondKeys(uint16_t ediv);
255-
// void _loadBondCCCD(uint16_t ediv);
256251
void _ble_handler(ble_evt_t* evt);
257252

258253
friend void SD_EVT_IRQHandler(void);

0 commit comments

Comments
 (0)