Hi,
Did any body manage to add MH09 to ESP8266 as custom c++?
I am trying with:
This is my code:
#include <esphome.h>
#include <SoftwareSerial.h>
#include <CDBLEProx.h>
void ble_event(BLE_PROXIMITY_EVENT eventArgs);
SoftwareSerial sw(D1,D3);
CDBLEProximity ble(&sw,ble_event);
class BLE_Prox : public Component {
public:
void ble_event(BLE_PROXIMITY_EVENT eventArgs) {
if (eventArgs.eventID==BLE_EVENT_ON_DEVICE_LOST) {
Serial.println("No device");
Serial.println("");
//ESP_LOGD("custom", "Something");
}
if (eventArgs.eventID==BLE_EVENT_ON_DEVICE_APPROACH) {
Serial.println("New device");
//Serial.print("MAC: "); Serial.println(eventArgs.device.mac);
//Serial.print("HL : "); Serial.println(eventArgs.device.hilo);
//Serial.print("HI : "); Serial.println(eventArgs.device.hi);
//Serial.print("LO : "); Serial.println(eventArgs.device.lo);
//Serial.print("SIG: "); Serial.println(eventArgs.device.rssi);
//Serial.println("");
}
if (eventArgs.eventID==BLE_EVENT_ON_DEVICE_MOVED) {
Serial.println("Device moved");
//Serial.print("MAC: "); Serial.println(eventArgs.device.mac);
//Serial.print("HL : "); Serial.println(eventArgs.device.hilo);
//Serial.print("HI : "); Serial.println(eventArgs.device.hi);
//Serial.print("LO : "); Serial.println(eventArgs.device.lo);
//Serial.print("SIG: "); Serial.println(eventArgs.device.rssi);
//Serial.println("");
}
}
void setup() override {
Serial.begin(9600);
ble.begin();
}
void loop() override {
ble.update();
}
};
But I get:
/home/seeb/.platformio/packages/toolchain-xtensa/bin/…/lib/gcc/xtensa-lx106-elf/4.8.2/…/…/…/…/xtensa-lx106-elf/bin/ld: .pioenvs/mini4/src/main.cpp.o:(.text.startup._GLOBAL__sub_I_logger_logger+0x8): undefined reference to `ble_event(BLE_PROXIMITY_EVENT)’
collect2: error: ld returned 1 exit status
*** [.pioenvs/mini4/firmware.elf] Error 1