tomaskovacik / BK3254

arduino library for A2DP bluetooth module based on BK3254 chip from Beken Corp (F-6888) and BK3266 based module F-6988 from HYT named HY5066 (not HY5066SR)
GNU General Public License v3.0
54 stars 18 forks source link

Fails to link when using SoftwareSerial on ESP8266 #5

Closed dzid26 closed 5 years ago

dzid26 commented 5 years ago

There is something in the BK3254 library that conflicts with SoftwareSerial. WIth HardwareSerial there is no problem. Also SoftwareSerial works by itself.

#define USE_SW_SERIAL
#include "BK3254.h"
SoftwareSerial ESPserial(2, 3); // RX | TX
BK3254 BT(&ESPserial, 2);

void setup(void){
}
void loop(void){
}

../appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-3-20ed2b9/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: ..\AppData\Local\Temp\arduino_build_936\sketch\sketch_feb03a.ino.cpp.o:(.text.startup._GLOBAL__sub_I_ESPserial+0x8): undefined reference to `BK3254::BK3254(SoftwareSerial*, unsigned char)'

../appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-3-20ed2b9/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: ..\AppData\Local\Temp\arduino_build_936\sketch\sketch_feb03a.ino.cpp.o: in function `__static_initialization_and_destruction_0':

..\AppData\Local\Temp\arduino_modified_sketch_685099/sketch_feb03a.ino:3: undefined reference to `BK3254::BK3254(SoftwareSerial*, unsigned char)'

collect2.exe: error: ld returned 1 exit status

Error details change depending on size of the program..

tomaskovacik commented 5 years ago

Use_sw_serial must be in bk3254.h Try it.ThxOn 4 Feb 2019 03:34, dzid26 notifications@github.com wrote:#define USE_SW_SERIAL

include "BK3254.h"

SoftwareSerial ESPserial(2, 3); // RX | TX BK3254 BT(&ESPserial, 2);

void setup(void){ } void loop(void){ }

../appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-3-20ed2b9/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: ..\AppData\Local\Temp\arduino_build_936\sketch\sketch_feb03a.ino.cpp.o:(.text.startup._GLOBAL__sub_I_ESPserial+0x8): undefined reference to BK3254::BK3254(SoftwareSerial*, unsigned char)' ../appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-3-20ed2b9/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: ..\AppData\Local\Temp\arduino_build_936\sketch\sketch_feb03a.ino.cpp.o: in function__static_initialization_and_destruction_0': ..\AppData\Local\Temp\arduino_modified_sketch_685099/sketch_feb03a.ino:3: undefined reference to `BK3254::BK3254(SoftwareSerial*, unsigned char)' collect2.exe: error: ld returned 1 exit status

Error details change depending on size of the program.. There is something in the BK3254 library that conflicts with SoftwareSerial. WIth HardwareSerial no problem. Also SoftwareSerial works by itself.

—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or mute the thread.

dzid26 commented 5 years ago

I tried it and it worked! Thanks. (Having SoftwareSerial makes my project so much less annoying since for some reason BK3254 is not able to pull down NodeMCU RX line which is connected to CH340G serial converter via 470ohm resistor. I wasted so much time until I put scope there and found out that it barely spikes down. Just throwing this information here - maybe someone will find it useful)

I don't understand though why defining constant before including header works in libraries like Encoder.h https://github.com/PaulStoffregen/Encoder/blob/3e2cf3ea12f5b6b24e6b9a28096d06d5853a0057/examples/NoInterrupts/NoInterrupts.pde#L13

Also, it seems that Arduino IDE caches the compilation somwhere, because once I make the example work by implementing your suggestion, then it works even if I undo that change. It makes it tricky to analyze and Arduino IDE needs to be restarted to bahave again as original.

tomaskovacik commented 5 years ago

probably because of this:

https://github.com/PaulStoffregen/Encoder/blob/3e2cf3ea12f5b6b24e6b9a28096d06d5853a0057/Encoder.h#L43

I will try it :)

t.

tomaskovacik commented 5 years ago

ok, it did not work, probably because another include is caled based on this not only some functionality in library code like in encoder lib.

also adafruit use it in their libs so there is probably no workaround :/