如何使用核心蓝牙框架获取数据? [英] How to use core bluetooth framework get data?

查看:133
本文介绍了如何使用核心蓝牙框架获取数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发iOS核心蓝牙应用程序,我可以使用iphone4S连接蓝牙设备,但我不知道如何与设备通信。我想从设备中读取信息。

I am working on an iOS core Bluetooth application, i can connect the bluetooth device use iphone4S , but i dont know how to communication with the device. i want to read information form the device.

我也看到这个源代码 https://github.com/sergiomtzlosa/CoreBluetooth-Demo/

和本文如何从核心蓝牙设备读取信息

但我不明白如何传输数据。

but i dont understand how to transfer data.

有人可以帮助我吗?谢谢

can some one help me? thank you

推荐答案

要使用CoreBluetooth,首先您的设备必须支持蓝牙4.0中的蓝牙低功耗。您无法通过iOS的UI连接到设备,您必须为它开发自己的UI,因为您的应用程序只需要连接到您感兴趣的服务的设备。

To use CoreBluetooth, first your device must support Bluetooth Low Energy in Bluetooth 4.0. You can't connect to the device through iOS's UI for LE, you will have to develop your own UI for it because your application need to connect to only the devices with the services that you are interested in.

之后,您可以在更新特征值时订阅设备通知,然后使用CoreBluetooth API读取值。如果设备具有可写入的特性,那么您的应用程序可以使用CoreBluetooth API写入特征。

After that, you can subscribe to notification of the device when a characteristic value is updated, and then read the value using CoreBluetooth API. If the device has a characteristic that can be written to, then your application can write to the characteristic using CoreBluetooth API.

这是一般的想法,希望能回答您的问题。

That's the general idea, hope that answers your question.

编辑:看看这些样本:


  1. 心率监测器

  2. 温度传感器

  1. Heart Rate Monitor
  2. Temperature Sensor

这篇关于如何使用核心蓝牙框架获取数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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