ios Xcode 中的 iPhone 模拟器是否支持低功耗蓝牙?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10024608/
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
Does the iPhone simulator in Xcode support Bluetooth Low Energy?
提问by Etan
I'm trying some iOS test applications on the new Mac mini, that supports Bluetooth Low Energy. The CoreBluetoothframework is used in those. However, I'm not able to get Bluetooth working in the iPhone simulator, that is part of Xcode.
我正在新的 Mac mini 上尝试一些 iOS 测试应用程序,它支持低功耗蓝牙。该CoreBluetooth框架在那些使用。但是,我无法在 iPhone 模拟器中使用蓝牙,这是 Xcode 的一部分。
When I allocate a new CBCentralManager, centralManagerDidUpdateState: receives CBCentralManagerStatePoweredOff
which stands for Bluetooth is currently powered off.
当我分配一个新的CBCentralManager 时, centralManagerDidUpdateState: 接收CBCentralManagerStatePoweredOff
代表蓝牙当前已关闭。
The first time I ran the text application, a box was then opened up that looked pretty bugged (only language variables were used, not the actual texts) and with two buttons. The first led me to the settings panel where there was an option to enable Bluetooth. However, after I told it to enable Bluetooth, it just shows the spinning animation, and it won't either complete or cancel. Even after rebooting the Mac, there is still only the spinning animation. The box also does not open up anymore.
我第一次运行文本应用程序时,打开了一个看起来很糟糕的框(只使用了语言变量,而不是实际的文本)和两个按钮。第一个让我进入设置面板,那里有一个启用蓝牙的选项。但是,在我告诉它启用蓝牙后,它只显示旋转动画,不会完成或取消。即使在重新启动 Mac 后,仍然只有旋转动画。这个盒子也没有再打开。
Essentially, I think that the iPhone simulator should support Bluetooth Low Energy. Otherwise, it does not really make sense that there is an option in the settings application on the simulator. Also, the central manager state is CBCentralManagerStatePoweredOff
but not CBCentralManagerStateUnsupported
which would stand for The platform doesn't support Bluetooth Low Energy. This gives also hope that support could exist.
本质上,我认为 iPhone 模拟器应该支持低功耗蓝牙。否则,模拟器上的设置应用程序中有一个选项实际上没有意义。此外,中央管理器状态是CBCentralManagerStatePoweredOff
但不是CBCentralManagerStateUnsupported
代表平台不支持低功耗蓝牙。这也给希望支持可能存在。
- Does the iPhone simulator support Bluetooth Low Energy?
- If yes, how can I enable it?
- iPhone 模拟器是否支持低功耗蓝牙?
- 如果是的话,我怎么能允许吗?
采纳答案by chwi
The simulator does supportBluetooth Low Energy (4.0) according to this appnote from Apple. The only problem is that even if you have a computer with BLE inside, you will not be able to use the simulator together with it, because (I think) you occupy the availability on BLE for other devices to discover your computer, thereby restricting the functionality of the Mac.
根据 Apple 的这篇应用说明,模拟器确实支持低功耗蓝牙 (4.0)。唯一的问题是,即使您有一台内置 BLE 的计算机,您也无法将模拟器与它一起使用,因为(我认为)您占用了 BLE 上其他设备发现您的计算机的可用性,从而限制了Mac 的功能。
So if you go get yourself a BLE USB dongle you will be able to use it in simulator.
因此,如果您自己购买 BLE USB 加密狗,您将能够在模拟器中使用它。
EDIT: Adding information from @JoeShaw:
编辑:从@JoeShaw 添加信息:
Unfortunately it appears as though Core Bluetooth support has been dropped from the simulator for iOS 7. Reference: doubleencore.com/2013/09/whats-new-in-bluetooth-le-ios-7. In addition, the linked technote seems to have been removed.
不幸的是,iOS 7 模拟器似乎已经取消了对 Core Bluetooth 的支持。参考:doubleencore.com/2013/09/whats-new-in-bluetooth-le-ios-7。此外,链接的技术说明似乎已被删除。
回答by mezulu
I have been using the simulator to test BLE apps - but you need to be on OSX 10.7. As Wilhelmsen mentioned, you also need a BLE USB dongle. In addition, you need to set an NVRAM setting:
我一直在使用模拟器来测试 BLE 应用程序 - 但您需要使用 OSX 10.7。正如 Wilhelmsen 提到的,您还需要一个 BLE USB 加密狗。此外,您需要设置一个 NVRAM 设置:
$sudo nvram bluetoothHostControllerSwitchBehavior="never"
See this Technical Note from Apple for more details on using the simulator to test BLE apps: http://developer.apple.com/library/ios/#technotes/tn2295/_index.html
有关使用模拟器测试 BLE 应用程序的更多详细信息,请参阅 Apple 的此技术说明:http: //developer.apple.com/library/ios/#technotes/tn2295/_index.html
回答by Joe Shaw
According to http://www.doubleencore.com/2013/09/whats-new-in-bluetooth-le-ios-7/, Core Bluetooth support has been dropped from the simulator as of iOS 7. I haven't figured out why yet, but it means you will need to test on real hardware in the future.
根据http://www.doubleencore.com/2013/09/whats-new-in-bluetooth-le-ios-7/,从 iOS 7 开始,模拟器已经取消了对 Core Bluetooth 的支持。我还没有想到不知道为什么,但这意味着您将来需要在真实的硬件上进行测试。
It also appears as though Apple has removed Tech Note 2295, as I get redirected when I hit the URL.
看起来好像 Apple 已经删除了 Tech Note 2295,因为我在点击 URL 时被重定向。
回答by Etan
I've found that Apple writes in their own samplesthat the simulator cannot be used to test Core Bluetooth-based applications.
我发现 Apple 在他们自己的示例中写道,模拟器不能用于测试基于Core Bluetooth的应用程序。
Important: This project requires a Bluetooth LE Capable Device (Currently only the iPhone 4S) and will not work on the simulator.
重要提示:这个项目需要一个支持蓝牙 LE 的设备(目前只有 iPhone 4S)并且不能在模拟器上运行。
回答by kj13ennett
I've been working on a BLE app for the past week and can say with confidence that no, the simulator does not support BLE unless the mac that your using has BLE(Macbook Air) - but even then i'm not 100% sure how to enable this(most likely by just turing on BLE on your mac and on the simulator).
过去一周我一直在开发 BLE 应用程序,并且可以自信地说不,模拟器不支持 BLE,除非您使用的 mac 有 BLE(Macbook Air)——但即便如此,我也不是 100% 确定如何启用此功能(很可能只需在 Mac 和模拟器上启用 BLE)。
If you don't have a BLE enabled mac, have to find yourself a 4s to do testing with!
如果您没有启用 BLE 的 mac,则必须找到一个 4s 来进行测试!
回答by O.C.
Actually I tried in the simulator and does not work. The simulator does not recognize if you have a Bluetooth 4.0 in your computer but if you are using Command line tool projects in Xcode then it works. just for the cases you want to create something in Command line tool.
实际上我在模拟器中尝试过并且不起作用。模拟器无法识别您的计算机中是否有蓝牙 4.0,但如果您在 Xcode 中使用命令行工具项目,则它可以工作。仅适用于您想在命令行工具中创建某些内容的情况。