41
41
#include " bonding.h"
42
42
#include " bluefruit.h"
43
43
44
- using namespace Adafruit_LittleFS_Namespace ;
44
+ enum {
45
+ FO_READ = Adafruit_LittleFS_Namespace::FILE_O_READ,
46
+ FO_WRITE = Adafruit_LittleFS_Namespace::FILE_O_WRITE,
47
+ };
45
48
46
49
#define BOND_DEBUG 1
47
50
@@ -68,7 +71,7 @@ static void get_fname (char* fname, uint8_t role, uint8_t const mac[6])
68
71
mac[0 ], mac[1 ], mac[2 ], mac[3 ], mac[4 ], mac[5 ]);
69
72
}
70
73
71
- static bool bdata_skip_field (File* file)
74
+ static bool bdata_skip_field (Adafruit_LittleFS_Namespace:: File* file)
72
75
{
73
76
int len = file->read ();
74
77
VERIFY (len > 0 );
@@ -77,7 +80,7 @@ static bool bdata_skip_field(File* file)
77
80
return true ;
78
81
}
79
82
80
- static void bdata_write (File* file, void const * buffer, uint16_t bufsize)
83
+ static void bdata_write (Adafruit_LittleFS_Namespace:: File* file, void const * buffer, uint16_t bufsize)
81
84
{
82
85
file->write ( (uint8_t ) bufsize );
83
86
file->write ( (uint8_t const *) buffer, bufsize);
@@ -106,7 +109,7 @@ static void bond_save_keys_dfr (uint8_t role, uint16_t conn_hdl, bond_keys_t con
106
109
// delete if file already exists
107
110
if ( InternalFS.exists (filename) ) InternalFS.remove (filename);
108
111
109
- File file (filename, FILE_O_WRITE , InternalFS);
112
+ Adafruit_LittleFS_Namespace:: File file (filename, FO_WRITE , InternalFS);
110
113
VERIFY (file,);
111
114
112
115
// ------------- save keys -------------//
@@ -150,8 +153,8 @@ bool bond_load_keys(uint8_t role, ble_gap_addr_t* addr, bond_keys_t* bkeys)
150
153
char filename[BOND_FNAME_LEN];
151
154
get_fname (filename, role, addr->addr );
152
155
153
- File file (InternalFS);
154
- if ( file.open (filename, FILE_O_READ ) )
156
+ Adafruit_LittleFS_Namespace:: File file (InternalFS);
157
+ if ( file.open (filename, FO_READ ) )
155
158
{
156
159
int keylen = file.read ();
157
160
if ( keylen > 0 )
@@ -172,10 +175,10 @@ bool bond_load_keys(uint8_t role, ble_gap_addr_t* addr, bond_keys_t* bkeys)
172
175
// Resolvable address, we have to go through the whole list to perform IRK Address matching
173
176
174
177
char const * dpath = (role == BLE_GAP_ROLE_PERIPH ? BOND_DIR_PRPH : BOND_DIR_CNTR);
175
- File dir (dpath, FILE_O_READ , InternalFS);
176
- File file (InternalFS);
178
+ Adafruit_LittleFS_Namespace:: File dir (dpath, FO_READ , InternalFS);
179
+ Adafruit_LittleFS_Namespace:: File file (InternalFS);
177
180
178
- while ( !ret && (file = dir.openNextFile (FILE_O_READ )) )
181
+ while ( !ret && (file = dir.openNextFile (FO_READ )) )
179
182
{
180
183
int keylen = file.read ();
181
184
if ( keylen == sizeof (bond_keys_t ) )
@@ -217,7 +220,7 @@ static void bond_save_cccd_dfr (uint8_t role, uint16_t conn_hdl, ble_gap_addr_t
217
220
char filename[BOND_FNAME_LEN];
218
221
get_fname (filename, role, id_addr->addr );
219
222
220
- File file (filename, FILE_O_WRITE , InternalFS);
223
+ Adafruit_LittleFS_Namespace:: File file (filename, FO_WRITE , InternalFS);
221
224
VERIFY (file,);
222
225
223
226
file.seek (0 ); // write mode start at the end, seek to beginning
@@ -266,7 +269,7 @@ bool bond_load_cccd(uint8_t role, uint16_t conn_hdl, ble_gap_addr_t const* id_ad
266
269
char filename[BOND_FNAME_LEN];
267
270
get_fname (filename, role, id_addr->addr );
268
271
269
- File file (filename, FILE_O_READ , InternalFS);
272
+ Adafruit_LittleFS_Namespace:: File file (filename, FO_READ , InternalFS);
270
273
if ( file )
271
274
{
272
275
bdata_skip_field (&file); // skip key
@@ -298,10 +301,10 @@ void bond_print_list(uint8_t role)
298
301
{
299
302
char const * dpath = (role == BLE_GAP_ROLE_PERIPH ? BOND_DIR_PRPH : BOND_DIR_CNTR);
300
303
301
- File dir (dpath, FILE_O_READ , InternalFS);
302
- File file (InternalFS);
304
+ Adafruit_LittleFS_Namespace:: File dir (dpath, FO_READ , InternalFS);
305
+ Adafruit_LittleFS_Namespace:: File file (InternalFS);
303
306
304
- while ( (file = dir.openNextFile (FILE_O_READ )) )
307
+ while ( (file = dir.openNextFile (FO_READ )) )
305
308
{
306
309
if ( !file.isDirectory () && bdata_skip_field (&file) ) // skip key
307
310
{
0 commit comments