Skip to content

Commit e81f60c

Browse files
committed
update clear bonds examples
1 parent 393ee6c commit e81f60c

File tree

1 file changed

+7
-53
lines changed

1 file changed

+7
-53
lines changed

libraries/Bluefruit52Lib/examples/Peripheral/clearbonds/clearbonds.ino

Lines changed: 7 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <bluefruit.h>
2020
#include <Nffs.h>
21+
#include <utility/bonding.h>
2122

2223
void setup()
2324
{
@@ -29,13 +30,17 @@ void setup()
2930

3031
Serial.println();
3132
Serial.println("----- Before -----\n");
32-
printDir("/adafruit/bond");
33+
bond_print_list(BLE_GAP_ROLE_PERIPH);
34+
bond_print_list(BLE_GAP_ROLE_CENTRAL);
3335

3436
Bluefruit.clearBonds();
37+
Bluefruit.Central.clearBonds();
3538

3639
Serial.println();
3740
Serial.println("----- After -----\n");
38-
printDir("/adafruit/bond");
41+
42+
bond_print_list(BLE_GAP_ROLE_PERIPH);
43+
bond_print_list(BLE_GAP_ROLE_CENTRAL);
3944
}
4045

4146
void loop()
@@ -46,54 +51,3 @@ void loop()
4651
delay(1000);
4752
}
4853

49-
void printDir(const char* cwd)
50-
{
51-
// Open the input folder
52-
NffsDir dir(cwd);
53-
54-
Serial.println(cwd);
55-
56-
// File Entry Information which hold file attribute and name
57-
NffsDirEntry dirEntry;
58-
59-
// Loop through the directory
60-
while( dir.read(&dirEntry) )
61-
{
62-
// Indentation
63-
Serial.print("|_ ");
64-
65-
char eName[64];
66-
dirEntry.getName(eName, sizeof(eName));
67-
68-
char fullpath[256];
69-
strcpy(fullpath, cwd);
70-
strcat(fullpath, "/");
71-
strcat(fullpath, eName);
72-
73-
Serial.print( eName );
74-
75-
if ( dirEntry.isDirectory() )
76-
{
77-
Serial.println("/");
78-
}else
79-
{
80-
// Print file size starting from position 50
81-
int pos = 3 + strlen(eName);
82-
83-
// Print padding
84-
for (int i=pos; i<50; i++) Serial.print(' ');
85-
86-
// Print at least one extra space in case current position > 50
87-
Serial.print(' ');
88-
89-
NffsFile file(fullpath);
90-
91-
Serial.print( file.size() );
92-
Serial.println( " Bytes");
93-
94-
file.close();
95-
}
96-
}
97-
98-
dir.close();
99-
}

0 commit comments

Comments
 (0)