Posts

Post not yet marked as solved
0 Replies
98 Views
I'm trying to broadcast some customized data into the peripheral advertisingData package. Based on the WWDC 2019, and some posts Ios BLE extended Advertising example, seems like with iphone devices that support bluetooth 5.0, we can send up to 124 bytes. However Apple didn't say how to send extensive advertisement data (which key or API to use). And I tested with the CBAdvertisementDataLocalNameKey, seems like I can still ONLY send within 31 bytes. My code: @IBAction func switchChanged(_ sender: Any) { // All we advertise is our service's UUID. if advertisingSwitch.isOn { peripheralManager.startAdvertising([CBAdvertisementDataServiceUUIDsKey: [TransferService.serviceUUID], CBAdvertisementDataLocalNameKey: "1234567890asddsgsfhgfshfgshfsggdrfgdbfsbfgshgfshbfgb"]) } else { peripheralManager.stopAdvertising() } } And on the central side, my code: func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String: Any], rssi RSSI: NSNumber) { if let name = advertisementData[CBAdvertisementDataLocalNameKey] as? String { os_log("name:", String(name)) } } But I only got the first some bytes: name String "1234567890asddsgsfhgfshfgs" My question is, does apple really support Extended Advertising starting from iPhone 8? If so, how should I use it to send data up to 124 bytes?
Posted Last updated
.
Post not yet marked as solved
0 Replies
169 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
.