Hi,
first I’m new here and want to thank PlatformIO for this great development environment.
I want to use ESP Now in my Arduino project which should run for ESP32 and ESP8266. I found the library WiFiEspNow which I manually copied to my project as I plan some mods to it.
My platformio.ini file contains this line
default_envs = esp32doit-devkit-v1, d1_mini, esp12e
The class is called EspNowClass and in the EspNow.cpp file the imports are as followed:
#include "EspNow.h"
#include <AES.h>
#if defined(ESP8266)
#include <c_types.h>
#include <espnow.h>
#elif defined(ESP32)
#include <esp_now.h>
#else
#error "This library supports ESP8266 and ESP32 only."
#endif
There are some methods in the cpp file like
bool EspNowClass::begin() {
return esp_now_init() == 0 &&
#ifdef ESP8266
esp_now_set_self_role(ESP_NOW_ROLE_COMBO) == 0 &&
#endif
esp_now_register_recv_cb(reinterpret_cast<esp_now_recv_cb_t>(EspNowClass::recv_cb)) == 0 &&
esp_now_register_send_cb(reinterpret_cast<esp_now_send_cb_t>(EspNowClass::send_cb)) == 0;
}
void EspNowClass::end() {
esp_now_deinit();
}
When I build the project the build succeeds for the esp32 but fails for the d1_mini and esp12e… The error message is all over the place for every esp_now_* function as well as for any ESP Now type in the espnow.h Here’s the error message of esp_now_init()
src/EspNow.cpp: In member function 'bool EspNowClass::begin()':
src/EspNow.cpp:57:25: error: 'esp_now_init' was not declared in this scope
return esp_now_init() == 0 &&
^
d1_mini and esp12e define ESP8266 properly so I would expect espnow.h to be included. Otherwise an include error should be seen. The header file exist in the installed package framework-arduinoespressif8266 in tools/sdk/include/espnow.h
Any help is very much appreciated.
Thanks,
Kujtim