Core Bluetooth

RSS for tag

Communicate with Bluetooth 4.0 low energy devices using Core Bluetooth.

Core Bluetooth Documentation

Posts under Core Bluetooth tag

174 Posts
Sort by:
Post not yet marked as solved
4 Replies
2.9k Views
Greetings.I have an app today that uses multipeer connectivity extensively. Currently, when the user switches away from the app, MPC disconnects the session(s) - this is by design apparently (per other feedback). I'd like to hear if anyone has experimented with iOS9 multitasking / multipeer and whether MPC sessions can stay alive?Thanks
Posted
by
Post not yet marked as solved
7 Replies
8.9k Views
I am having an issue with CoreBluetooth on iOS. My app is serving as a central that connects to one physical bluetooth peripheral. I have no issues discovering, connecting, and reading data from the peripheral. The particular information I need is provided through a notification. I can begin recieving the info after setting the notify value:devicePeripheral.setNotifyValue(true, forCharacteristic: dataCharacteristic)I am also keeping a strong reference to my devicePeripheral after discovery and to the dataCharacteristic after the peripheral is connected and its characteristics have been discovered.After setting the notify value, I begin receiving the data at a frequent interval. For the app's purpose, I need to collect data from this notification for an extended period of time.The issue I am facing is that the peripheral is automatically disconnected exactly every 30 seconds, even while my notify value is set to true- so in the middle of reading data, I am suddenly forcibly disconnected exactly every 30 seconds. I have added code that upon disconnection, I rescan and reconnect, reset the notify value and carry on capturing data. The problem is that I need to capture data continuously without interruption, and that capture is being interrupted consistently every 30 seconds. This causes a gap of lost data.After exactly 30 seconds, "didDisconnectPeripheral" fires with the following error:Error Domain=CBErrorDomain Code=0 "Unknown error." UserInfo=0x174b6b90 {NSLocalizedDescription=Unknown error.}Can anyone offer any suggestions as to why this might be ocurring, and how I might resolve it?I have also developed an Android client that interacts with this same peripheral, and it does not suffer from the same issue- there is no 30 second disconnect on that platform, and I have no issues collecting data for an extended period of time. I have also tested connecting to my peripheral from OS X. I have not found the 30 second disconnect issue on OS X either- it appears that issue is isolated to iOS.I have tested with a iPhone 5 running iOS 8.4.1, and an iPhone 6S+ running iOS 9.2Thanks
Posted
by
Post not yet marked as solved
12 Replies
26k Views
Hi,I'm currently looking into CoreBluetooth, but I'm already struggeling with the simple setup. On starting the test app github I receive the below error message:Search not started as central isn't powered on! unknown2016-08-12 20:37:18.050489 SwiftBluetooth[1865:574397] [CoreBluetooth] XPC connection invalidThis is happening while I had my bluetooth headphones sucessfully connected to the iPhone.So I would expect that at least the headphones get recognised.Device: iPhone 6 OS: 10.0Thanks for your helpTimo
Posted
by
Post not yet marked as solved
2 Replies
633 Views
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.
Posted
by
Post not yet marked as solved
1 Replies
1.3k Views
Hi all,I am currently developing an Apple accessory for music playback using Bluetooth A2DP/AVRCP.I already know that Bluetooth device should support AVRCP 1.6 or higher to get the cover-art image.However iPhone seems to have another method to get the cover-art image even if AVRCP version is lower than 1.6.No matter how I search, but I could not find any solutions for the above.I would appreciate it if you provide any clues.Thanks,
Posted
by
Post not yet marked as solved
1 Replies
586 Views
I am trying the access the state of bluetooth by calling the following api in my applicationcentralManager = CBCentralManager(delegate: self, queue: nil)Initializing the central Manager by calling CBCentralManager shows iOS default system alert informing the user that the app is trying to access Bluetooth (with OK and Settings option). Can we disable the system alert? Can we customize the bluetooth system alert.Thanks,Jala
Posted
by
Post not yet marked as solved
1 Replies
1.4k Views
Hello, I am developing an IOS Application for our Bluetooth Low Energy device, and I am running into a problem whereas i am unable to write to a certain characteristic (that is set to require authenticated write and authenticated read) on a BGM111. The problem i am experiencing happens in the following order: First Run: 1.) Connect to device 2.) Write a "secret" code to the device, causing it to enable bonding mode 3.) Read the characteristic that is set to Authenticated Read, forcing the IOS App to request to pair with it (user presses Allow Pair) 4.) Write the desired value to the characteristic, which works on this run Second Run and beyond (any time after closing the application, and re-opening it): 1.) Connect to device 2.) Write "secret" code again, to ensure this is still a valid device, (again causing enabling of bonding mode) 3.) Read the characteristic again (works) 4.) Write the desired value to the characteristic, which this time gives the error of "The specified UUID is not allowed for this operation." which has an error code value of 8Why am i getting this issue? Thanks, mwpeterson92
Posted
by
Post not yet marked as solved
2 Replies
8.7k Views
Which Bluetooth Profiles / services are supported by iOS?I found this:https://support.apple.com/en-us/HT204387I read up the iOS 11.3 will only see the built in pre-defined profiles. Is there a work around?Hands-Free Profile (HFP 1.6)Phone Book Access Profile (PBAP)Advanced Audio Distribution Profile (A2DP)Audio/Video Remote Control Profile (AVRCP 1.4)Personal Area Network Profile (PAN) Human Interface Device Profile (HID)Message Access Profile (MAP)So the Android phones will see the advertising of all kinds of BT / BLE devices, but iPhone does not, unless it was previousely paired by a custom app.Once you "Forget" this device on iPhone, it goes away and will not be seen during scanning.So even a Serial Port dongle with Serial Port Profile is not supported.(SPP), unless it is drive by a custom app?Any help appreciated
Posted
by
Post not yet marked as solved
2 Replies
2.1k Views
I am trying to send a simple JSON to a connected Bluetooth peripheral but getting some problems in the process.The properties read from the peripheral in the didDiscoverCharacteristicsFor method are the following:po characteristic.properties ▿ CBCharacteristicProperties - rawValue : 10Which as this is a mask and if I am not mistaken this states that I can read (2) and write (8) from/to the device.I am writing the data as soon as I discover a new characteristic that matches the requirements in the following wayfunc peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService,error: Error?) { for characteristic in service.characteristics! { let characteristic = characteristic as CBCharacteristic print(characteristic.uuid) if characteristic.uuid.isEqual(RX_UUID) { // Received only support for writing with response, writing without response is not allowed if characteristic.properties.contains(CBCharacteristicProperties.write) { self.writeJsonStringToPeripheral(peripheral: peripheral, characteristic: characteristic, writeType: .withResponse) } else if characteristic.properties.contains(CBCharacteristicProperties.writeWithoutResponse) { self.writeJsonStringToPeripheral(peripheral: peripheral, characteristic: characteristic, writeType: .withoutResponse) } } } } func writeJsonStringToPeripheral(peripheral: CBPeripheral, characteristic: CBCharacteristic, writeType: CBCharacteristicWriteType) { do { let msgDictionary = ["SSID": self.wiFiCredentials.SSID, "Password": self.wiFiCredentials.Password] let jsonData = try JSONSerialization.data(withJSONObject: msgDictionary, options: []) //let data = "".data(using: .utf8) peripheral.writeValue(jsonData, for: characteristic, type: writeType) } catch let error as NSError { debugPrint("Error in auth message JSON: \(error.description)") This snippet calls the function at line 10 indicating the possibility of writing with a response and after callign it the didWriteValueFor delegate method is called.func peripheral(_ peripheral: CBPeripheral, didWriteValueFor characteristic: CBCharacteristic, error: Error?) { if let error = error { print(error) } else { print("Value writen sucessfully.") } }Printing the following error.Error Domain=CBATTErrorDomain Code=3 "Writing is not permitted." UserInfo={NSLocalizedDescription=Writing is not permitted.}I've made myself sure that the device is connected and I can also see it in the Settings.app. I am a bit lost and I don't know what could be going on here.On the other side if I force the writing to be withoutResponse I get another console log2020-03-25 22:23:50.286662+0100 Cloudy[2595:1232291] [CoreBluetooth] WARNING: Characteristic does not specify the "Write Without Response" property - ignoring response-less writeAfter sending the specified JSON to the device it should start a sequence to connect to the specified WiFi SSID. I am sure the hardware works because I can set those values using the console on the device itself and the process works so there must be something I am missing here that causes this to fail.This test has been done using an iPhone 6S running ios 13.3.1.
Posted
by
Post not yet marked as solved
9 Replies
8.4k Views
Hi,I have been working with CoreBluetooth for a while now and I've never run into this error before. This error occurred when I tried connecting to my desired peripheral. I've pasted the error message below:Domain=CBATTErrorDomain Code=14 "Peer removed pairing information" UserInfo={NSLocalizedDescription=Peer removed pairing information}I've tried to connect with the peripheral using a third-party app on the Android platform, and it works fine. However, third-party application on iOS isn't able to connect to this peripheral. It timeout when connecting on the iOS platform with the third-party app.I'm not sure what the source of this error is, or how to go about solving this error?Thanks!
Posted
by
Post not yet marked as solved
1 Replies
1k Views
Hello everyone, sorry for my ignorance about it, with ANCS I managed to get all the notifications except the alarm that rings and the timer expired, where am I wrong? do they travel on other channels like gatt? if yes can someone help me understand how to receive these 2 information? the alarm goes off and the timer expired? Thanks in advance to everyone who will help me, Marco.
Posted
by
Post marked as solved
2 Replies
1.8k Views
I'm writing a command line tool for macOS which interfaces with BLE devices. I have a problems with regards to permissions: If I launch my tool on the command line, it gets killed by the OS. Only if I launch it via the debugger, I get the alerter to allow the bluetooth permission. My plist that contains the NSBluetoothAlwaysUsageDescription key is embedded as __TEXT __info_plist in the binary. Is this no longer enough for a command-line tool to access security-guarded OS facilities these days?
Posted
by
Post not yet marked as solved
2 Replies
3.2k Views
Team, is there anyway, if we can wakeup the app while it is in suspended mode. I am using BLE scanning to share/receive the TCN token and generate notifications, but while app in sleep/suspended mode it stops. is there anyway to trigger this scanning or wake up the app without any manual intervention. we are trying to achieve this with help of silent notifications. can you help to figure out how many silent notification we can trigger in an hour ?
Posted
by
Post not yet marked as solved
73 Replies
51k Views
Hi, I am an application developer for Mac. Our application uses bluetooth to connect to our hardware devices. Since the upgrade to MacOS 12.0.1 Monterey Bluetooth is broken customer wide. Hence pairing works but our driver cannot connect (code worked for MacOS 10.7 - 11.3). The internet reports a lot of Bluetooth issues related to Broadcom BT on Monterey and the Bluetooth Framework has changed significantly by Apple. Where can I find detailed information about Apple's Bluetooth changes ? Should I just wait until Apple fixes this from their side ? Any other guidance is appreciated. Thank you?
Posted
by
Post not yet marked as solved
3 Replies
2.0k Views
Hello. Having a hard time with this one. The Apple Media Service is documented here (1). It seems like an elegant and simply system to control audio over BLE with a custom hardware solution. I have set up various boards I have, including Arduino Nano BLE and Adafruit Huzzah ESP32, using fairly straightforward scripts. This "device" I am building then should show up on the iPhone > Settings App > Bluetooth > Other Devices. I should able to connect to the device, and have it get media information from the iPhone and be able to control it What happens is a bit odd. First nothing shows up in Other Devices. I then use a BLE integrator app like BLE Scanner, and it shows up as Arduino (despite what I name it). I can connect to it, and interesting it lists APPLE MEDIA as a service UUID (which is correct!). Now if I go back to Settings App > Bluetooth, because I have connected to my device with BLE Scanner, it shows as connected and under "My Devices" ! However it doesn't work, no audio is controlled. As a test I tried flicking the Play Pause characteristic but it does nothing (can see it in the Arduino code below where it flips every 4 second). Is there an example of using Apple Media Device BLE control? I found one using MicroPython but I don't want to use micropython, and I am not sure what I am doing different. The Arduino code is here. I have been trying to get this to work for a while now, using many, many different boards / chips. Any help is appreciated: BLEService mediaService("89D3502B-0F36-433A-8EF4-C502AD55F8DC"); BLEUnsignedCharCharacteristic audioControlChar("9B3C81D8-57B1-4A8A-B8DF-0E56F7CA51C2", BLEWrite | BLENotify); BLEUnsignedCharCharacteristic entityUpdateChar("2F7CABCE-808D-411F-9A0C-BB92BA96C102", BLEWrite | BLENotify); BLEUnsignedCharCharacteristic entityAttributeChar("C6B2F38C-23AB-46D8-A6AB-A3A870BBD5D7", BLEWrite | BLERead); int playPauseSwitch = 1; // for now flip between 0 (pause) and play (1) on 9B3C81D8 characteristic, every 4 seconds long previousMillis = 0; // count for test to flip play pause void setup() { Serial.begin(9600); while (!Serial); pinMode(LED_BUILTIN, OUTPUT); // begin initialization if (!BLE.begin()) { Serial.println("starting BLE failed!"); while (1); } BLE.setLocalName("MediaController"); mediaService.addCharacteristic(audioControlChar); mediaService.addCharacteristic(entityUpdateChar); mediaService.addCharacteristic(entityAttributeChar); BLE.setAdvertisedService(mediaService); // add the service UUID BLE.addService(mediaService); BLE.advertise(); Serial.println("Bluetooth device active, waiting for connections..."); } void loop() { // wait for a BLE central BLEDevice central = BLE.central(); // if a central is connected to the peripheral: if (central) { Serial.print("Connected to central: "); // print the central's BT address: Serial.println(central.address()); // turn on the LED to indicate the connection: digitalWrite(LED_BUILTIN, HIGH); while (central.connected()) { long currentMillis = millis(); // For now flip play pause characteristics every 4 seconds if (currentMillis - previousMillis >= 4000) { previousMillis = currentMillis; flipPlayPause(); } } // when the central disconnects, turn off the LED: digitalWrite(LED_BUILTIN, LOW); Serial.print("Disconnected from central: "); Serial.println(central.address()); } } void flipPlayPause() { if (playPauseSwitch == 0) { playPauseSwitch = 1; } else { playPauseSwitch = 0; } audioControlChar.writeValue(playPauseSwitch); } (1) - Apple BLE Media Service https://developer.apple.com/library/archive/documentation/CoreBluetooth/Reference/AppleMediaService_Reference/Introduction/Introduction.html#//apple_ref/doc/uid/TP40014716-CH2-SW1
Posted
by
Jot
Post not yet marked as solved
1 Replies
1.6k Views
Hi, I'm trying to make a watch app that transfer data watch to watch(or iOS). (Not for backup) So, I looked up for core bluetooth feature. It was a nice and kind document. However, I bumped in to a problem that might cause a severe flaw in my project, which is.. the distance (range) that the apple watch can reach to another one. I googled it and found out 33 feet would be the limit range of bluetooth 4.0 (or 5.0 whatever). BUT, when I google just "bluetooth 4.0 and 5.0 range", the range was way over the distance mentioned, like 10 times way further. Some say up to 100m (330 feet), other say 60m (200feet). So If is there anyone who tested the real range of bluetooth working via watch to watch?? Well.. thank you for reading my post, and I hope anyone can answer me! :)
Posted
by
Post not yet marked as solved
1 Replies
739 Views
I'm writing a MacOS Application to mimic some real hardware for debugging purposes. The application acts as a peripheral (using CBPeripheralManager). It advertises a single service, the primary service, with two characteristics. I have both iOS and Android applications that connect to the MacOS app. For the iOS application, everything works. I can connect to the app, discover services, and manipulate characteristics. The Android application does a BLE scan for peripherals with the service ID and the MacOS application shows up as being available. After connecting to the peripheral, however, when the Android application asks to discover the services of the peripheral, the one service my peripheral offers does not show up. Somehow the service makes it into the advertisement but does not show up during service discovery. Can anyone explain why my services would be advertised, but then not discoverable?
Posted
by
Post not yet marked as solved
1 Replies
793 Views
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?
Posted
by