Core Bluetooth

RSS for tag

Communicate with Bluetooth 4.0 low energy devices using Core Bluetooth.

Posts under Core Bluetooth tag

175 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Bluetooth Low Energy HID Gamepad PnP not accepted by iOS devices
Dear support We are developing a Bluetooth Low Energy HID Gamepad and are having issues connecting it to iOS devices (iPhone). Pairing is always successful. The issue is related to the PnP ID used. 1. If we use a PnP ID for a gamepad currently on the market - like a Google Stadia - there is no issue. The Gamepad connects (pairs) with the iPhone and is recognised in the iPhone "settings->general->game controller" Also if a "Game Controller Tester" APP is installed on the iPhone this works ok. 2. If we use our own PnP the Gamepad connects (pairs) but iPhone does not recognise it in "settings->general->game controller" . Also the "Game Controller Tester" APP does not work. The question is :- Is there something we need to do with our own PnP for it to be recognised by iOS devices. For info - on Android and Windows our PnP is recognised ok - we can control a Game Controller APP with it. The issue is only with Apple iOS devices. Any help would be welcome. Thanks JESP
3
0
534
Nov ’23
CBConnectPeripheralOptionEnableAutoReconnect not working
Hi, I am trying to use the new parameter option CBConnectPeripheralOptionEnableAutoReconnect when connecting to a peripheral. However I am receiving the error One or more parameters were invalid. I tested on iOS 17.1. I try to connect using this code: centralManager.connect(peripheral, options: [CBConnectPeripheralOptionEnableAutoReconnect: true]) Am I missing something? It looks like an iOS bug.
1
0
392
Nov ’23
Authorization-plugin: Invoke the Core Bluetooth APIs from the plugin
Hello, is it possible to interact with a nearby device through Bluetooth LE, from the authorization plugin? Currently, I have: a plugin bundle, registered with the authorization mechanisms; a daemon that I have set up to contain all the business logic added the com.apple.security.device.bluetooth entitlement to the daemon package, to allow Bluetooth communication; registered the daemon through LaunchDaemons so that it is managed by launchd And I'm using XPC to communicate between the plugin and the daemon. When I send the request to the daemon to scan for peripherals, I get a TCC error: 0xd5a Error 0x23e5 161 0 tccd: [com.apple.TCC:access] Refusing TCCAccessRequest for service kTCCServiceBluetoothAlways from client Sub:{...} in background session The above error seems to suggest that I can't grant the bluetooth permission from the daemon itself, is there a recommended way to grant permissions before running it? And if granted, would I be able to utilize the framework successfully from the logon screen? Other options I have tried: Invoking the framework directly from the plugin, which failed. Probably because the Security agent process isn't entitled to communicate via Bluetooth and that it would require changing the host process entitlements plist, which I don't have access to? 🤔 Attempting to use a launch agent in lieu of a daemon, with proper entitlement, but that didn't work either. Probably because launch agents are loaded after the user has successfully logged in and I was invoking it before? 🤔 And lastly, I looked into the possibility of utilizing Privacy Preference MDM payload to grant access, but it seems like the MDM options do not include Bluetooth support. Is there any other way to accomplish this? Thank you!
2
0
476
Nov ’23
Determine if a device support BLE Extended Advertising
I need to receive extended BLE advertising packets. I have my device advertising extended advertising packets (verified on third party app and embedded devices), however, I do not receive any of these packets in the centralManager didDiscover callback. I tried to see if my devices support extended advertising via the code below, however this check is always negative on both an iPad Mini 5th gen and an iPhone 14. Both of these should support BLE 5.0 features, correct? Is there some changes I need to make for my CBCentralManager scanning or callbacks to receive extended advertising data? if #available(iOS 13.0, *) { if CBCentralManager.supports(CBCentralManager.Feature.extendedScanAndConnect) { print("This device supports BLE Extended Advertising."); } else { print("This device does NOT BLE Extended Advertising."); } } else { print("Not iOS 13"); }
0
0
373
Nov ’23
How to pair specific BLE devices with designated iOS devices with multiple iOS devices and BLE devices in the same vicinity?
We need a method to uniquely pair 4 phones to 4 Bluetooth LE devices (each phone connects to one BLE device). They will all be operating at the same time, in the same room. On Android we store a list of MAC addresses of the BLE devices and the phone app lets the user select which device to connect. On Apple, MAC addresses can not be read when peripherals are discovered, so we are stuck. The preferred Apple approach seems to be to connect to a BLE device, then read its serial number, and check if it is the correct device. However, if we have 4 BLE devices all active at the same time, we could get stuck in an infinite loop where the phone keeps reconnecting to the same BLE device, finding it has the wrong serial number, disconnecting, ad infinitum. The "UUID encrypted MAC address" seems like a bad workaround. It would require all 4 users to wait for each other while they uniquely pair. If anyone accidentally left their BLE device on while another person was pairing, things could break. How do we solve this problem?
0
0
449
Oct ’23
Send Notification when Ble Device is discovered.
Hello there, So I'm currently building a small Ble Device that can be controlled via an app. For ease of use I want to give the users the ability to turn on a setting to receive a notification when the the device is turned on or in range. In other words if the phone can discover it. The difficult part is that I want this behaviour to also work if the app is terminated. I already tried using iBeacons by adding the iBeacon capability to my Ble Device and waiting for it to be discovered so the app launches in background mode. This technically works but I'm looking for a more elegant solution to bring the app from terminated to background if a Ble Device is scanned. Is there any way to accomplish that? Thanks for your help.
1
0
1.3k
Oct ’23
The Meaning of the Value Returned by readRSSI
CoreBluetooth will only update the RSSI value for a connected BLE device at least one second after the last call to readRSSI, effectively limiting the rate at which the RSSI value can be read to once every second. Is this a momentary measurement, or does it represent some kind of average over this one second? If this is not an average, what is the rationale for limiting the rate at which the RSSI value can be measured? Rate limitation verified in this thread: https://developer.apple.com/forums/thread/739727
1
0
483
Oct ’23
CoreBluetooth RSSI Measurement Rate Limitation
We are using the CoreBluetooth framework to communicate with a BLE device. We have the requirement to take many RSSI measures over a short span of time. To obtain these measurements, we call readRSSI on the peripheral object. The behavior we observe is that Core Bluetooth invokes didReadRSSI only once every second. This behavior does not seem to be documented anywhere. We have found several reports of the same issue, which have not been answered. For Example: https://developer.apple.com/forums/thread/698235 https://developer.apple.com/forums/thread/77277 https://stackoverflow.com/questions/61216589/fast-update-rssi-bluetooth-in-ios The first question would be: Is this the intended behavior? Secondly, is it documented somewhere? And lastly, are there any workarounds that would allow for a higher rate of taking RSSI measurements than 1 per second?
3
0
710
Oct ’23
Issue with Bluetooth Background Scanning on iOS 15.7.3. BLE. Swift
I'm facing an issue with background scanning of Bluetooth on devices with iOS 15.7.3. I'm developing an application that needs to discover BLE devices even in the background mode. However, the didDiscover method is not getting called during background scanning. Here's what I've already checked and configured in my project: Appropriate permissions for Bluetooth usage and background processing are in place. Flags in the project settings for background processing are configured correctly. I've verified that BLE devices are set up for advertising in the background. There are no physical obstacles or interference; devices and BLE devices are in an open environment. Additional details and conditions: The application initiates background scanning in the applicationDidEnterBackground method. At the beginning of the test, the BLE device is not accessible. I bring it near the iPhone after approximately 5 minutes of the app being in the background. If I don't move the BLE device away from the iPhone, it is detected almost immediately after the app goes into the background, but only once. The phone screen doesn't lock during the test. The CBCentralManagerOptionRestoreIdentifierKey option is used in the CBCentralManager. On an iPhone 12 mini with iOS 16.3.1, background scanning works, but the device is found only once for call scanForPeripherals method. The following filters are used: CBUUID(string: "330C5AD1-7261-4F06-B87C-0F6342365C2E") and CBUUID(string: "4c6607e0-2c3d-4fca-b201-0246773d6e9c"). If during the test you go to the Bluetooth settings of the iPhone (where there is a search for devices), the didDiscover method begins to report found devices Advertisement data for BLE looks like this 7 elements 0 : 2 elements key : "kCBAdvDataServiceUUIDs" value : 1 element 0 : 4C6607E0-2C3D-4FCA-B201-0246773D6E9C 1 : 2 elements key : "kCBAdvDataRxSecondaryPHY" value : 0 2 : 2 elements key : "kCBAdvDataTimestamp" value : 719149435.0168051 3 : 2 elements key : "kCBAdvDataLocalName" value : GB3_0CCE 4 : 2 elements key : "kCBAdvDataRxPrimaryPHY" value : 0 5 : 2 elements key : "kCBAdvDataServiceData" value : 1 element 0 : 2 elements key : 330C5AD1-7261-4F06-B87C-0F6342365C2E value : \<01020304\> 6 : 2 elements key : "kCBAdvDataIsConnectable" value : 1 Here is a link to the repository with the test application. This is a test application that I use for testing. The repository contains code that is not needed for testing. The required classes for testing are AppConfiguration, BackgroundScanManager, and BackgroundBLEManager. After bringing the BLE device near the iPhone, I wait for approximately 15-20 minutes. Please, help me understand why the didDiscover method is not being called in the background mode on iOS 15.7.3. Perhaps someone has encountered a similar problem and can provide advice or recommendations? Thank you very much!
1
0
894
Oct ’23
CBConnectPeripheralOptionEnableAutoReconnect option VS connect
In iOS17 this new option has been added in the peripheral connection option CBConnectPeripheralOptionEnableAutoReconnect The documentation states: After a peripheral device connects, this setting enables the system to initiate a connection to the peer device automatically when the link drops. The system uses centralManager(_:didDisconnectPeripheral:timestamp:isReconnecting:error:) to notify the caller about the disconnection. To get the same behavior I used to schedule a new connection after a disconnection depending on the error type. I'm trying to understands if the are more benefits using that flag instead the of "old" way. Can someone clarify that? Best, Andrea
2
3
482
Oct ’23
Problem with access to bluetooth
HI, i am new to IOS development. I work with Xcode 15.0, and IOS 17.0.3 I want to write an app to control a small robot using bluetooth. I get the following error message : This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSBluetoothAlwaysUsageDescription key with a string value explaining to the user how the app uses this data. However, in my infpo.plist, i have the following settings : <dict> <key>NSBluetoothAlwaysUsageDescription</key> <array> <string>This application requires Bluetooth to connect to the roboter</string> </array> <key>UIApplicationSceneManifest</key> <dict> <key>UIApplicationSupportsMultipleScenes</key> <false/> <key>UISceneConfigurations</key> <dict> <key>UIWindowSceneSessionRoleApplication</key> <array> </array> </dict> </dict> </dict> The project section looks like this : Any ideas ?
1
0
889
Oct ’23
xcode 17 failure with real device iOS 17 in flutter
When running the flutter project, the following message appears: Failed to verify code signature of /var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.payaqa/extracted/Runner.app : 0xe8008015 (A valid provisioning profile for this executable was not found.) Verify that the Developer App certificate for your account is trusted on your device. Open Settings on the device and navigate to General -> VPN & Device Management, then select your Developer App certificate to trust it. But, when I connected the iPhone show to trust. I can run other projects without problem with Switf directly. But when I tried to run using Flutter, show me this message. Macos: Sonoma 14 Flutter: channel Stable: 3.13.6 Xcode 15: 15A240d
6
1
2k
Oct ’23
fatal error: Index out of range...
class CalculatorViewModel : NSObject, ObservableObject, Identifiable { var id = UUID() @Published var output = "Disconnected" @Published var connected = false @Published var databasePath = String() enum itemType : Int{ case angle = 1 case degree = 2 case grip1 = 3 case grip2 = 4 } struct test_Array: Identifiable { var id = UUID() var time: String var swingNum : Int var dataSeqInSwing: Int var timeStampInSeq: Double var itemType: Int var value: Double } @Published var testDBdata = [test_Array] () ..... private var centralManager: CBCentralManager? func connectCalculator() { output = "Connecting..." centralQueue = DispatchQueue(label: "test.discovery") centralManager = CBCentralManager(delegate: self, queue: centralQueue) } .... func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) { ..... if characteristic.uuid == outputCharUUID, var data = characteristic.value { ..... DispatchQueue.main.async() { for index in tupleSets { strItemSets = index.components(separatedBy: ",") ....... var itemN = 1 for indexStr in strItemSets { self.golfDBdata[numDB].dataSeqInSwing = countItem. <= Error self.golfDBdata[numDB].itemType = itemN self.golfDBdata[numDB].value = Double(strItemSets[itemN]) ?? 0.0
5
0
660
Oct ’23
Connecting to a bluetooth device while app is terminated
Hello everyone! I'm currently working on an iOS app developed with Swift that involves connecting to a specific ble (Bluetooth Low Energy) device and exchanging data even when the app is terminated or running in the background. I'm trying to figure out a way to wake up my application when a specific Bluetooth device(uuid is known) is visible and then connect to it and exchange data. Is this functionality achievable? Thank you in advance for your help!
4
0
1.1k
Oct ’23
application(_:didFinishLaunchingWithOptions:) always invoked with nil bluetooth centrals in iOS 13
Hi, my app needs to use BLE in background mode and I have set up everything according to the CoreBluetooth docs and everything is running as expected except for application(_:didFinishLaunchingWithOptions:), which always returns a nil launchOptions. The reason why I want to use the bluetooth centrals keys in launchOptions is that I want to differentiate whether the central is newly created or restored from the background activities, so that I can have different init/reinit paths. But without the launchOptions, I am not sure how to achieve that. Some people said since iOS13 the launchOptions have been migrated to the scene delegate, but there is no equivalent option for the bluetooth centrals, does anyone know how to resolve it? Thanks.
0
0
243
Oct ’23
BLE MIDI auto connection/pairing
Hi there, We're developing a product which has a BLE module that advertises itself as a BLE MIDI device. The goal for our iOS app is to have the phone auto-connect to the device, which it already bonded with. Exactly like headphones; Bond one time, and everytime the headphones turn on, the phone automaticly pairs/connects to the headphones. At the moment, a new connection is required every time the the device turns on and advertises. I've read on the apple BLE documentation page, that from iOS 16 or later "the system automatically reconnects Bluetooth Low Energy (BLE) MIDI peripherals when powered on, if the device supports pairing. Previously, it was necessary to use Audio MIDI Setup to establish BLE MIDI connections." ( https://developer.apple.com/documentation/coremidi/midi_bluetooth/ ) However, neither our iPhones that run iOS 16+ or macOS 13+ devices re-connect to the BLE MIDI device. How can I achieve this? As per official BLE documentation, pairing is initiated by the central device (smartphone etc.) and the peripheral (BLE MIDI device) should simply store the MAC address + security information of the central device that it is currently bonded with.
0
0
639
Oct ’23