More logging cleanup
This commit is contained in:
parent
0ae3afc254
commit
d343439d21
|
@ -189,7 +189,7 @@ void BleFingerprint::fingerprintServiceAdvertisements(NimBLEAdvertisedDevice *ad
|
|||
for (size_t i = 0; i < serviceAdvCount; i++) {
|
||||
auto uuid = advertisedDevice->getServiceUUID(i);
|
||||
#ifdef VERBOSE
|
||||
Serial.printf("Verbose | MAC: %s, ID: %-58s%ddBm AD: %s\r\n", getMac().c_str(), getId().c_str(), rssi, advertisedDevice->getServiceUUID(i).toString().c_str());
|
||||
Serial.printf("Verbose | %s | %-58s%ddBm AD: %s\r\n", getMac().c_str(), getId().c_str(), rssi, advertisedDevice->getServiceUUID(i).toString().c_str());
|
||||
#endif
|
||||
if (uuid == roomAssistantService) {
|
||||
asRssi = BleFingerprintCollection::rxRefRssi + RM_ASST_TX;
|
||||
|
@ -257,7 +257,7 @@ void BleFingerprint::fingerprintServiceData(NimBLEAdvertisedDevice *advertisedDe
|
|||
BLEUUID uuid = advertisedDevice->getServiceDataUUID(i);
|
||||
std::string strServiceData = advertisedDevice->getServiceData(i);
|
||||
#ifdef VERBOSE
|
||||
Serial.printf("Verbose | MAC: %s, ID: %-58s%ddBm SD: %s/%s\r\n", getMac().c_str(), getId().c_str(), rssi, uuid.toString().c_str(), hexStr(strServiceData).c_str());
|
||||
Serial.printf("Verbose | %s | %-58s%ddBm SD: %s/%s\r\n", getMac().c_str(), getId().c_str(), rssi, uuid.toString().c_str(), hexStr(strServiceData).c_str());
|
||||
#endif
|
||||
|
||||
if (uuid == exposureUUID) { // found COVID-19 exposure tracker
|
||||
|
@ -329,7 +329,7 @@ void BleFingerprint::fingerprintServiceData(NimBLEAdvertisedDevice *advertisedDe
|
|||
void BleFingerprint::fingerprintManufactureData(NimBLEAdvertisedDevice *advertisedDevice, bool haveTxPower, int8_t txPower) {
|
||||
std::string strManufacturerData = advertisedDevice->getManufacturerData();
|
||||
#ifdef VERBOSE
|
||||
Serial.printf("Verbose | MAC: %s, ID: %-58s%ddBm MD: %s\r\n", getMac().c_str(), getId().c_str(), rssi, hexStr(strManufacturerData).c_str());
|
||||
Serial.printf("Verbose | %s | %-58s%ddBm MD: %s\r\n", getMac().c_str(), getId().c_str(), rssi, hexStr(strManufacturerData).c_str());
|
||||
#endif
|
||||
if (strManufacturerData.length() >= 2) {
|
||||
String manuf = Sprintf("%02x%02x", strManufacturerData[1], strManufacturerData[0]);
|
||||
|
@ -507,7 +507,7 @@ bool BleFingerprint::query() {
|
|||
|
||||
bool success = false;
|
||||
|
||||
Serial.printf("%u Query | MAC: %s, ID: %-58s%ddBm %lums\r\n", xPortGetCoreID(), getMac().c_str(), id.c_str(), rssi, now - lastSeenMillis);
|
||||
Serial.printf("%u Query | %s | %-58s%ddBm %lums\r\n", xPortGetCoreID(), getMac().c_str(), id.c_str(), rssi, now - lastSeenMillis);
|
||||
|
||||
NimBLEClient *pClient = NimBLEDevice::getClientListSize() ? NimBLEDevice::getClientByPeerAddress(address) : nullptr;
|
||||
if (!pClient) pClient = NimBLEDevice::getDisconnectedClient();
|
||||
|
@ -524,14 +524,14 @@ bool BleFingerprint::query() {
|
|||
iphone = sMdl.find("iPhone") == 0;
|
||||
if (!sName.empty() && sMdl.find(sName) == std::string::npos && sName != "Apple Watch") {
|
||||
if (setId(String("name:") + kebabify(sName).c_str(), ID_TYPE_QUERY_NAME, String(sName.c_str()))) {
|
||||
Serial.printf("\u001b[38;5;104m%u Name | MAC: %s, ID: %-58s%ddBm %s\u001b[0m\r\n", xPortGetCoreID(), getMac().c_str(), id.c_str(), rssi, sName.c_str());
|
||||
Serial.printf("\u001b[38;5;104m%u Name | %s | %-58s%ddBm %s\u001b[0m\r\n", xPortGetCoreID(), getMac().c_str(), id.c_str(), rssi, sName.c_str());
|
||||
}
|
||||
success = true;
|
||||
}
|
||||
|
||||
if (!sMdl.empty()) {
|
||||
if (setId(String("apple:") + kebabify(sMdl).c_str(), ID_TYPE_QUERY_MODEL, String(sMdl.c_str()))) {
|
||||
Serial.printf("\u001b[38;5;136m%u Model | MAC: %s, ID: %-58s%ddBm %s\u001b[0m\r\n", xPortGetCoreID(), getMac().c_str(), id.c_str(), rssi, sMdl.c_str());
|
||||
Serial.printf("\u001b[38;5;136m%u Model | %s | %-58s%ddBm %s\u001b[0m\r\n", xPortGetCoreID(), getMac().c_str(), id.c_str(), rssi, sMdl.c_str());
|
||||
}
|
||||
success = true;
|
||||
}
|
||||
|
@ -542,7 +542,7 @@ bool BleFingerprint::query() {
|
|||
std::string sRmAst = pClient->getValue(roomAssistantService, rootAssistantCharacteristic);
|
||||
if (!sRmAst.empty()) {
|
||||
if (setId(String("roomAssistant:") + kebabify(sRmAst).c_str(), ID_TYPE_RM_ASST)) {
|
||||
Serial.printf("\u001b[38;5;129m%u RmAst | MAC: %s, ID: %-58s%ddBm %s\u001b[0m\r\n", xPortGetCoreID(), getMac().c_str(), id.c_str(), rssi, sRmAst.c_str());
|
||||
Serial.printf("\u001b[38;5;129m%u RmAst | %s | %-58s%ddBm %s\u001b[0m\r\n", xPortGetCoreID(), getMac().c_str(), id.c_str(), rssi, sRmAst.c_str());
|
||||
}
|
||||
success = true;
|
||||
}
|
||||
|
@ -555,7 +555,7 @@ bool BleFingerprint::query() {
|
|||
|
||||
qryAttempts++;
|
||||
qryDelayMillis = min(int(pow(10, qryAttempts)), 60000);
|
||||
Serial.printf("%u QryErr| MAC: %s, ID: %-58s%ddBm Try %d, retry after %dms\r\n", xPortGetCoreID(), getMac().c_str(), id.c_str(), rssi, qryAttempts, qryDelayMillis);
|
||||
Serial.printf("%u QryErr | %s | %-58s%ddBm Try %d, retry after %dms\r\n", xPortGetCoreID(), getMac().c_str(), id.c_str(), rssi, qryAttempts, qryDelayMillis);
|
||||
|
||||
didQuery = false;
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ bool Loop() {
|
|||
pAdvertising->setAdvertisementType(BLE_GAP_CONN_MODE_UND);
|
||||
pAdvertising->addServiceUUID(heartRate->getUUID());
|
||||
pAdvertising->start();
|
||||
Serial.printf("%u Advert| HRM\r\n", xPortGetCoreID());
|
||||
Serial.printf("%u Advert | HRM\r\n", xPortGetCoreID());
|
||||
} else {
|
||||
pAdvertising->reset();
|
||||
pAdvertising->setMaxInterval(3200);
|
||||
|
@ -222,7 +222,7 @@ bool Loop() {
|
|||
pAdvertising->setAdvertisementType(BLE_GAP_CONN_MODE_NON);
|
||||
pAdvertising->setAdvertisementData(*oAdvertisementData);
|
||||
pAdvertising->start();
|
||||
Serial.printf("%u Advert| iBeacon\r\n", xPortGetCoreID());
|
||||
Serial.printf("%u Advert | iBeacon\r\n", xPortGetCoreID());
|
||||
}
|
||||
lastEnrolling = enrolling;
|
||||
if (enrolling) enrollingEndMillis = millis() + 120000;
|
||||
|
|
23
src/GUI.cpp
23
src/GUI.cpp
|
@ -53,24 +53,25 @@ void Loop() {
|
|||
|
||||
void Added(BleFingerprint *f) {
|
||||
if (f->getIgnore()) return;
|
||||
Serial.printf("%u New %s | MAC: %s, ID: %-58s%ddBm %s\r\n", xPortGetCoreID(), f->getRmAsst() ? "R" : (f->getAllowQuery() ? "Q" : " "), f->getMac().c_str(), f->getId().c_str(), f->getRssi(), f->getDiscriminator().c_str());
|
||||
Serial.printf("%u New %s | %s | %-58s%ddBm %s\r\n", xPortGetCoreID(), f->getRmAsst() ? "R" : (f->getAllowQuery() ? "Q" : " "), f->getMac().c_str(), f->getId().c_str(), f->getRssi(), f->getDiscriminator().c_str());
|
||||
}
|
||||
|
||||
void Removed(BleFingerprint *f) {
|
||||
if (f->getIgnore() || !f->getAdded()) return;
|
||||
Serial.printf("\u001b[38;5;236m%u Del | MAC: %s, ID: %-58s%ddBm %s\u001b[0m\r\n", xPortGetCoreID(), f->getMac().c_str(), f->getId().c_str(), f->getRssi(), f->getDiscriminator().c_str());
|
||||
Serial.printf("\u001b[38;5;236m%u Del | %s | %-58s%ddBm %s\u001b[0m\r\n", xPortGetCoreID(), f->getMac().c_str(), f->getId().c_str(), f->getRssi(), f->getDiscriminator().c_str());
|
||||
}
|
||||
|
||||
void Close(BleFingerprint *f) {
|
||||
Serial.printf("\u001b[32m%u Close | MAC: %s, ID: %-58s%ddBm\u001b[0m\r\n", xPortGetCoreID(), f->getMac().c_str(), f->getId().c_str(), f->getNewestRssi());
|
||||
Serial.printf("\u001b[32m%u Close | %s | %-58s%ddBm\u001b[0m\r\n", xPortGetCoreID(), f->getMac().c_str(), f->getId().c_str(), f->getNewestRssi());
|
||||
Display::Status("C:%s\r\n", f->getId().c_str());
|
||||
}
|
||||
|
||||
void Left(BleFingerprint *f) {
|
||||
Serial.printf("\u001b[33m%u Left | MAC: %s, ID: %-58s%ddBm\u001b[0m\r\n", xPortGetCoreID(), f->getMac().c_str(), f->getId().c_str(), f->getNewestRssi());
|
||||
Serial.printf("\u001b[33m%u Left | %s | %-58s%ddBm\u001b[0m\r\n", xPortGetCoreID(), f->getMac().c_str(), f->getId().c_str(), f->getNewestRssi());
|
||||
Display::Status("L:%s\r\n", f->getId().c_str());
|
||||
}
|
||||
void Motion(bool pir, bool radar) {
|
||||
Serial.printf("%u Motion| Pir: %s Radar: %s\r\n", xPortGetCoreID(), pir ? "yes" : "no", radar ? "yes" : "no");
|
||||
Serial.printf("%u Motion | Pir: %s Radar: %s\r\n", xPortGetCoreID(), pir ? "yes" : "no", radar ? "yes" : "no");
|
||||
Display::Status("Pir:%s Radar:%s\r\n", pir ? "yes" : "no", radar ? "yes" : "no");
|
||||
LEDs::Motion(pir, radar);
|
||||
}
|
||||
|
@ -82,13 +83,13 @@ void Seen(bool inprogress) {
|
|||
void Update(unsigned int percent) {
|
||||
LEDs::Update(percent);
|
||||
if (percent == UPDATE_STARTED) {
|
||||
Serial.printf("%u Update| %s\r\n", xPortGetCoreID(), "started");
|
||||
Serial.printf("%u Update | %s\r\n", xPortGetCoreID(), "started");
|
||||
Display::Status("Update:%s\r\n", "started");
|
||||
} else if (percent == UPDATE_COMPLETE) {
|
||||
Serial.printf("%u Update| %s\r\n", xPortGetCoreID(), "finished");
|
||||
Serial.printf("%u Update | %s\r\n", xPortGetCoreID(), "finished");
|
||||
Display::Status("Update:%s\r\n", "finished");
|
||||
} else {
|
||||
Serial.printf("%u Update| %d%%\r\n", xPortGetCoreID(), percent);
|
||||
Serial.printf("%u Update | %d%%\r\n", xPortGetCoreID(), percent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,9 +99,9 @@ void Connected(bool wifi, bool mqtt) {
|
|||
|
||||
void Counting(BleFingerprint *f, bool add) {
|
||||
if (add)
|
||||
Serial.printf("\u001b[36m%u C# +1 | MAC: %s, ID: %-58s%ddBm (%.2fm) %lums\u001b[0m\r\n", xPortGetCoreID(), f->getMac().c_str(), f->getId().c_str(), f->getRssi(), f->getDistance(), f->getMsSinceLastSeen());
|
||||
Serial.printf("\u001b[36m%u C# +1 | %s | %-58s%ddBm (%.2fm) %lums\u001b[0m\r\n", xPortGetCoreID(), f->getMac().c_str(), f->getId().c_str(), f->getRssi(), f->getDistance(), f->getMsSinceLastSeen());
|
||||
else
|
||||
Serial.printf("\u001b[35m%u C# -1 | MAC: %s, ID: %-58s%ddBm (%.2fm) %lums\u001b[0m\r\n", xPortGetCoreID(), f->getMac().c_str(), f->getId().c_str(), f->getRssi(), f->getDistance(), f->getMsSinceLastSeen());
|
||||
Serial.printf("\u001b[35m%u C# -1 | %s | %-58s%ddBm (%.2fm) %lums\u001b[0m\r\n", xPortGetCoreID(), f->getMac().c_str(), f->getId().c_str(), f->getRssi(), f->getDistance(), f->getMsSinceLastSeen());
|
||||
}
|
||||
|
||||
void Wifi(unsigned int percent) {
|
||||
|
@ -117,7 +118,7 @@ void Status(const char *format, ...) {
|
|||
va_start(args, format);
|
||||
vasprintf(&message, format, args);
|
||||
va_end(args);
|
||||
Serial.printf("%u Status| %s", xPortGetCoreID(), message);
|
||||
Serial.printf("%u Status | %s", xPortGetCoreID(), message);
|
||||
Display::Status(message);
|
||||
free(message);
|
||||
}
|
||||
|
|
|
@ -296,13 +296,13 @@ void onMqttMessage(const char *topic, const char *payload) {
|
|||
auto idPos = top.lastIndexOf("/", configPos - 1);
|
||||
if (idPos < 0) goto skip;
|
||||
auto id = top.substring(idPos + 1, configPos);
|
||||
Serial.printf("%d MQTT | Config %s: %s\r\n", xPortGetCoreID(), id.c_str(), pay.c_str());
|
||||
Serial.printf("%d Config | %s to %s\r\n", xPortGetCoreID(), id.c_str(), pay.c_str());
|
||||
BleFingerprintCollection::Config(id, pay);
|
||||
} else if (setPos > 1) {
|
||||
auto commandPos = top.lastIndexOf("/", setPos - 1);
|
||||
if (commandPos < 0) goto skip;
|
||||
auto command = top.substring(commandPos + 1, setPos);
|
||||
Serial.printf("%d MQTT | Set %s: %s\r\n", xPortGetCoreID(), command.c_str(), pay.c_str());
|
||||
Serial.printf("%d Set | %s to %s\r\n", xPortGetCoreID(), command.c_str(), pay.c_str());
|
||||
|
||||
bool changed = false;
|
||||
if (command == "restart")
|
||||
|
@ -324,7 +324,7 @@ void onMqttMessage(const char *topic, const char *payload) {
|
|||
if (changed) online = false;
|
||||
} else {
|
||||
skip:
|
||||
Serial.printf("%d MQTT | Unknown: %s: %s\r\n", xPortGetCoreID(), topic, payload);
|
||||
Serial.printf("%d Unknown| %s to %s\r\n", xPortGetCoreID(), topic, payload);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -214,7 +214,7 @@ bool sendDeleteDiscovery(const String &domain, const String &name)
|
|||
|
||||
bool alias(const String &alias, const String &id, const String &name = "")
|
||||
{
|
||||
Serial.printf("%u Alias | %s to %s\r\n", xPortGetCoreID(), alias.c_str(), id.c_str());
|
||||
Serial.printf("%u Alias | %s to %s\r\n", xPortGetCoreID(), alias.c_str(), id.c_str());
|
||||
doc.clear();
|
||||
doc["id"] = id;
|
||||
doc["name"] = name;
|
||||
|
|
Loading…
Reference in New Issue