IOBluetooth

RSS for tag

Gain user-space access to Bluetooth devices using IOBluetooth.

Posts under IOBluetooth tag

184 Posts

Post

Replies

Boosts

Views

Activity

Issues with IOBluetoothDeviceInquiry Delegate
All, I have an issue where my IOBluetoothDeviceInquiry and IOBluetoothDevicePair objects do not seem to be triggering all of their lifecycle states. Here is some sample code below. What am I missing here. In this example, the deviceInquiryStarted trigger never fires, even though it clearly starts and finds devices. Also devices are not added to the @Published object as they are found. Also the sender.stop() does not seem to work when coming from the delegate to stop the search. I feel like I am just missing something here as it relates to delegates. I am just looking to scan for HID devices like mice, keyboards and headsets. Then allow the user to pair the device, and list paired devices. I am pretty new to IOBluetooth so any help is appreciated. import IOBluetooth import IOBluetoothUI import SwiftUI class BluetoothSearchDelegate : NSObject, ObservableObject, IOBluetoothDeviceInquiryDelegate {          @Published var devices: [IOBluetoothDevice] = []          func deviceInquiryDeviceFound(_ sender: IOBluetoothDeviceInquiry, device: IOBluetoothDevice) {         debugPrint("********** DEVICE FOUND ************")         self.devices.append(device)     }          func deviceInquiryStarted(_ sender: IOBluetoothDeviceInquiry) {         debugPrint("inquiryStarted")     }          func deviceInquiryComplete(_ sender: IOBluetoothDeviceInquiry, error: IOReturn, aborted: Bool) {         sender.stop()         print("completed")     } } class BluetoothController: ObservableObject {          //     // DEVICE LISTS     //     @Published var devices: [IOBluetoothDevice] = []          //     // SEARCH TYPE     //     let searchType: IOBluetoothDeviceSearchTypes = kIOBluetoothDeviceSearchClassic.rawValue          //     // BLUETOOTH DEVICE     //     let btDevice: IOBluetoothDevice = IOBluetoothDevice()          //     // DELEGATES     //     let searchDelegate = BluetoothSearchDelegate()          //     // AGENTS     //     let searchAgent: IOBluetoothDeviceInquiry     let pairingAgent = IOBluetoothDevicePair()          init() {         self.searchAgent = IOBluetoothDeviceInquiry(delegate: self.searchDelegate)         self.searchAgent.searchType = self.searchType     }          func scan() {         self.searchAgent.inquiryLength = 1         self.searchAgent.start()         self.devices = self.searchDelegate.devices     }          func getPairedDevices() -> [IOBluetoothDevice] {         let devices = IOBluetoothDevice.pairedDevices() as? [IOBluetoothDevice]         debugPrint(devices ?? [])         return devices ?? []     }          func stop() {         self.searchAgent.stop()         self.devices = self.searchAgent.foundDevices() as? [IOBluetoothDevice] ?? []         self.searchAgent.clearFoundDevices()                  debugPrint("Device Count: \(self.devices.count)")     }          func pair(device: IOBluetoothDevice) -> IOBluetoothDevicePair {         self.pairingAgent.setDevice(device)         pairingAgent.start()         return pairingAgent     }          func stopPairing(pairingAgent: IOBluetoothDevicePair) {         pairingAgent.stop()     }                } struct ContentView: View {     @State var isScanning: Bool = false     @State var isPairing: Bool = false     @ObservedObject var bt = BluetoothController()          var body: some View {         VStack {             Text("Scan for bt devices").padding()             Button(action: {                 if !self.isScanning {                     self.bt.scan()                     self.isScanning.toggle()                     return                 } else {                     self.bt.stop()                     self.isScanning.toggle()                     return                 }                              }, label: {                 Text(self.isScanning ? "Stop" : "Scan")             }).padding()                          List(self.bt.searchDelegate.devices, id: \.self) { device in                 HStack {                     Text("\(device.name)")                     Spacer()                     Button(action: {                         var pairingAgent: IOBluetoothDevicePair = IOBluetoothDevicePair()                         if !self.isPairing {                             pairingAgent = bt.pair(device: device)                         } else {                             bt.stopPairing(pairingAgent: pairingAgent)                         }                     }, label: {                                                  if !self.isPairing {                             Text("Pair")                         } else {                             Text("Stop")                         }                     })                 }             }         }     } }
0
0
1.3k
Jun ’22
Have an iOS/iPadOS app be a bluetooth audio receiver
I was wondering if it is possible to use the bluetooth API on iPadOS to let an app become an emulated "bluetooth speaker/car". I want to make an app where an iPhone or Android phone can connect to it via bluetooth so the app can play the audio from the phone, and receive and handle calls just like a car can play audio and handle calls and display call information via bluetooth. I would also like to know if the app could also get contact information from the phone over bluetooth. If it is possible to do so, how? I would love a friendly nudge in the right direction :)
0
0
1.1k
Jun ’22
Cross Transport Key Derivation
Any developer has experience in CTKD? I saw it was mentioned in WWDC 2019 (https://developer.apple.com/videos/play/wwdc2019/901), and it stated that there would be a sample project from documentation (https://developer.apple.com/documentation/corebluetooth/using_core_bluetooth_classic). But I could not find further information on it.
1
0
1.4k
Jun ’22
Repeating BLE pairing requests
I am currently working on an IOS application that pairs with a raspberry pi advertising a UART BLE service. The application successfully discovers the peripheral and attempts to connect to it. However, I keep getting a pop up window from IOS with a request to pair with the device. If I press "cancel", the app disconnects from the peripheral. If I press "pair", the peripheral connects. However, the app continues sending me pairing requests. Is this a known bug with IOS? Is there any way to get around this issue?
3
0
3.7k
Jun ’22
Press some special characters by HID usage codes
Hi everyone, I am developing a virtual keyboard device connected to an iOS device by Bluetooth. And how to press any special characters by HID usage. I have tried all combinations of keys option + shift + key or option + key but there aren't any characters that I want Particularly, I want to press the character '@' in the Lithuanian language for iOS devices by Bluetooth virtual keyboard. Are there any combinations of keys to press these special characters? Dien Vu
0
0
960
Jun ’22
Bluetooth UHP IOS 14.2 problem iphone 12
Iphone 12 new with bluetooth handsfree UHP, Cadillac,Opel,Saab. connect ok, receive and make calls ok, but when you will end the call, the sustem of the car turns crazy, sometimes loose conection, sometimes freeze the call on the car but it’s ended on the phone. several test done, changing configuration on the phone,with no result, The most surprising it’s thats if the person tbat makes tbe call to you end the call, everything it’s ok. same car eith iphone 11 Ios 14.1 works fine ahy thoughts about?
3
0
1.3k
Jun ’22
Remap different keyboard using IOHID
Hi there! I'm currently new to Mac OS dev (coming from a history of Linux dev). I have an external BT keyboard and a couple keys are mapped differently than my Mac keyboard (§ to ` for example). I'm wondering if it's possible to write a kernel extension that detects the key sent from the BT keyboard and remap the key code. I don't really know whether this is possible and if it is, where to look in the ecosystem. It's a bit different from Linux. Thank you!
1
0
1.2k
May ’22
how to use the cache of GATT datatbase in IOS
Here I have an requirement that ios ble app may not repeatedly does service and characterice discovery process if that the gatt database in the peer device is not changed. To use the cache in the ios could fast the operation on peer device. And it said to use the cache of gatt database in IOS needs the condition which IOS and ble device need to be paired firstly. However my ios app does not need to be paired. who could tell how to do with it ?
0
0
706
May ’22
Bluetooth and Wi-Fi issues
So i got this problem where i cant turn on bluetooth or wifi in my i phone. Thoes worked fine just minute ago but suddenly both of thoes stopped working. I tried to restart phone, restart wifi settings and restart all of the settings but nothing seems to work. What i can do?
1
0
608
Apr ’22
why my bluetooth won’t turn on
Hi my bluetooth wont turn on after monterey Is anyone solved his problem of bluetooth turning on after monterey 12.3.1 or public beta 12.4? I updated to it but yet can’t turning on bluetooth of my core i5 macbook / anyone does have better solution? / I delete plist / rest smc and nvram / reset bluetooth / reinstall mac old and new versions / clean install mac / try unsigned blufix kext / try pkill bluetoothd in terminal try bluetool by brew / force quit bluetoothd and… / but didn’t solve it and I cant turn on bluetooth and using my magic mouse 2
1
0
948
Apr ’22
my right airpod is not charging properly after ios 15.4.1 update
My right airpod is not charging properly after the update. It shows it is always connected to the phone even when it is in the case. And when charging only left AirPod is getting charged. When I receive a call through the phone I am still getting airpods option. I tried unpairing and pairing, cleaned the case thoroughly, restarted my phone but nothing helped. Help me find a solution.
0
0
577
Apr ’22
Bluetooth in Monterey
Hi, our Java-Bluetooth library avetanaBluetooth has stopped working with the Monterey update. I can also see that the Apple provided "Bluetooth Explorer" tool is not working as expected anymore. Inquires do not show any devices discoverable nearby. Is there any recommendation how to fix this in our code or is this something that Apple needs to fix internally? Any roadmap on when to expect a solution? Thanks Moritz
1
0
1.3k
Apr ’22
iAP2(BT) doesnt have space to write when or after calling.
Hi, Before my question, I've sent this ticket to Apple Bug Report. But it need to wait a lot of time for getting response. So that I leave it on the Developer Forums. Please help or try to give some ideas how to achieve this. Thanks! Initially, there are running two apps in our project. The first one is sending the data with iAP2(Bluetooth)(40KB per sec). The other is sending the data with BLE(150 byte per 100 ms). The BT device is same(iAP2(BT), BLE). The phone connect with a Bluetooth headset and play a music. Normally, they work well. All of transmission are sent well. *** BTW: The MFi device is also made by us. *** But when answering a phone call, the iAP2 data looks like is hung on the iOS. We get two situations. The first one is no space. Check by the api(https://developer.apple.com/documentation/foundation/outputstream/1411335-hasspaceavailable). All of commands could not be sent. The other the hasSpaceAvailable is true. By checking the api(https://developer.apple.com/documentation/foundation/outputstream/1411335-hasspaceavailable), the content is sent completed. The results both of them are same. The iAP2(BT) could not be sent to the MFi device. We also traced the air-sniffer log, but we got nothing. The transmission between iPhone and the device stopped. We have no idea about it. Please help or try to give some ideas how to analyze this. Thanks!
0
0
1.1k
Mar ’22
How to restrict textfield to take input from virtual keyboard only not from any other connected Bluetooth Device (scanner device)?
I am working on an iPad application which uses Henex HC-3208R wireless bar code scanner. While doing scanning the scanner reads the code from the QR code or barcode and copies the code in the textfield where focus is there which need to be restricted. If by mistakenly the focus goes to any textfield and you trigger the scanning button in device at the same time then it reads the code and copies it to the textfield. I also tried to distinguish between the text inputs from the virtual keyboard and bluetooth input device so that I can block the text coming from bluetooth scanner device but there is no changes in the textfield delegates, it behaves the same. If we can get to know the source of the key strike when focus is already there in a textfield, that will be much helpful. PS: I am connecting the scanner as using HID Profile and it is treated as a bluetooth keyboard by iPad.This is expected as device treats bar code scanner as bluetooth keyboard, but we can forcefully open the virtual keyboard on long pressing the arrow-up icon in keyboard task bar which is shown everytime. Please let me know if it is possible or any other suggestion which I can try. Thanks in advance.
0
0
654
Mar ’22
Issues with IOBluetoothDeviceInquiry Delegate
All, I have an issue where my IOBluetoothDeviceInquiry and IOBluetoothDevicePair objects do not seem to be triggering all of their lifecycle states. Here is some sample code below. What am I missing here. In this example, the deviceInquiryStarted trigger never fires, even though it clearly starts and finds devices. Also devices are not added to the @Published object as they are found. Also the sender.stop() does not seem to work when coming from the delegate to stop the search. I feel like I am just missing something here as it relates to delegates. I am just looking to scan for HID devices like mice, keyboards and headsets. Then allow the user to pair the device, and list paired devices. I am pretty new to IOBluetooth so any help is appreciated. import IOBluetooth import IOBluetoothUI import SwiftUI class BluetoothSearchDelegate : NSObject, ObservableObject, IOBluetoothDeviceInquiryDelegate {          @Published var devices: [IOBluetoothDevice] = []          func deviceInquiryDeviceFound(_ sender: IOBluetoothDeviceInquiry, device: IOBluetoothDevice) {         debugPrint("********** DEVICE FOUND ************")         self.devices.append(device)     }          func deviceInquiryStarted(_ sender: IOBluetoothDeviceInquiry) {         debugPrint("inquiryStarted")     }          func deviceInquiryComplete(_ sender: IOBluetoothDeviceInquiry, error: IOReturn, aborted: Bool) {         sender.stop()         print("completed")     } } class BluetoothController: ObservableObject {          //     // DEVICE LISTS     //     @Published var devices: [IOBluetoothDevice] = []          //     // SEARCH TYPE     //     let searchType: IOBluetoothDeviceSearchTypes = kIOBluetoothDeviceSearchClassic.rawValue          //     // BLUETOOTH DEVICE     //     let btDevice: IOBluetoothDevice = IOBluetoothDevice()          //     // DELEGATES     //     let searchDelegate = BluetoothSearchDelegate()          //     // AGENTS     //     let searchAgent: IOBluetoothDeviceInquiry     let pairingAgent = IOBluetoothDevicePair()          init() {         self.searchAgent = IOBluetoothDeviceInquiry(delegate: self.searchDelegate)         self.searchAgent.searchType = self.searchType     }          func scan() {         self.searchAgent.inquiryLength = 1         self.searchAgent.start()         self.devices = self.searchDelegate.devices     }          func getPairedDevices() -> [IOBluetoothDevice] {         let devices = IOBluetoothDevice.pairedDevices() as? [IOBluetoothDevice]         debugPrint(devices ?? [])         return devices ?? []     }          func stop() {         self.searchAgent.stop()         self.devices = self.searchAgent.foundDevices() as? [IOBluetoothDevice] ?? []         self.searchAgent.clearFoundDevices()                  debugPrint("Device Count: \(self.devices.count)")     }          func pair(device: IOBluetoothDevice) -> IOBluetoothDevicePair {         self.pairingAgent.setDevice(device)         pairingAgent.start()         return pairingAgent     }          func stopPairing(pairingAgent: IOBluetoothDevicePair) {         pairingAgent.stop()     }                } struct ContentView: View {     @State var isScanning: Bool = false     @State var isPairing: Bool = false     @ObservedObject var bt = BluetoothController()          var body: some View {         VStack {             Text("Scan for bt devices").padding()             Button(action: {                 if !self.isScanning {                     self.bt.scan()                     self.isScanning.toggle()                     return                 } else {                     self.bt.stop()                     self.isScanning.toggle()                     return                 }                              }, label: {                 Text(self.isScanning ? "Stop" : "Scan")             }).padding()                          List(self.bt.searchDelegate.devices, id: \.self) { device in                 HStack {                     Text("\(device.name)")                     Spacer()                     Button(action: {                         var pairingAgent: IOBluetoothDevicePair = IOBluetoothDevicePair()                         if !self.isPairing {                             pairingAgent = bt.pair(device: device)                         } else {                             bt.stopPairing(pairingAgent: pairingAgent)                         }                     }, label: {                                                  if !self.isPairing {                             Text("Pair")                         } else {                             Text("Stop")                         }                     })                 }             }         }     } }
Replies
0
Boosts
0
Views
1.3k
Activity
Jun ’22
Have an iOS/iPadOS app be a bluetooth audio receiver
I was wondering if it is possible to use the bluetooth API on iPadOS to let an app become an emulated "bluetooth speaker/car". I want to make an app where an iPhone or Android phone can connect to it via bluetooth so the app can play the audio from the phone, and receive and handle calls just like a car can play audio and handle calls and display call information via bluetooth. I would also like to know if the app could also get contact information from the phone over bluetooth. If it is possible to do so, how? I would love a friendly nudge in the right direction :)
Replies
0
Boosts
0
Views
1.1k
Activity
Jun ’22
Cross Transport Key Derivation
Any developer has experience in CTKD? I saw it was mentioned in WWDC 2019 (https://developer.apple.com/videos/play/wwdc2019/901), and it stated that there would be a sample project from documentation (https://developer.apple.com/documentation/corebluetooth/using_core_bluetooth_classic). But I could not find further information on it.
Replies
1
Boosts
0
Views
1.4k
Activity
Jun ’22
Repeating BLE pairing requests
I am currently working on an IOS application that pairs with a raspberry pi advertising a UART BLE service. The application successfully discovers the peripheral and attempts to connect to it. However, I keep getting a pop up window from IOS with a request to pair with the device. If I press "cancel", the app disconnects from the peripheral. If I press "pair", the peripheral connects. However, the app continues sending me pairing requests. Is this a known bug with IOS? Is there any way to get around this issue?
Replies
3
Boosts
0
Views
3.7k
Activity
Jun ’22
Press some special characters by HID usage codes
Hi everyone, I am developing a virtual keyboard device connected to an iOS device by Bluetooth. And how to press any special characters by HID usage. I have tried all combinations of keys option + shift + key or option + key but there aren't any characters that I want Particularly, I want to press the character '@' in the Lithuanian language for iOS devices by Bluetooth virtual keyboard. Are there any combinations of keys to press these special characters? Dien Vu
Replies
0
Boosts
0
Views
960
Activity
Jun ’22
Bluetooth UHP IOS 14.2 problem iphone 12
Iphone 12 new with bluetooth handsfree UHP, Cadillac,Opel,Saab. connect ok, receive and make calls ok, but when you will end the call, the sustem of the car turns crazy, sometimes loose conection, sometimes freeze the call on the car but it’s ended on the phone. several test done, changing configuration on the phone,with no result, The most surprising it’s thats if the person tbat makes tbe call to you end the call, everything it’s ok. same car eith iphone 11 Ios 14.1 works fine ahy thoughts about?
Replies
3
Boosts
0
Views
1.3k
Activity
Jun ’22
Remap different keyboard using IOHID
Hi there! I'm currently new to Mac OS dev (coming from a history of Linux dev). I have an external BT keyboard and a couple keys are mapped differently than my Mac keyboard (§ to ` for example). I'm wondering if it's possible to write a kernel extension that detects the key sent from the BT keyboard and remap the key code. I don't really know whether this is possible and if it is, where to look in the ecosystem. It's a bit different from Linux. Thank you!
Replies
1
Boosts
0
Views
1.2k
Activity
May ’22
how to use the cache of GATT datatbase in IOS
Here I have an requirement that ios ble app may not repeatedly does service and characterice discovery process if that the gatt database in the peer device is not changed. To use the cache in the ios could fast the operation on peer device. And it said to use the cache of gatt database in IOS needs the condition which IOS and ble device need to be paired firstly. However my ios app does not need to be paired. who could tell how to do with it ?
Replies
0
Boosts
0
Views
706
Activity
May ’22
Logi MX Master 3 and MX Keys are not discoverable after upgrading to macOS Monterey 12.4 (21F79)
My Logi devices were working perfectly well for the last 2 years, but after recently upgrading to macOS Monterey 12.4 (21F79), these devices are not showing up in the list of Bluetooth devices, its not getting discovered, can anyone help to resolve this issue.
Replies
0
Boosts
0
Views
661
Activity
May ’22
iBeacon detection when app is closed
Does anyone know if I can create an app that can detect ibeacon even if the app is closed? I need to send the user a local notification when a region is entered (at an immediate distance) while the app is closed.
Replies
1
Boosts
0
Views
1.9k
Activity
May ’22
Bluetooth pairs but will not connect Monterey 12.3.3 with iPhone 15.4.1
Last week or two AirDrop will not work and Bluetooth connection immediately gets dropped after pairing and connecting momentarily
Replies
1
Boosts
1
Views
830
Activity
May ’22
Bluetooth and Wi-Fi issues
So i got this problem where i cant turn on bluetooth or wifi in my i phone. Thoes worked fine just minute ago but suddenly both of thoes stopped working. I tried to restart phone, restart wifi settings and restart all of the settings but nothing seems to work. What i can do?
Replies
1
Boosts
0
Views
608
Activity
Apr ’22
why my bluetooth won’t turn on
Hi my bluetooth wont turn on after monterey Is anyone solved his problem of bluetooth turning on after monterey 12.3.1 or public beta 12.4? I updated to it but yet can’t turning on bluetooth of my core i5 macbook / anyone does have better solution? / I delete plist / rest smc and nvram / reset bluetooth / reinstall mac old and new versions / clean install mac / try unsigned blufix kext / try pkill bluetoothd in terminal try bluetool by brew / force quit bluetoothd and… / but didn’t solve it and I cant turn on bluetooth and using my magic mouse 2
Replies
1
Boosts
0
Views
948
Activity
Apr ’22
my right airpod is not charging properly after ios 15.4.1 update
My right airpod is not charging properly after the update. It shows it is always connected to the phone even when it is in the case. And when charging only left AirPod is getting charged. When I receive a call through the phone I am still getting airpods option. I tried unpairing and pairing, cleaned the case thoroughly, restarted my phone but nothing helped. Help me find a solution.
Replies
0
Boosts
0
Views
577
Activity
Apr ’22
Non-Mac Bluetooth devices are not working
hi Team, after upgrading my Mac to Monterey m not able to connect my Non-Mac Bluetooth devices. please sort this out as I am suffering from this.
Replies
0
Boosts
0
Views
555
Activity
Apr ’22
Bluetooth in Monterey
Hi, our Java-Bluetooth library avetanaBluetooth has stopped working with the Monterey update. I can also see that the Apple provided "Bluetooth Explorer" tool is not working as expected anymore. Inquires do not show any devices discoverable nearby. Is there any recommendation how to fix this in our code or is this something that Apple needs to fix internally? Any roadmap on when to expect a solution? Thanks Moritz
Replies
1
Boosts
0
Views
1.3k
Activity
Apr ’22
macbook with m1 processor not finding esp32 over bluetooth
The library I use in esp32 is bledevice.h cpp. macbook finds my esp32 through 3rd party software. but macos can't find it with bluetooth software.
Replies
0
Boosts
0
Views
1.3k
Activity
Apr ’22
iAP2(BT) doesnt have space to write when or after calling.
Hi, Before my question, I've sent this ticket to Apple Bug Report. But it need to wait a lot of time for getting response. So that I leave it on the Developer Forums. Please help or try to give some ideas how to achieve this. Thanks! Initially, there are running two apps in our project. The first one is sending the data with iAP2(Bluetooth)(40KB per sec). The other is sending the data with BLE(150 byte per 100 ms). The BT device is same(iAP2(BT), BLE). The phone connect with a Bluetooth headset and play a music. Normally, they work well. All of transmission are sent well. *** BTW: The MFi device is also made by us. *** But when answering a phone call, the iAP2 data looks like is hung on the iOS. We get two situations. The first one is no space. Check by the api(https://developer.apple.com/documentation/foundation/outputstream/1411335-hasspaceavailable). All of commands could not be sent. The other the hasSpaceAvailable is true. By checking the api(https://developer.apple.com/documentation/foundation/outputstream/1411335-hasspaceavailable), the content is sent completed. The results both of them are same. The iAP2(BT) could not be sent to the MFi device. We also traced the air-sniffer log, but we got nothing. The transmission between iPhone and the device stopped. We have no idea about it. Please help or try to give some ideas how to analyze this. Thanks!
Replies
0
Boosts
0
Views
1.1k
Activity
Mar ’22
How to restrict textfield to take input from virtual keyboard only not from any other connected Bluetooth Device (scanner device)?
I am working on an iPad application which uses Henex HC-3208R wireless bar code scanner. While doing scanning the scanner reads the code from the QR code or barcode and copies the code in the textfield where focus is there which need to be restricted. If by mistakenly the focus goes to any textfield and you trigger the scanning button in device at the same time then it reads the code and copies it to the textfield. I also tried to distinguish between the text inputs from the virtual keyboard and bluetooth input device so that I can block the text coming from bluetooth scanner device but there is no changes in the textfield delegates, it behaves the same. If we can get to know the source of the key strike when focus is already there in a textfield, that will be much helpful. PS: I am connecting the scanner as using HID Profile and it is treated as a bluetooth keyboard by iPad.This is expected as device treats bar code scanner as bluetooth keyboard, but we can forcefully open the virtual keyboard on long pressing the arrow-up icon in keyboard task bar which is shown everytime. Please let me know if it is possible or any other suggestion which I can try. Thanks in advance.
Replies
0
Boosts
0
Views
654
Activity
Mar ’22
Raspberry Pi - controlling iPhone
Hi, is there any possibility to control iPhone over Raspberry's Bluetooth? For example, when I press button, iPhone will stop playing music. Thanks a lot!
Replies
1
Boosts
0
Views
1.2k
Activity
Mar ’22