Replaced all of the logging with proper log levels

This commit is contained in:
Ben Meadors
2022-12-30 10:27:07 -06:00
parent 8193215294
commit f1cdfd163d
68 changed files with 519 additions and 524 deletions

View File

@@ -9,7 +9,7 @@ void *SimpleAllocator::alloc(size_t size)
assert(nextFree + size <= sizeof(bytes));
void *res = &bytes[nextFree];
nextFree += size;
Serial.printf("Total simple allocs %u\n", nextFree);
LOG_DEBUG("Total simple allocs %u\n", nextFree);
return res;
}
@@ -52,7 +52,7 @@ void *operator new(size_t sz) throw(std::bad_alloc)
void operator delete(void *ptr) throw()
{
if (activeAllocator)
Serial.println("Warning: leaking an active allocator object"); // We don't properly handle this yet
LOG_DEBUG("Warning: leaking an active allocator object\n"); // We don't properly handle this yet
else
free(ptr);
}

View File

@@ -33,7 +33,7 @@ class BluetoothPhoneAPI : public PhoneAPI
{
PhoneAPI::onNowHasData(fromRadioNum);
LOG_DEBUG("BLE notify fromNum\n");
LOG_INFO("BLE notify fromNum\n");
fromNum.notify32(fromRadioNum);
}
@@ -55,7 +55,7 @@ void onConnect(uint16_t conn_handle)
char central_name[32] = {0};
connection->getPeerName(central_name, sizeof(central_name));
LOG_DEBUG("BLE Connected to %s\n", central_name);
LOG_INFO("BLE Connected to %s\n", central_name);
}
/**
@@ -66,21 +66,21 @@ void onConnect(uint16_t conn_handle)
void onDisconnect(uint16_t conn_handle, uint8_t reason)
{
// FIXME - we currently assume only one active connection
LOG_DEBUG("BLE Disconnected, reason = 0x%x\n", reason);
LOG_INFO("BLE Disconnected, reason = 0x%x\n", reason);
}
void onCccd(uint16_t conn_hdl, BLECharacteristic *chr, uint16_t cccd_value)
{
// Display the raw request packet
LOG_DEBUG("CCCD Updated: %u\n", cccd_value);
LOG_INFO("CCCD Updated: %u\n", cccd_value);
// Check the characteristic this CCCD update is associated with in case
// this handler is used for multiple CCCD records.
if (chr->uuid == fromNum.uuid) {
if (chr->notifyEnabled(conn_hdl)) {
LOG_DEBUG("fromNum 'Notify' enabled\n");
LOG_INFO("fromNum 'Notify' enabled\n");
} else {
LOG_DEBUG("fromNum 'Notify' disabled\n");
LOG_INFO("fromNum 'Notify' disabled\n");
}
}
}
@@ -135,14 +135,14 @@ void onFromRadioAuthorize(uint16_t conn_hdl, BLECharacteristic *chr, ble_gatts_e
// or make empty if the queue is empty
fromRadio.write(fromRadioBytes, numBytes);
} else {
// LOG_DEBUG("Ignoring successor read\n");
// LOG_INFO("Ignoring successor read\n");
}
authorizeRead(conn_hdl);
}
void onToRadioWrite(uint16_t conn_hdl, BLECharacteristic *chr, uint8_t *data, uint16_t len)
{
LOG_DEBUG("toRadioWriteCb data %p, len %u\n", data, len);
LOG_INFO("toRadioWriteCb data %p, len %u\n", data, len);
bluetoothPhoneAPI->handleToRadio(data, len);
}
@@ -152,7 +152,7 @@ void onToRadioWrite(uint16_t conn_hdl, BLECharacteristic *chr, uint8_t *data, ui
*/
void onFromNumAuthorize(uint16_t conn_hdl, BLECharacteristic *chr, ble_gatts_evt_read_t *request)
{
LOG_DEBUG("fromNumAuthorizeCb\n");
LOG_INFO("fromNumAuthorizeCb\n");
authorizeRead(conn_hdl);
}
@@ -204,14 +204,14 @@ static uint32_t configuredPasskey;
void NRF52Bluetooth::shutdown()
{
// Shutdown bluetooth for minimum power draw
LOG_DEBUG("Disable NRF52 bluetooth\n");
LOG_INFO("Disable NRF52 bluetooth\n");
Bluefruit.Advertising.stop();
}
void NRF52Bluetooth::setup()
{
// Initialise the Bluefruit module
LOG_DEBUG("Initialize the Bluefruit nRF52 module\n");
LOG_INFO("Initialize the Bluefruit nRF52 module\n");
Bluefruit.autoConnLed(false);
Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
Bluefruit.begin();
@@ -225,7 +225,7 @@ void NRF52Bluetooth::setup()
configuredPasskey = config.bluetooth.mode == Config_BluetoothConfig_PairingMode_FIXED_PIN ?
config.bluetooth.fixed_pin : random(100000, 999999);
auto pinString = std::to_string(configuredPasskey);
LOG_DEBUG("Bluetooth pin set to '%i'\n", configuredPasskey);
LOG_INFO("Bluetooth pin set to '%i'\n", configuredPasskey);
Bluefruit.Security.setPIN(pinString.c_str());
Bluefruit.Security.setIOCaps(true, false, false);
Bluefruit.Security.setPairPasskeyCallback(NRF52Bluetooth::onPairingPasskey);
@@ -248,30 +248,30 @@ void NRF52Bluetooth::setup()
bledfu.begin(); // Install the DFU helper
// Configure and Start the Device Information Service
LOG_DEBUG("Configuring the Device Information Service\n");
LOG_INFO("Configuring the Device Information Service\n");
bledis.setModel(optstr(HW_VERSION));
bledis.setFirmwareRev(optstr(APP_VERSION));
bledis.begin();
// Start the BLE Battery Service and set it to 100%
LOG_DEBUG("Configuring the Battery Service\n");
LOG_INFO("Configuring the Battery Service\n");
blebas.begin();
blebas.write(0); // Unknown battery level for now
// Setup the Heart Rate Monitor service using
// BLEService and BLECharacteristic classes
LOG_DEBUG("Configuring the Mesh bluetooth service\n");
LOG_INFO("Configuring the Mesh bluetooth service\n");
setupMeshService();
// Supposedly debugging works with soft device if you disable advertising
if (isSoftDeviceAllowed)
{
// Setup the advertising packet(s)
LOG_DEBUG("Setting up the advertising payload(s)\n");
LOG_INFO("Setting up the advertising payload(s)\n");
startAdv();
LOG_DEBUG("Advertising\n");
LOG_INFO("Advertising\n");
}
}
@@ -283,7 +283,7 @@ void updateBatteryLevel(uint8_t level)
void NRF52Bluetooth::clearBonds()
{
LOG_DEBUG("Clearing bluetooth bonds!\n");
LOG_INFO("Clearing bluetooth bonds!\n");
bond_print_list(BLE_GAP_ROLE_PERIPH);
bond_print_list(BLE_GAP_ROLE_CENTRAL);
@@ -293,12 +293,12 @@ void NRF52Bluetooth::clearBonds()
void NRF52Bluetooth::onConnectionSecured(uint16_t conn_handle)
{
LOG_DEBUG("BLE connection secured\n");
LOG_INFO("BLE connection secured\n");
}
bool NRF52Bluetooth::onPairingPasskey(uint16_t conn_handle, uint8_t const passkey[6], bool match_request)
{
LOG_DEBUG("BLE pairing process started with passkey %.3s %.3s\n", passkey, passkey+3);
LOG_INFO("BLE pairing process started with passkey %.3s %.3s\n", passkey, passkey+3);
screen->startBluetoothPinScreen(configuredPasskey);
if (match_request)
@@ -309,16 +309,16 @@ bool NRF52Bluetooth::onPairingPasskey(uint16_t conn_handle, uint8_t const passke
if (!Bluefruit.connected(conn_handle)) break;
}
}
LOG_DEBUG("BLE passkey pairing: match_request=%i\n", match_request);
LOG_INFO("BLE passkey pairing: match_request=%i\n", match_request);
return true;
}
void NRF52Bluetooth::onPairingCompleted(uint16_t conn_handle, uint8_t auth_status)
{
if (auth_status == BLE_GAP_SEC_STATUS_SUCCESS)
LOG_DEBUG("BLE pairing success\n");
LOG_INFO("BLE pairing success\n");
else
LOG_DEBUG("BLE pairing failed\n");
LOG_INFO("BLE pairing failed\n");
screen->stopBluetoothPinScreen();
}

