palto42 / komoot-navi

BLE Receiver for diplaying navigation info from Komoot app.
17 stars 3 forks source link

Komoot Service not Discovered #2

Closed thefriedc closed 4 years ago

thefriedc commented 4 years ago

Hi @palto42,

thanks for sharing your project. I had the same idea with an ESP and display laying around at home. After some googling, I found your project.

I got a question according the BLE service scan and am hoping that you can help me out. I am having troubles discovering the Komoot service.

Also when using your code, the ESP32 does not find the Komoot BLE Service. Komoot points out, that the ESP32 device must be paired with the Android device, but my Android phone cannot detect the ESP BLE client.

When I use the ESP BLE Server Sketch from Arduino IDE I can see the device in my Android Bluethooth devices list.

So my question: Did you need to pair your device in the Android settings and was there something you had to configure in the Komoot app for making this work?

I would be really grateful if you could point me in some direction.

Cheers Chris

palto42 commented 4 years ago

Hi @thefriedc I'm using it with a Samsung S8 with Android 9 and latest Komoot version 10.2.6 There is no pairing required for this BLE service, you just need to start the navigation in Kommot and this will automatically start the BLE service. Then start the ESP and it should find the service and connect. Just merged the Development branch into Master, but there was no change in the BLE code. I'm using PlatformIO (under VS Code or Atom) for compiling with the BLE library is "ESP32 BLE Arduino" version >= 0.4.16 (as defined in the platformio.ini).

What environment have you used for compile/upload?

thefriedc commented 4 years ago

Thanks a lot for the detailed information!

I am stuck with Android 8 on my Nexus 5x at the moment. I think this could cause the trouble.

Regarding the BLE Code - I tested with some BLE Tools and providing test services on my phone and I could detect all of them on my ESP. Nevertheless - I am not quite sure why Komoot pointed out the device pairing step explicitly on their github README

Hopefully I can get an Android 9 device for testing soon.

Thanks for your help! Chris

palto42 commented 4 years ago

Hi Chris

You are right that the device needs pairing, it was too long ago that I did it so that I forgot ;-)

But the pairing is not done in the Android Bluetooth settings but in the app itself. I updated the README in the "develop" branch with short instructions. Note that the device is paired as "Ciclo HAC bike computer".

I don't think that you need Android 9, I'm using this since more than a year ans as far as I remember it was still on Android 8 in the beginning.

thefriedc commented 4 years ago

Thank you - I am getting a little bit closer. I can discover the service indeed, when komoot tries to find the "HAC bike computer" (how did you come up with that idea at all?) Unfortunately - komoot is not able to discover the ESP client(?) so there is no pairing. Not getting past the "waiting for connection" message.

palto42 commented 4 years ago

The app stays in the connection dialog with "waiting for connection" even after it has discoveerd a device, but the discovered device is shown above the "waiting..." line.

Komoot-app-waiting

If you see the "Ciclo HAC device" with a check mark, you have to manually go back to the settings.

Btw.: I found another similar project jstiefel / esp32_komoot_ble .

thefriedc commented 4 years ago

I am never getting a checkmark during the connection process...

Actually I found out that there is maybe some Problem with the ESP32 BLE lib which is actually Version 1.0.1 now. My ESP is rebooting upon a kernel panic after reading the ble characteristic

I also found the other project already - there is also someone who also encountered the kernel panic problem :) https://github.com/jstiefel/esp32_komoot_ble/issues/3#issuecomment-530089381

Thanks again for putting in such an effort!

Just in case - I'll let you know, when I made some progress.

palto42 commented 4 years ago

Thanks for the hint regarding issues with new version, although I'm not sure if it's a bug in the BLE library or the Espressif ESP32 platform code 1.10.0 (or the combination).

First I tried my current code with old BLE lib 0.4.16 and new 1.0.1. Both didn't connect to Komoot, but I also didn't face kernel panic. It was just got stuck in the connection process.

Then I checked the updated examples on ESP32_BLE_Arduino and copied the changes to my code in new branch testing. With this the connection in the Komoot app settings can be established, but now I get the kernel panic if it tries to connect in navigation mode.

... so this needs some more testing and debugging

thefriedc commented 4 years ago

Never touch a running systen ;)

Sorry, to have you put in this situation. Everything seemed to work just fine.

So I also tried your code from testing branch. According to serial output the service is discovered and characteristics is obtained but then it seems to be stuck as you described:

Show messge: BLE try to connect BLE Advertised Device found: Name: , Address: 24:fc:e5:5c:ab:6d, manufacturer data: 7500420401806024fce55cab6d26fce55cab6c01000000000000 BLE Advertised Device found: Name: Nexus 5X, Address: 7b:b6:0b:53:26:a0, serviceUUID: 71c1e128-d92f-4fa8-a2b2-0f171db3436c Scan time: 0 connectToServer: - Create client

  • Connected to server
  • Refernce to service obtained - Refernce to characteristics obtained

But I still do get the kernel panic after some time - say 25 seconds.

Did you try to disconnect your device and start the initial connection process over?

palto42 commented 4 years ago

No worries, I still have my working device and try the new code on different test setup :-)

I can disconnect/re-connect the device old working code without issues, only with the current code doesn't work and gets stuck in panic loop.

thefriedc commented 4 years ago

Just to make sure: the panic loop is already during the connection screen on komoot?

On Tue, Sep 24, 2019, 09:41 Matthias notifications@github.com wrote:

