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
1 Replies
1.1k Views
Hello, When Apple officially released iOS16 to users in Sept and Oct this year, our custom device that uses a nRF52832 Nordic based BLE chip would no longer hold the connection for more that 90 seconds before disconnecting. Through other forums and documentation, we realized that with iOS16, Apple changed their requested Connection Intervals and we had to modify them on our product to solve. [Previously Worked with iOS15 & below] Connection Interval for Product: Min 7.5ms - Max 15ms Does not work with iOS16.0 Does work with iOS16.1 & iOS16.1.1 [Had to Change for iOS16.0, 16.0.1, 16.0.2, 16.0.3] Connection Interval for Product: Min 15ms - Max 30ms However, with the release of iOS16.1 in November, our original connection interval parameters work again. Does anyone know what Apple changed for iOS16.1 for the connection intervals? Why does iOS16.1 accept 7.5-15ms intervals when iOS16.0 doesn't? There are no changes to the connection interval requirements on the Apple Design Guidelines as of the last revision Oct26th,2022. Would really appreciate if anyone can share more info on the BLE change logs for iOS16.1. Thanks for the help!
Posted
by Marie_MN.
Last updated
.
Post not yet marked as solved
1 Replies
594 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 just-me.
Last updated
.
Post not yet marked as solved
0 Replies
65 Views
I'm trying to build a feature which allows: Peripheral send some info (up to 512 bytes) to central Central connects to all nearby peripheral, and display the connected peripherals as a list When user tap on any of the peripheral from the list, central send back some info back. In order to achieve this, I need to make sure to connect to the discovered peripherals before sending over the data because the data i want to send through BLE is larger than advertisementData MTU while peripheral starts broadcasting. However, I also saw some discussion suggesting that I should stop scanning first before establish connection. I wonder if you have any recommendation for my scenario. (Let's assume BLE is the ONLY approach I can go with for transferring data because I want to do this cross Android and iOS offline) Should I maintain 2 peripheral arrays to tracked the discovered and connected peripherals? Am I supposed to connect to the peripheral while scanning? If not, any recommendations? Thank you!
Posted Last updated
.
Post not yet marked as solved
2 Replies
133 Views
Hello, It's been more than three weeks that i've been freaking out about this crash that occurs while establishing a BLE connection to a peripheral, scan wifi networks and connect to one of them via BLE. Here is the crash's stacktrace and I hope that I can get some help in order to resolve this ungoing crash : +0x284 mov x2, x22 +0x288 mov x3, x28 +0x28c bl "swift::ConcurrentReadableHashMap<MallocTypeCacheEntry, swift::LazyMutex>::resize(swift::ConcurrentReadableHashMap<MallocTypeCacheEntry, swift::LazyMutex>::IndexStorage, unsigned char, MallocTypeCacheEntry*)" +0x290 mov x23, x0 +0x294 add x0, sp, #0x2c +0x298 mov x1, x23 +0x29c mov x2, x24 +0x2a0 mov x3, x28 +0x2a4 bl "std::__1::pair<MallocTypeCacheEntry*, unsigned int> swift::ConcurrentReadableHashMap<MallocTypeCacheEntry, swift::LazyMutex>::find<unsigned int>(unsigned int const&, swift::ConcurrentReadableHashMap<MallocTypeCacheEntry, swift::LazyMutex>::IndexStorage, unsigned long, MallocTypeCacheEntry*)" +0x2a8 and x26, x1, #0xffffffff +0x2ac cbnz x27, "_swift_allocObject_+0x2bc" +0x2b0 b "_swift_allocObject_+0x2cc" +0x2b4 mov x26, x1 +0x2b8 cbz x27, "_swift_allocObject_+0x2cc" +0x2bc ldr w8, [x27] +0x2c0 mov x22, x27 +0x2c4 cmp w24, w8 +0x2c8 b.lo "_swift_allocObject_+0x358" +0x2cc add x8, x24, x24, lsr #2 +0x2d0 add x9, x24, #0x1 +0x2d4 cmp x8, x9 +0x2d8 csinc x8, x8, x24, hi +0x2dc lsl x8, x8, #3 +0x2e0 add x0, x8, #0x8 +0x2e4 bl "DYLD-STUB$$malloc_good_size" +0x2e8 mov x28, x0 +0x2ec mov w1, #0xb407 +0x2f0 movk w1, #0x5640, lsl #16 +0x2f4 bl "0x1a255c690" +0x2f8 cbz x0, "_swift_allocObject_+0x49c" +0x2fc mov x22, x0 +0x300 mov x8, #0x7fffffff8 +0x304 add x8, x28, x8 +0x308 lsr x8, x8, #3 +0x30c str w8, [x0] +0x310 cbz x27, "_swift_allocObject_+0x34c" +0x314 add x0, x22, #0x8 +0x318 lsl x2, x24, #3 +0x31c mov x1, x25 +0x320 bl "DYLD-STUB$$memcpy" +0x324 mov w0, #0x10 +0x328 mov x1, #0x3c70 +0x32c movk x1, #0xaff9, lsl #16 +0x330 movk x1, #0x80, lsl #32 +0x334 movk x1, #0xa, lsl #48 +0x338 bl "0x1a255c690" +0x33c adrp x8, 403725 ; 0x6290d000 +0x340 ldr x9, [x8, #0xdf8] +0x344 stp x9, x27, [x0] +0x348 str x0, [x8, #0xdf8] +0x34c adrp x8, 403725 ; 0x6290d000 +0x350 add x8, x8, #0xde0 +0x354 stlr x22, [x8] +0x358 add x8, x22, x24, lsl #3 +0x35c ldp x10, x22, [sp, #0x8] +0x360 mov x9, x22 +0x364 bfi x9, x21, #32, #32 +0x368 str x9, [x8, #0x8] +0x36c stlr w10, [x20] +0x370 and x8, x26, #0xffffffff +0x374 and w16, w23, #0x3 +0x378 ldp x26, x25, [sp, #0x18] +0x37c cmp x16, #0x3 +0x380 csel x16, x16, xzr, ls +0x384 adrp x17, 0 ; 0x0 +0x388 add x17, x17, #0x6cc +0x38c ldrsw x16, [x17, x16, lsl #2] +0x390 adr x17, #0x0 +0x394 add x16, x17, x16 +0x398 br x16 +0x39c lsl x8, x8, #2 +0x3a0 lsl x8, x10, x8 +0x3a4 orr x8, x8, x23 +0x3a8 adrp x9, 403725 ; 0x6290d000 +0x3ac add x9, x9, #0xde8 +0x3b0 stlr x8, [x9] +0x3b4 b "_swift_allocObject_+0x3fc" +0x3b8 and x9, x23, #0xfffffffffffffffc +0x3bc tst x23, #0x3 +0x3c0 csel x9, xzr, x9, eq +0x3c4 add x8, x9, x8 +0x3c8 stlrb w10, [x8] +0x3cc b "_swift_allocObject_+0x3fc" +0x3d0 and x9, x23, #0xfffffffffffffffc +0x3d4 tst x23, #0x3 +0x3d8 csel x9, xzr, x9, eq +0x3dc add x8, x9, x8, lsl #1 +0x3e0 stlrh w10, [x8] +0x3e4 b "_swift_allocObject_+0x3fc" +0x3e8 and x9, x23, #0xfffffffffffffffc +0x3ec tst x23, #0x3 +0x3f0 csel x9, xzr, x9, eq +0x3f4 add x8, x9, x8, lsl #2 +0x3f8 stlr w10, [x8] +0x3fc dmb ish +0x400 adrp x8, 403725 ; 0x6290d000 +0x404 ldr w8, [x8, #0xdd8] +0x408 cbnz w8, "_swift_allocObject_+0x438" +0x40c adrp x8, 403725 ; 0x6290d000 +0x410 ldr x23, [x8, #0xdf8] +0x414 cbz x23, "_swift_allocObject_+0x430" +0x418 ldp x20, x0, [x23] +0x41c bl "DYLD-STUB$$free" +0x420 mov x0, x23 +0x424 bl "DYLD-STUB$$free" +0x428 mov x23, x20 +0x42c cbnz x20, "_swift_allocObject_+0x418" +0x430 adrp x8, 403725 ; 0x6290d000 +0x434 str xzr, [x8, #0xdf8] +0x438 adrp x0, 403725 ; 0x6290d000 +0x43c add x0, x0, #0xdf0 +0x440 bl "0x1a255c9f0" +0x444 bfi x22, x21, #32, #32 +0x448 mov x0, x26 +0x44c mov x1, x25 +0x450 mov x2, x22 +0x454 bl "swift::swift_slowAllocTyped(unsigned long, unsigned long, unsigned long long)" +0x458 cbz x19, "_swift_allocObject_+0x470" +0x45c mov x16, x0 +0x460 movk x16, #0x6ae1, lsl #48 +0x464 mov x17, x19 +0x468 pacda x17, x16 +0x46c b "_swift_allocObject_+0x474" +0x470 mov x17, #0x0 +0x474 mov w8, #0x3 +0x478 stp x17, x8, [x0] +0x47c ldp x29, x30, [sp, #0x80] +0x480 ldp x20, x19, [sp, #0x70] +0x484 ldp x22, x21, [sp, #0x60] +0x488 ldp x24, x23, [sp, #0x50] +0x48c ldp x26, x25, [sp, #0x40] +0x490 ldp x28, x27, [sp, #0x30] +0x494 add sp, sp, #0x90 +0x498 retab +0x49c bl "_swift_allocObject_.cold.1"
Posted Last updated
.
Post marked as solved
2 Replies
127 Views
This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSBluetoothAlwaysUsageDescription key with a string value explaining to the user how the app uses this data. I don't know how to add these permissions when i can't find plist files. It is not when any tutorial or document says it is
Posted Last updated
.
Post not yet marked as solved
0 Replies
123 Views
I've encountered a strange issue reading characteristics from a BLE device using CoreBluetooth ONLY ON iPHONE 12 AND iPHONE 12 PRO. The problem is that the BLE device receives a read characteristic request for an errored characteristic id. The BLE Device is using blue kitchen btstack (https://github.com/bluekitchen/btstack). We also filed a bug report on their side here Say i ask for a characteristic discovered with CBUUID "F97A6DA4-B3AA-44B0-8DE7-40D238BE5E02", the device receives a request for a "F97A6DA4-B3AA-44B0-8DE7-40D238BE5E09" id. The exact same swift code is working perfectly on MacOS, reading the right characteristic on the device. I is also perfectly fine, tested on various iOS versions on iPhone 8, SE (1st gen), 11, 13, 15. The only devices affected are the 12 & 12 Pro. I also tried using popular apps like light blue, or nRF Connect for iOS, and the iOS app has the same behavior on iPhone 12 & 12 Pro (that is wrong), but is ok on other iPhone devices. Has anyone encountered such a strange behavior and have any insight on how to solve that ?
Posted
by aactimage.
Last updated
.
Post not yet marked as solved
0 Replies
108 Views
Dear Apple support, We are working on one of the projects related to BLE, in which our BLE device is acting as a GATT client and our iPhone device (iPhone 13, OS17.3) is acting as a GATT server. Issue being faced: Whenever my BLE device subscribes to the ANCS notifications, and the moment the IOS device starts bombarding with the notifications available in notification center, the BLE device controller's heap memory becomes UNAVAILABLE in runtime for this notifications' queue and eventually making the BLE controller to reset. Thereafter, whenever user tries making a new connection session of BLE, again same thing repeats. Notifications allowed in BLE display : W-SMS, W-CALL, SMS, CALL, none other than this. Issue observed with : IF and ONLY 150 notifications and above available in notification center, otherwise our product works fine with iPhone with less number of notifications. We would like to know how we can curb the number of PRE-EXISTING type notifications available in the notification center flowing towards the BLE device? What best solution can be done at the IOS side, we also have IOS APP team for this project. What kind of APIs does Core Bluetooth framework can provide to the IOS developer in order to overcome this issue. Please suggest possible ways from the IPHONE device only to overcome this. BLE's software CANNOT BE CHANGED under any circumstances as the product is already in production and complaints are coming from end user (from the field). OUR GOAL : ONLY notifications which will be available in run time, i.e. AFTER SUCCESSFUL BLE connection established to be displayed in the BLE's display. We DON'T WANT older notifications to be displayed and flow towards BLE over ANCS. WE MUST make 'notification popup' option as ALLOW to be shared with our BLE device, otherwise SMS,CALL, W-SMS,W-CALL during live connection will not come on the BLE 's display.
Posted
by MM_GGN.
Last updated
.
Post not yet marked as solved
2 Replies
126 Views
I would like to know, do we have any support from iOS in order to turn on wifi and bluetooth using internal apis on tap of a button in my IOS App, I am struggling to find information over this, more precisely , I want to turn on wifi from my custom widget in I phone, is it possible then please share info.
Posted
by gmantrao.
Last updated
.
Post not yet marked as solved
0 Replies
113 Views
"When an iBeacon is received, a BLE scan API is called within didEnterRegion. However, if executed while the screen is off, Core Bluetooth's didDiscover does not function. Yet, if the screen is turned on once and then turned off again, didDiscover functions. Is there a way to make Core Bluetooth's didDiscover work while the screen is off?" Let me know if you need further assistance or clarification! func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) { if let beaconRegion = region as? CLBeaconRegion { startRanging(in: beaconRegion) } } func startRanging(in beaconRegion: CLBeaconRegion) { // バックグラウンドタスクを開始 bgTask = UIApplication.shared.beginBackgroundTask(expirationHandler: { [self] in print("バックグラウンドタスクの有効期限が切れ") // バックグラウンドタスクの有効期限が切れたときに、バックグラウンドタスクを終了 self.lm!.stopRangingBeacons(satisfying: beaconRegion.beaconIdentityConstraint) UIApplication.shared.endBackgroundTask(bgTask) // バックグラウンドタスクの識別子を無効 bgTask = .invalid }) // レンジング開始 self.lm!.startRangingBeacons(satisfying: beaconRegion.beaconIdentityConstraint) //サービス指定してCoreBluetoothを起動 self.centralManager.stopScan() self.centralManager.scanForPeripherals(withServices: [self.kServiceUUID], options: nil) // バックグラウンドタスク終了 let time = UIApplication.shared.backgroundTimeRemaining - 1.0 DispatchQueue.main.asyncAfter(deadline: .now() + time) { self.stopRanging(in: beaconRegion) } } func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) { print("---- didDiscover ----") print("peripheral-->\(peripheral)") print("advertisementData-->\(advertisementData)") print("rssi-->\(RSSI)") print("---------------------") }
Posted
by tgrgenki.
Last updated
.
Post not yet marked as solved
0 Replies
183 Views
When I connect a speed and cadence sensor to my Apple Watch in Bluetooth settings I expect to see the following HKQuantity types in workoutBuilder:(HKLiveWorkoutBuilder *)workoutBuilder didCollectDataOfTypes HKQuantityTypeIdentifierCyclingSpeed, HKQuantityTypeIdentifierDistanceCycling, and HKQuantityTypeIdentifierCyclingCadence. However, after starting an HKWorkoutSession I only get updates for HKQuantityTypeIdentifierDistanceCycling. I know that these metrics are being updated because the Apple Workout app displays them. I have authorized my app to read and write these quantity types, so what could I be missing here? Are these quantities only available to the workout app, as I haven't found a third-party app that sees these metrics when the sensors are connected this way?
Posted Last updated
.
Post not yet marked as solved
0 Replies
129 Views
We are having an issue with BLE peripheral devices it is not connecting to the device when we kill the app and try to get connected devices on app start it always returns empty. we are calling this function to get connected devices BleManager.getConnectedPeripherals This is working fine on iOS 16 but on iOS we are having issue we are using this library for BLE communication: react-native-ble-manager Devices: iPhone XR, iPhone 11 OS: 17 React Native: 0.71.11
Posted Last updated
.
Post not yet marked as solved
0 Replies
118 Views
Hi, we have an app which emits an iBeacon, this works correctly except when the app goes in background. Is there any way to avoid this behaviour, maybe under some conditions (for example when we are inside a region created with another iBeacon?). Also we need to emit another advertisement (of type iBeacon or CBAdvertisementDataServiceUUIDsKey, since we cannot write into CBAdvertisementDataManufacturerDataKey) but separated from this first one, that is 2 advertisements in parallel, so the listeners will receive 2 different packets. After some test I see that only the 1st iBeacon is emitted. Any ideas? Thanks in advance
Posted
by gmurari.
Last updated
.
Post marked as solved
1 Replies
196 Views
Hello, whenever I want to add a CBMutableDescriptor, either with CBMutableDescriptor(type: CBUUID(string: "2901"), value: nil) or using the defined string CBUUIDCharacteristicUserDescriptionString: I get the following error message: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Expecting NSData value type for Format descriptor' What am I doing wrong here? Thanks
Posted
by clemhousa.
Last updated
.
Post not yet marked as solved
1 Replies
207 Views
Since the Multipeer Connectivity framework no longer supports Bluetooth. (https://developer.apple.com/forums/thread/749346) Why does its official documentation still mention "In iOS, the framework uses infrastructure Wi-Fi networks, peer-to-peer Wi-Fi, and Bluetooth personal area networks for the underlying transport." ?(https://developer.apple.com/documentation/multipeerconnectivity) What is the purpose of using Bluetooth personal area networks for the underlying transport?
Posted Last updated
.
Post not yet marked as solved
1 Replies
252 Views
Hello, In this inquiry(https://developer.apple.com/forums/thread/747860), I came across this conclusion. “Apple disabled TCP/IP networking over Bluetooth completely. Apple’s peer-to-peer networking APIs now run exclusively over Wi-Fi." I have three questions I would like to ask. The Multipeer Connectivity Framework supports Wi-Fi networks, peer-to-peer Wi-Fi, and Bluetooth personal area networks. Since the framework abstracts away the underlying protocols, we cannot specify which protocol to choose. Can this framework still establish a pure Bluetooth connection now? (Not just using Bluetooth for the discovery phase). Given that the framework supports Bluetooth protocols, why does it not require Bluetooth permissions but only local network permissions? Does the Bluetooth protocol supported by the framework have the capability to discover traditional Bluetooth devices and services that the Core Bluetooth framework can discover?
Posted Last updated
.
Post not yet marked as solved
0 Replies
199 Views
hi I recently developed an iOS APP which will advertise in background, as I checked the developer document, device name and service uuid will be ignored when iOS APP goes to background. But I found an APP named Berkanan which can broadcast in backgound with device name and service uuid, and its device name length exceeds 8 bytes, does anyone know how it implements? thanks!
Posted
by Pandak.
Last updated
.
Post not yet marked as solved
1 Replies
153 Views
I'm trying an iAP2 connection (SPP open) with Bluetooth module and Apple product. But I don't know the iAP2 UUID for sure. Can someone tell me? And I'd like to know if MFi Program is required for iAP2 connection. I'd appreciate it if you could let me know the detailed procedure for iAP2 connection.
Posted
by dlehdyd.
Last updated
.
Post not yet marked as solved
0 Replies
167 Views
A device running with the following lines of code can receive a message from a peripheral. In this manner, though, I can only receive messages from one peripheral since the service and characteristic IDs are hardcoded in CentralViewModel.swift. So my question is how I can observe messages from multiple peripherals. Thanks. import SwiftUI struct ContentView: View { var body: some View { NavigationStack { VStack { NavigationLink(destination: CentralView()) { Text("Central") } .buttonStyle(.borderedProminent) .padding() } } } } // CentralView.swift // import SwiftUI struct CentralView: View { @StateObject var central: CentralViewModel = CentralViewModel() var body: some View { Text(central.message) .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading) .padding(20) .onDisappear { central.stopAction() } } } // CentralViewModel.swift // import Foundation import CoreBluetooth class CentralViewModel: NSObject, ObservableObject { @Published var message: String = "" var serviceUUID: CBUUID! var characteristicUUID: CBUUID! var centralManager: CBCentralManager! var discoveredPeripheral: CBPeripheral? var transferCharacteristic: CBCharacteristic? var writeIterationsComplete = 0 //var connectionIterationsComplete = 0 let defaultIterations = 5 var data: Data = Data() override init() { super.init() self.serviceUUID = CBUUID(string: "994F8A12-FE8E-4CCB-BD7B-1AE989A32853") self.characteristicUUID = CBUUID(string: "F4BD0CA2-7581-40E2-A517-1CE275A3A749") centralManager = CBCentralManager(delegate: self, queue: nil, options: [CBCentralManagerOptionShowPowerAlertKey: true]) } func stopAction() { centralManager.stopScan() } private func cleanup() { guard let discoveredPeripheral = discoveredPeripheral, case .connected = discoveredPeripheral.state else { return } for service in (discoveredPeripheral.services ?? [] as [CBService]) { for characteristic in (service.characteristics ?? [] as [CBCharacteristic]) { if characteristic.uuid == characteristicUUID && characteristic.isNotifying { self.discoveredPeripheral?.setNotifyValue(false, for: characteristic) } } } centralManager.cancelPeripheralConnection(discoveredPeripheral) } private func writeData() { guard let discoveredPeripheral = discoveredPeripheral, let transferCharacteristic = transferCharacteristic else { return } while writeIterationsComplete < defaultIterations && discoveredPeripheral.canSendWriteWithoutResponse { writeIterationsComplete += 1 } if writeIterationsComplete == defaultIterations { discoveredPeripheral.setNotifyValue(false, for: transferCharacteristic) } } } extension CentralViewModel: CBCentralManagerDelegate { func centralManagerDidUpdateState(_ central: CBCentralManager) { switch central.state { case .poweredOn: print("Power on") startScanningForPeripherals() return case .poweredOff : print("Power off") return case .resetting: print("Resetting") return case .unauthorized: print("Unauthorized") return case .unknown: print("Unknown") return case .unsupported: print("Unsupported") return @unknown default: print("An unknown central manager state has occurred") return } } func startScanningForPeripherals() { self.centralManager.scanForPeripherals(withServices: [self.serviceUUID], options: nil) } func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) { guard RSSI.intValue >= -50 else { return } if discoveredPeripheral != peripheral { print("Peripheral discovered") discoveredPeripheral = peripheral centralManager.connect(peripheral, options: nil) } } func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) { peripheral.delegate = self peripheral.discoverServices([serviceUUID]) print("Service discovered") } } extension CentralViewModel: CBPeripheralDelegate { func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) { if error != nil { cleanup() return } guard let peripheralServices = peripheral.services else { return } for service in peripheralServices { peripheral.discoverCharacteristics([characteristicUUID], for: service) } } func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) { if let error = error { print("Error discovering characteristics: \(error.localizedDescription)") cleanup() return } guard let serviceCharacteristics = service.characteristics else { return } for characteristic in serviceCharacteristics where characteristic.uuid == characteristicUUID { transferCharacteristic = characteristic peripheral.setNotifyValue(true, for: characteristic) } } func peripheral(_ peripheral: CBPeripheral, didUpdateNotificationStateFor characteristic: CBCharacteristic, error: Error?) { if let error = error { print("Error changing notification state: \(error.localizedDescription)") return } guard characteristic.uuid == characteristicUUID else { return } if characteristic.isNotifying { print("Notification began on \(characteristic)") } else { print("Notification stopped on \(characteristic). Disconnecting") cleanup() } } func peripheralIsReady(toSendWriteWithoutResponse peripheral: CBPeripheral) { print("Peripheral is ready to send data to YOU!") } func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) { if let error = error { print("Error discovering characteristics: \(error.localizedDescription)") cleanup() return } guard let characteristicData = characteristic.value, let stringFromData = String(data: characteristicData, encoding: .utf8) else { return } print("Received \(characteristicData.count) bytes: \(stringFromData)") if stringFromData == "EOM" { message = String(data: data, encoding: .utf8) ?? "" writeData() } else { data.append(characteristicData) } } }
Posted
by Tomato.
Last updated
.
Post not yet marked as solved
0 Replies
116 Views
Multiple CBPeripheralManager startAdvertising broadcast CBCentralManager can search the first CBPeripheralManager broadcast but CBCentralManager can search the second CBPeripheralManager broadcast . first CBPeripheralManager broadcast is still not stop .
Posted
by zhw0421.
Last updated
.