a couple years back I did a thread about how to do simple backrounding in a watch face, and at that time, time, the background just returned a string with the time it ran. This is similar, but here, the background uses BLE to talk to a Nordic Thingy52 and returns the temperature and the battery level, and shows some of the basics of the BLE interface in the new 3.1.0-beta1 SDK. To run it in the sim, you must user the 3.1.0 SDK, ave the HW for the sim to "talk" ble, and a Thingy52. For you have a f5+ with the speical CIQ FW, it will talk to the thingy52.
The ble stuff is all in BgBLE.mc and here's the basics:
A Temporal event starts things, and in onTemporalEvent, I create the profile manager, for the env and battery services and then pass that when I next set the Ble delegate. Then I start scanning.
In the delegate, onScanResults is called when BLE devices are seen in the scan. When a thingy is seen, I stop the scan and then pair the device.
When the device connects, I do a read of the battery level characteristic, and when that completes, I request notifications of temperature changes.
When I see the temp, I unpair and return the temperature, battery and timestamp in an array.
Lot's of println's so you see when things happen.
I did this one request at a time, because doing reads etc is single threaded to BLE, so I couldn't do the read and start notify at the same time, and didn't want to implement a queuing scheme for simplicity..
The only tricky thing is the thing goes to sleep after about 3 minutes, and the background can only run every 5 so you may have to wake up the thingy at times. (just tap it if it's been 4 minutes or so since the last time the BG ran.)