How to fix CBPeripheralManager's transmit queue is full?

╄→гoц情女王★ 提交于 2019-12-11 11:07:56

问题


I have a problem in CBPeripheralManager's method.

- (BOOL)updateValue:(NSData *)value forCharacteristic:(CBMutableCharacteristic *)characteristic onSubscribedCentrals:(NSArray *)centrals

According to Apple documentation, It will return YES if the update could be sent, or NO if the underlying transmit queue is full.

And I am getting NO. How should I fix this?


回答1:


When the output queue is full, you need to delay sending the response.

The worker queue scheme. The easiest way to solve this is by creating a worker queue where you insert the chunks of data you want to send and create a dispatcher block that takes the items and sends them out. When the queue is full, the current chunk is placed back on the head of the queue and after receiving the peripheralManagerIsReadyToUpdateSubscribers: you try to send again. If the central is disconnected or the connection is broken for some other reason, you should cancel all sending.



来源:https://stackoverflow.com/questions/23240447/how-to-fix-cbperipheralmanagers-transmit-queue-is-full

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!