core-bluetooth

CoreBluetooth: How to design code for many characteristics (30 - 40)?

徘徊边缘 提交于 2019-12-03 12:08:25
I searched around a bit and just found this as a possible duplicate question: Multiple CBPeripheral's for same device My problem is: I have multiple services which all together have about 30-40 characteristics (Yes, I need all of them...). As starting point for dealing with CoreBluetooth I always used the Apple Sample Code ( CoreBluetooth Temperature Sensor ). Discovery and Service/Characteristic handling is divided into two classes and this works fine for just a few characteristics. But handling this huge amount of characteristics in one class is not what I understand under "good software

iOS 8 Core Bluetooth not discovering peripherals

不羁的心 提交于 2019-12-03 11:40:58
I'm having trouble getting Core Bluetooth to discover peripherals on iOS 8. Same code works fine on iOS 7 device. Initially I thought it would be a permissions issue since I had been doing some iBeacon work and there are some changes in Core Location permissions on iOS 8. I couldn't find anything online that helped with that however. Here is a link to a sample project that works fine for me on iOS 7 but not on iOS 8: https://github.com/elgreco84/PeripheralScanning If I run this project on an iOS 7 device it will log advertisement data for a number of devices around me. On iOS 8 the only output

Can't connect to AirPods via BLE

China☆狼群 提交于 2019-12-03 11:26:38
I am trying to connect automatically to my AirPods with a simple app using BLE. I get the name of the device and the status to "connecting", but for some reason I can't connect to it. Function 'didConnect peripheral' is never triggered. I tried all different approaches from tutorials and from other posts, tried to store the peripheral data in an array to keep the reference but nothing seem to work. Is there any step which I can get some extra info between 'didDiscover' and 'didConnect'? Working in XCode 9.2, using Swift 4 and iOS 11.2 on iPhone. Here's my code: let deviceName = "AirPods de

Check Bluetooth status - Swift 4

限于喜欢 提交于 2019-12-03 10:36:40
I have a problem with the Bluetooth in Xcode. I can’t find a great solution on how to check if Bluetooth is on or not. I want just that. I searched around the web some solution, but nothing works for me. Any idea on how to check Bluetooth? I imported the CoreBluetooth class and I made this line of code: if CBPeripheralManager.authorizationStatus() == .denied { code } if CBPeripheralManager.authorizationStatus() == .authorized { code } Implement CBCentralManagerDelegate delegate for that. var manager:CBCentralManager! viewDidLoad() { // Or init() manager = CBCentralManager() manager.delegate =

How to use core bluetooth framework get data?

馋奶兔 提交于 2019-12-03 10:03:26
问题 I am working on an iOS core Bluetooth application, i can connect the bluetooth device use iphone4S , but i dont know how to communication with the device. i want to read information form the device. i also see this sources code https://github.com/sergiomtzlosa/CoreBluetooth-Demo/ and this article How to read information from core bluetooth device but i dont understand how to transfer data. can some one help me? thank you 回答1: To use CoreBluetooth, first your device must support Bluetooth Low

Setting Notifications on Characteristic results in Invalid Handle error

試著忘記壹切 提交于 2019-12-03 09:17:22
Using CoreBluetooth I want to send data from iPhone to Mac. For this I wrote code like iPhone as 'Peripheral' and Mac as 'Central'. It works perfectly, but sometimes it disconnects directly and then it continuously connects and disconnects. Some times when it is trying to reconnect, In Central it directly calls 'didDisconnectPeripheral' delegate method. But some times it has error "The handle is invalid" in 'didUpdateNotificationStateForCharacteristic'. I referred all the links in net. But I am not able to solve this problem. I thought in iPhone it was storing Bluetooth cache. Please suggest a

How to use service soliciting with IOBluetooth/CoreBluetooth?

房东的猫 提交于 2019-12-03 09:09:07
What I'm trying to do is use the Apple Notification Center Service (ANCS) from my iPhone on my Mac. To make my Mac show up on in my iPhone's Bluetooth settings, I apparently need to use service soliciting. What I've tried so far is initiate a CBPeripheralManager on my Mac, add the ANCS service to it and start advertising. That doesn't seem to do it, as my Mac doesn't show up in my iPhone's Bluetooth settings. What I've also tried is initiate a CBCentralManager and start scanning, with the ANCS UUID in the CBCentralManagerScanOptionSolicitedServiceUUIDsKey key, which doesn't work either. Does

IOS Core Bluetooth : Writing NSData for Characteristic

一世执手 提交于 2019-12-03 08:48:33
I am using the following code to write the 0xDE value for a Bluetooth Caracteristic (Reset Device) using the IOS Core Bluetooth : ... NSData *bytes = [@"0xDE" dataUsingEncoding:NSUTF8StringEncoding]; [peripheral writeValue:bytes forCharacteristic:characteristic type:CBCharacteristicWriteWithResponse]; ... is there any mistake in my code because the value is not written properly? Try creating your data with an array of single byte values. const uint8_t bytes[] = {0xDE}; NSData *data = [NSData dataWithBytes:bytes length:sizeof(bytes)]; This is a useful approach for creating arbitrary constant

How can I reconnect to device after disconnecting in Core Bluetooth

送分小仙女□ 提交于 2019-12-03 07:54:58
问题 In Core Bluetooth, after connecting to a device, I turn off the device and the device is disconnected. But when I turn on the device again, there is no didDiscoverPeripheral called again. How can I reconnect to the device again? 回答1: When you disconnect a device with cancelPeripheralConnection the didDisconnectPeripheral delegate method will be invoked. However from iOS 6.0 the device remains connected for about 40-50 seconds (or more), so no didDiscoverPeripheral will be invoked in that

iOS 8 CoreBluetooth deprecated RSSI methods

二次信任 提交于 2019-12-03 07:54:36
So from reading the CBPeripheralDelegate documentation, it appears that RSSI and peripheralDidUpdateRSSI:error: were deprecated with iOS 8. I noticed that my signal strength indicator was no longer being updated, so I did some research and found a new method ( [CBPeripheralDelegate peripheral:didReadRSSI:error:] ) that supposedly get called back asynchronously after calling the readRSSI method. Unfortunately, this method does not seem to get called back either, even though I did set the parent class as the CBPeripheral delegate. Has anyone else had issues with the iOS 8 CoreBluetooth updates?