iPhone corebluetooth中央管理器将数据发送到外设 [英] iPhone corebluetooth central Manager send data to peripheral

查看:120
本文介绍了iPhone corebluetooth中央管理器将数据发送到外设的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将数据从iPhone发送到蓝牙设备,然后发现并连接。
我指的是这个教程连接。

I want to send data from iPhone to a bluetooth device which get discovered and connects. I am referring this tutorial to connect.

我无法将数据发送到与外部附件框架连接的外部蓝牙设备。

I am not able to send data to external bluetooth device which is connected as we do with External Accessory framework.

我正在使用iPhone5,因为它有蓝牙4.0

I am using iPhone5 as it has Bluetooth 4.0

推荐答案

在核心蓝牙中,您需要使用这些特性进行通信。在外部附件框架中没有基于标准流的API,我不知道任何实现类似内容的开源库。

In Core Bluetooth you need to use the characteristics for communication. There is no standard stream based API like in the External Accessory Framework and I don't know of any open source libraries that implement something like that.

基本操作

外设 - >中央:


  1. Central订阅特征(带有通知或指示)

  2. 外围设备接收订阅的回调,因此知道中央正在侦听

  3. 外围更新特征

  4. Central收到特征更新通知

  1. Central subscribes to characteristic (either with notifications or indications)
  2. Peripheral receives the subscribed callback so knows that the central is listening
  3. Peripheral updates characteristic
  4. Central receives characteristic updated notification

Central - > Peripheral:

Central -> Peripheral:


  1. 中央写入特征

  2. 外设接收写请求更新

您可以实现的实际速度取决于各种因素。有迹象表明数据永远不会丢失(如TCP),但通知没有这样的保证(如UDP)。

The actual speed you can achieve depends on various factors. With indications the data is never lost (like TCP) but notifications don't have such guarantees (like UDP).

更多信息

我建议您查看官方核心蓝牙编程指南,并专注于

I suggest you check out the official Core Bluetooth Programming Guide and concentrate on the

  • Performing common Central Role tasks
  • Performing common Peripheral Role tasks

部分。但更好的是按原样研究整个指南。有关工作示例,请查看Apple的 BTLE Transfer 示例。

sections. But better would be studying the whole guide as is. For a working example, check out the BTLE Transfer example from Apple, as well.

这篇关于iPhone corebluetooth中央管理器将数据发送到外设的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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