如何修复CBPeripheralManager的发送队列已满? [英] How to fix CBPeripheralManager's transmit queue is full?

查看:203
本文介绍了如何修复CBPeripheralManager的发送队列已满?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在CBPeripheralManager的方法上有问题.

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

根据Apple documentation,如果可以发送更新,它将返回YES;如果基础传输队列已满,则将返回NO.

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

我得到了NO.我该如何解决?

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

推荐答案

当输出队列已满时,您需要延迟发送响应.

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.

这篇关于如何修复CBPeripheralManager的发送队列已满?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