[UWP] [C#] [IoT] [蓝牙LE] Raspberry Pi 3无法通过蓝牙LE和自定义GATT服务器互相发现 [英] [UWP] [C#] [IoT] [Bluetooth LE] Raspberry Pi 3's Can't Discover Each Other with Bluetooth LE and Custom GATT Server

查看:72
本文介绍了[UWP] [C#] [IoT] [蓝牙LE] Raspberry Pi 3无法通过蓝牙LE和自定义GATT服务器互相发现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

Hi everyone,

希望这是一个正确的论坛。我不确定这是一般的UWP蓝牙问题还是Raspberry Pi / IoT问题。或两者兼而有。

Hopefully this is the right forum to ask this. I wasn't sure if this was a general UWP Bluetooth question or a Raspberry Pi/IoT question. Or both.

我遇到的基本问题是我有两个运行Windows 10 IoT Core 17134的Raspberry Pi 3,它们都运行自定义GATT服务器,他们可以使用DeviceWatcher类扫描附近的BLE设备时,找不到对方。目标是
让他们互相看见,所以如果其中一个人通过BLE接收数据,那么它可以转身并将其传输到另一个。多跳场景。

The basic problem I have is that I have two Raspberry Pi 3's, both running Windows 10 IoT Core 17134, both running a custom GATT server, and they can't find each other when using the DeviceWatcher class to scan for nearby BLE devices. The goal is for them to see each other, so if one of them receives data over BLE then it can turn around and transmit it to the other one. A multi-hop scenario.

总体设置是这样的。我有一个桌面(x64)充当GATT客户端,通过BLE将一个字节块传输到具有前景UWP应用程序的Pi。两个Pi使用后台应用程序同时扮演GATT服务器和GATT客户端角色。他们
应该能够作为服务器接收数据,然后作为客户端重新传输数据。通过启动GATT服务器并宣传我的服务来启动物联网后台应用程序,然后它使用DeviceWatcher枚举和过滤附近的BLE设备以查找
其他服务器。

The overall setup is this. I have a desktop (x64) that is acting as a GATT client to transmit a blob of bytes over BLE to the Pi's with a foreground UWP app. The two Pi's play both a GATT server and GATT client role, using a background app. They should be able to both receive data as a server, then re-transmit the data as a client. The IoT background app starts up by starting the GATT server and advertising my services, then it uses a DeviceWatcher to enumerate and filter nearby BLE devices to find other servers.

一旦GATT服务器在Pi上运行,我的桌面就能够扫描并找到它们,然后成功地将数据单独传输到两者。但是,即使我运行

完全相同的代码
,它们在设备枚举阶段无法看到对方。他们可以看到桌面,奇怪的是,但不是彼此。桌面不是GATT服务器,所以我不在乎他们是否看到它。

Once the GATT server is running on the Pi's, my desktop is able to scan for and find them, then successfully transmit the data to both individually. But, even when I run the exact same code that the desktop uses on the Pi's, they can't see each other during the device enumeration phase. They can see the desktop, weirdly, but not each other. The desktop isn't a GATT server so I don't care if they see it or not.

 值得注意的是Pi的
可以
看到对方。所以,我不确定问题是否是一个操作顺序问题,一旦他们开始宣传GATT服务,他们就无法发现其他问题。但是
并没有解释为什么他们可以看到桌面而不是彼此。

 Of note is that the Pi's can see each other when my background app isn't running, just using the general Bluetooth menu. So, I'm not sure if the problem is an order of operations issue, where they can't discover others once they start advertising the GATT services. But that doesn't explain why they can see the desktop but not each other.

此外,我正在连接没有配对的设备。每次我的代码连接到另一个设备并通过BLE与它通信之后,我通过处理服务,处理BleDevice对象和强制垃圾收集来关闭连接。
一切正常,我可以快速连续重复连接/发送数据。所以,我认为问题不在于设备连接时无法发现。另外,在我开始传输数据之前,我会进行扫描,因此当我进行设备枚举时,没有人会将
连接到其他任何人。

Also, I'm connecting to devices without pairing. After every time my code connects to another device and talks to it over BLE, I close the connection by disposing of services, disposing of the BleDevice object, and forcing a garbage collection. This all works fine and I'm able to repeatedly connect/send data in rapid succession. So, I don't think the issue is that the devices can't be discovered while they're connected to. Plus, I do the scanning before I start transmitting data anyway, so no one should have a connection open to anyone else when I'm doing the device enumeration.

非常感谢任何帮助。我不确定我应该发布哪些代码部分,所以如果你想知道它在特定点上是如何工作的话我可以发帖。

Any help would be much appreciated. I wasn't sure what parts of the code I should post, so I can post snippets if you want to see how it's working at a particular point.

推荐答案

您好,

由于您的问题是针对IOT的,我已将其移至正确的论坛。

As your question is IOT specific, I've moved it to the right forum.

祝你好运,

Barry


这篇关于[UWP] [C#] [IoT] [蓝牙LE] Raspberry Pi 3无法通过蓝牙LE和自定义GATT服务器互相发现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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