BLE & problems while learning

I've just started playing with the BLE code, and come across a couple of things which have caused me problems so far. I thought I'd mention them here in case I'm doing something wrong, or they shouldn't happen or maybe it will help someone else:

  •  I thought I'd start off with the easiest uuid (or so I thought haha!) - so I set out to use the generic access, and get the device name ...
    • So service uuid = 00001800-0000-1000-8000-00805f9b34fb
    • Characteristic uuid = 00002a00-0000-1000-8000-00805f9b34fb
  • Running this in the simulator works fine to register the profile, but as soon as I try on my watch it crashes. No stack trace or anything. Just "Error: System Error" and "Details: Profile Registration Unhandled Error". Eventually I get around to trying a different (random-ish) uuid and of course that works fine ... So I'm guessing it is just the generic access one that doesn't work - maybe because the system code is using it itself in some way? (as device name is returned in scan results?)
  • A second problem that didn't help, is that in the simulator when I call BluetoothLowEnergy.registerProfile() then onProfileRegister() in the delegate is not called, making it hard to check the code. Again it turns out that running on my watch it works differently, and onProfileRegister() is actually called correctly.
  • I would expect it would be on a per app basis, and at some point, there may be less than 3 if you have a bunch of apps.

    You do know that you don't have to use a background process for BLE in a DF, right?  See the coin colleter sample in the SDK.

  • Yep in the data field I just have the BLE code running in the main process - but I've been thinking of trying some BLE in a background process for a watchface, as potentially it should be possible I think? That's what made me mention other background tasks as I was trying to think of how many different apps could be trying to use BLE at once!

    Even though it would only run once every 5 minutes in a watchface, for something like displaying the battery level of an e-bike that update rate would be fine. Although I'm not sure how expensive it would be to keep scanning every 5 minutes throughout the day for all the available BLE devices. And whether in that single update every 5 minutes it would be possible to scan, connect and retrieve some data values ...

  • I posted the source for a watch face that has a background process with BLE to get data from a thingy52 a few months back.  It's very possible.  I thought about doing one with the raspberry pi (I'm set up to get temperature form that), but opted to do it as a widget instead, as there are too many times I wouldn't be in BLE range to make a watchface  practical.

  • Cool, that sounds very interesting Slight smile

    I've found your post (forums.garmin.com/.../a-very-simple-wf-with-a-background-that-talks-ble-to-the-thingy52), so will check it out when I have some time, thanks!

  • I am trying to get Markdotai's emtb (github.com/.../emtb) running on a VivoActive 4 but it does not run correctly.
    It all runs fine with the simulator and a Nordic nRF52 or with an Edge 830.
    I have added  in the bleDelegate the onProfileRegister(uuid, status) but only on the VivoActive I get a status = 2 on each 2nd and 3th profile.
    Only the first profile is always registered (changing the order does not help).
    A status with value 2 is not documented in the API. I have also added getAvailableConnectionCount and it returns 3 (always).
    Suggestions ?

    ble:initialize
    bleInitProfiles avail:3
    ble:onScanStateChange SCAN_STATE_SCANNING SUCCESS
    ble:onProfileRegister 000018EF-5348-494D-414E-4F5F424C4500 SUCCESS
    ble:onProfileRegister 000018FE-1212-EFDE-1523-785FEABCD123 ERROR 2
    ble:onProfileRegister 0000180F-0000-1000-8000-00805F9B34FB ERROR 2

  • Sounds like this may be a bug in the va4 FW.  Try to create a simple app to demonstrate this, then file a bug report of that example app.

  •  - wow awesome testing, thanks for the investigating Slight smile The fact you have both a Vivo4 and a Nordic nRF52 is incredible! Will keep following with interest, and if I can help let me know.

    It looks like the profile register is being called in Initialize() so a simple fail example app should be quite short. I notice my code doesn't actually check the result of onProfileRegister, and it also doesn't wait for it to be called for each of the 3 profiles before continuing with other stuff. I don't know whether your modified version does, or if it's necessary. I think I assumed it would execute immediately and always succeed ...

  • My modified code doesn't wait either. I think I will try that in an example app. I just implemented all methods of BleDelegate, added a lot of println's to see what happens and printed the statusses as string. 

  • - cool, I've upvoted.

    Note you can also upvote it yourself, which may improve the time it takes to be investigated or fixed Slight smile