snowzach / echbt

55 stars 3 forks source link

Is anyone having issues connecting to BLE on the bike? #5

Closed lamxing closed 1 year ago

lamxing commented 2 years ago

Recently bought the ESP32 board and the BLE scan was not able to find the bike. It found a bunch of other BT devices, just not the bike for some reason. Using a BT scanner app on the phone, I was able to find the bike.

It used to work with an older ESP32 board that I've bought, but the newer ones do not seem to be able to connect. Can someone share some insights?

snowzach commented 2 years ago

I have found that I need to be pretty close to the bike and it must not be paired with any other device and the light must be blinking blue. If that's all true, I am curious what you see when you scan using BT scanned apps on the phone. Does it see one of these UUIDs

static BLEUUID     deviceUUID("0bf669f0-45f2-11e7-9598-0800200c9a66");
static BLEUUID    connectUUID("0bf669f1-45f2-11e7-9598-0800200c9a66");
static BLEUUID      writeUUID("0bf669f2-45f2-11e7-9598-0800200c9a66");
static BLEUUID     sensorUUID("0bf669f4-45f2-11e7-9598-0800200c9a66");
lamxing commented 2 years ago

Yeah on the phone it does show this serviceUUID, just can't ever see it on the ESP32. I wonder if the device itself is faulty (but tried 5 of them from 2 different vendors), or something changed in the underline lib that caused this...

kingdogfish commented 2 years ago

Same boat. Phone can find the echelon but the recommended board does not see it on BLE

snowzach commented 2 years ago

So someone was having issues with this, and I shipped them one of my boards after loading the software on it and it worked fine for them. I'm not sure if it's cheap copycat hardware or they changed something with the bluetooth libraries in Arduino. These are the ones I bought FWIW https://www.amazon.com/gp/product/B07DKD79Y9

kingdogfish commented 2 years ago

Interesting. I bought the makerfocus one. The one listed in the readme https://www.amazon.com/gp/product/B076KJZ5QM not the hiletgo version

I'll purchase one of those and give it a go. I'm watching the serial output and am seeing random devices.. I don't know enough to troubleshoot further.

kingdogfish commented 2 years ago

What version/integration are you using? I am going to start trying multiples. ESP32 BLE Arduino version 1.0.1 is what I am on

I removed that.

I've done some random stuff to no luck, but I am getting a device advertising now, but no serviceUUID

11:10:24.119 -> BLE Advertised Device found: Name: ECH-SPORT-105779, Address: 58:3a:93:18:1e:6b, manufacturer data: 4c001005301cea9e4e, txPower: 6

also curiously the Address is changing

edit edit edit. Power cycled bike.

11:13:34.779 -> BLE Advertised Device found: Name: ECH-SPORT-105779, Address: 58:3a:93:18:1e:6b, manufacturer data: 4c001005711cea9e4e, serviceUUID: 00001010-0000-1000-8000-00805f9b34fb

snowzach commented 2 years ago

I'm just using plain old arduino with the standard tools. Version 1.8.13 with the Heltec libraries https://resource.heltec.cn/download/package_heltec_esp32_index.json I compiled it and I uploaded a binary to the releases page of this repo.

kingdogfish commented 2 years ago

I'm 1.8.19 with the Heltec as well. I flashed your BIN and same exact things. So it might be hardware revision or something of the ESP chip? Or I have a newer bike and it's doing something funky.

I plug in the bike, have it really close/on the bike, and my phone can attach to it. I can use a BLE app to make it connect. ESP - no go.

Makerfocus: Chip Info:

Hiletgo: Chip Info:

Or, I wonder if it's related to V1 vs V2 or V2.1 of the heltec design. I'm clearly on one of the V2 variants. The Hiletgo is also a v2 variant.

snowzach commented 2 years ago

Hmmm... the service ID doesn't look like any of the other identifiers from my bike. If you can use a bluetooth debugger on your phone and read the attributes, it might be just as simple as replacing the service IDs.

image

snowzach commented 2 years ago

I am not sure if there is an app on iphone like android where you can connect to ble devices. If you can try that and see if it emits "characteristics" with the same uuids then it must be something with the firmware and newer devices.

kingdogfish commented 2 years ago

update: can spoof the device using an app on my phone and the ESP connects to my device no problem at all. So I think it's an incompatibility with the bike's bluetooth and the ESP or the ESP's library. Probably the hardware itself.

So, I am able to run the generic ESP32 BLE example client test on a esp32-devkitv1 and this line pops up!

16:58:24.514 -> BLE Advertised Device found: Name: ECH-SPORT-105779, Address: e4:9b:58:9d:21:08, serviceUUID: 0bf669f0-45f2-11e7-9598-0800200c9a66

So I think we have a heltec incompatibility. Tried a random ESP32 and it DID work with your script after cutting out the display code. So! I don't know how to fork or push or request or how to do any of that on github, but I am going to find a screen/display and get it working with your glorious code

I did a dirty hack for now image

// all the heltec code and added this to the update display loop Serial.println("Cadence: " + String(cadence) + " Power: " + String(power) + " Resistance: " + String(resistance));

snowzach commented 1 year ago

Good hack!

boojew commented 3 months ago

I was struggling with this same issue.. I believe the issue seems to be in the board manager libraries and potentially with how the ble library is reporting UUIDs. My fix was two part

I need to do more testing, but so far it works

boojew commented 3 months ago

For anyone looking at this, I did make some code mods that need some further testing- but the current maker focus board Bluetooth antenna is underpowered for this. I upgraded to a Heltec Lora with external antenna and it now works very reliably.

snowzach commented 3 months ago

Feel free to open a PR, happy to accept changes if it makes it more reliable...