does esp_log_set_vprintf() work with arduino framework?
Posted: Fri Aug 07, 2020 4:28 am
Hello,
trying to leverage the esp_log_set_vprintf() to direct the output to network service. And having no luck with it. Is it because of the arduino framwork ?
in the output i see that it executes the esp_log_set_vprintf(&double_vprintf);. But nothing seemed to come out from the double_vprintf(). I expect to see messages going over to mqqt and on the serial...
thank you for helping out.
trying to leverage the esp_log_set_vprintf() to direct the output to network service. And having no luck with it. Is it because of the arduino framwork ?
Code: Select all
#include <AWS_IOT.h>
#include <WiFi.h>
...
int double_vprintf(const char *fmt, va_list args) {
if (hornbill.publish(TOPIC_NAME,"Static payload") == 0) {
Serial.println("Printing from double_vprintf()");
} else {
Serial.println("hornbill.publish failed from the vprintf() ");
};
Serial.println("Printing from doubel_vprintf");
return vprintf(fmt, args);
}
...
void setup() {
...
if(0 == hornbill.subscribe(TOPIC_NAME,mySubCallBackHandler)) {
ESP_LOGI(TAG,"Registering double_vprint() ");
esp_log_set_vprintf(&double_vprintf);
ESP_LOGI(TAG,"Subscribe Successful");
// Serial.println("Subscribe Successful");
} else {
ESP_LOGE(TAG,"Subscribe Failed, Check the Thing Name and Certificates");
// Serial.println("Subscribe Failed, Check the Thing Name and Certificates");
while(1);
}
...
}
oid loop() {
if(msgReceived == 1) {
msgReceived = 0;
Serial.print("Received Message:");
Serial.println(rcvdPayload);
}
if(tick >= 5) { // publish to topic every 5seconds
tick=0;
sprintf(payload,"Hello from hornbill ESP32 : %d",msgCount++);
if(hornbill.publish(TOPIC_NAME,payload) == 0) {
ESP_LOGI(TAG,"Publish Message: %s",payload);
Serial.print("Publish Message:");
Serial.println(payload);
} else {
ESP_LOGI(TAG,"Publish failed");
Serial.println("Publish failed");
}
}
vTaskDelay(1000 / portTICK_RATE_MS);
tick++;
}
in the output i see that it executes the esp_log_set_vprintf(&double_vprintf);. But nothing seemed to come out from the double_vprintf(). I expect to see messages going over to mqqt and on the serial...
thank you for helping out.