扫描从C / C BLE装置++ [英] Scanning for BLE Devices from C/C++

查看:354
本文介绍了扫描从C / C BLE装置++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从<一个href=\"https://developer.apple.com/library/mac/documentation/DeviceDrivers/Conceptual/Bluetooth/BT_Bluetooth_On_MOSX/BT_Bluetooth_On_MOSX.html#//apple_ref/doc/uid/TP30000997-CH215-TPXREF107\"相对=nofollow>蓝牙设备访问指南,我读过蓝牙API应该accessable从C或C ++。我发现在IOBluetooth框架,涉及蓝牙,并包含结构来定义搜索creteria枚举和数据的一些C-头(IOBluetoothUserLib.h,Bluetooth.h),但我无法查找采取此类枚举或数据结构的任何功能作为参数。根据该文件,我将不得不创造一个CBCentralManager但我无法找到一个方法来从C或C ++这样做。

背景:我们使用OS / X作为BLE的开发刍议一个发展plattform启用微控制器。要在此微控制器我想写一个引导程序BLE更新固件,我想有一个命令行客户端来更新固件。所有code是用C ++编写,我会不喜欢学习objectiv-C这个小任务。

任何指针,文档,示例?

感谢您

托斯滕


解决方案

  

根据该文件,我将不得不创造一个CBCentralManager但我无法找到一个方法来从C或C ++这样做。


您参考的文档是经典蓝牙,为此,IOBluetooth框架有一些功能。 CBCentralManager是CoreBluetooth经理,这是蓝牙LE只。

有关经典蓝牙,你想要的经理是从由于IOKit框架的HID管理器,文档可以找到<一个href=\"https://developer.apple.com/library/mac/documentation/IOKit/Reference/IOHIDManager_header_reference/\"相对=nofollow>此处。如果你搜索周围,你会发现许多由于IOKit和IOHIDManager(<一个C ++的使用示例href=\"http://stackoverflow.com/questions/11887304/getting-mouse-events-from-hidmanager-in-osx-with-c\">1, <一href=\"http://stackoverflow.com/questions/7190852/using-iohidmanager-to-get-modifier-key-events\">2).

由于IOKit实际上可能给你你需要的所有功能,但IOBluetooth提供了一些蓝牙特定功能。从<一个href=\"https://developer.apple.com/library/mac/documentation/DeviceDrivers/Conceptual/Bluetooth/BT_Develop_BT_Apps/BT_Develop_BT_Apps.html#//apple_ref/doc/uid/TP30000997-CH216-TP9\"相对=nofollow>开发蓝牙应用的:


  

虽然你不需要使用蓝牙API访问HID类设备,您可以选择使用函数或方法从蓝牙框架,提升了用户的体验。例如,您的应用程序可以提供一个让用户知道,如果一个设备不支持特定的服务蓝牙特定的信息。


from the "Bluetooth Device Access Guide", I've read that the Bluetooth API should be accessable from C or from C++. I've found some C-headers (IOBluetoothUserLib.h, Bluetooth.h) in the IOBluetooth framework that are related to Bluetooth and contain enumerations and data structured to define search creteria but I fail to find any function that takes such enumeration or data structure as parameter. According to the documentation I would have to create a CBCentralManager but I fail to find a way to do so from C or C++.

Background: We use OS/X as a developing plattform for devlopment of BLE enabled microcontrollers. To update firmware on this microcontrollers I want to write a BLE bootloader and I want to have a commandline client to update the firmware. All of the code is written in C++ and I wouldn't like to learn objectiv-C for this small task.

Any pointers, documentation, examples?

thank you

Torsten

解决方案

According to the documentation I would have to create a CBCentralManager but I fail to find a way to do so from C or C++.

The documentation you refer to is for classic Bluetooth, for which the IOBluetooth framework has some functionality. CBCentralManager is the manager from CoreBluetooth, which is for Bluetooth LE only.

For classic Bluetooth, the manager you want is the HID Manager from the IOKit framework, documentation for which can be found here. If you search around, you'll find lots of examples of C++ usage of IOKit and IOHIDManager (1, 2).

IOKit may in fact give you all the functionality you need, but IOBluetooth supplies some Bluetooth specific features. From Developing Bluetooth Applications:

Although you don’t need to use the Bluetooth API to access a HID-class device, you may choose to use functions or methods from the Bluetooth framework to enhance the user’s experience. For example, your application can provide Bluetooth-specific information that lets the user know if a device doesn’t support a particular service.

这篇关于扫描从C / C BLE装置++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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