Core Bluetooth

RSS for tag

Communicate with Bluetooth 4.0 low energy devices using Core Bluetooth.

Posts under Core Bluetooth tag

176 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

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
247
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
642
Oct ’23
WatchOS CoreBluetooth maximum peripheral connections
I have an app running on WatchOS. How many BLE peripherals can my app connect to at the same time? If the number of peripheral objects is limited in some way, is the limit imposed on each instance of CBCentralManager? Or is the limit imposed on each app? I have a use case that would require four BLE peripheral connections. Is tis possible? I have another use case that would require 6 BLE peripheral connections. Is this possible?
1
0
375
Oct ’23
Generate 64 bytes using ECDSA SHA 256 using pem file in XCode
// here is the code snippet func generateSignatureWithPEMFile(data: Data, privateKeyPEM: String) -> Data? { let privateKeyBIO = BIO_new(BIO_s_mem()) let privateKeyPEMData = privateKeyPEM.data(using: .utf8) _ = privateKeyPEMData?.withUnsafeBytes { buffer in BIO_write(privateKeyBIO, buffer.baseAddress, Int32(buffer.count)) } let privateKey = PEM_read_bio_PrivateKey(privateKeyBIO, nil, nil, nil) let signature = UnsafeMutablePointer.allocate(capacity: 64) var signatureLength: UInt32 = 64 let ctx = EVP_MD_CTX_new() EVP_DigestInit(ctx, EVP_sha256()) _ = data.withUnsafeBytes { buffer in EVP_DigestUpdate(ctx, buffer.baseAddress, buffer.count) } EVP_SignFinal(ctx, signature, &signatureLength, privateKey) EVP_MD_CTX_free(ctx) EVP_PKEY_free(privateKey) BIO_free(privateKeyBIO) return Data(bytes: signature, count: Int(signatureLength)) } // usage let dataToSign = Data(hex: key)! let stringDataToSign = Data(stringToSign.utf8) if let signature = generateSignatureWithPEMFile(data: dataToSign, privateKeyPEM: privateKeyPEM) { let signatureHex = signature.map { String(format: "%02x", $0) }.joined() print("Signature (Hex): (signatureHex)") peripheralsConnected!.writeValue(signature, for: characteristic, type: .withResponse) } else { print("Failed to generate the signature.") } but i am getting 70 bytes or 71 bytes or 72 bytes in the debug console @eskimo pls help me !! i am stuck on this point from many days, any help will be appreciated, thanks in advance!!
0
0
300
Oct ’23
What CoreBluetooth physical layer?
We have a process in our iPhone app that uses CoreBluetooth to transfer a large amount of data over time using Bluetooth LE. Now I'm looking for ways to speed up this process. From what I have gathered, there is no way to set a preferred phyaical layer (PHY) for CoreBluetooth. How does iOS determine the best PHY to use? Is there any way I can influence it? I was not able to locate any documentation from Apple mentioning "physical layer" or "phy" for CoreBluetooth, only a brief GitHub Issue for a multiplatform networking library that discussed setting a "PreferredPhy" for iOS.
0
0
521
Oct ’23
Bluetooth Device Implementation
Hello all, I am interested in trying to develop a short-medium range (>100 meters) tracking device for a hobby project in order to gain some literacy in mobile phone software, and have a few questions. I am new to working with anything iOS so please correct me in any mistakes I make in this query. Is RFID or Bluetooth better for tracking and implementation on iOS? How difficult is device implementation into iOS and apps such as find my iPhone? How would one go about it? If I wanted a tracking device to send notifications based on location/distance from another device, could I do that with Apples framework or would I have to create my own app? What programming language would be used in this sort of endeavor? Would C++ work or does iOS use different ones? Thanks in advance, any and all advice is greatly appreciated.
1
0
582
Sep ’23
BLE Cycling Power Service for Watch Workout
Hi, I have an app that implements the Cycling Power Service 1.1, https://www.bluetooth.com/de/specifications/specs/cycling-power-service-1-1/ As expected, I can select this app as a Health Device in the Bluetooth settings of my Apple Watch. However, when I run the BLE app on the paired iPhone, the Apple Watch does not detect the BLE Service as a Health Device! Is this a bug, or is it designed this way? If so, is there another API where I can send power meter data from iOS to a running Watch Workout?
2
0
577
Sep ’23
Get List/Count of bluetooth connected devices to Ipad
I am working on a Application which requires to identify list of bluetooth paired devices connected to Ipad. I have used scanforperipherals(withServices:nil) in CoreBluetooth framework but I see state is always disconnected even though device is connected to iPad. output : <CBPeripheral: 0x281d000, identifier = 31EADDCE-5DBC-E57F-84DB-1488C20460F9, name = AirPods Pro, mtu = 0, state = disconnected> Later used Retrieveconnectedperipherals method (https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1518924-retrieveconnectedperipherals ) and tried to fetch the Bluetooth connected devices list. But this method mandates to provide ServiceUUID list of the devices that needs to be fetched which doesn't help me as I need to fetch all devices list. I understand EAAccessoryManager framework gets the list of MFI devices but it mandates to provide protocol names of devices. let connectedDevices = EAAccessoryManager.shared().connectedAccessories as? [EAAccessory] Would like to know if there is any way to fetch the list/count of Bluetooth devices connected to iPad without providing UUIDs/Protocol names. Thanks in advance! Let me know if any other information is required.
0
0
508
Sep ’23
Multi Anchor Nearby Interaction
Scenario: We have a museum where each exhibit has a UWB BLE accessory. A user moves around the museum with their phone application in the background. Once a user enters an exhibit area (Determined by UWB distances) a background task is initiated (audio/notification/widget). The Question: In our current understanding of the protocol, the user must pair to each exhibit anchor beforehand, significantly impairing the user experience and bloating their Bluetooth-paired device list. Is it possible now or potentially in the future to not require pairing for pre-approved devices? Alternatively, pairing to a hub that acts as an intermediary between the phone and accessories also seems like an appropriate compromise.
1
0
680
Mar ’24
What is Service UUID for bluetooth devices like Apple Airpods.
I am working on a Application which requires to identify whether any airpods are connected to Ipad. I have used retrieveConnectedPeripherals(withServices:) in CoreBluetooth framework (https://developer.apple.com/documentation/corebluetooth/cbcentralmanager/1518924-retrieveconnectedperipherals ) and tried to fetch the bluetooth connected devices list. But this method mandates to provide ServiceUUID list of the devices that needs to be fetched. Based on available information on various forums , I tried to used below UUIDS for fetching bluetooth connected airpods from this doc (https://www.bluetooth.com/specifications/assigned-numbers) but none of them worked for me. retrieveConnectedPeripherals() returns empty list everytime eventhough airpods are connected to Ipad during testing. Audio Stream Control service 0x184E, Automation IO service 0x1815, Broadcast Audio Announcement service 0x1852, Broadcast Audio Scan service 0x184F, Common Audio service 0x1853, Generic Media Control service 0x1849, Media Control service 0x1848, Microphone Control service 0x184D, Volume Control service 0x1844, Audio Input Control service 0x1843 Other UUIDs tried : 0x1108 0x1112 0x111E 0x111F Would like to know correct UUID for apple Airpods. Thanks in advance! Let me know if any other information is required.
1
0
1.2k
Sep ’23
Connecting to a Bluetooth Peripheral on the application level only.
Hi there! My team and I are currently working on developing an iOS application that connects to our proprietary hardware using Bluetooth technology. During our development process, we encountered an issue related to the central manager's behavior. Specifically, the central manager only disconnects the peripheral device from the app level, leaving the connection active at the system level. In the context of the cancelPeripheralConnection discussion, one of the reasons cited for not allowing the app to disconnect the peripheral from the system is as follows: Because other apps may still have a connection to the peripheral, canceling a local connection doesn’t guarantee that the underlying physical link is immediately disconnected (source) For our situation, the challenge lies in the fact that no other application should have access to this specific peripheral. It is designed exclusively for our system's use. To address this, our current workaround involves sending a custom disconnect command to our device via a designated characteristic. However, we are keen to explore if there's a way to establish the initial connection to the peripheral in a manner that avoids creating a system-level connection altogether. Thank you for your assistance! Liz
2
0
412
Sep ’23
iOS 17 Bluetooth DFU bug
We were using this library (https://github.com/NordicSemiconductor/IOS-DFU-Library) from Nordic Semiconductor to perform OTA firmware update. Everything works perfectly until iOS 17 came out. Some of our users are on iOS 17 beta program, they experienced firmware update issues with it. In our testing, the update progress can initiate without any issue, however, at some random point during the update (sometimes 1%, sometimes 60%, it's totally random) the progress gets stuck. The firmware update wasn't an issue on iOS 16 and below, so we suspect that it's a bug on the new OS, not on the library.
2
1
1.4k
Oct ’23
ios swift application instance time alive
Hi all, I have created an application that uses location services and bluetooth services. Inside AppDelegate using significant location changes I am assigning a new instance of CBCentralManager like this How long this instance is staying alive? I am noticing that it may last even five days but I am not sure which parameters affect this? class AppDelegate: UIResponder, UIApplicationDelegate ,CLLocationManagerDelegate,CBCentralManagerDelegate,UNUserNotificationCenterDelegate { private static var centralManager : CBCentralManager! func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { if let keys = launchOptions?.keys { if keys.contains(.location) { AppDelegate.centralManager = CBCentralManager(delegate: self, queue: nil) locationManager.requestAlwaysAuthorization() locationManager.allowsBackgroundLocationUpdates = true locationManager.pausesLocationUpdatesAutomatically = false } } return true } func centralManager(_ central: CBCentralManager, didDiscover peripheral:CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) { AppDelegate.centralManager.connect(peripheral, options: nil)* } func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) { AppDelegate.centralManager.connect(peripheral, options: nil) } func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) { AppDelegate.centralManager.connect(peripheral, options: nil) } }
0
0
292
Aug ’23
Pairing for MFi
Hi everyone, I'm currently working on a Bluetooth device that doesn't support pairing. While going through the MFi certification documents, I noticed that pairing seems to be a required feature. Has anyone had experience getting MFi certification for a device that doesn't support pairing? Is it even possible? Any insights or guidance would be greatly appreciated! Thanks in advance for your help!
0
0
513
Aug ’23
can iphone 5 communicate with other BLE device ?
can iphone 5 communicate with other BLE device ? i have made ios app communication with other device by bluetootch classic (BR/EDR) because my customer want my app to communicate old device using bluetooth classic, but, i found that the first iphone model using BLE is iphone 5 (2012 made) using BT4 last model of iphone using bluetooth classic is iphone 4s(2011 made) can iphone 5 communicate with other BLE device ?
0
0
449
Aug ’23
NIErrorCodeInvalidConfiguration error code using the function NINearbyAccessoryConfiguration(Accessory:BluetoothPeerIdentifier)
Ranging is working great when I'm removing the BluetoothPeerIdentifier parameter but if I want to do some background ranging, I need to be able to use the removed parameter. Somehow when I'm both AccessoryData and BluetoothPeerIdentifier parameters, I got the NIErrorCodeInvalidConfiguration error code and i can't range anymore. Do you guys have a fix for that? The parameter BluetoothPeerIdentifier is not NULL so it should work properly... Thank you, Marc
0
0
607
Aug ’23
BLE connexion: popup display rules
Hello, I'm new to CoreBluetooth framework and I want to understand the rules behind Bluetooth connexion popups displayed by iOS. I understood that while developing a BLE Central role application, I have no control over whitch security popup bill be displayed. During my tests with Apple BLE demo project CoreBluetoothLESample, I managed to activate the display of a pairing popup adding .indicateEncryptionRequired option to the characteristic options in the PeripheralViewController class: let transferCharacteristic = CBMutableCharacteristic( type: TransferService.characteristicUUID, properties: [.notify, .writeWithoutResponse, .indicateEncryptionRequired], value: nil, permissions: [.readable, .writeable] ) My question is: Can I find a documentation about pairing popups display rules on central iOS device (just a "Cancel/Pair" popup without PIN check, popup with PIN check, popup asking to enter a PIN, or no popup at all) regarding peripheral security level and/or capabilities (can display a PIN or not) ? Thank you for any help !
0
0
326
Aug ’23