No worries, I still have my working device and try the new code on different test setup :-)

I can disconnect/re-connect the device old working code without issues, only with the current code doesn't work and gets stuck in panic loop.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/palto42/komoot-navi/issues/2?email_source=notifications&email_token=AAWGXFNM365LT6N2LQY5R33QLHACHA5CNFSM4IYDINXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7NNBKA#issuecomment-534433960, or mute the thread https://github.com/notifications/unsubscribe-auth/AAWGXFJNI6Z3MBDX7QD4MVDQLHACHANCNFSM4IYDINXA .

palto42 commented 4 years ago

The panic loop starts if I start the navigation in the app. No crash if I just do the initial pairing (seems most other devices also work for pairing, e.g. 'Metz')

It always crashes in the "connectToServer" function after "Refernce to characteristics obtained" if it tries to register for notifications pRemoteCharacteristic->registerForNotify(notifyCallback);.

...
connectToServer:  - Create client
 - Connected to server
 - Refernce to service obtained - Refernce to characteristics obtained
 - can read
The characteristic value was: 9'#<␂�
 - can notify
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
...

Added some extra print commands for debugging this in testing branch.

palto42 commented 4 years ago

I tried the proposed fix from https://github.com/nkolban/esp32-snippets/issues/902#issuecomment-529969098 and it seems to work.

I forked the BLE lib and applied the fix in testing branch: https://github.com/palto42/ESP32_BLE_Arduino.git#testing (in PlatformIO I can simply reference this as library dependency).

No other code changed than https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/BLERemoteCharacteristic.cpp#L465-L466

thefriedc commented 4 years ago

Now I am completely lost. Didn't the instruction of chegewara mean to "remove" those two lines? Not to add them?

Nevertheless - I switched to PlatformIO on VS Code (Used Arduino IDE before) and also included your modified fork of BLE Arduino as dependency. Thanks for the hint! My Komoot app is still stuck on during the device connection process. There is never a device showing up in my Komoot app.

The serial output of my ESP would look promising

connectToServer: - Create client

  • Connected to server
  • Refernce to service obtained - Refernce to characteristics obtained
  • can read The characteristic value was:
  • can notify

But I am still missing the

Connected to desired service on BLE server

Seems my system is still stuck on the `pRemoteCharacteristic->registerForNotify(notifyCallback);

I switch to your master branch and try my luck there ...

thefriedc commented 4 years ago

Today, I tried to connect with an Android 9 phone it worked right away! Connected instantly and navigation instructions were written to the serial monitor when a route was started. Display does not show anything but this is OK since I am using a different display.

Komoot Version is 10.2.6 (using the same on my Android 8.1) Used the code of your testing branch and the BLE lib fork.

Thank you very much again for helping and sharing this cool project!

One question left: How long can you run your BLE thingy with an LiPo 600mAh battery?

palto42 commented 4 years ago

I have not really tested the operation time of the 600mAh LiPo, but I think it's maybe a bit oversized. I mainly selected it because it was cheap and size was ok. I have a smaller 150mAh LiPo which I will try next.

linusheck commented 4 years ago

Now I am completely lost. Didn't the instruction of chegewara mean to "remove" those two lines? Not to add them?

Nevertheless - I switched to PlatformIO on VS Code (Used Arduino IDE before) and also included your modified fork of BLE Arduino as dependency. Thanks for the hint! My Komoot app is still stuck on during the device connection process. There is never a device showing up in my Komoot app.

The serial output of my ESP would look promising

connectToServer: - Create client

  • Connected to server
  • Refernce to service obtained - Refernce to characteristics obtained
  • can read The characteristic value was:
  • can notify

But I am still missing the

Connected to desired service on BLE server

Seems my system is still stuck on the `pRemoteCharacteristic->registerForNotify(notifyCallback);

I switch to your master branch and try my luck there ...

Same for me for getting stuck at registerForNotify. Did it work on every version of Android that you tried? My phone has Android 7, beginning to suspect that may be the cause...

thefriedc commented 4 years ago

Same for me for getting stuck at registerForNotify. Did it work on every version of Android that you tried? My phone has Android 7, beginning to suspect that may be the cause...

Well, it did never work on stock Android. Tested versions are 8 and 9 (stock and Android One).

I could make it work on a Huawei device with their Android 9. And it worked on a Samsung Galaxy 6 device with (I guess) Android 8.

I wonder if one of those proprietary bike computer devices which use BLE connect can connect with Komoot running on native Android.

I cannot find that Komoot BLE github repo anymore. Did they remove it?

palto42 commented 4 years ago

Komoot moved the documentation from Github to Google Docs https://docs.google.com/document/d/1iYgV4lDKG8LdCuYwzTXpt3FLO_kaoJGGWzai8yehv6g/

thefriedc commented 4 years ago

Yes, I recognized that. I guess, this was done so no one can post bugs to their repository anymore.

On Wed, 4 Mar 2020, 20:08 Matthias, notifications@github.com wrote:

Komoot moved the documentation from Github to Google Docs https://docs.google.com/document/d/1iYgV4lDKG8LdCuYwzTXpt3FLO_kaoJGGWzai8yehv6g/

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/palto42/komoot-navi/issues/2?email_source=notifications&email_token=AAWGXFPSMWDJHIUP7QMZCI3RF2RMLA5CNFSM4IYDINXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENZVHZY#issuecomment-594760679, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWGXFI7YK6P2XEFLPTME4TRF2RMLANCNFSM4IYDINXA .