mirror of
https://github.com/thelsing/knx.git
synced 2025-07-30 13:46:26 +02:00
Add logs for ESP32
This commit is contained in:
parent
24f8e1eee6
commit
205c1f5b15
@ -73,6 +73,7 @@ uint32_t Esp32Platform::uniqueSerialNumber()
|
||||
void Esp32Platform::restart()
|
||||
{
|
||||
println("restart");
|
||||
KNX_LOGI(KTAG, "restart");
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
@ -110,7 +111,7 @@ int Esp32Platform::readBytesMultiCast(uint8_t* buffer, uint16_t maxLen, uint32_t
|
||||
if (len > maxLen)
|
||||
{
|
||||
println("Unexpected UDP data packet length - drop packet");
|
||||
|
||||
KNX_LOGW(KTAG, "Unexpected UDP data packet length - drop packet");
|
||||
for (size_t i = 0; i < len; i++)
|
||||
_udp.read();
|
||||
|
||||
@ -144,11 +145,15 @@ bool Esp32Platform::sendBytesUniCast(uint32_t addr, uint16_t port, uint8_t* buff
|
||||
{
|
||||
_udp.write(buffer, len);
|
||||
|
||||
if (_udp.endPacket() == 0)
|
||||
if (_udp.endPacket() == 0){
|
||||
println("sendBytesUniCast endPacket fail");
|
||||
KNX_LOGE(KTAG, "endBytesUniCast endPacket fail");
|
||||
}
|
||||
}
|
||||
else
|
||||
else{
|
||||
println("sendBytesUniCast beginPacket fail");
|
||||
KNX_LOGE(KTAG, "endBytesUniCast beginPacket fail");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -166,6 +166,7 @@ TPAckType Bau07B0::isAckRequired(uint16_t address, bool isGrpAddr)
|
||||
if (address == 0)
|
||||
{
|
||||
println("Invalid broadcast detected: destination address is 0, but address type is \"individual\"");
|
||||
KNX_LOGE(KTAG, "Invalid broadcast detected: destination address is 0, but address type is \"individual\"");
|
||||
}
|
||||
|
||||
return TPAckType::AckReqNone;
|
||||
|
@ -56,6 +56,7 @@ uint8_t BauSystemB::checkmasterResetValidity(EraseCode eraseCode, uint8_t channe
|
||||
case EraseCode::ConfirmedRestart:
|
||||
{
|
||||
println("Confirmed restart requested.");
|
||||
KNX_LOGI(KTAG, "Confirmed restart requested.");
|
||||
return successCode;
|
||||
}
|
||||
|
||||
@ -63,6 +64,7 @@ uint8_t BauSystemB::checkmasterResetValidity(EraseCode eraseCode, uint8_t channe
|
||||
{
|
||||
// TODO: increase download counter except for confirmed restart (PID_DOWNLOAD_COUNTER)
|
||||
println("ResetAP requested. Not implemented yet.");
|
||||
KNX_LOGW(KTAG, "ResetAP requested. Not implemented yet.");
|
||||
return successCode;
|
||||
}
|
||||
|
||||
@ -70,6 +72,7 @@ uint8_t BauSystemB::checkmasterResetValidity(EraseCode eraseCode, uint8_t channe
|
||||
{
|
||||
// TODO: increase download counter except for confirmed restart (PID_DOWNLOAD_COUNTER)
|
||||
println("ResetIA requested. Not implemented yet.");
|
||||
KNX_LOGW(KTAG, "ResetIA requested. Not implemented yet.");
|
||||
return successCode;
|
||||
}
|
||||
|
||||
@ -77,6 +80,7 @@ uint8_t BauSystemB::checkmasterResetValidity(EraseCode eraseCode, uint8_t channe
|
||||
{
|
||||
// TODO: increase download counter except for confirmed restart (PID_DOWNLOAD_COUNTER)
|
||||
println("ResetLinks requested. Not implemented yet.");
|
||||
KNX_LOGW(KTAG, "ResetLinks requested. Not implemented yet.");
|
||||
return successCode;
|
||||
}
|
||||
|
||||
@ -84,6 +88,7 @@ uint8_t BauSystemB::checkmasterResetValidity(EraseCode eraseCode, uint8_t channe
|
||||
{
|
||||
// TODO: increase download counter except for confirmed restart (PID_DOWNLOAD_COUNTER)
|
||||
println("ResetParam requested. Not implemented yet.");
|
||||
KNX_LOGW(KTAG, "ResetParam requested. Not implemented yet.");
|
||||
return successCode;
|
||||
}
|
||||
|
||||
@ -91,6 +96,7 @@ uint8_t BauSystemB::checkmasterResetValidity(EraseCode eraseCode, uint8_t channe
|
||||
{
|
||||
// TODO: increase download counter except for confirmed restart (PID_DOWNLOAD_COUNTER)
|
||||
println("Factory reset requested. type: with IA");
|
||||
KNX_LOGI(KTAG, "Factory reset requested. type: with IA");
|
||||
return successCode;
|
||||
}
|
||||
|
||||
@ -98,11 +104,13 @@ uint8_t BauSystemB::checkmasterResetValidity(EraseCode eraseCode, uint8_t channe
|
||||
{
|
||||
// TODO: increase download counter except for confirmed restart (PID_DOWNLOAD_COUNTER)
|
||||
println("Factory reset requested. type: without IA");
|
||||
KNX_LOGI(KTAG, "Factory reset requested. type: without IA");
|
||||
return successCode;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
KNX_LOGW(KTAG, "Unhandled erase code: %02X", eraseCode);
|
||||
print("Unhandled erase code: ");
|
||||
println(eraseCode, HEX);
|
||||
return invalidEraseCode;
|
||||
@ -211,7 +219,7 @@ void BauSystemB::restartRequestIndication(Priority priority, HopCountType hopTyp
|
||||
if (restartType == RestartType::BasicRestart)
|
||||
{
|
||||
println("Basic restart requested");
|
||||
|
||||
KNX_LOGI(KTAG, "Basic restart requested");
|
||||
if (_beforeRestart != 0)
|
||||
_beforeRestart();
|
||||
}
|
||||
@ -227,6 +235,7 @@ void BauSystemB::restartRequestIndication(Priority priority, HopCountType hopTyp
|
||||
{
|
||||
// Cannot happen as restartType is just one bit
|
||||
println("Unhandled restart type.");
|
||||
KNX_LOGI(KTAG, "Unhandled restart type.");
|
||||
_platform.fatalError();
|
||||
}
|
||||
|
||||
@ -280,12 +289,14 @@ void BauSystemB::propertyExtDescriptionReadIndication(Priority priority, HopCoun
|
||||
if (propertyId > 0xFF || propertyIndex > 0xFF)
|
||||
{
|
||||
println("BauSystemB::propertyExtDescriptionReadIndication: propertyId or Idx > 256 are not supported");
|
||||
KNX_LOGI(KTAG, "BauSystemB::propertyExtDescriptionReadIndication: propertyId or Idx > 256 are not supported");
|
||||
return;
|
||||
}
|
||||
|
||||
if (descriptionType != 0)
|
||||
{
|
||||
println("BauSystemB::propertyExtDescriptionReadIndication: only descriptionType 0 supported");
|
||||
KNX_LOGI(KTAG, "BauSystemB::propertyExtDescriptionReadIndication: only descriptionType 0 supported");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -212,6 +212,7 @@ void BauSystemBDevice::groupValueReadIndication(uint16_t asap, Priority priority
|
||||
if (secCtrl.dataSecurity != requiredGoSecurity)
|
||||
{
|
||||
println("GroupValueRead: access denied due to wrong security flags");
|
||||
KNX_LOGE(KTAG, "GroupValueRead: access denied due to wrong security flags");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -248,6 +249,7 @@ void BauSystemBDevice::groupValueWriteIndication(uint16_t asap, Priority priorit
|
||||
if (secCtrl.dataSecurity != requiredGoSecurity)
|
||||
{
|
||||
println("GroupValueWrite: access denied due to wrong security flags");
|
||||
KNX_LOGE(KTAG, "GroupValueWrite: access denied due to wrong security flags");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "knx_log.h" // ESP32 Logs
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <arpa/inet.h>
|
||||
|
@ -219,6 +219,7 @@ bool DataLinkLayer::sendTelegram(NPDU& npdu, AckType ack, uint16_t destinationAd
|
||||
if (!frame.valid())
|
||||
{
|
||||
println("invalid frame");
|
||||
KNX_LOGW(KTAG, "invalid frame");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,10 @@ Dpt::Dpt()
|
||||
Dpt::Dpt(short mainGroup, short subGroup, short index /* = 0 */)
|
||||
: mainGroup(mainGroup), subGroup(subGroup), index(index)
|
||||
{
|
||||
if (subGroup == 0)
|
||||
if (subGroup == 0){
|
||||
println("WARNING: You used and invalid Dpt *.0");
|
||||
KNX_LOGW(KTAG, "You used and invalid Dpt *.0");
|
||||
}
|
||||
}
|
||||
|
||||
bool Dpt::operator==(const Dpt& other) const
|
||||
|
34
src/knx/knx_log.h
Executable file
34
src/knx/knx_log.h
Executable file
@ -0,0 +1,34 @@
|
||||
#ifndef __KNX_LOG_H__
|
||||
#define __KNX_LOG_H__
|
||||
|
||||
#pragma once
|
||||
|
||||
// #ifdef ESP32
|
||||
|
||||
#include "esp_log.h"
|
||||
|
||||
// Uncomment enable KNX SDK LOGS
|
||||
#define KNX_SDK_ENABLE_LOGS
|
||||
|
||||
static const char* KTAG = "KNX_LIB";
|
||||
|
||||
#ifdef KNX_SDK_ENABLE_LOGS
|
||||
|
||||
#define KNX_LOGE ESP_LOGE
|
||||
#define KNX_LOGW ESP_LOGW
|
||||
#define KNX_LOGI ESP_LOGI
|
||||
#define KNX_LOGD ESP_LOGD
|
||||
#define KNX_LOGV ESP_LOGV
|
||||
#else
|
||||
|
||||
#define KNX_LOGE(...) ((void)0)
|
||||
#define KNX_LOGW(...) ((void)0)
|
||||
#define KNX_LOGI(...) ((void)0)
|
||||
#define KNX_LOGD(...) ((void)0)
|
||||
#define KNX_LOGV(...) ((void)0)
|
||||
|
||||
#endif // KNX_SDK_ENABLE_LOGS
|
||||
|
||||
// #endif // ESP32
|
||||
|
||||
#endif // __KNX_LOG_H__
|
@ -14,6 +14,7 @@ Memory::~Memory()
|
||||
void Memory::readMemory()
|
||||
{
|
||||
println("readMemory");
|
||||
KNX_LOGW(KTAG, "readMemory");
|
||||
|
||||
uint8_t* flashStart = _platform.getNonVolatileMemoryStart();
|
||||
size_t flashSize = _platform.getNonVolatileMemorySize();
|
||||
@ -21,6 +22,7 @@ void Memory::readMemory()
|
||||
if (flashStart == nullptr)
|
||||
{
|
||||
println("no user flash available;");
|
||||
KNX_LOGW(KTAG, "no user flash available;");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -76,6 +78,9 @@ void Memory::readMemory()
|
||||
print(", stored hardwareType: ");
|
||||
printHex("", hardwareType, LEN_HARDWARE_TYPE);
|
||||
println("");
|
||||
KNX_LOGW(KTAG, "manufacturerId or hardwareType are different");
|
||||
KNX_LOGW(KTAG, "expexted manufacturerId: %02X , stored manufacturerId: %02X, expexted hardwareType: %02X, stored hardwareType: %02X",
|
||||
(unsigned int)_deviceObject.manufacturerId(), (unsigned int)manufacturerId, (unsigned int)_deviceObject.hardwareType(), (unsigned int)hardwareType);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -85,17 +90,21 @@ void Memory::readMemory()
|
||||
print(_deviceObject.apiVersion, HEX);
|
||||
print(", stored api version: ");
|
||||
println(apiVersion, HEX);
|
||||
KNX_LOGW(KTAG, "DataObject api changed, any data stored in flash is invalid. expexted DataObject api version: %02X, stored api version: %02X",
|
||||
(unsigned int)_deviceObject.apiVersion, (unsigned int)apiVersion);
|
||||
}
|
||||
|
||||
if (versionCheck == FlashAllInvalid)
|
||||
{
|
||||
println("ETS has to reprogram PA and application!");
|
||||
KNX_LOGW(KTAG, "ETS has to reprogram PA and application!");
|
||||
return;
|
||||
}
|
||||
|
||||
println("restoring data from flash...");
|
||||
print("saverestores ");
|
||||
println(_saveCount);
|
||||
KNX_LOGI(KTAG, "restoring data from flash...saverestores %d", _saveCount);
|
||||
|
||||
for (int i = 0; i < _saveCount; i++)
|
||||
{
|
||||
@ -105,15 +114,17 @@ void Memory::readMemory()
|
||||
}
|
||||
|
||||
println("restored saveRestores");
|
||||
|
||||
KNX_LOGI(KTAG, "restored saveRestores");
|
||||
if (versionCheck == FlashTablesInvalid)
|
||||
{
|
||||
println("TableObjects are referring to an older firmware version and are not loaded");
|
||||
KNX_LOGW(KTAG, "TableObjects are referring to an older firmware version and are not loaded");
|
||||
return;
|
||||
}
|
||||
|
||||
print("tableObjs ");
|
||||
println(_tableObjCount);
|
||||
KNX_LOGI(KTAG, "tableObjs %d", _tableObjCount);
|
||||
|
||||
for (int i = 0; i < _tableObjCount; i++)
|
||||
{
|
||||
@ -132,6 +143,7 @@ void Memory::readMemory()
|
||||
}
|
||||
|
||||
println("restored Tableobjects");
|
||||
KNX_LOGI(KTAG, "restored Tableobjects");
|
||||
}
|
||||
|
||||
void Memory::writeMemory()
|
||||
@ -158,6 +170,7 @@ void Memory::writeMemory()
|
||||
|
||||
print("save saveRestores ");
|
||||
println(_saveCount);
|
||||
KNX_LOGI(KTAG, "save saveRestores %d", _saveCount);
|
||||
|
||||
for (int i = 0; i < _saveCount; i++)
|
||||
{
|
||||
@ -167,6 +180,7 @@ void Memory::writeMemory()
|
||||
|
||||
print("save tableobjs ");
|
||||
println(_tableObjCount);
|
||||
KNX_LOGI(KTAG, "save tableobjs %d", _tableObjCount);
|
||||
|
||||
for (int i = 0; i < _tableObjCount; i++)
|
||||
{
|
||||
@ -180,6 +194,7 @@ void Memory::writeMemory()
|
||||
if (block == nullptr)
|
||||
{
|
||||
println("_data of TableObject not in _usedList");
|
||||
KNX_LOGW(KTAG, "_data of TableObject not in _usedList");
|
||||
_platform.fatalError();
|
||||
}
|
||||
|
||||
@ -245,6 +260,7 @@ uint8_t* Memory::allocMemory(size_t size)
|
||||
if (!blockToUse)
|
||||
{
|
||||
println("No available non volatile memory!");
|
||||
KNX_LOGE(KTAG, "No available non volatile memory!");
|
||||
_platform.fatalError();
|
||||
}
|
||||
|
||||
@ -288,6 +304,7 @@ void Memory::freeMemory(uint8_t* ptr)
|
||||
if (!found)
|
||||
{
|
||||
println("freeMemory for not used pointer called");
|
||||
KNX_LOGE(KTAG, "freeMemory for not used pointer called");
|
||||
_platform.fatalError();
|
||||
}
|
||||
|
||||
@ -329,6 +346,7 @@ MemoryBlock* Memory::removeFromList(MemoryBlock* head, MemoryBlock* item)
|
||||
if (!head || !item)
|
||||
{
|
||||
println("invalid parameters of Memory::removeFromList");
|
||||
KNX_LOGE(KTAG, "invalid parameters of Memory::removeFromList");
|
||||
_platform.fatalError();
|
||||
}
|
||||
|
||||
@ -350,6 +368,7 @@ MemoryBlock* Memory::removeFromList(MemoryBlock* head, MemoryBlock* item)
|
||||
if (!found)
|
||||
{
|
||||
println("tried to remove block from list not in it");
|
||||
KNX_LOGW(KTAG, "tried to remove block from list not in it");
|
||||
_platform.fatalError();
|
||||
}
|
||||
|
||||
@ -476,12 +495,14 @@ void Memory::addNewUsedBlock(uint8_t* address, size_t size)
|
||||
if (smallerFreeBlock == nullptr)
|
||||
{
|
||||
println("addNewUsedBlock: no smallerBlock found");
|
||||
KNX_LOGW(KTAG, "addNewUsedBlock: no smallerBlock found");
|
||||
_platform.fatalError();
|
||||
}
|
||||
|
||||
if ((smallerFreeBlock->address + smallerFreeBlock->size) < (address + size))
|
||||
{
|
||||
println("addNewUsedBlock: found block can't contain new block");
|
||||
KNX_LOGW(KTAG, "addNewUsedBlock: found block can't contain new block");
|
||||
_platform.fatalError();
|
||||
}
|
||||
|
||||
|
@ -602,6 +602,7 @@ bool TpUartDataLinkLayer::sendFrame(CemiFrame& cemiFrame)
|
||||
if (_txQueueCount > MAX_TX_QUEUE)
|
||||
{
|
||||
println("Ignore frame because transmit queue is full!");
|
||||
KNX_LOGW(KTAG, "Ignore frame because transmit queue is full!");
|
||||
}
|
||||
|
||||
dataConReceived(cemiFrame, false);
|
||||
@ -703,10 +704,14 @@ void TpUartDataLinkLayer::clearUartBuffer()
|
||||
|
||||
void TpUartDataLinkLayer::connected(bool state /* = true */)
|
||||
{
|
||||
if (state)
|
||||
if (state){
|
||||
println("TP is connected");
|
||||
else
|
||||
KNX_LOGI(KTAG, "TP is connected");
|
||||
}
|
||||
else{
|
||||
println("TP is disconnected");
|
||||
KNX_LOGI(KTAG, "TP is disconnected");
|
||||
}
|
||||
|
||||
_connected = state;
|
||||
}
|
||||
@ -934,6 +939,7 @@ void TpUartDataLinkLayer::loop()
|
||||
if (_rxOverflow)
|
||||
{
|
||||
println("TPUart overflow detected!");
|
||||
KNX_LOGE(KTAG, "TPUart overflow detected!");
|
||||
_rxOverflow = false;
|
||||
_rxState = RX_INVALID;
|
||||
}
|
||||
@ -941,6 +947,7 @@ void TpUartDataLinkLayer::loop()
|
||||
if (_tpState)
|
||||
{
|
||||
print("TPUart state error: ");
|
||||
KNX_LOGE(KTAG, "TPUart state error: %d", _tpState);
|
||||
println(_tpState, 2);
|
||||
_tpState = 0;
|
||||
}
|
||||
|
@ -224,11 +224,13 @@ template <class P, class B> class KnxFacade : private SaveRestore
|
||||
if (_progLedState)
|
||||
{
|
||||
println("progmode on");
|
||||
KNX_LOGI(KTAG, "progmode on");
|
||||
progLedOn();
|
||||
}
|
||||
else
|
||||
{
|
||||
println("progmode off");
|
||||
KNX_LOGI(KTAG, "progmode off");
|
||||
progLedOff();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user