4141#include " bonding.h"
4242#include " bluefruit.h"
4343
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+ };
4548
4649#define BOND_DEBUG 1
4750
@@ -68,7 +71,7 @@ static void get_fname (char* fname, uint8_t role, uint8_t const mac[6])
6871 mac[0 ], mac[1 ], mac[2 ], mac[3 ], mac[4 ], mac[5 ]);
6972}
7073
71- static bool bdata_skip_field (File* file)
74+ static bool bdata_skip_field (Adafruit_LittleFS_Namespace:: File* file)
7275{
7376 int len = file->read ();
7477 VERIFY (len > 0 );
@@ -77,7 +80,7 @@ static bool bdata_skip_field(File* file)
7780 return true ;
7881}
7982
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)
8184{
8285 file->write ( (uint8_t ) bufsize );
8386 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
106109 // delete if file already exists
107110 if ( InternalFS.exists (filename) ) InternalFS.remove (filename);
108111
109- File file (filename, FILE_O_WRITE , InternalFS);
112+ Adafruit_LittleFS_Namespace:: File file (filename, FO_WRITE , InternalFS);
110113 VERIFY (file,);
111114
112115 // ------------- save keys -------------//
@@ -150,8 +153,8 @@ bool bond_load_keys(uint8_t role, ble_gap_addr_t* addr, bond_keys_t* bkeys)
150153 char filename[BOND_FNAME_LEN];
151154 get_fname (filename, role, addr->addr );
152155
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 ) )
155158 {
156159 int keylen = file.read ();
157160 if ( keylen > 0 )
@@ -172,10 +175,10 @@ bool bond_load_keys(uint8_t role, ble_gap_addr_t* addr, bond_keys_t* bkeys)
172175 // Resolvable address, we have to go through the whole list to perform IRK Address matching
173176
174177 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);
177180
178- while ( !ret && (file = dir.openNextFile (FILE_O_READ )) )
181+ while ( !ret && (file = dir.openNextFile (FO_READ )) )
179182 {
180183 int keylen = file.read ();
181184 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
217220 char filename[BOND_FNAME_LEN];
218221 get_fname (filename, role, id_addr->addr );
219222
220- File file (filename, FILE_O_WRITE , InternalFS);
223+ Adafruit_LittleFS_Namespace:: File file (filename, FO_WRITE , InternalFS);
221224 VERIFY (file,);
222225
223226 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
266269 char filename[BOND_FNAME_LEN];
267270 get_fname (filename, role, id_addr->addr );
268271
269- File file (filename, FILE_O_READ , InternalFS);
272+ Adafruit_LittleFS_Namespace:: File file (filename, FO_READ , InternalFS);
270273 if ( file )
271274 {
272275 bdata_skip_field (&file); // skip key
@@ -298,10 +301,10 @@ void bond_print_list(uint8_t role)
298301{
299302 char const * dpath = (role == BLE_GAP_ROLE_PERIPH ? BOND_DIR_PRPH : BOND_DIR_CNTR);
300303
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);
303306
304- while ( (file = dir.openNextFile (FILE_O_READ )) )
307+ while ( (file = dir.openNextFile (FO_READ )) )
305308 {
306309 if ( !file.isDirectory () && bdata_skip_field (&file) ) // skip key
307310 {
0 commit comments