iOS Core蓝牙从设备获取所有功能描述 [英] iOS Core bluetooth get all features description from device

查看:122
本文介绍了iOS Core蓝牙从设备获取所有功能描述的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Core Bluetooth从我的设备中获取所有可用功能.

How to can I get all available features from my device using Core Bluetooth.

我认为在获取任何信息之前,我们需要通过低功耗蓝牙观察所有设备.

I figured that before get any information we need to observe all devices via low energy bluetooth.

因此第一步是通过CBCentralManager扫描所有外围设备scanForPeripheralsWithServices.在委托回调中:

So the first step is scan for all peripheral devices scanForPeripheralsWithServices via CBCentralManager. In the delegate callback:

- (void)centralManager:(CBCentralManager *)central
 didDiscoverPeripheral:(CBPeripheral *)peripheral
     advertisementData:(NSDictionary *)advertisementData
                  RSSI:(NSNumber *)RSSI 

我们可以保存外围设备标识符,并保存外围设备以供将来处理,例如更改某些特性,关闭/打开等.

we can save peripheral identifier and save peripheral to handle it in future like change some characteristics, switch off/on and etc.

但是我的问题是如何获得对此功能的描述,例如,我具有一些特征,但是我不知道如何使用.在哪里可以找到有关此未来的信息.

But my question how to get description of this function, for example I got some characteristic, but I don't know how to use. Where to find info about this future.

让我描述一下情况.例如,我的声音播放器具有一些选项,可以通过蓝牙处理音量.

Let me describe situation. For example I have sound player with some options where I can handle volume of sound via bluetooth.

因此,我需要先获取外围设备,然后检测服务,然后发现特征以找到卷属性",但是如何找到它,我应该如何理解在哪里可以找到此信息的最小/最大卷量.例如,我们可以传递0作为最小体积,传递1作为最大体积.但它也可以在0到1000或任何其他范围内.如何检测此信息?

So I need to get peripheral first, then detect service and then discover characteristic to find volume "property", but how can I find it, how should I understand which is min/max amount of volume where to find this information. For example we can pass 0 as min volume amount and 1 as a max. But it also could be in range from 0 to 1000 or any other. How to detect this information?

推荐答案

您不能确定找到每个特征的文档",例如可能的值等等.
如果服务与特性遵循蓝牙文档,并且本身就是文档",仅遵循文档,它是这里.从理论上讲,这些知名"服务和字符应具有UUID,例如"0x0000".
例如:电池服务为0x180F, 电池电量为0x2A19,可能值具有已定义的协议.

You can't be sure to find the "documentation" for each characteristics, like what are the possible values, etc.
If the Services & the Characteristics follow the documentation of Bluetooth, and are per se "documented", it just follow the doc, it's here. In theory, theses "well known" services and characters should have an UUID like "0x0000".
Example: Battery service is 0x180F, Battery Level is 0x2A19 and the possible values have a defined protocol.

对于其他自定义服务/特性,这更困难.每个人都有自己的文档,并且UUID更长(如果开发时遵循了规则). 如果已设置,则可以阅读 CBDescriptor 以获得更多信息.

For other custom services/characteristics, it's more difficult. Each one has their own documentation, and the UUID is longer (if it's developed respecting the rules). If set, you can read the CBDescriptor to get more info.

在所有情况下,您都必须参考低功耗蓝牙文档,或者是制造商自定义的文档.无论哪种方式,都与逆向强化有关.

In all case, you have to either refer to the Bluetooth Low Energy Documentation, or if it's custom to the manufacturer. Either wise, it's all about reverse-engeenering.

这篇关于iOS Core蓝牙从设备获取所有功能描述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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