【问题标题】:Turn on and off the Bluetooth connection on Mac在 Mac 上打开和关闭蓝牙连接
【发布时间】:2014-09-23 07:03:36
【问题描述】:

我是 mac 新手。我想问我如何以编程方式打开和关闭 Mac 上的蓝牙连接?任何人都可以建议任何简单的教程,任何链接。我搜索但力求得到结果。 在此先感谢

【问题讨论】:

标签: macos xcode6


【解决方案1】:

blueutil 是一个开源命令行 实用程序,用于控制 OSX 中的蓝牙 I/O。

$ blueutil status # Print bluetooth status
$ blueutil on # Switch bluetooth on
$ blueutil off # Switch bluetooth off

使用 Core Bluetooth 框架,您可以通过三种方式 重新连接到外围设备。你可以:

  • 使用retrievePeripheralsWithIdentifiers: 方法检索已知外围设备(您过去发现或连接的外围设备)的列表。如果您要查找的外围设备在列表中,请尝试连接它。
  • 使用retrieveConnectedPeripheralsWithServices: 方法检索当前连接到系统的外围设备列表。如果您要查找的外围设备在列表中,请将其本地连接到您的应用。
  • 使用 scanForPeripheralsWithServices:options: 方法扫描和发现外围设备。如果您找到它,请连接到它。

【讨论】:

  • 你能告诉一步一步的过程吗?
  • 命令现在是:blueutil -p 1 # on、blueutil -p 0 #off 和 blueutil # 仅用于状态。还有 blueutil --help
【解决方案2】:

我也遇到过这种情况,但解决起来要容易得多。

  1. 打开“蓝牙文件交换”
  2. 转到首选项
  3. 如果选择“发送文件”或“浏览”,请选择“无”

这应该要么自动关闭蓝牙,要么至少释放 UI 控件上的系统锁定/阻止。

【讨论】:

    猜你喜欢
    • 2011-08-09
    • 2023-03-28
    • 2020-06-17
    • 1970-01-01
    • 1970-01-01
    • 2023-03-30
    • 1970-01-01
    • 2011-01-26
    • 1970-01-01
    相关资源
    最近更新 更多