I am learning Core Bluetooth to improve my general skills and marketability for new jobs. I have written a MacOS app that acts as a CBPeripheralManager and an iOS app that acts as a CBCentralManager. I have gotten the Peripheral to stream small data chunks to the Central just fine.Now I am looking to learn how to send larger data amounts. I have seen the sample code for sending data to subscribers in chunks and am in the process of porting that to Swift. But the CoreBluetooth docs also say: "Note: Use notifications to send a single packet of data to subscribed centrals. That is, when you update a subscribed central, you should send the entire updated value in a single notification, by calling the updateValue:forCharacteristic:onSubscribedCentrals: method only once. Depending on the size of your characteristic’s value, not all of the data may be transmitted by the notification. If this happens, the situation should be handled on the central side through a call to the readValueForCharacteristic: method of the CBPeripheral class, which can retrieve the entire value." https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/PerformingCommonPeripheralRoleTasks/PerformingCommonPeripheralRoleTasks.html#//apple_ref/doc/uid/TP40013257-CH4-SW1What I can't figure out is how to use `readValueForCharacteristic:` properly for a peridoically-updating characteristic. Is that possible, actually? I can't seem to subscribe to it to know when ot updates and then call `readValueForCharacteristic` as that endlessly tries to read the data but only gets the partial data. I tried sending an update notification from the Peripheral on one characteristic at the same time as I updated the data on a second characteristic. Then when the central gets the first characteristic update, it tries reading the second charcteristic but it gets `nil` for the value. But if I implement peripheralManager:didReceive readRequest:, and print the value of the characteristic, the Peripheral thinks it has data.I have also noticed that `readValueForCharacteristic:` also causes subscritptions to time out after 30 seconds or so, if I get this working do I need to resubscribe to services after doing it?Peripheral code is at https://github.com/natebirkholz/BluetoothTransmitter/tree/MultipleCharacteristicsCentral code is at https://github.com/natebirkholz/BluetoothTest/tree/MultipleCharacteristics
Post
Replies
Boosts
Views
Activity
I know how to initialize a UIImage with an SVG from the assets catalog, is there not a way to do it with an SVG downloaded from an API?
UIImage(data: ) fails. So does UIImage(contentsOfFile:)
Why only do this halfway?