core-bluetooth

How can I use CoreBluetooth for Python without giving up the main thread

纵然是瞬间 提交于 2020-12-04 08:40:28
问题 I am trying to implement a generic BLE interface that will run on OS/X and talk to a BLE peripheral device. The peripheral is very complex: It can be queried, sent hundreds of different commands, offers notifications, etc. I need to be able to connect to it, send it commands, read responses, get updates, etc. I have all of the code I need but am being frustrated by one thing: From the limited information I can find online, it looks like the only way to make CoreBluetooth's delegate callbacks

Extract data from kCBAdvDataManufacturerData on Swift

本秂侑毒 提交于 2020-12-03 07:53:41
问题 I have a TI sensor Tag as a peripheral that broadcasts BLE data in the form of kCBAdvDataManufacturerData. I would like to extract different values from this data in iOS. I am executing the following in Swift: func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber){ for (index, foundPeripheral) in peripherals.enumerated(){ if foundPeripheral.peripheral?.identifier == peripheral.identifier{ peripherals[index

Extract data from kCBAdvDataManufacturerData on Swift

狂风中的少年 提交于 2020-12-03 07:50:28
问题 I have a TI sensor Tag as a peripheral that broadcasts BLE data in the form of kCBAdvDataManufacturerData. I would like to extract different values from this data in iOS. I am executing the following in Swift: func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber){ for (index, foundPeripheral) in peripherals.enumerated(){ if foundPeripheral.peripheral?.identifier == peripheral.identifier{ peripherals[index

CoreBluetooth XPC connection invalid

半腔热情 提交于 2020-12-01 02:00:43
问题 public class BLE: NSObject, CBCentralManagerDelegate { var centralManager:CBCentralManager! public override init() { super.init() self.centralManager = CBCentralManager.init(delegate: self, queue: nil) } public func centralManagerDidUpdateState(_ central: CBCentralManager) { switch central.state { case .unknown: print("unknown") case .resetting: print("resetting") case .unsupported: print("unsupported") case .unauthorized: print("unauthorized") case .poweredOff: print("powered off") case

CoreBluetooth XPC connection invalid

狂风中的少年 提交于 2020-12-01 01:59:30
问题 public class BLE: NSObject, CBCentralManagerDelegate { var centralManager:CBCentralManager! public override init() { super.init() self.centralManager = CBCentralManager.init(delegate: self, queue: nil) } public func centralManagerDidUpdateState(_ central: CBCentralManager) { switch central.state { case .unknown: print("unknown") case .resetting: print("resetting") case .unsupported: print("unsupported") case .unauthorized: print("unauthorized") case .poweredOff: print("powered off") case

CoreBluetooth XPC connection invalid

我与影子孤独终老i 提交于 2020-12-01 01:59:14
问题 public class BLE: NSObject, CBCentralManagerDelegate { var centralManager:CBCentralManager! public override init() { super.init() self.centralManager = CBCentralManager.init(delegate: self, queue: nil) } public func centralManagerDidUpdateState(_ central: CBCentralManager) { switch central.state { case .unknown: print("unknown") case .resetting: print("resetting") case .unsupported: print("unsupported") case .unauthorized: print("unauthorized") case .poweredOff: print("powered off") case

WARNING: The advertisement key 'Service Data' is not allowed

我是研究僧i 提交于 2020-07-05 10:26:55
问题 I am developing a BLE peripheral app. By requirement, the advertising packet must contain Service Data field. I have done this in Android, the packet should be like this: 0x16 is Service Data field listed here https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile/ Same thing, I do it in iOS. I use BluetoothCore framework to implement the bluetooth peripheral. Below is the attribute I should use to set value for Service Data field: advertisementData

Scan peripheral when app in background (ex. when screen locked)

自作多情 提交于 2020-06-23 14:08:12
问题 I have an app which is working in background. I use CBPeripheralManager to Advertising and CBCentralManager to scan. I use two ıos (IOS 11.3 and IOS 13.4.1) device. First one is advertising foreground and background. Second one is scan foreground and background. I can scan; App in the background, phone is unlocked - Works perfect App in background, phone is locked, screen is lighted - Works perfect App in background, phone locked, screen is off - Doesn't work! /* I check it Advertising app

How to update Battery Level in BLE Device with CoreBluetooth in Swift?

元气小坏坏 提交于 2020-05-25 08:06:21
问题 func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) { for c in service.characteristics!{ print("---Characteristic found with UUID: \(c.uuid) \n") let uuid = CBUUID(string: "2A19")//Battery Level if c.uuid == uuid{ //peripheral.setNotifyValue(true, for: c)//Battery Level peripheral.readValue(for: c) } } } } func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) { /* Battery Level */