Fixed bug in hoermann.h and prints log message into esp_logd now.
This commit is contained in:
@@ -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
|
||||||
{
|
{
|
||||||
|
@@ -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.
|
||||||
|
Reference in New Issue
Block a user