Using the new Arduino IDE for ESP8266 and found bugs, report them here

Moderator: igrr

User avatar
By emxfer
#39131 Hello,
i've the Arduino IDe 1.5 r5, ESP8266 2.0 platform libraries (Linux Ubuntu 64 platform).
The IDE works perfectly on all examples and the code works on NODEMCU, but now i'm trying to test an espnow communication program as downloaded from lowreal.net (this sketch is for slave) and i got an error.

Code: Select all#include <Arduino.h>
#include <ESP8266WiFi.h>
extern "C" {
#include <espnow.h>
#include <user_interface.h>
}

#define WIFI_DEFAULT_CHANNEL 1

uint8_t mac [] = {0x1A, 0xFE, 0x34, 0xEE, 0x84, 0x88};

void printMacAddress (uint8_t * macaddr) {
  Serial.print ("{");
  for (int i = 0; i < 6; i ++) {
    Serial.print ("0x");
    Serial.print (macaddr [i], HEX);
    if (i < 5) Serial.print (',');
  }
  Serial.println ("}");
}

void setup () {
  pinMode (13, OUTPUT);

  Serial.begin (74880);
  Serial.println ("Initializing ...");
  WiFi.mode (WIFI_STA);

  uint8_t macaddr [6];
  wifi_get_macaddr (STATION_IF, macaddr);
  Serial.print ("mac address (STATION_IF):");
  printMacAddress (macaddr);

  wifi_get_macaddr (SOFTAP_IF, macaddr);
  Serial.print ("mac address (SOFTAP_IF):");
  printMacAddress (macaddr);

  if (esp_now_init () == 0) {
    Serial.println ("direct link init ok");
  } else {
    Serial.println ("dl init failed");
    ESP.restart ();
    return;
  }

  esp_now_set_self_role (ESP_NOW_ROLE_CONTROLLER);
  esp_now_register_recv_cb ([] (uint8_t * macaddr, uint8_t * data, uint8_t len) {
    Serial.println ("recv_cb");

    Serial.print ("mac address:");
    printMacAddress (macaddr);

    Serial.print ("data:");
    for (int i = 0; i < len; i ++) {
      Serial.print (data [i], HEX);
    }
    Serial.println ("");
  });
  esp_now_register_send_cb ([] (uint8_t * macaddr, uint8_t status) {
    Serial.println ("send_cb");

    Serial.print ("mac address:");
    printMacAddress (macaddr);

    Serial.print ("status ="); Serial.println (status);
  });

  int res = esp_now_add_peer (mac, (uint8_t) ESP_NOW_ROLE_SLAVE, (uint8_t) WIFI_DEFAULT_CHANNEL, NULL, 0);

  uint8_t message [] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x08};
  esp_now_send (mac, message, sizeof (message));
  ESP.deepSleep (2.5e6, WAKE_RF_DEFAULT);

  // Esp_now_unregister_recv_cb ();
  // Esp_now_deinit ();
}

void loop () {
}


The compile process give the following errors:

Code: Select allESPNOW_Slave.cpp.o:(.text.setup+0x34): undefined reference to `esp_now_init'
ESPNOW_Slave.cpp.o:(.text.setup+0x38): undefined reference to `esp_now_set_self_role'
ESPNOW_Slave.cpp.o:(.text.setup+0x3c): undefined reference to `esp_now_register_recv_cb'
ESPNOW_Slave.cpp.o:(.text.setup+0x40): undefined reference to `esp_now_register_send_cb'
ESPNOW_Slave.cpp.o:(.text.setup+0x44): undefined reference to `esp_now_add_peer'
ESPNOW_Slave.cpp.o:(.text.setup+0x4c): undefined reference to `esp_now_send'
ESPNOW_Slave.cpp.o: In function `HardwareSerial::begin(unsigned long)':
/home/user/.arduino15/packages/esp8266/hardware/esp8266/2.0.0/cores/esp8266/HardwareSerial.h:77: undefined reference to `esp_now_init'
ESPNOW_Slave.cpp.o: In function `setup':
/home/user/Downloads/arduino-1.6.5-r5/ESPNOW_Slave.ino:28: undefined reference to `esp_now_set_self_role'
/home/user/Downloads/arduino-1.6.5-r5/ESPNOW_Slave.ino:28: undefined reference to `esp_now_register_recv_cb'
/home/user/Downloads/arduino-1.6.5-r5/ESPNOW_Slave.ino:31: undefined reference to `esp_now_register_send_cb'
/home/user/Downloads/arduino-1.6.5-r5/ESPNOW_Slave.ino:33: undefined reference to `esp_now_add_peer'
/home/user/Downloads/arduino-1.6.5-r5/ESPNOW_Slave.ino:36: undefined reference to `esp_now_send'
collect2: error: ld returned 1 exit status
Error compiling.


It seems that the linker is'nt able to find the libespnow.a library, that i found under
~/.arduino15/packages/esp8266/hardware/esp8266/2.0.0/tools/sdk/lib/ path.

I don't know if it is a bug or i'm missing something can someone please help?

Regards

Emilio
User avatar
By Koichi Kurahashi
#44161 Hi,


Quit Arduino IDE and edit this file:
~/Library/Arduino15/packages/esp8266/hardware/esp8266/2.1.0/platform.txt

// sorry I don't know about windows...

Search "compiler.c.elf.libs", and append "-lespnow" at the end of the line. Then you can build it by Arduino IDE.


koichi
User avatar
By emxfer
#48767 Thanks Dand anny Koichi,
your solutions worked as a charm, at the end i settled for koichi solution, less changes, and now all ESPNow library is completeliy accessible by Arduino IDE.

Thanks again
Emilio