Core Bluetooth

RSS for tag

Communicate with Bluetooth 4.0 low energy devices using Core Bluetooth.

Core Bluetooth Documentation

Posts under Core Bluetooth tag

215 Posts
Sort by:
Post not yet marked as solved
1 Replies
39 Views
Hi! Reading the documentation for AXMFiHearingDevice, or to be more specific, reading the pairedDeviceIdentifiers I can see we need to define the manufacturer identifier(?) for my app's hearing.aid.app entitlement. But the documentation doesn't specify which key I am meant to be defining here. I saw another comment about 2 weeks ago, in which we are meant to request offical tech support, but is there a plan to make this available to others? (the post in question)
Posted
by rlandaeta.
Last updated
.
Post not yet marked as solved
0 Replies
65 Views
I'm implementing an app to connect to a bluetooth printer using CoreBluetooth. Here is some part of my code. var centralManager: CBCentralManager? var printerPeripheral: CBPeripheral? var printerCharacteristic: CBCharacteristic? public init() { centralManager = CBCentralManager(delegate: self, queue: nil) } public func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) { if peripheral.name?.contains("printername") == true { printerPeripheral = peripheral centralManager?.connect(printerPeripheral!, options: nil) } } public func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) { printerPeripheral?.delegate = self printerPeripheral?.discoverServices(nil) } public func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) { for service in peripheral.services ?? [] { peripheral.discoverCharacteristics(nil, for: service) } } public func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) { } After the line printerPeripheral?.discoverServices(nil), I got the error. Unrecognized selector -[MyPrinterManager centralManager:didUpdateMTUForPeripheral:] It has not yet reached didDiscoverServices nor didDiscoverCharacteristicsFor service I can't find anything about didUpdateMTUForPeripheral anywhere. Anyone has any idea how I should fix this?
Posted
by mrhangz.
Last updated
.
Post not yet marked as solved
6 Replies
323 Views
I want to use iPhone as a bluetooth keyboard or joystick to control a host device. To input contents or play games on another device. As far as I know. My goal can't be done. There are three relate frameworks: CoreBluetooth. When I try to add a peripheral with HID service 1812, the method returns a error. There's another HID service 1124, over BT classic. Is it available? ExternalAccessory. Our host device is not a MFI device. GameController. By this iPhone can work as a host device, not a input device. Thanks for any suggestions!
Posted
by Luke_187.
Last updated
.
Post not yet marked as solved
2 Replies
1.3k Views
i understand that an AppClip cannot be invoked by a BLE packet or iBeacon, but I wonder if it is possible for an app clip, once invoked, to scan for BLE — I.e. can an AppClip include any app functionality, or is it limited to certain APIs.
Posted
by DXBDaniel.
Last updated
.
Post not yet marked as solved
2 Replies
930 Views
In my app the shortcut intent handler is scanning for Bluetooth devices and based of a given selection it connects to them devices and perform some actions. Now as soon the option 'Show When Run' is set to disabled, the Bluetooth centralManager does no longer connect to any peripheral, device scanning is still working though and running the shortcut by Siri is working as well. As a result, automation doesn't work and apparently I cannot use the shortcut as widget on lockscreen. What else does the 'Show When Run' option apart from raising a user notification after the shortcut completed? Could this be a missing permission issue? I already added required keys on the info.plist for Bluetooth access and added Bluetooth background option on both app and shortcut targets.
Posted
by deelay05.
Last updated
.
Post not yet marked as solved
0 Replies
72 Views
I have a BLE peripheral I have connected to before with an iPhone running iOS 16 (via my app). The peripheral has a utility to change its name. After the name change my app still displays the old name. I've run into this issue before, a year or so ago, under an older version of iOS. Performing a reboot of the phone would clear the cached name and allow the new name to appear. This remedy no longer works in iOS 16. I have verified with another iOS device and an Android app that the new name is being advertised. I monitor for a name change with peripheralDidUpdateName but that function never gets called. How do I clear the cache in iOS 16? I do not need to do this programmatically and I would rather not reset the iPhone, which WILL work.
Posted Last updated
.
Post marked as solved
2 Replies
84 Views
Looking for a solution to scan and connect to bluetooth PAN profile devices(via NAP role). We have implemented the below code using CoreBluetooth library. With this approach, we are not able to discover PAN devices, however, other Bluetooth devices are discovered. public class BluetoothScanner : CBCentralManagerDelegate, ICBPeripheralDelegate { private CBCentralManager centralManager; CBPeripheralManager peripheralManager; private List<CBPeripheral> bluetoothDevices = new List<CBPeripheral>(); private CBPeripheral connectedPeripheral; public List<CBPeripheral> BluetoothDevices { get => bluetoothDevices; set => bluetoothDevices = value; } public BluetoothScanner() { centralManager = new CBCentralManager(this, null); } public override void UpdatedState(CBCentralManager central) { if (central.State == CBCentralManagerState.PoweredOn) { NSDictionary keyValuePairs = new NSDictionary(); PeripheralScanningOptions options = new PeripheralScanningOptions(); options.AllowDuplicatesKey = true; central.ScanForPeripherals((CBUUID[])null,options ); } else { Console.WriteLine("Bluetooth is not available"); } } public override void DiscoveredPeripheral(CBCentralManager central, CBPeripheral peripheral, NSDictionary advertisementData, NSNumber RSSI) { if (advertisementData.ContainsKey(CBAdvertisement.DataServiceUUIDsKey) && advertisementData[CBAdvertisement.DataServiceUUIDsKey] is NSArray serviceUuids) { Console.WriteLine("serviceUUID:" + serviceUuids.ToString()); var _serviceUuid = serviceUuids.ToString(); string serviceUuid = _serviceUuid.Trim().Replace("(", "").Replace(")", "").Replace("\n", "").Replace(" ", ""); if (serviceUuid.Equals("1116") || serviceUuid.Equals("1115") || serviceUuid.Equals("1124")) { Console.WriteLine($"Discovered NAP device: {peripheral.Name} ({peripheral.Identifier})"); } } if (!BluetoothDevices.Contains(peripheral) && peripheral.Name !=null) { BluetoothDevices.Add(peripheral); } } }
Posted Last updated
.
Post not yet marked as solved
0 Replies
99 Views
On my QZ app i'm trying to establish a bluetooth connection with a Garmin device. Everything works fine on my Mac Air M1 but with Iphone or Ipad there is a major issue in the connection state (the external device never asks for a connection even if it sees the iOS or iPadOS device). Checking with Packet Logger and comparing the full trace from Mac, Iphone and Ipad, the only major difference is the tag "H4 sleep" and "H4 power". My idea about these is that, probably due to power consumption thing, on iPadOS and iOS, the bluetooth chip will go to standby for some seconds even when an app is using it (i'm advertising). I tried also to connect my iPhone or iPad to the power supply without any difference. Of course these devices are not in low power mode. I guess there is a major issue on the bluetooth stack of these devices. Let me know I have the full bt log if you need them from both sides (Mac and iOS or iPadOS)
Posted
by Cagnulein.
Last updated
.
Post not yet marked as solved
0 Replies
69 Views
I am completely new to this and I am trying to get the speed in my iOS app. I am able to get the angle but not able to get the velocity. This is the code from ESP32 which sends angle and velocity together: // Calculate Swing Speed if (micros() > sampleRate) { if (startTime == 0) { timeOfSwing = 0; if (total_accel > 9) { startTime = millis(); } } else { timeOfSwing = millis() - startTime; if (total_accel > max_accel) { max_accel = total_accel; } if (total_accel < 9) { startTime = 0; max_accel = 0; } } sampleRate = micros() + 200; } velocity = max_accel * (timeOfSwing / 1000.0) * 2.237; // Scale velocity up since accelerometer is not at tip of the bat velocity *= 1.2; // Calculate angle if (sendAngle.update()) { angle = abs(57 * atan2((double)lis.y, (double)lis.z)); // this is the angle if (checkValue != 0) { Serial.print(checkValue); checkValue = 0; } else { // Combine angle and speed into 1 integer to send via bluetooh data = angle << 8; data = data | peakVelocity; Serial.print(data); } } This is the code I have written for iOS: @State var response = Data() { didSet { output = UInt16(String(data: response, encoding: .utf8) ?? "0") ?? 0 BatAngle = output >> 8 BatVelocity = output & 255 } } This is the area where I want the velocity to get displayed: Text("\(BatVelocity)") .bold() .font(.system(size: 52)) .foregroundColor(.black) Please Help
Posted
by rohan007.
Last updated
.
Post not yet marked as solved
1 Replies
191 Views
Does anyone know how to add the entitlement hearing.aid.app that's required to use the pairedDeviceIdentifiers() method. It's noted in the method discussion but doesn't appear to possible to add via Xcode or the profile on the developer.apple.com site. This function returns each CBPeripheral with a manufacturer that matches the manufacturer in your app's hearing.aid.app entitlement. For bimodal hearing devices, specify an array of manufacturers for this entitlement.
Posted Last updated
.
Post not yet marked as solved
0 Replies
108 Views
Bluetooth not working, debug mode gives this report , unable to attach all of it due to file size restrictions. please help Bluetooth Explorer_2023-03-06-091822_Utsuks-MacBook-Pro.crash Bluetooth Explorer_2023-03-06-094223_Utsuks-MacBook-Pro.crash Bluetooth Explorer_2023-03-06-095634_Utsuks-MacBook-Pro.crash Bluetooth Explorer_2023-03-06-095634.crash mds_2023-03-06-143223.crash
Posted Last updated
.
Post not yet marked as solved
0 Replies
148 Views
When app goes to background I wanted to connect bluetooth device with Core Bluetooth, With BGProcessingTaskI was able to perform background task(it executes after 15 min keeping app in background) but connection is not happening it didn't trigger CBCentralManagerDelegatemethods. Here is what I've tried. I have enabled necessary Background Modes in Capabilities. Added required things in info.plist. When app launches I'm registering BGProcessingTask as below. When app goes to background will submit request and after 15 min it starts executing task handleBackgroundSync function. In the handleBackgroundSync function as usual I'm trying to connect bluetooth device with Core Bluetooth. With breakpoint can debug upto scanning but CBCentralManagerDelegate delegates methods are not triggering and when I come to foreground then it triggers. Is there a way to establish bluetooth connection with the BGProcessingTask can someone please suggest ?
Posted Last updated
.
Post not yet marked as solved
0 Replies
188 Views
Urgent Help Required please: 2D Bluetooth barcode/QR code Scanner not scanning product code in a proper sequential order. Barcode/ QR codes when scanned does not come in proper order in iPads. Tested in notes and browser in iPads. Note: 1. Scanner works fine with other Mac products and Windows devices. 2. Issues occurred after Ios update: Ios version: previous version <15, updated version >16. 3. Scanner does not need any firmware updates and does not have any support for it. 4. Tried everything like reset all setting/ factory reset/ erase all data/ force restart/ diagnose/ contacted apple support. 5. **Apple Case ID: 101946377186 ** Can anyone please suggest me something on it? As it seems to be the Ios update and version the possible cause that not compatible with the scanner. I have also requested if we can roll back to the previous version: Apple support said they can't.
Posted
by TimMagill.
Last updated
.
Post not yet marked as solved
0 Replies
193 Views
After searching for a few days, i have come to know that iOS doesn't allow recording in background. Through recording continues when it has started in foreground and goes to background. Came to know that, "This is a new a privacy protection restriction introduced in 12.4" When trying to start recording from background, we get “AVAudioSession.ErrorCode.cannotStartRecording” error. What do i need: our application needs to starts recording audio and transmit it while in background when user presses an external button i.e. PTT button of a BLE device. It seems there are several similar issue posted in this forum but neither could i find any plausible solution nor got any specific documentation from Apple. Requesting to help me out or at least please provide me a specific documentation stating "background recording is not possible". And if any workaround exists, please suggest. P.S. we are using **AVAudioSession.sharedInstance().setCategory(.playAndRecord, mode: .spokenAudio, options: [.mixWithOthers, .allowBluetooth, .allowBluetoothA2DP, .duckOthers]) **
Posted
by mcpttdev.
Last updated
.
Post not yet marked as solved
0 Replies
280 Views
Hey everyone, I recently developed a WatchOS app which includes a peripheral manager that starts advertising when the app is loaded. I've observed that on the Apple Watch Series 8, the Bluetooth advertising stops functioning when the watch is locked/screen off. However, on other series such as Series 7, 6, etc with the latest WatchOS, the app works as expected. I know that the app doesn't broadcast any of my data while running in the background, nevertheless, the watch still advertises BLE. However, on Series 8, I noticed that no advertising packets are being sent except for the offline finding Find My packets. I would appreciate any insights or suggestions that could help resolve this issue. Thanks in advance!
Posted
by roomme.
Last updated
.
Post not yet marked as solved
7 Replies
1.7k Views
Hi, Our PC/SC IFD Handler plugin loaded and running inside of com.apple.ifdhandler system process stops working on BigSur because the TCC engine denies com.apple.ifdhandler access to bluetooth. Our IFD Handler communicates via BLE to the SmartCardReader. Here the relevant messages from the log AUTHREQATTRIBUTION: msgID=4121.1, attribution={responsible={identifier=com.apple.ifdreader, pid=4115, auid=0, euid=0, responsiblepath=/System/Library/CryptoTokenKit/com.apple.ifdreader.slotd/Contents/MacOS/com.apple.ifdreader, binarypath=/System/Library/CryptoTokenKit/com.apple.ifdreader.slotd/Contents/MacOS/com.apple.ifdreader}, requesting={identifier=com.apple.ifdbundle, pid=4121, auid=0, euid=0, binarypath=/System/Library/CryptoTokenKit/com.apple.ifdreader.slotd/Contents/XPCServices/com.apple.ifdbundle.xpc/Contents/MacOS/com.apple.ifdbundle}, }, standard 15:21:59.836608+0100 tccd AUTHREQSUBJECT: msgID=4121.1, subject=com.apple.ifdreader, 15:21:59.836956+0100 tccd Refusing TCCAccessRequest for service kTCCServiceBluetoothAlways from client Sub:{com.apple.ifdreader}Resp:{identifier=com.apple.ifdreader, pid=4115, auid=0, euid=0, responsiblepath=/System/Library/CryptoTokenKit/com.apple.ifdreader.slotd/Contents/MacOS/com.apple.ifdreader, binary_path=/System/Library/CryptoTokenKit/com.apple.ifdreader.slotd/Contents/MacOS/com.apple.ifdreader} in background session We tried to add com.apple.security.device.bluetooth entitlement to our plugin and also we added NSBluetoothAlwaysUsageDescription and NSBluetoothPeripheralUsageDescription to its Info.plist file but nothing works Does anyone know how to allow platform binary to access bluetooth? if not, all plugins written that runs inside of platform process will not be able to access bluetooth.
Posted
by xenox.
Last updated
.
Post not yet marked as solved
7 Replies
2.5k Views
I am pretty sure iOS 13.4 (beta and later) did support Coded PHY (Long Range). Tested devices are iPhone SE2 and iPhone 11 Pro. However, it seems iOS 14 removed the support of Coded PHY, accidentally or on purpose, I don't know? The same PHY update request returns "1M PHY" in iOS 14, but "Coded PHY" in iOS 13 (13.4 beta and later). Anyone knows why? Samson
Posted Last updated
.
Post not yet marked as solved
0 Replies
361 Views
Hi, I use the CoreBluetooth framework in one of my apps. It is working at pairing and scanning. But I have a problem: If the device was paired with the iPhone's Bluetooth settings, I am no longer able to scan it using the scanForPeripherals(withServices:options:) function. Please explain why it is and how to know device was paired with iPhone's Setting on CoreBluetooth? Thanks
Posted Last updated
.