added bond debug when at level 2
This commit is contained in:
1 parent
48718392c3
commit
cd2da96afb
3 files changed
+30
-9
No files matched your search
+11
-8
@@ -16,10 +16,10 @@
|
||||
#define ARDUINO_MAIN
|
||||
#include "Arduino.h"
|
||||
|
||||
#if CFG_DEBUG >= 3
|
||||
#include "SEGGER_SYSVIEW.h"
|
||||
#endif
|
||||
#define DBG_MEM_INFO 0
|
||||
#define DBG_MEM_INFO_INTERVAL 60000
|
||||
|
||||
// DEBUG Level 1
|
||||
#if CFG_DEBUG
|
||||
// weak function to avoid compilation error with
|
||||
// non-Bluefruit library sketch such as ADC read test
|
||||
@@ -27,7 +27,11 @@ void Bluefruit_printInfo() __attribute__((weak));
|
||||
void Bluefruit_printInfo() {}
|
||||
#endif
|
||||
|
||||
#define MEMINFO_INTERVAL 60000
|
||||
// DEBUG Level 3
|
||||
#if CFG_DEBUG >= 3
|
||||
#include "SEGGER_SYSVIEW.h"
|
||||
#endif
|
||||
|
||||
|
||||
// Weak empty variant initialization function.
|
||||
// May be redefined by variant files.
|
||||
@@ -48,7 +52,6 @@ static void loop_task(void* arg)
|
||||
// If Serial is not begin(), call it to avoid hard fault
|
||||
if ( !Serial.started() ) Serial.begin(115200);
|
||||
dbgPrintVersion();
|
||||
|
||||
Bluefruit_printInfo();
|
||||
#endif
|
||||
|
||||
@@ -56,12 +59,12 @@ static void loop_task(void* arg)
|
||||
{
|
||||
loop();
|
||||
|
||||
#if CFG_DEBUG > 1 // Full Debug
|
||||
#if CFG_DEBUG >= 2 && DBG_MEM_INFO
|
||||
static uint32_t meminfo_ms = 0;
|
||||
if (meminfo_ms + MEMINFO_INTERVAL < millis())
|
||||
if (meminfo_ms + DBG_MEM_INFO_INTERVAL < millis())
|
||||
{
|
||||
meminfo_ms += millis();
|
||||
Serial.printf("Memory Info (print every %d seconds)\n", MEMINFO_INTERVAL/1000);
|
||||
Serial.printf("Memory Info (print every %d seconds)\n", DBG_MEM_INFO_INTERVAL/1000);
|
||||
dbgMemInfo();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -64,6 +64,12 @@ extern "C"
|
||||
void adafruit_ble_task(void* arg);
|
||||
void adafruit_soc_task(void* arg);
|
||||
|
||||
#if CFG_DEBUG >= 2
|
||||
#define printBondDir() dbgPrintDir(CFG_BOND_NFFS_DIR)
|
||||
#else
|
||||
#define printBondDir()
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* INTERNAL FUNCTION
|
||||
*------------------------------------------------------------------*/
|
||||
@@ -220,6 +226,8 @@ err_t AdafruitBluefruit::begin(bool prph_enable, bool central_enable)
|
||||
Nffs.begin();
|
||||
(void) Nffs.mkdir_p(CFG_BOND_NFFS_DIR);
|
||||
|
||||
printBondDir();
|
||||
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
@@ -751,6 +759,8 @@ void AdafruitBluefruit::clearBonds(void)
|
||||
|
||||
// Create an empty one
|
||||
Nffs.mkdir_p(CFG_BOND_NFFS_DIR);
|
||||
|
||||
printBondDir();
|
||||
}
|
||||
|
||||
bool AdafruitBluefruit::_saveBondKeys(void)
|
||||
@@ -758,7 +768,11 @@ bool AdafruitBluefruit::_saveBondKeys(void)
|
||||
char filename[BOND_FILENAME_LEN];
|
||||
sprintf(filename, BOND_FILENAME, _bond_data.own_enc.master_id.ediv);
|
||||
|
||||
return Nffs.writeFile(filename, &_bond_data, sizeof(_bond_data));
|
||||
VERIFY( Nffs.writeFile(filename, &_bond_data, sizeof(_bond_data)) );
|
||||
|
||||
printBondDir();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AdafruitBluefruit::_loadBondKeys(uint16_t ediv)
|
||||
@@ -833,5 +847,7 @@ void AdafruitBluefruit::_saveBondedCCCD(void)
|
||||
Nffs.writeFile(filename, sys_attr, len);
|
||||
}
|
||||
|
||||
printBondDir();
|
||||
|
||||
rtos_free(sys_attr);
|
||||
}
|
||||
@@ -89,4 +89,6 @@ public:
|
||||
|
||||
extern ApacheNffs Nffs;
|
||||
|
||||
void dbgPrintDir(const char* cwd);
|
||||
|
||||
#endif /* NFFS_H_ */
|
||||
Reference in new issue
Block a user