Posts

Post not yet marked as solved
1 Replies
871 Views
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
Posted Last updated
.
Post not yet marked as solved
6 Replies
729 Views
I am working with a device that is sending analog video to an iOS device in the YUY2 format, which is kCVPixelFormatType_422YpCbCr8_yuvs in Core Video. The video is sent via http one frame at a time. This signal is similar to another device I have implemented in the past which gets one frame at a time of MPEG video.What I have done historically is fill a (NS)Data object with each frame as it arrives and then render the frame from that Data object as a UIImage. This works great with MPEG but does not work with the YUY2 data.After doing a bit of research, I think I need to treat the data as a CVPixelBufferPool and render from that in this manner, but I don't know how to convert the Data to a CVPixelBufferPool. Of course, I could be barking up the wrong tree. I would greatly appreciate guidance on this matter, either converting Data to a CVPixelBufferPool or an alternative approach. Thanks in advance.
Posted Last updated
.