I'm developing my software, but noticed one issue I couldn't get rid of. I'm developing in Arduino IDE and using BLE libraries provided by M5Stack package. Even the simplest examples also have this issue.
Program comes down to this:
- Initialise and start BLE server with onConnect() and onDisconnect() callbacks.
- Start advertising BLE device.
Expected behaviour is: I launch Cardputer, it advertises itself as BLE device, I connect to it.
Actual behaviour: I launch Cardputer, BLE server automatically fires onConnect(), then onDisconnect() (it does it constantly if I advertise when disconnected). But I still can connect to it.
I can even get mac address of a supposedly connected device. But my Bluetooth scanner doesn't show this mac, also this mac isn't from Cardputer.
I tried changing a lot of parameters, but discovered that not advertising (removing BLEDevice::startAdvertising();) removes this issue. But that means I can't connect to it now.
I tried loading the same program on M5StickC Plus2 and it actually works as expected. onConnect() and onDisconnect() don't fire automatically.
How do I solve this issue? My Cardputer is basically new.