BLE not connecting on iOS 17 and above

I was able to get a fully functional app for iOS working, but I was testing it on an iPad running iOS 15 and now upon testing with an iPhone running iOS 17 the same app runs, yet does not connect to my BLE device. No errors are thrown when running. It was hard to pin down exactly which BLE functions iOS would accept for the iPad with iOS 15, but I need it to be able to connect to my device on both versions of iOS. any help is appreciated. Included is an image of my code and the .aia file on github


https://github.com/freshLobster/IM_screwball

Hello Aidan

Is the BLE device actually found by the iPhone?

Thoughts:

  1. The BLE range might be better on the iPad than it is on the iPhone.
  2. The global int list_i is only used as a List index ( value does not change from '1') before the code declares a device has been found - so that Alert is a false positive.
  3. The device names found/selected have a portion extracted - is that something you have been instructed to do? I ask because the BLE Lib for Android handles that for you. Your code assumes that every device name is structured in the same manner. That might be because they are on the Apple platform or maybe because your App only ever works with one specific device - if that is true, the name data could be stored on the App's first run and recalled thereafter.
  4. Stop scanning before attempting to connect
  5. Connect Button - you have a scenario where a disconnection could be immediately followed by a connection - that could buy trouble. A disconnection should not be required?

Did you get the permission prompts from the app when you try it on iOS 17? And what is the type of select_device? You seem to be starting to scan multiple times in BeforePicking and TouchDown. I wonder if that is also a source of issues. BeforePicking suggests that select_device is a ListPicker, and it might be that it's pushing a new view controller when the permission prompt is trying to be shown. Also, the ListPicker won't update while it is shown (e.g., in Bluetooth1.DeviceFound). For this flow, a ListView would be a better option.

Thanks for the response Chris. Yes the device is found by the phone.

  1. the range is fine, device shows up on both platforms as well as android and BLE equipped phones. the BLE device has its own antenna so range is actually really good.

  2. Thanks for pointing that out, I modified the structure of the block to increment the index from 0 after adding an item to the dict. it only happens once though because I dont want a flood of alerts. New block is as such:

  3. There is a separate version of the app for android where I dont need to do this. Through some testing I could only get the device list as a csv string and not the separate names without numbers, so the full string is the key and only the first number string of the device is the key. It's a holdover from some trial and error stuff that doesnt really do anything so I'm going to remove it.

  4. I've made this modification and will let you know how it works out once I have access to an iOS 17 device again for testing (I personally own an android so I have to borrow one)

  5. The intention is if it is already connected to a device and the user selects a different device to connect it will terminate the previous connection and connect to the new device. This is for forward compatibility with future devices as the app will be used for more than one model of device in the future. (it controls high end monster masks, but theres only one that currently uses the app)

Thanks for the advice! Like I mentioned, the app ran well and was fully functional in iOS 15 and doesnt encounter runtime errors on iOS 17, it just doesnt do anything when the connect button is pressed and never actually establishes a connection and doesnt throw any error or alert of a failed connection.

Yes I got permission prompts and that all works fine, I can see in settings that the phone has given the app BLE permissions. select_device is a list picker and only updates when BLE devices are found during scanning. There is only one device that this app can control at the moment, but I need an interface that can be used in the future when there are more device options created. The main problem is most likely somewhere in the peculiarities of how iOS 17 handles BLE connections since the app as is works fine in iOS 15.

Hi

Looks like the last two lines in the Device Found block belong in the 'then' Block.

What most developers do for these progress messages is to send them to a Label component. Use Alerts only when something has gone seriously wrong.

So have the disconnection much earlier in the code. If the User is going to swap devices there should be a button for that, so that everything, display and code, is reset.

I have also added the code my BLE device is running to github so you can see what the device itself is doing.
https://github.com/freshLobster/IM_screwball/blob/main/BLE_set_animation_state_espNow_UNIVERSAL_1_0_0_2.ino

None of the BLE methods for connecting are working. I could use any help I can get. A solid list of which BLE methods are known to work for iOS 17 and above would be very helpful.