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

Clarification on MFi Certification Capabilities for Enhanced Bluetooth Functionality
Hello Apple Developer Community, I represent a team working on an iOS application that interacts with a Bluetooth Low Energy (BLE) module in vehicles. We're exploring advanced functionalities and have a couple of queries: Automatic PIN Handling: Is there a method for our app to programmatically input a PIN for Bluetooth pairing, bypassing the usual popup prompt? We aim to streamline the user experience by eliminating manual PIN entry. Programmatic Bond Management: Can our app directly "forget" a paired Bluetooth device without requiring the user to manually do so in the iOS settings? This feature would significantly enhance our app's usability. MFi Certification Benefits: Would obtaining MFi certification enable any of the above functionalities, or provide us with additional APIs or capabilities to manage Bluetooth connections more effectively? We appreciate any guidance or insights you can provide on these matters. Understanding these capabilities is crucial for the development of our application. Thank you in advance for your assistance. Best regards,
0
0
240
Dec ’23
Missing multiple imports in CoreBluetooth.framework
I've been repeatedly getting the following error when compiling my project: Unknown class name 'CBCentralManagerDelegate'; did you mean 'CBCentralManager' Within CoreBluetooth.framework my CoreBluetooth.h is as follows: /*! * @header * @file CoreBluetooth.h * @framework CoreBluetooth * * @discussion Bluetooth Low Energy framework * * @copyright 2011 Apple, Inc. All rights reserved. */ #ifndef _CORE_BLUETOOTH_H_ #define _CORE_BLUETOOTH_H_ #endif #import <CoreBluetooth/CBDefines.h> #if __OBJC__ #import <CoreBluetooth/CBCentralManager.h> #import <CoreBluetooth/CBPeripheralManager.h> #import <CoreBluetooth/CBPeripheral.h> #import <CoreBluetooth/CBCentral.h> #import <CoreBluetooth/CBService.h> #import <CoreBluetooth/CBCharacteristic.h> #import <CoreBluetooth/CBDescriptor.h> #import <CoreBluetooth/CBError.h> #import <CoreBluetooth/CBUUID.h> #import <CoreBluetooth/CBAdvertisementData.h> #import <CoreBluetooth/CBATTRequest.h> #endif Specifically I'm missing #import <CoreBluetooth/CBCentralManagerDelegate.h> as well as the relevant class within my Headers folder. Does anyone know why this might be the case? I'm using Xcode 15.1 Beta 3.
1
0
307
Nov ’23
visionOS as a BLE peripheral: CBMutableService init unavailable
I'd like to have the visionOS be a peripheral, in BLE terminology. This is required, as the hardware that will act as the central cannot act as peripheral (don't ask). The problem is some initializers I seem to need to advertise a mutable service are not available: 1. 'init(type:primary:)' has been explicitly marked unavailable here (CoreBluetooth.CBMutableService) It would seem that this isn't supported yet. Is this currently possible some other way, or will it be possible in the future?
2
0
322
Nov ’23
Android Device is not Listing For iphone Devices for coreBluetoothScanning
Hello Apple Support Team, As per the business requirement, we have to communicate and exchange data chunks between applications running on iPhones and Android-based or Android phones through Bluetooth interface. We have achieved the requirement through IP/Wifi communication. We are trying to connect to Android and iPhone devices via Bluetooth through an iOS application. We carried out Bluetooth implementation using CoreBluetooth libraries. Below are the findings done by our development team: Core Bluetooth Library Implementation           Importing Core Bluetooth Library in BTConnectionManager class, which uses CBCentralManagerDelegate, CBPeripheralDelegate, CBCentralManager, CBPeripheral as peripheral, [CBPeripheral] array as peripherals array. Using the below methods: centralManagerDidUpdateState, centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber), centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral), peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?), peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: Service, error: Error?) we are able to scan and connect to BLE devices Findings: We were able to get the list of low-energy devices like Airpods, Earphones and Bluetooth music devices. But Not able to scan Bluetooth high-energy devices like PAX / Android Phones   Please suggest to us the approach to make the Android running devices listed through the Core Bluetooth library. Thanks & Regards
0
0
562
Nov ’23
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
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
Custom pairing scree
whenever i connect a BT peripheral and try to to read a characteristic first time, i see the "Bluetooth pairing request" popup for the user to enetr the PIN. I want to develop a custom screen for pairing PIN entry. How can we do this? I did not find any code examples or APIs in any documentation.
2
0
718
Oct ’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
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
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
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
1 minute Delay in External Accessory framework showBluetoothAccessoryPicker
I have to pair the classic Bluetooth device with my iOS application. For that, I have implemented showBluetoothAccessoryPicker with the External Accessory framework. EAAccessoryManager.shared().showBluetoothAccessoryPicker(withNameFilter: nil)), this is the code I have used for that. Added "Supported external accessory protocols" in .plist and enabled Wireless Accessory Configuration from capabilities. The actual issue is the picker displaying the device to pair with a 1-minute delay. What is the reason behind this reason and how can we resolve that?
1
0
856
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