Fixed bug in hoermann.h and prints log message into esp_logd now.

This commit is contained in:
2025-09-29 19:18:23 +02:00
parent 2809b1a167
commit b8581dcf31
2 changed files with 10 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
#include "hciemulator.h" #include "hciemulator.h"
#include <string>
#define CHECKCHANGEDSET(Target, Value, Flag) \ #define CHECKCHANGEDSET(Target, Value, Flag) \
if ((Target) != (Value)) \ if ((Target) != (Value)) \
@@ -22,14 +23,19 @@ void LogCore(int Level, const char *msg, const unsigned char *data = NULL, size_
} }
if (data != NULL && datalen > 0) if (data != NULL && datalen > 0)
{ {
String newmsg(msg); //std::string newmsg(msg);
char* newmsg = (char*)malloc(strlen(msg) + datalen * 3 + 1);
strncpy(newmsg, msg, strlen(msg) + 1);
newmsg[strlen(msg)] = '\0';
char str[4]; char str[4];
for (size_t i = 0; i < datalen; i++) for (size_t i = 0; i < datalen; i++)
{ {
snprintf(str, sizeof(str), "%02x ", data[i]); snprintf(str, sizeof(str), "%02x ", data[i]);
newmsg += str; str[3] = '\0';
strncat(newmsg, str, sizeof(str));
} }
Serial.println(newmsg); ESP_LOGD(TAG, newmsg);
free(newmsg);
} }
else else
{ {

View File

@@ -46,7 +46,7 @@ class HoermannMainComponent: public Component{
dispatcherFn, // Function to implement the task dispatcherFn, // Function to implement the task
"ModBusTask", // Name of the task "ModBusTask", // Name of the task
10000, // Stack size in words 10000, // Stack size in words
true, // Task input parameter this, // Task input parameter
// 1, // Priority of the task // 1, // Priority of the task
configMAX_PRIORITIES - 1, configMAX_PRIORITIES - 1,
&modBusTask, // Task handle. &modBusTask, // Task handle.