ios 制作一个可以连接另一个蓝牙设备的简单iphone应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11693703/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 19:28:37  来源:igfitidea点击:

Make a simple iphone app that can connect another bluetooth device

iphoneiosxcodebluetooth

提问by Clarence

I know some basic about iOS programming, now i want to connect my app to another non iphone device e.g. connecting to a bluetooth device that can control a light bulb on and off, or control any furnitures.

我知道一些关于 iOS 编程的基本知识,现在我想将我的应用程序连接到另一个非 iphone 设备,例如连接到可以控制灯泡开和关或控制任何家具的蓝牙设备。

My question is, besides iOS xcode, what kind of program i need to learn in order to achieve my goal?

我的问题是,除了 iOS xcode,我需要学习什么样的程序才能实现我的目标?

Is there any sources that i can learn from it?

有没有我可以从中学习的来源?

回答by Etan

For Bluetooth Low Energy devices, you can use the CoreBluetoothframework to access them.

对于低功耗蓝牙设备,您可以使用CoreBluetooth框架来访问它们。

For Classic Bluetooth devices or accessories that make use of the Dock connector, the protocols are not open, and joining the Made for iPhone (MFi) program is required. I do not suggest this for beginning.

对于使用 Dock 连接器的经典蓝牙设备或配件,协议未开放,并且需要加入 Made for iPhone (MFi) 计划。我不建议从这个开始。

My suggestion is to buy for example a Polar Heart Rate Belt that supports Bluetooth Low Energy. These use standard protocols. Sample codeis available from Apple that shows how to read out the heart rate from such a device.

我的建议是购买例如支持蓝牙低功耗的 Polar 心率带。这些使用标准协议。Apple 提供的示例代码显示了如何从此类设备读取心率。

As soon as you have mastered the heart rate monitor example, a next step would be to acquire a programmable Bluetooth Low Energy chip (however, often, the development tools for those are rather expensive!). Those chips can be programmed with custom profiles to listen for Bluetooth Low Energy connections and then performing defined operations (lighting a LED) when writes to characteristics occur. So, you are not limited to heart rate monitors and similar devices.

一旦您掌握了心率监测器示例,下一步就是获取可编程蓝牙低功耗芯片(但是,这些芯片的开发工具通常相当昂贵!)。这些芯片可以使用自定义配置文件进行编程,以侦听低功耗蓝牙连接,然后在写入特性时执行定义的操作(点亮 LED)。因此,您不仅限于心率监测器和类似设备。

Keywords that you can search for: GATT protocol, Bluetooth Low Energy, CoreBluetooth.

您可以搜索的关键字:GATT 协议、低功耗蓝牙、CoreBluetooth。

I know that it's a steep learning curve for beginners, but the area is pretty new. However, I can assure you that it's a fun area.

我知道对于初学者来说这是一个陡峭的学习曲线,但这个领域很新。但是,我可以向您保证,这是一个有趣的区域。

回答by chwi

I also think that you should look in to embedded C programming for the slave device (Heart Rate Monitor)

我还认为您应该查看从设备的嵌入式 C 编程(心率监视器)

回答by Don

You could get a tod Smart Beacon Development kit for ~$150 and then use BGScript to code the firmware to control the BLE device from your phone or pc. todhq.com for more info.

您可以花 150 美元左右购买一个智能信标开发套件,然后使用 BGScript 编写固件以从您的手机或 PC 控制 BLE 设备。todhq.com 了解更多信息。