为esp32天线获取信号量(蓝牙/ wifi双模) [英] acquire a semaphore for the esp32 antenna (bluetooth/wifi dualmode)

查看:175
本文介绍了为esp32天线获取信号量(蓝牙/ wifi双模)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个esp32应用程序,在该应用程序中我同时启用了蓝牙和wifi。

I am trying to build a esp32 application, where I have bluetooth and wifi enabled at the same time.

蓝牙与a2dp配置文件一起使用,其中esp是接收器。收到数据后,应通过UDP套接字发布该数据,以广播到网络。

Bluetooth is used with the a2dp profile, where the esp is a sink. After receiving the data, it should be published over a UDP socket as a broadcast to the network.

问题出在天线上。 bt和wifi都在共享它。 a2dp流似乎永久获取天线并很少释放它(〜2个包/分钟,我有〜3000个包/分钟)。

The problem is the antenna. Both bt and wifi are sharing it. The a2dp stream seems to permanently acquiring the antenna and releasing it very rarely (~2 packages/min, I have ~3000 packages/min).

所以我的问题是:是否存在某种信号量,可以完全控制天线来获取?这样我的套接字就能将数据发送到网络吗?

So my question: Is there some kind of semaphore, which can be acquired to have the full control over the antenna? So my socket would be able to send the data to the network?

我正在将esp32与freeRTOS一起使用。 freeRTOS库是用C编写的,但是我试图将所有内容都包装在C ++中。我仍然认为此问题与C库有关,因此我用C对其进行了标记。

I am using my esp32 with freeRTOS. The freeRTOS lib is written in C, but I am trying to wrap everything in C++. Still I think this problem is related to a C lib so I tag it with C.

我愿意接受任何有关如何构建该库的建议。

I am open for any suggestions how to build that. Thanks in advance.

更新

我正在使用 release / v3.3 来自官方 esp-idf 回购。

I am using release/v3.3 from the official esp-idf repo.

我有: CONFIG_SW_COEXIST_ENABLE = y CONFIG_SW_COEXIST_PREFERENCE_WIFI = y

我在配置中找不到 CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE

所提到的配置不起作用。

The mentioned configuration doesn't work.

我尝试阅读该帖子,但找不到任何内容我的lib中的 scan_window scan_interval 。据说它在 gap_api 中的某个位置,但是找不到。

I tried reading the post, but can't find any "scan_window" or "scan_interval" in my lib. It was written that it is somewhere in the gap_api but can't find it.

这是我的代码+配置: https://github.com/Dimfred/esp32_bt_streamer

Here is my code + config: https://github.com/Dimfred/esp32_bt_streamer

套接字客户端任务(应广播 a2dp_msg )从此处开始:
https://github.com/Dimfred/esp32_bt_streamer/blob/master/main/app/event_handler.cpp# L22

The socket client task, which should broadcast the a2dp_msg, is started here: https://github.com/Dimfred/esp32_bt_streamer/blob/master/main/app/event_handler.cpp#L22

从站点/访问点/蓝牙/ a2dp弹出的所有事件都被捕获在event_handler.hpp / cpp

All events popped from station/access point/bluetooth/a2dp are all caught in event_handler.hpp/cpp

推荐答案

如您所见,蓝牙在WIFI上具有更高的优先级。

As you saw, Bluetooth has higher priority on WIFI.

看看 CONFIG_SW_COEXIST_ENABLE 并确保已启用。您还需要配置 CONFIG_SW_COEXIST_PREFERENCE 连接到WIFI。请参阅页面上的其他标志,可以根据您的应用程序进行更新。

Have a look at CONFIG_SW_COEXIST_ENABLE and make sure it is enabled. You also need to configure CONFIG_SW_COEXIST_PREFERENCE to WIFI. Please see the page for additional flags that you could update depending on your application.

如果您想离开负责处理共存设备(BL和WIFI)的硬件),则可以禁用 CONFIG_SW_COEXIST_ENABLE 并减小扫描窗口并增加BL的扫描间隔,以留出时间让WIFI可以访问天线。有关更多详细信息,请参见此帖子

If you want to leave the hardware responsible for handling the co-existing devices (BL and WIFI), you can disable CONFIG_SW_COEXIST_ENABLE and reduce the scan window and increase the scan interval of the BL to leave time for WIFI to get access to the antenna. See this post for more details.

回答有关可能的信号/互斥量的原始问题。我怀疑是否有一个可供您使用的可访问性,而我将让API(软件)处理访问天线的共存模块。但是,一旦设置 CONFIG_SW_COEXIST_ENABLE (标志重命名为 CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE ),您始终可以检查代码在做什么。参见 https://github.com/espressif /esp-idf/blob/81ca1c01395f604972fbf141cfbe49764a746023/components/esp_wifi/src/phy_init.c

To answer your original question about a possible semaphore/mutex. I doubt there is one accessible for you to use and I would leave the API (software) handling the co-existing modules accessing the antenna. But you can always checkout what the code is doing once CONFIG_SW_COEXIST_ENABLE is set (the flag is renamed to CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE). See https://github.com/espressif/esp-idf/blob/81ca1c01395f604972fbf141cfbe49764a746023/components/esp_wifi/src/phy_init.c

这篇关于为esp32天线获取信号量(蓝牙/ wifi双模)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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