From e81f60cd2eeddf0213937e3191c3e6a890e5398c Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 26 Feb 2018 16:07:34 +0700 Subject: [PATCH] update clear bonds examples --- .../Peripheral/clearbonds/clearbonds.ino | 60 +++---------------- 1 file changed, 7 insertions(+), 53 deletions(-) diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/clearbonds/clearbonds.ino b/libraries/Bluefruit52Lib/examples/Peripheral/clearbonds/clearbonds.ino index e1181313..b98129aa 100644 --- a/libraries/Bluefruit52Lib/examples/Peripheral/clearbonds/clearbonds.ino +++ b/libraries/Bluefruit52Lib/examples/Peripheral/clearbonds/clearbonds.ino @@ -18,6 +18,7 @@ #include #include +#include void setup() { @@ -29,13 +30,17 @@ void setup() Serial.println(); Serial.println("----- Before -----\n"); - printDir("/adafruit/bond"); + bond_print_list(BLE_GAP_ROLE_PERIPH); + bond_print_list(BLE_GAP_ROLE_CENTRAL); Bluefruit.clearBonds(); + Bluefruit.Central.clearBonds(); Serial.println(); Serial.println("----- After -----\n"); - printDir("/adafruit/bond"); + + bond_print_list(BLE_GAP_ROLE_PERIPH); + bond_print_list(BLE_GAP_ROLE_CENTRAL); } void loop() @@ -46,54 +51,3 @@ void loop() delay(1000); } -void printDir(const char* cwd) -{ - // Open the input folder - NffsDir dir(cwd); - - Serial.println(cwd); - - // File Entry Information which hold file attribute and name - NffsDirEntry dirEntry; - - // Loop through the directory - while( dir.read(&dirEntry) ) - { - // Indentation - Serial.print("|_ "); - - char eName[64]; - dirEntry.getName(eName, sizeof(eName)); - - char fullpath[256]; - strcpy(fullpath, cwd); - strcat(fullpath, "/"); - strcat(fullpath, eName); - - Serial.print( eName ); - - if ( dirEntry.isDirectory() ) - { - Serial.println("/"); - }else - { - // Print file size starting from position 50 - int pos = 3 + strlen(eName); - - // Print padding - for (int i=pos; i<50; i++) Serial.print(' '); - - // Print at least one extra space in case current position > 50 - Serial.print(' '); - - NffsFile file(fullpath); - - Serial.print( file.size() ); - Serial.println( " Bytes"); - - file.close(); - } - } - - dir.close(); -}