Core Bluetooth

RSS for tag

Communicate with Bluetooth 4.0 low energy devices using Core Bluetooth.

Posts under Core Bluetooth tag

186 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Example for AccessorySetupKit bluetoothTransportBriding
Hi there! I'm developing a dual-mode bluetooth accessory and would like to pair it through AccessorySetupKit. I'm using an ESP32 with Bluekitchen btstack. This supports CTKD, which seems to be a requirement for the Bluetooth transport bridging according the WWDC19 session 901. I've been in contact with the btstack developer and verified that I can get the device to generate an LTK for the classic transport when reading an encrypted attribute. I'm not able to get this to work with the bluetoothTransportBriding option with AccessorySetupKit though. What I've found so far is that if I omit the .bluetoothTransportBriding option during pairing I will get a pairing request when I read an encrypted attribute after connecting with the CBConnectPeripheralOptionEnableTransportBridgingKey option. If I accept this request it seems like the system automatically brings up the A2DP profile. However if I include .bluetoothTransportBriding and/or .bluetoothPairingLE this option does not pop up, but the system does not bring up the A2DP profile. In this case things seem to end up in a weird situation where the device doesn't show up for pairing in Bluetooth Settings either, making it impossible to manually connect for A2DP. Based on the AccessorySetupKit example from WWDC24 I've created a dice accessory firmware for ESP32 using btstack. The code for this is available here: https://github.com/ljodal/esp32-btstack-ctkd-test I've also tweaked the AccessorySetupKit example app for iOS to add the ASAccessory.SupportOptions. The code for that is available here: https://github.com/ljodal/accessorysetupkit-ctkd-test Is there any documentation available anywhere on what is expected of the device for Bluetooth Transport Bridging to work with AccessorySetupKit?
0
0
87
1d
CoreBluetooth and BLE AdvertisementData
Hi, We're receiving data via centralManager.centralManager.scanForPeripherals, with no options or filtering (for now), and in the func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) callback, we get advertisementData for each bluetooth device found. But, I know one of my BLE devices is sending an Eddystone TLM payload, which generally is received into the kCBAdvDataServiceData part of the advertisementData dictionary, but, it doesn't show up. What is happening however (when comparing to other devices that do show that payload), is I've noticed the "isConnectable" part is false, and others have it true. Technically we're not "connecting" as such as we're simply reading passive advertisement data, but does that have any bearing on how CoreBluetooth decides to build up it's AdvertisementData response? Example (with serviceData; and I know this has Eddystone TLM) ["kCBAdvDataLocalName": FSC-BP105N, "kCBAdvDataRxPrimaryPHY": 1, "kCBAdvDataServiceUUIDs": <__NSArrayM 0x300b71f80>( FEAA, FEF5 ) , "kCBAdvDataTimestamp": 773270526.26279, "kCBAdvDataServiceData": { FFF0 = {length = 11, bytes = 0x36021892dc0d3015aeb164}; FEAA = {length = 14, bytes = 0x20000be680000339ffa229bbce8a}; }, "kCBAdvDataRxSecondaryPHY": 0, "kCBAdvDataIsConnectable": 1] Vs This also has Eddystone TLM configured ["kCBAdvDataLocalName": 100FA9FD-7000-1000, "kCBAdvDataIsConnectable": 0, "kCBAdvDataRxPrimaryPHY": 1, "kCBAdvDataRxSecondaryPHY": 0, "kCBAdvDataTimestamp": 773270918.97273] Any insight would be great to understand if the presence of other flags drive the exposure of ServiceData or not...
0
0
14
1d
Terrible performance on iPad 11th BLE attribute notification messages.
We've been developing an iOS app in Swift for several years that run on iPad tablets in which our proprietary device emits EEG signals via BLE to the app running on the iPad tablet. The device emits the data as BLE notification messages in which the MTU is set to the maximum size that is allowed between our device and the iPad. Our device when communicating with the app running on a 10th generation iPad running iOS 18.5 it takes less than 200ms to transmit an interval of EEG signals which occurs at 500ms. Under the same conditions same version of iOS & app and the same device but using an iPad 11th generation, it takes anywhere from 800ms to 1.1 seconds (4x to 5x) to transmit an interval. Our device transmits the EEG ****** using several ATT notification messages using the maximum MTU size. We are perplexed about such a huge step down in performance when running on the iPad 11th generation tablets. iPad generation Chipset Firmware -------------------------------------------------------------- 10th BCM_4387 22.5.614.3457 11th SRS_7923 HCI Rev. 2504 sub. 5003 We know that the 10th generation iPad used chipset manufactured by Broadcom. Whereas the iPad 11th generation that we've received uses a SRS chipset in which I'm unfamiliar with that chipset's manufacturer. We question if this performance degradation is due from the chipset manufacturer, the firmware revision when using attribute notifications messages over BLE in such a context. Using PacketLogger as to log the communication between the iPad tablets and our device and after analysis we haven't found anything that identifies difference in configuration settings that are exchanged between our device and iPad tablets that account for this performance degradation. Fortunately, our device is designed to work in complex environments & contexts and thus it has mechanisms accounting for transmission delays and interferences. I'd appreciate if any other Apple Developer or Apple staff is aware of the degradation when transmitting BLE attribute notification messages with the newer Apple devices using this series of chipset. If so, then: Are there any recommendations of solutions to improve this latency? Is this is being addressed for iPad 11th generation tablets? Regards, Steven Belbin Principal Developer at NeuroServo Inc.
0
0
47
3d
Unable to use Bluetooth in watchOS companion app if iOS uses AccessorySetupKit
FB18383742 Setup 🛠️ Xcode 16.4 (16F6) 📱 iPhone 13 mini (iOS 18.0.1) ⌚️ Apple Watch Series 10 (watchOS 11.3.1) Observations As AccessorySetupKit does not request "Core Bluetooth permissions", when a watchOS companion app is installed after having installed the iOS app, the toggle in the watch settings for Privacy & Security > Bluetooth is turned off and disabled After removing the iPhone associated with the Apple Watch, Bluetooth works as expected in the watchOS app Upon reinstalling the iOS app, there's a toggle for Bluetooth in the iOS ASK app's settings and the ASK picker cannot be presented 🤨 From ASK Documentation: AccessorySetupKit is available for iOS and iPadOS. The accessory’s Bluetooth permission doesn’t sync to a companion watchOS app. But this doesn't address not being able to use Core Bluetooth in a watch companion app at all 🥲 Reproducing the bug Install the iOS + watchOS apps Launch iOS app, tap "start scan", observe devices can be discovered (project is set up to find heart rate monitors) Launch watchOS, tap allow on Bluetooth permission pop-up watchOS app crashes 💥 Meanwhile, in the iOS app, there should be a log entry for 💗 CBCentralManager state: poweredOff and the ASK picker is no longer able to discover any devices The state of the device permissions: iOS app has no paired accessories or Bluetooth permission watchOS app's Bluetooth permission shown as turned off & disabled Remove the iOS app Relaunch the watchOS app Notice the CBCentralManager state is unauthorized Remove and reinstall the watchOS app Tap allow on Bluetooth permission pop-up watchOS app does not crash and CBCentralManager state is poweredOn The state of the watch permissions: Bluetooth is turned on & the toggle is not disabled Note that at this time the iOS app is not installed, there is no way to remove Bluetooth permission for the watch app. Reinstall + launch the iOS app Notice a warning in the log: [##### WARNING #####] App has companion watch app that maybe affected if using CoreBluetooth framework. Please read developer documentation for AccessorySetupKit. Notice a log entry for 💗 CBCentralManager state: poweredOn before tapping start scan Tap start scan and observe another log entry: Failed to show picker due to: The operation couldn’t be completed. (ASErrorDomain error 550.) ASErrorDomain 550: The picker can't be used because the app is in the background. Is this the expected error? 🤔 The state of the iOS permissions: The app's settings show a Bluetooth toggle normally associated with Core Bluetooth, but the app never showed a Core Bluetooth pop-up The iOS ASK app now has Core Bluetooth permission 😵‍💫 Following up with Apple This is a known bug that should be fixed in watchOS 26 when Bluetooth permissions for watch apps can be set independently of the iOS app. I've yet to test it with watchOS 26. See repo for the same post with screenshots of the settings and demo code reproducing the bug: https://github.com/superturboryan/AccessorySetupKit-CoreBluetooth-watchOS-Demo
1
0
192
2d
Evolution of HealthKit workout API on iOS 26 and iPadOS 26 - HKLiveWorkoutDataSource and built-in Sensor Support
I am very happy to see that HealthKit with OS26 is bringing HKLiveWorkoutDataSource to iOS and iPadOS. I have been replicating a similar type for the last several years for users that only have an iPhone. I did notice that the data types that the different platform data sources collect automatically is different. That makes sense if you think exclusively about what the device can actually capture. Bluetooth HRM is the only Bluetooth SIG profile that is out-of-the-box supported for Apple Health on iOS and iPadOS (right?). Whereas watchOS 10 got all of the cycling sensors (woohoo!). It would be great if the types to collect were the same across platforms even if the device couldn't collect the data now, because then in the future when / if new sensor support is added, it will be transparent to developers. Fantastic. Easier life as an indie / third party developer. At least that is the idea. And yes, I know I can also write Core Bluetooth code and roll my own SIG implementation for the cycling profiles, but Apple already has this code in one os, 'just copy it, it will be easy'. I know that isn't the reality especially against the new ASK framework, but one can hope and dream right? Imagine how many more apps would contribute that data if it was supported out of the box. An alternative, GitHub is a great place for Apple to share their Core Bluetooth implementation of the SIG profiles :). Just another thought. Here are some feedbacks related to this: FB17931751 - HealthKit: Add built-in support for cycling sensors on iOS and iPadOS - copy paste the code from watchOS. It will be easy they said (June 2025) FB12323089 - CoreBluetooth / Health / Bluetooth Settings: Add support for cycling sensors announced in watchOS 10 to iOS and iPadOS 17 (June 2023) FB14311218 - HealthKit: Expected outdoor cycling to include .cyclingSpeed quantity type as a default HKLiveWorkoutDataSource type to collect (July 2024) FB14978701 - Bluetooth / HealthKit / Fitness: Expose information about the user specified for Apple Watch paired Cycing Speed Sensor like isConnected and wheelCircumference values (August 2024) FB18402258 - HealthKit: HKLiveWorkoutDataSource should collect same types on iOS and watchOS even if device cannot produce data today (June 2025) FB14236080 - Developer Documentation / HealthKit: Update documentation for HKLiveWorkoutDataSource typesToCollect for which sample types are automatically collected by watchOS 10 and 11 (July 2024) Tangentially related: FB10281304 - HealthKit: Add HKActivityTypes canoeBikeRun and kayakBikeRun (June 2022) FB10281349 - HealthKit: Add HKActivityType walkCanoeWalk and walkKayakWalk (June 2022) FB7807993 - Add HKQuantityTypeIdentifier.paddleDistance for canoeing, kayaking, etc type workouts (June 2020) FB12508654 - HealthKit / Settings / Bluetooth / Workouts: Cycling sensor support doesn't allow for 'bike selection' in use case of multiple bikes and multiple sensors (borrow a bike to ride together) - production usability issue (July 2023)
0
1
64
1w
Behavior differences when using CBCentralManager on different iPhone configurations
Hi, I am developing an app that checks if Bluetooth is available on the device or not (does not actually use any Bluetooth capabilities). The only CoreBluetooth API's that I use are: CBCentralManager the state property of the CBCentralManager centralManagerDidUpdateState When I am testing, I experience different behaviors on my test devices. On an iPhone 15 iOS 18.5, the app works fine. However, on an iPhone 13 iOS 18.3.2, the app crashes with the following error: 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. Why is this permission required on my iPhone 13 iOS 18.3.2, but not my iPhone 15 iOS 18.5? Why do I experience different behavior on different iPhone configurations?
3
0
65
1w
A way to enable both notify and indicate
I have a BLE device and I'm developing an iOS app that communicates with that device. The device has a characteristic that has both notify and indicate properties, and sends some messages via notify and others via indicate, therefore I cannot use setNotifyValue. If the specified characteristic’s configuration allows both notifications and indications, calling this method enables notifications only. Is there any way to enable simultaneously both notify and indicate for the same characteristic?
1
0
37
1w
IOS 26,BLE Localname is truncated to 6 bytes
When I startAdvertising, my localName is long,Will not be truncated and the type is 0X09; self.advertisementData = @{CBAdvertisementDataLocalNameKey: localDevName, CBAdvertisementDataServiceUUIDsKey: @[[CBUUID UUIDWithString:serviceUUID]] }; [self.peripheralManager startAdvertising:self.advertisementData]; IOS 18.5: The service uuids in ADV_IND occupies 24 bytes, the local name in SCAN_RESP is 20 bytes in size and has not been truncated, and there is no manufacturer specific data in SCAN_RESP;You can view the following image: But in IOS26, why is the local name truncated to only 6 bytes for the same message, and why does SCAN_RESP always contain Manufacturer Specific Data; Why is there such a big difference, and what changes has iOS 26 made for broadcasting? Is it necessary to include Manufacturer Specific Data in the IOS 26 SCAN.RESP message? What documents are available for reference? Is there any way to ensure that the local name is not truncated? Is there a maximum length limit Are there other ways to broadcast longer data? Does anyone know why? thank
1
0
92
2w
Questions about BLE broadcasting in version 26
After upgrading to iOS system 26, the local name broadcast type is 08, but before upgrading, it is 09 and will be included in the scan resp message; In version 26, the scan resp will also include Manufacturer Specific Data. Before the upgrade, the broadcast message may not necessarily include Manufacturer Specific Data; What I want to ask is, are there any restrictions on Bluetooth broadcasting in version 26? Is it necessary to include Manufacturer Specific Data data? If Manufacturer Specific Data data is included, it may cause fields in the local name broadcast to be truncated and use simple names of type 08
1
0
46
2w
Bluetooth not working in Satellite mode – iOS blocks Bluetooth access for EV charging app
We have developed a live iOS application, built using Swift and UIKit, that enables users to connect via Bluetooth to an EV charging box. Once connected, users can start and stop the charging process directly from the app. The app also requires an active internet connection initially, as it uses server-side functionality to select and authorize the charging box. However, we recently discovered an issue affecting users on iPhone 14 and iPhone 15 models, specifically when the device enters Satellite mode (Emergency SOS via Satellite) — i.e., when there is no mobile data or Wi-Fi. In this mode, the system Satellite screen is triggered and Bluetooth stops functioning, preventing our app from connecting to the EV box. Users are unable to proceed, even though the app would still be usable via Bluetooth once the box is selected. We have already declared required Bluetooth background modes (bluetooth-central, bluetooth-peripheral) in Info.plist, and the app functions perfectly outside of this scenario. However, the behavior in Satellite mode appears to either disable Bluetooth entirely or restrict access from third-party apps. We’d like to know Is this the expected default behavior on iOS in Satellite mode? Is there any entitlement or exception available to allow Bluetooth access in such emergency scenarios (especially for critical utilities like EV charging)? Can an app like ours be made visible under the Satellite settings, or request access under this mode? This is a concern for users in remote or basement locations where mobile data is unavailable, and they rely solely on Bluetooth to charge their vehicles. Please advise if there is a workaround or planned support in future iOS versions. Thank you.
1
0
37
2w
CarKeySewssion
CarKeySession stays in the foreground with no BLE connection and disconnection events passthrough to the App! Here is my code: public func remoteControlSession(_ session: CarKeyRemoteControlSession, vehicleDidUpdateReport: VehicleReport) { Log.i(tag: "carKeySession", "vehicle connect state: (vehicleDidUpdateReport.isConnected)") Log.i(tag: "carKeySession", "vehicle identifier: (vehicleDidUpdateReport.identifier.lowercased()), (self.vehicleIdentifier.lowercased())") } } I don't know why it was not called. And the method which is "func remoteControlSession(_ session: CarKeyRemoteControlSession, didReceivePassthroughData: Data, fromVehicle vehicleID: String)" can work well!
0
0
110
1w
BLE advertisement
Dear Apple: After upgrading to version 26 of the iPhone, when broadcasting using the local name, the iPhone 15 Pro Max was truncated to iPhone 15 Pro Ma with a type of 08 (shortened), but the overall length of the broadcast did not exceed 31 bytes
1
0
52
2w
BLE advertisement and scan response
Dear Apple: If a BLE advertisement carries both a 16-bit service UUIDs and a 128-bit service UUIDs along with a local name, the local name will be placed in the scan response, then when the advertisement is turned off, both the 16-bit and 128-bit service UUIDs disappear while the local name persists. Subsequently, when transmitting a new advertisement that includes the 16-bit service UUIDs and local name, the resulting advertisement contains two local names. What methods can be used to avoid having two local names appearing simultaneously?Thanks
1
0
56
2w
AccesorySetupKit - device not found when ManufacturerData is present
Hello, I am working on a application that connects to a peripheral using AccessorySetupKit. Peripheral is currently advertising it's custom service UUID. With this setup I am able to discover and connect to the device without issues. Firmware team wants to introduce a change and add a "manufacturer data" to the advertisment for better recognition. Upon testing with iOS app, it turns out that current code breaks and does not discover the device anymore. I am unable to configure AccessorySetupKit to be able to discover the device when it has both service uuid and manufacturer data in advertisment. Removing the newly added manufacturer data "fixes" the issue and app is able to discover peripherals again. Looking at the documentation of ASDiscoveryDescriptor it does not specify that those are mutually excluding fields nor does it provide any insight how the configured fields are evaluated against each other. Is this a bug in AccessorySetupKit? Is there a way to update the descriptor in a way that application will still be able to discover the peripheral if only service UUID is provided? Thanks in advance
4
0
71
2d
VisionOS-The prompt to use Bluetooth does not appear app developed by Unity6 with metal rendering
I am developing a VisioPro application that requires Bluetooth function and needs to receive signals from external devices via Bluetooth in Unity6 with "Metal Rendering with Compositor Services".I have supplemented my info.plist file with the following line: Privacy-BluetoothAlwaysUsageDescription Uses BLE to communicate with devices. Despite this, when I launch the app on VisionPro, the prompt to use Bluetooth does not appear. What could be the issue? What additional settings do I need to configure to enable Bluetooth usage?
3
0
34
3d
BLE Scan Response
The iPhone XS Max and Garmin watch pairing cannot use BLE to send Scan Response; it can only send BLE advertisements. May I ask if this is a limitation of the Apple system? So far, we have tested several iPhone models, and only the iPhone XS Max has this issue. We are not sure if other untested models have the same problem.
2
0
47
3w
Constraining Beacon with CLBeaconIdentityCondition
In reference to this webpage, I'm turning my iPad to an iBeacon device. class BeaconViewModel: NSObject, ObservableObject, CBPeripheralManagerDelegate { private var peripheralManager: CBPeripheralManager? private var beaconRegion: CLBeaconRegion? private var beaconIdentityConstraint: CLBeaconIdentityConstraint? //private var beaconCondition: CLBeaconIdentityCondition? override init() { super.init() if let uuid = UUID(uuidString: "abc") { beaconIdentityConstraint = CLBeaconIdentityConstraint(uuid: uuid, major: 123, minor: 456) beaconRegion = CLBeaconRegion(beaconIdentityConstraint: beaconIdentityConstraint!, identifier: "com.example.myDeviceRegion") peripheralManager = CBPeripheralManager(delegate: self, queue: nil, options: nil) } } func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) { switch peripheral.state { case .poweredOn: startAdvertise() case .poweredOff: peripheralManager?.stopAdvertising() default: break } } func startAdvertise() { guard let beaconRegion = beaconRegion else { return } let peripheralData = beaconRegion.peripheralData(withMeasuredPower: nil) peripheralManager?.startAdvertising(((peripheralData as NSDictionary) as! [String: Any])) } func stopAdvertise() { peripheralManager?.stopAdvertising() } } In Line 10, I'm using CLBeaconidentityConstraint to constrain the beacon. Xcode says that this class is deprecated and suggests that we use CLBeaconIdentityCondition. But if I try to use it, Xcode says Cannot find type 'CLBeaconIdentityCondition' in scope I've just updated Xcode to 16.4. I still get the same error. So how do we use CLBeaconIdentityCondition to constrain the beacon? My macOS version is Sequoia 15.5. Thanks.
2
0
104
3w