UWP Bluetooth​LEAdvertisement​Watcher periodically gets in Aborted state - bluetooth

My UWP C# application is by essence a headless one running in Win 10 IoT (current Insiders Preview build 10.0.17035.1000) on Raspberry Pi 3 SBC. Part of its functionality is to communicate with BLE devices. It is pretty stable but there are some UWP BLE communication problems I encounter. The most important one for now is that UWP Bluetooth​LEAdvertisement​Watcher, after started and stopped multiple times, periodically gets in Aborted state on a Start command. The solution I currently use to recover from a pending Aborted state is to restart the device using ShutdownManager.BeginShutdown() method. Can you, please, advise me if there is a more elegant solution to recover the Bluetooth​LEAdvertisement​Watcher to Started state.

Related

Qt Bluetooth Low Energy Multiple Connections

Qt: 5.10,
Linux Ubuntu 17.10,
Bluez 5.4x
and I´m using QBluetooth to connect with multiple Bluetooth Low Energy Devices. Everything works fine for one Connection. But when I connect to a second Device with QLowEnergyController::connectToDevice() I get the following error and the first Connection gets aborted:
qt.bluetooth.bluez: Cannot connect due to pending active LE Connections
qt.bluetooth.bluez: void QBluetoothSocketPrivate::_q_readNotify() 21 error: -1 "Software caused Connection abort"
After that the second connection gets established.
I`m using one instance of QLowEnergyController in Central Mode per Connection.
After a Research I think it should be possible to create multiple Connections to BLE Peripherals with the Bluez Bluetooth Protocol Stack. But I´m not sure if QBluetooth support this Feature...
Does anybody know something about multiple LE Connections with QBluetooth?
Is this the right way to establish a second Connection?
Does somebody know a good Workaround?
Thanks for your help!
The problem isn't BLE, but its Qt implementation. The documentation says that any attempt to connect simultaneously to two BLE devices using QLowEnergyController will fail. Check it there: http://doc.qt.io/qt-5/qlowenergycontroller.html ; Section "Detailed Description", paragraph 5:
"BlueZ based Linux cannot maintain two connected instances of QLowEnergyController to the same remote device. In such cases the second call to connectToDevice() may fail."
According to this, it should be possible to establish connexion to two different remote devices using two instances of the class, but it simply doesn't work. If you keep on reading the documentation, you'll find out that " This limitation may disappear at some stage in the future.".
I tried a workaround by disconnecting from the first device before connecting to the second device (both TI SensorTag), but since I had to re-discover the services and re-enable the sensors (see disconnectFromDevice() in the documentation) every time I would re-connect the program became way too slow.
If you want to connect to two devices using Qt, you have to use the Bluez API through the D-Bus with Qt's D-Bus classes.
Edit:
I managed to connect to multiple devices using D-Bus classes. The architecture of my program isn't much more complicated, only the syntax got a little more tricky. The only big issue was the BlueZ version: the D-Bus interface changed a lot between 5.3x (default Ubuntu 16.04) that doesn't support Low Energy (experimental...) and later versions. I think that's the reason why Qt's D-Bus Bluetooth hasn' been enabled yet. Since BLE isn't flagged as experimental since BlueZ 5.42, you should be fine using D-Bus with your current version. For the record, I'm perfectly fine using D-Bus with Raspbian's default 5.9 BlueZ.

Can I connect via Bluetooth(or USB) to a device sitting locally at my desk from the App running on Test-Cloud?

I work with POS devices. We have a cross-platform mobile Xamarin App which talks to POS devices using Bluetooth or USB.It would be a great help if you can do that.
No you cannot, unfortunately the only way to interact with any device needed by the mobile client is through web requests. Unfortunately this is limited because no 1 BLE solution would work for everyone (actually it would only work for very few).
Another challenge is that the automated UI tests will run in the order determined by Xamarin Test Cloud and you may potentially have multiple devices interacting with your one device.
You could do this all locally though on your own device. You would just trigger the UITest locally through the command line and have the BLE device by your phone. I know this isn't ideal, but really one of your best options here.
The other option you have is creating a middle-man for your POS devices. Basically the middleman would be a REST API hosted on some IoT device that contains BLE integration. You would than have to forward the BLE requests from the IoT device to your POS device, but this solution would require larger time frames for the data to transfer and wouldn't necessarily be a "real-world" testing scenario. I would expect that you would have some false failure tests due to the details with creating this solution. I have done something similar for Particle, but I was only able to run UI Tests on 1 device at a time.
Disclosure: I work for Xamarin/Microsoft.

iOS 7.1 iPod 5th generation request for the state of beacon and ranging not happening

With the update of iOS 7.1 there is much changes in the ibeacon API for requesting, ranging beacon in the background even when app is killed or not launched, here are some of the things i observed as per the ranging for the beacons , in iPod 5th gen running with iOS 7.1
didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region
doen't get called, but where as i run the same code in iPhone5 with 7.1 all the methods were getting called, its kind of a weird behaviour i'm facing,
http://www.proxima.io/blog/posts/2014-03-12-ios-7-1-ibeacon-tech-deep-dive/
as per the above link , it gives me something like there is not much update about ibeacon for the iOS7.1 in iPod 5th generation
Does any one faced this kind of same issue?
Be sure you wait up to 15 minutes to get a call to didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region before you conclude it does not work. On some devices, detection cash take that long. See here. Do not expect calls to be received on both devices in a similar time frame. One may be fast and the other slow based on model and internal state.
Other tips: try rebooting both devices to put them in the same state, and verify the problem persists. Avoid running other iBeacon or Bluetooth apps simultaneously, as this can affect your test results. I do not have access to an iPod for testing, but I know other folks report (including those at the page you reference) that iPods work fine with these APIs

SW2 Control Extension stop updating the Display when the smartphone is idle

I'm working on a Control Extension for Sony SmartWatch 2 that needs to update a TextView every second on the SW2 Display.
It happens that if I've my Smartphone connected via USB or when USB disconnected if I've my Smartphone screen active, the Control Extension works as expected on SmartWatch 2.
But soon my SmartPhone screen idles, the control extension stops the regular TextView updates. First starts breaking and eventually get stuck. The Extension is not closed by the Host Application and the SW2 continues well paired with the Smartphone. In fact if I touch the display, the Extension appears to recover state for some moments with a few TextView updates, but rapidly breaks and get stuck again.
Meanwhile, if I turn ON my Smartphone screen, the control extension recovers the state and resume the normal TextView updates.
It seems that when the smartphone idles it stops to send the regular bluetooth messages to the SW2. I've tried many solutions to avoid this behaviour, even set the keepRunningWhenConnected to true. But the behaviour is allways the same.
Is anyone also having this problem or have a clue for the solution?
Thanks :)
What model of phone are you using?
If it is indeed that the bluetooth connection is not persisting then you could try the following possible solutions:
Is there a setting on the phone to keep bluetooth on even when going into idle?
You could set the phone to not go into idle while your app is running, of course this is not ideal as it will cause battery drain.
Ok. After testing and testing several solutions (AlarmManager, BluetoothAdapter, etc...) I came to following conclusion:
Its not the Bluetooth connection that is lost, otherwise the SmartWatch 2 would lost connection with the Smartphone, and that never happens. In fact is the Phone CPU that is lost by the ControlExtension, because when the Smartphone idles the CPU also idles. By loosing the Phone CPU the ControlExtension cannot process the "sendText(...)" call and this means that the corresponding upper call "sendHostApp(...)" that uses the Bluetooth messages its also never called, that's why the TextView is not updated on the SmartWatch 2.
Also I think that when I touch the SmartWatch 2 screen, this triggers an hardware interruption that wake up the Phone CPU for short seconds to answer to the SmartWatch 2 Touch Event and thats why when I touch the SW2 screen the TextView is updated a few times before get stuck again.
This works fine for static Control Extension applications that only display static content and/or replies to the user (touch, swipe, etc...) events. But its a complete disaster for Control Extensions applications that need to be doing some processing regardless the user direct interaction.
I never though in this terms because I though that it was the job of the SmartConnect Host Application to guarantee Phone CPU to the Control Extensions.
So the solution for some apps could be using an AlartManager in order to schedule wake up calls to do some processing. For other apps the solution could be the PowerManger and use a wakelock.aquire()/wakelock.release().

iOS BLE - How to keep app active in the background?

I am trying to find a clever way to keep a BLE app active in the background on iOS 6, without breaking any of Apple's rules. I plan to use the phone as a peripheral device and another BLE circuit as the central. My app will automatically be opened when a user arrives to a building using geofencing. After that the iPhone will connect to the first BLE central device it sees (the device will be in its white list). The user will then be able to move throughout the building switching to different BLE "nodes".
My question is: What do I need to do in the background when a user is stationary at their desk so that the app does not get suspended due to memory resources?
My idea is based on this solution for a separate problem: There could potentially (not regularly) be 10-50 users in an area with only a few BLE "nodes" and I read at bluetooth.org that I could setup a dynamic connection system, basically rotating connections through all the users.
My idea is to setup a similar dynamic system where the central device (not the iPhone) disconnects the device on regular intervals (30-40 minutes) and then the iPhone will reconnect.
Is this something that some feasible? Is this against the iOS development guidelines? I was unable to find anything explicit about this. I have also asked on the iOS developer forum, but unfortunately it is not as popular as this site.
Thanks in advance!
Xcode -> Project target -> Capabilities -> Enable background mode
Check Uses Bluetooth LE Accessories
Capabilities
Also enable the following key in .plist file
Required background modes
App communicates using CoreBluetooth
Plist

Resources