Core Bluetooth

RSS for tag

Communicate with Bluetooth 4.0 low energy devices using Core Bluetooth.

Core Bluetooth Documentation

Posts under Core Bluetooth tag

176 Posts
Sort by:
Post not yet marked as solved
2 Replies
780 Views
Hi, I have 2 questions: the api for L2CAP is only for BLE or can also work for BR/EDR? (currently didn't manage to connect with BR/EDR) I use https://github.com/bluekitchen/CBL2CAPChannel-Demo on iPhone with le_credit_based_flow_control_mode from blue kitchen and the throughput was very low. I also tried to use L2TEST from Bluez (which uses L2CAP BASIC MODE) but it failed to connect Can anybody help how to increase throughput? The best result I received was 18 kilobyte/second. Thank you
Posted
by
Post not yet marked as solved
1 Replies
1.2k 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
by
Post not yet marked as solved
3 Replies
1.1k Views
I'm working on a BLE app with a hardware partner using samples of their device, which I am able to erase and re-flash when needed. When I try to use the device it initially works fine. I can connect to it, make requests, and get back responses. However, after a short time and a few successful runs, I start getting the error "Encryption is insufficient". The error is seen in the "didUpdateValueFor" function. I can still connect to the device, and enumerate all of its services and characteristics, but I can't read any data. If at this point I re-flash the device and also go into the iOS setting app and "forget" it, then I can use the device normally again, at least for a while. What causes this? Is there a way I can fix it in my app? Thanks, Frank
Posted
by
Post not yet marked as solved
0 Replies
299 Views
I have called the func stopAdvertising() but the Advertising still runs although the state isAdvertising is false. I tried to uninstall the app but it does not change anything How can I stop Advertising?
Posted
by
Post not yet marked as solved
2 Replies
905 Views
Hi, I've read over many of the helpful posts on background modes ([1], [2], and responses to my thread [3]) but am encountering something that doesn't quite line up with my understanding. Background My app is using Bluetooth background mode in order to receive data from a peripheral periodically and then perform a network request (eventually, this will involve two network requests, one of them being an upload of audio, which will be a much larger transfer of up to a couple hundred KB, possibly requiring m4a compression first). In background mode, all the Bluetooth messages (currently a small string) are received reliably. The app is woken up and from my understanding, given some time to run in the background. I perform a POST request using URLSession.shared.dataTask(with: request). Problem Encountered These often succeed but sporadically fail with a timeout in background mode and with the error message "connection was lost". Furthermore, nearly every request in background mode is associated with some sort of connection error that appears in the log. Given that many of the requests still succeed, I'm not sure what to make of these. I see a variety of different ones. For example: Case 1: 2023-05-23 16:33:49.428668-0700 ChatGPT for Monocle[4775:1088487] [connection] nw_read_request_report [C1] Receive failed with error "Socket is not connected" 2023-05-23 16:33:49.429633-0700 ChatGPT for Monocle[4775:1088487] [connection] nw_read_request_report [C1] Receive failed with error "Socket is not connected" 2023-05-23 16:33:49.431677-0700 ChatGPT for Monocle[4775:1088487] [connection] nw_read_request_report [C1] Receive failed with error "Socket is not connected" 2023-05-23 16:33:49.440358-0700 ChatGPT for Monocle[4775:1088487] [quic] quic_conn_send_frames_for_key_state_block_invoke [C1.1.1.1:2] [-0151a6eeef6cab8c6b53cceead6cada7cf118a4e] unable to request outbound data 2023-05-23 16:33:49.440528-0700 ChatGPT for Monocle[4775:1088487] [quic] quic_conn_send_frames_for_key_state_block_invoke [C1.1.1.1:2] [-0151a6eeef6cab8c6b53cceead6cada7cf118a4e] unable to request outbound data 2023-05-23 16:33:49.440640-0700 ChatGPT for Monocle[4775:1088487] [quic] quic_conn_send_frames_for_key_state_block_invoke [C1.1.1.1:2] [-0151a6eeef6cab8c6b53cceead6cada7cf118a4e] unable to request outbound data 2023-05-23 16:33:49.440784-0700 ChatGPT for Monocle[4775:1088487] [quic] quic_conn_send_frames_for_key_state_block_invoke [C1.1.1.1:2] [-0151a6eeef6cab8c6b53cceead6cada7cf118a4e] unable to request outbound data 2023-05-23 16:33:49.441459-0700 ChatGPT for Monocle[4775:1088487] [quic] quic_conn_send_frames_for_key_state_block_invoke [C1.1.1.1:2] [-0151a6eeef6cab8c6b53cceead6cada7cf118a4e] unable to request outbound data 2023-05-23 16:33:49.441684-0700 ChatGPT for Monocle[4775:1088487] [quic] quic_conn_send_frames_for_key_state_block_invoke [C1.1.1.1:2] [-0151a6eeef6cab8c6b53cceead6cada7cf118a4e] unable to request outbound data 2023-05-23 16:33:49.445598-0700 ChatGPT for Monocle[4775:1088487] [connection] nw_endpoint_handler_add_write_request [C1.1.1.1 104.18.6.192:443 failed channel-flow (satisfied (Path is satisfied), viable, interface: en0[802.11], ipv4, ipv6, dns)] Cannot send after flow table is released 2023-05-23 16:33:49.445773-0700 ChatGPT for Monocle[4775:1088487] [connection] nw_write_request_report [C1] Send failed with error "Socket is not connected" 2023-05-23 16:33:49.446925-0700 ChatGPT for Monocle[4775:1088487] Connection 1: received failure notification 2023-05-23 16:33:49.447348-0700 ChatGPT for Monocle[4775:1088487] Connection 1: write error 1:57 2023-05-23 16:33:49.464436-0700 ChatGPT for Monocle[4775:1088487] [connection] nw_endpoint_handler_unregister_context [C1.1.1.1 104.18.6.192:443 failed channel-flow (satisfied (Path is satisfied), viable, interface: en0[802.11], ipv4, ipv6, dns)] Cannot unregister after flow table is released 2023-05-23 16:33:49.464974-0700 ChatGPT for Monocle[4775:1088487] [] nw_endpoint_flow_fillout_data_transfer_snapshot copy_info() returned NULL Case 2: 2023-05-23 16:34:09.422783-0700 ChatGPT for Monocle[4775:1088784] [connection] nw_read_request_report [C3] Receive failed with error "Socket is not connected" 2023-05-23 16:34:09.423511-0700 ChatGPT for Monocle[4775:1088784] [connection] nw_read_request_report [C3] Receive failed with error "Socket is not connected" 2023-05-23 16:34:09.425478-0700 ChatGPT for Monocle[4775:1088784] [connection] nw_read_request_report [C3] Receive failed with error "Socket is not connected" 2023-05-23 16:34:09.434263-0700 ChatGPT for Monocle[4775:1088784] [quic] quic_conn_send_frames_for_key_state_block_invoke [C3.1.1.1:2] [-01809801f02b5c3795812501322b6f9d3c91236f] unable to request outbound data The code that is generating these requests is fairly straightforward: public func send(query: String, apiKey: String, model: String, completion: @escaping (String, ChatGPTError?) -> Void) { let requestHeader = [ "Authorization": "Bearer \(apiKey)", "Content-Type": "application/json" ] _payload["model"] = model if var messages = _payload["messages"] as? [[String: String]] { messages.append([ "role": "user", "content": "\(query)" ]) _payload["messages"] = messages } let jsonPayload = try? JSONSerialization.data(withJSONObject: _payload) let url = URL(string: "https://api.openai.com/v1/chat/completions")! var request = URLRequest(url: url) request.httpMethod = "POST" request.allHTTPHeaderFields = requestHeader request.httpBody = jsonPayload _task = URLSession.shared.dataTask(with: request) { data, response, error in if let error = error { DispatchQueue.main.async { completion("", ChatGPTError.networkRequestFailed(error: error)) } return } if let data = data { let (contentError, response) = self.extractContent(from: data) if let contentError = contentError { DispatchQueue.main.async { completion("", contentError) } } else if let response = response { DispatchQueue.main.async { completion(response, nil) } } return } DispatchQueue.main.async { completion("", ChatGPTError.responsePayloadParseError) } } _task?.resume() } Questions Is there any way to make this process more reliable? I assume the error messages are meaningful and should not be ignored. If not, will I end up encountering issues when trying to upload larger payloads? Thank you! -- B.
Posted
by
Post not yet marked as solved
0 Replies
442 Views
As a result, I judged this phenomenon to be an iOS bug. In a technical article by some knowledgeable people, CoreBluetooth said that when it goes into the background, it goes into passive scanning instead of active scanning. So I actually checked. First, send the advertised data on the BLE module board. Next, when the app side receives the advertised data, it skips the scan request. When the BLE module board receives a scan request, it will send a scan response. As a result, the strange thing was that the app was able to get the scan response whether it was in the foreground or the background. But it was one of confusion rather than joy. As a test, if the BLE module board side changes the data packet of the scan response while the application side is in the background state and resends it, the application side does not acquire the changed data. For some reason it returns the past scan response data acquired in the foreground. Why is the specification to return the past scan response? Or am I doing something wrong? I saw the official documentation about this, but there is no description anywhere in the iOS specification. I don't care about any information, so I would like to borrow wisdom from all the experts. thank you.
Posted
by
Post not yet marked as solved
0 Replies
293 Views
I'm initialising my CBPeripheralManager with the option [CBPeripheralManagerOptionShowPowerAlertKey: false] but this key does not suppress the system alert if the bluetooth is either turned off from Settings app or the control centre. Is there a way to disable this alert?
Posted
by
Post not yet marked as solved
0 Replies
418 Views
Hi everybody, In my app when I do following steps: I don't allow access to bluetooth for my app I start the pairing Then I navigate to settings and enable bluetooth access and coming back to the app. I see two different behaviours in two different OS version **So for iOS 15: It is opening me the home screen and I must start the pairing again. for iOS 16: It is opening the view that asks from user "Do you want to perform connection?" and I should select there again if I want or not and then pairing starts again.** Is it because of iOS versions that we cannot really influence on it? Because the implementation is same for both OS version. That is why I started to think that it is not a bug, but it is a iOS related feature. Can you share your ideas about it? If it is iOS related, is there any documentation that I can read? I have searched but couldn't find... Thanks in advance!
Posted
by
Post not yet marked as solved
0 Replies
390 Views
Does the iPhone or iPad support reception of the following communication standards? If so, please let me know if there is an swift API available. ・Bluetooth 5.x Long Range ・Wi-Fi Neighbor Awareness Networking (Wi-Fi Aware) ・Wi-Fi Beacon
Posted
by
Post not yet marked as solved
0 Replies
334 Views
I have been looking into this concept off and on for a while and came across this previous post. The answer to their question was no due to the fact that they seemed to want a more guaranteed version of data transmission. But what if you don't care about this? I am attempting to make an experiment of a system to swap data between instances of a game while the app isn't open. (Optional of course, for battery and privacy reasons.) If the app detects the broadcasted data from the other app instance, it will save this and use it for optional game features. Imagine you can decorate a simple house, the data of this house is made as small as possible, and then broadcast for other instances of the game to download and allow players to view, with the received data only being shown after a random period of 2-8 hours in order to minimize the possibility of tracking. For this example, it is not mandatory for the data to make it to the peer's phone or vice versa, it would just be nice if it did. Is this possible in the iOS background bluetooth system?
Posted
by
Post not yet marked as solved
0 Replies
853 Views
Hello, I am working with Core bluetooth functionality incase of iOS. In one of our bluetooth hardware using pairing key to pair device. When the device is turned off and turned on again and we try to connect same device its giving us above bluetooth error of Code=14 "Peer removed pairing information" The only way to reconnect this device is to forget that from setting and reconnect. I am aware about answers regarding following above steps. But we required any other way as in our application we are connecting again device automatically and its always stopping users from background connect. In case of Android OS the Android OS is asking pairing key again and no steps required for forgetting it. So is any similar options available for iOS in latest OS or fix is pending from iOS ? Thanks
Posted
by
Post not yet marked as solved
1 Replies
400 Views
Hi There, I am currently coding an app which uses the CoreBluetooth Function to scan for nearby peripherals. I keep finding myself an error when I specifically click on my Bluetooth page. The error I am met with is: "Thread 1: "String does not represent a valid UUID"". I have tried my luck with fixing this error but can't see to find the root of the problem. Help would kindly be appreciated In finding how to fix this. Cheers, hupfawil2023
Posted
by
Post not yet marked as solved
0 Replies
366 Views
I create a gatt over br/edr link with my watch on ios 16, my watch is a peripheral device as gatts , iphone as a central device to connect my watch by gatt over br/edr , the BLE link is not connected ... my watch need to connect ancs service as gattc , done ios support gattc connection on gatt over br/edr link?
Posted
by
Post not yet marked as solved
0 Replies
457 Views
How do I use Core Bluetooth in the simplest possible way to send a value of 0 to 1 from an iOS device to a bluetooth peripheral that does nothing but interpret the value sent to it as how strongly a vibrating component on the bluetooth peripheral should vibrate. A value of zero would mean the peripheral device doesn't vibrate at all, of course. The bluetooth peripheral would be the bluetooth ***** of course, and the iOS device would be the bluetooth master. The ***** device doesn't need to send anything at all to the master iOS device, except to link to the master. I don't know if that would allow the ***** bluetooth device to be any less expensive or smaller or simpler.
Posted
by
Post not yet marked as solved
0 Replies
427 Views
Hi is it possible to advertise any data at background that can be parsed by other central device? While your app is in the background, the local name isn’t advertised and all service UUIDs are in the overflow area. How to read/parse overflow area? Thanks
Posted
by
Post not yet marked as solved
0 Replies
479 Views
I am trying to turn an iOS device into a Bluetooth keyboard/joystick peripheral. I know iOS 16 supports the HID profile for communication with Bluetooth keyboards and game controllers (https://support.apple.com/en-us/HT204387). However, is it also possible for an iOS device to act as a HID device, advertising services like the HID? I've seen an app, BlueTouch seems to make the similar functionality, and sample code on Github (https://gist.github.com/conath/c606d95d58bbcb50e9715864eeeecf07) suggest this might be possible. Has there been any change in iOS that would allow an iOS device to act as a Bluetooth HID device? Could you point me to the relevant documentation or sample code? Thanks for any guidance you can provide.
Posted
by
Post not yet marked as solved
0 Replies
876 Views
My company has a Bluetooth 4.2 hardware product that requires a connection interval of 15ms to operate correctly. Starting with the release of iOS 16, we noticed these connection parameters are being rejected and we are provided a connection interval of 30ms which leads to severe packet loss. I'm aware of the note on page 193 of this document that specifies this may happen on some devices, but it had not been an issue up until the release of iOS 16. Does anyone know the precise circumstances that would lead to the scaling of this interval? Is there anything that can be done in software or firmware to get around the issue?
Posted
by
Post not yet marked as solved
0 Replies
398 Views
i am coding swift Bluetooth classic Communication program. my app need to communicate with esp32 with Bluetooth classic. but i didn't know how i can do this. there are so many sample code that use Bluetooth Low Energy communication with Swift or SwiftUI but i can't find Bluetooth classic with swift or swiftui. i think apple doesn't support Bluetooth Classic Communication . for example, they doesn't explain well about "Using core bluetooth classic" guide at their document at apple web site.
Posted
by
Post not yet marked as solved
0 Replies
578 Views
I'm trying to make an iOS (SwiftUI based) app to connect the arduino and send the current latitude value of ios to arduino. I successfully made the view that allow user to select the bluetooth device, and the UUID/name of the device is successfully displayed. Also, the arduino device detects connection (I used LiquidCrystal to display serial and it says "OK+CONN" and "OK+LOST" if connection was lost.), but when I click "fetch location" button, nothing happens on arduino side. The code is in stackoverflow due to character limits: https://stackoverflow.com/questions/76752529/arduino-hm-10-bluetooth-with-ios-connected-but-it-doesnt-send-values
Posted
by