- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有一个启用了蓝牙的 [嵌入式] Linux 设备,我想通过蓝牙将它的内部网络(未连接到互联网)共享到 Android 设备(尝试过 Android 6.x 和现在的 7.1.2 - Lineage OS [根])。该设置已经适用于 Linux 或 Windows 客户端。我通读了大量的帖子和文档,但我就是无法让它在 Android 设备上运行:
我的 Linux 设备:dnsmasq 作为 DHPC 服务器,启用蓝牙并且“bt-pan”[1] 已启动并运行(桥接接口称为 bt-pan0
)。通过 Dbus-Events,我自动“信任”任何新连接的设备。设备类(如果重要的话)使用 hciconfig 配置为 0x020000。
在我的 Android 手机上,我与我的 Linux 设备(热点)配对(自动运行)并连接(使用“互联网访问”)。在 dnsmasq 日志中,我看到连接的设备正确获取了 IP 地址。
从 linux-box 我可以在发布的 IP 地址上 ping 手机,我看到一个新的 bnep0
设备被创建并添加到 bt-pan0
网桥.
当我通过 adb shell
连接到我的手机时,我还看到正在使用我的 dnsmasq 提供的正确 IP/网络掩码设置创建一个 bt-pan
设备。不幸的是,当启用 Wifi 或移动数据时 - 我无法通过它的 IP 地址 ping linux-box。禁用 Wifi 和移动数据时 - 设置工作正常。这是我通过 adb shell
执行的一些命令的输出 - 如果需要更多输出,我会尽快提供(移动数据 IP 地址在粘贴时由我修改):
# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.10.0 * 255.255.255.0 U 0 0 0 bt-pan
123.456.78.16 * 255.255.255.252 U 0 0 0 rmnet_data0
# ip route get 192.168.10.5
192.168.10.5 via 123.456.78.18 dev rmnet_data0 src 123.456.78.17 uid 0
cache
# ip rule show
0: from all lookup local
10000: from all fwmark 0xc0000/0xd0000 lookup legacy_system
10500: from all oif dummy0 uidrange 0-0 lookup dummy0
10500: from all oif rmnet_data0 uidrange 0-0 lookup rmnet_data0
10500: from all oif bt-pan uidrange 0-0 lookup bt-pan
13000: from all fwmark 0x10063/0x1ffff lookup local_network
13000: from all fwmark 0x100b9/0x1ffff lookup rmnet_data0
13000: from all fwmark 0x100ba/0x1ffff lookup bt-pan
14000: from all oif dummy0 lookup dummy0
14000: from all oif rmnet_data0 lookup rmnet_data0
14000: from all oif bt-pan lookup bt-pan
15000: from all fwmark 0x0/0x10000 lookup legacy_system
16000: from all fwmark 0x0/0x10000 lookup legacy_network
17000: from all fwmark 0x0/0x10000 lookup local_network
19000: from all fwmark 0xb9/0x1ffff lookup rmnet_data0
19000: from all fwmark 0xba/0x1ffff lookup bt-pan
22000: from all fwmark 0x0/0xffff lookup rmnet_data0
23000: from all fwmark 0x0/0xffff uidrange 0-0 lookup main
32000: from all unreachable
在 bt-pan0
设备的 dnsmasq 配置中,我设置了一个空的 default-gw(dhcp-option 3)和一个正确的 DNS 服务器(dhcp-option 6)。我阅读了有关设置 dhcp 选项 121(无类静态路由)的信息,但这也不起作用(DHCP 请求不查询 121)...
如果有人知道发生了什么或知道为什么此设置会导致问题 - 我会很高兴最终弄清楚。
最佳答案
我一直不明白为什么路由不起作用。
幸运的是,我可以设置我正在使用的库 (Paho MQTT) 的 SocketFactory。因此 - 我使用 ConnectivityManager 查找蓝牙设备及其“网络”对象(提供“getSocketFactory”)以在 MQTT 中设置 SocketFactory。然后连接工作。
ConnectivityManager cm =(ConnectivityManager)ctx.getSystemService(CONNECTIVITY_SERVICE);
Networks[] nets = cm.getAllNetworks();
... 找到蓝牙设备并使用“getSocketFactory”。查找蓝牙设备
cm.getNetworkInfo(network);
有帮助
关于android - Linux 到 Android 蓝牙网络共享 (PAN),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48502036/
是否可以识别我周围启用了蓝牙的设备?我不需要与他们交流,只知道他们就在那里。 我正在寻找类似于 android 的 BluetouthDevice.startDiscovery() 的东西 这样的事情
蓝牙的 HTTP 代理服务是否允许我将 BLE 设备视为 HTTP 服务器,例如以便与设备对话的应用可以向其发送 GET/POST/PUT 请求? 或者这个操作是相反的方向,BLE 设备通过应用程序向
我正在与BlueZ库一起在Linux下管理蓝牙堆栈。我正在尝试打开一个套接字,该套接字应与已知UUID的特定服务连接。我已成功尝试按照以下示例在服务器和客户端之间打开套接字: http://peopl
有谁知道蓝牙设备如何获取范围内可发现设备的设备 ID? 理想情况下,我正在寻找涉及蓝牙协议(protocol)最小实现的最简单解决方案。 一个起点会很好,我只是想创建一个设备,它可以以最小的功耗存储附
蓝牙双模设备是否可以在与 BT LE 设备配对的同时被经典蓝牙发现?如果设备不能同时运行这两种模式也没关系,但我真的应该在这些模式之间切换芯片吗?我只是在 BT 4 Core 规范中找不到答案 最佳答
我目前正在开展一个涉及乐高 Mindstorms 套件的项目。砖 block 是 NXT,我对蓝牙 ping 速率很好奇。 我对其进行了 100 次 ping 测试,得到了一些有趣的结果。延迟似乎分为
我正在启动一个通过蓝牙进行无线 MIDI 连接的项目。据我所知,BT规范中没有定义MIDI配置文件。 我想知道你们中的一些人是否有兴趣分享有关通过 BT 使用 MIDI 的最佳方式的经验,特别是关于延
Closed. This question is off-topic。它当前不接受答案。
我想通过蓝牙将我的摩托罗拉机器人连接到 OBDKey。我以 BluetoothChat 为例连接蓝牙,使用 KWP 作为协议(protocol) 然后我写byte[]命令 command[0]=ra
几个月前,我用 C# 编写了一个 Messenger 程序,可以让许多客户端连接到服务器并进行聊天。 现在,我想为 android 编写相同的程序。在阅读了 Android Developers 中的
我目前正在制作一个与蓝牙相关的 Android 实用程序,我需要更改我的设备的设备发现范围.. 我有办法这样做吗?我目前正在考虑使用 TPL 来执行此操作,但我不太确定.. Android 应用程序或
我正在为两个玩家构建 tic tac,需要蓝牙连接来交换一些数据,我可以启用蓝牙,启用发现能力,但我不知道“BluetoothServerSocket”和客户端“BluetoothSocket”中的问
这个问题不太可能帮助任何 future 的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况相关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visi
我正在 Microsoft visual studio express 2012,C++ 中制作一个程序,以便与具有此 mac 地址的设备建立简单的蓝牙连接:“00:12:08:24:15:50”,
我正在为 python import bluetooth 使用蓝牙模块,我相信它是 PyBluez 包。我能够从 bluetooth.BluetoothSocket 类进行连接、发送和接收,但我的应用
我正在为 python import bluetooth 使用蓝牙模块,我相信它是 PyBluez 包。我能够从 bluetooth.BluetoothSocket 类进行连接、发送和接收,但我的应用
我尝试通过以下命令来做到这一点: ./configure -developer-build -opensource -nomake examples -nomake tests make module
我有一个服务,理论上可以在没有关联 Activity 的情况下工作(因为“服务”适用于 Android 平台)。 此服务使用蓝牙,特别是注册一个具有给定名称的蓝牙服务来监听通信。当然,它必须启用蓝牙才
谁知道是否可以制作一个应用程序通过蓝牙模拟触摸屏鼠标或触控板? 如何让 PC(或 MAC)知道我是鼠标设备? 问候, 胡安 最佳答案 您应该看看蓝牙 HID 规范。这可能是可能的,具体取决于您用来模拟
我的问题很简单。我想知道什么是我的应用程序的最佳实践,以便它可以“防打瞌睡”。随着 Android N 将在更多情况下应用 Doze,这变得更加相关。 阅读时Doze Documentation有一部
我是一名优秀的程序员,十分优秀!