View File

@@ -32,7 +32,7 @@ bool loopCanSleep() {
// handle standard gcc assert failures
void __attribute__((noreturn)) __assert_func(const char *file, int line, const char *func, const char *failedexpr)
{
LOG_DEBUG("assert failed %s: %d, %s, test=%s\n", file, line, func, failedexpr);
LOG_ERROR("assert failed %s: %d, %s, test=%s\n", file, line, func, failedexpr);
// debugger_break(); FIXME doesn't work, possibly not for segger
// Reboot cpu
NVIC_SystemReset();
@@ -73,7 +73,7 @@ void setBluetoothEnable(bool on)
if (on) {
if (!nrf52Bluetooth) {
if (!useSoftDevice)
LOG_DEBUG("DISABLING NRF52 BLUETOOTH WHILE DEBUGGING\n");
LOG_INFO("DISABLING NRF52 BLUETOOTH WHILE DEBUGGING\n");
else {
nrf52Bluetooth = new NRF52Bluetooth();
nrf52Bluetooth->setup();
@@ -142,7 +142,7 @@ void nrf52Setup()
#ifdef BQ25703A_ADDR
auto *bq = new BQ25713();
if (!bq->setup())
LOG_DEBUG("ERROR! Charge controller init failed\n");
LOG_ERROR("ERROR! Charge controller init failed\n");
#endif
// Init random seed
@@ -178,8 +178,7 @@ void cpuDeepSleep(uint64_t msecToWake)
auto ok = sd_power_system_off();
if (ok != NRF_SUCCESS) {
LOG_DEBUG("FIXME: Ignoring soft device (EasyDMA pending?) and forcing "
"system-off!\n");
LOG_ERROR("FIXME: Ignoring soft device (EasyDMA pending?) and forcing system-off!\n");
NRF_POWER->SYSTEMOFF = 1;
}

View File

@@ -108,9 +108,9 @@ bool SimRadio::canSendImmediately()
if (busyTx || busyRx) {
if (busyTx)
LOG_DEBUG("Can not send yet, busyTx\n");
LOG_WARN("Can not send yet, busyTx\n");
if (busyRx)
LOG_DEBUG("Can not send yet, busyRx\n");
LOG_WARN("Can not send yet, busyRx\n");
return false;
} else
return true;
@@ -199,7 +199,7 @@ void SimRadio::startSend(MeshPacket * txp)
memcpy(&c.data.bytes, p->decoded.payload.bytes, p->decoded.payload.size);
c.data.size = p->decoded.payload.size;
} else {
LOG_DEBUG("Payload size is larger than compressed message allows! Sending empty payload.\n");
LOG_WARN("Payload size is larger than compressed message allows! Sending empty payload.\n");
}
p->decoded.payload.size = pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes), &Compressed_msg, &c);
p->decoded.portnum = PortNum_SIMULATOR_APP;