iOS之蓝牙开发—何时触发(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)peripheral方法
2016-06-06 17:13
399 查看
经过整个下午的调试,总算清楚何时会触发 - (void)centralManager:(CBCentralManager
*)central didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError
*)error 方法。
当调用手机连接外设的方法: - (void)connectPeripheral:(CBPeripheral *)peripheral
options:(nullable NSDictionary<NSString *, id>
*)options;,作为中心设备的手机会和硬件之间建立连接,但是建立连接也是需要一定时间的,具体的时间是多少我并没有测算出来,肯定是很短暂的,但也不是微乎其微。
就在这短暂的时间内,如果调用手机和外设断开的代理方法: - (void)cancelPeripheralConnection:(CBPeripheral
*)peripheral; 那么就会进入连接失败的代理方法之中: - (void)centralManager:(CBCentralManager *)central
didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error;
/*!
* @method centralManager:didFailToConnectPeripheral:error:
*
* @param central The central manager providing this information.
* @param peripheral The <code>CBPeripheral</code> that has failed to connect.
* @param error The cause of the failure.
*
* @discussion This method is invoked when a connection initiated by {@link connectPeripheral:options:} has failed to complete. As connection attempts do not
* timeout, the failure of a connection is atypical and usually indicative of a transient issue.
*
*/
苹果官方给出的解释是由{@link connectPeripheral:options:}发起的连接没有完成,就会调用。
*)central didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError
*)error 方法。
当调用手机连接外设的方法: - (void)connectPeripheral:(CBPeripheral *)peripheral
options:(nullable NSDictionary<NSString *, id>
*)options;,作为中心设备的手机会和硬件之间建立连接,但是建立连接也是需要一定时间的,具体的时间是多少我并没有测算出来,肯定是很短暂的,但也不是微乎其微。
就在这短暂的时间内,如果调用手机和外设断开的代理方法: - (void)cancelPeripheralConnection:(CBPeripheral
*)peripheral; 那么就会进入连接失败的代理方法之中: - (void)centralManager:(CBCentralManager *)central
didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error;
/*!
* @method centralManager:didFailToConnectPeripheral:error:
*
* @param central The central manager providing this information.
* @param peripheral The <code>CBPeripheral</code> that has failed to connect.
* @param error The cause of the failure.
*
* @discussion This method is invoked when a connection initiated by {@link connectPeripheral:options:} has failed to complete. As connection attempts do not
* timeout, the failure of a connection is atypical and usually indicative of a transient issue.
*
*/
苹果官方给出的解释是由{@link connectPeripheral:options:}发起的连接没有完成,就会调用。
相关文章推荐
- hdu 1023 Train Problem II
- 比Android更深远的改变世界——谷歌开源人工智能系统TensorFlow文档中文版
- CF Gym 100685E Epic Fail of a Genie
- Rails中destroy_all和delete_all的差别
- http://www.hainiaowo.com/ask/detail-8974-1
- 动态更改屏幕方向的简单例子(LANDSCAPE与PORTRAIT)
- Andoid自动判断输入是电话,网址或者Email的方法----Linkify的应用!
- 关于Notificaiton的比较全面的
- CF 675E Trains and Statistic(线段树 + Dp)
- Magento Service Temporarily Unavailable报错解决办法
- Xcode7 does not contain bitcode. 的错误
- leetcode 219. Contains Duplicate II
- Arun Jaitley:要健康最好让银行保持增长势头
- Mysql错误:1396 (HY000): Operation CREATE USER failed for 'XXX'
- 关于使用由CA机构(EJBCA)颁发的证书实现SLLSocket双向认证服务端报null cert chain的解决方案
- WaitHandle.WaitOne 方法 ()
- AIDL的简单Demo
- AI:忧郁的机器人
- LeetCode-70.Climbing Stairs
- details——内容可伸缩的标签