多种新配网方式WIFI Easy connect(也叫Device Provisioning Protocol), 乐鑫统一配网(Provisioning),matter测试
DPP
WIFI Easy connect(也叫Device Provisioning Protocol)简称DPP,在idf的examples中有个dpp-enrollee目录就是示例。
乐鑫基本全系支持的。我在C3上试运行是可以的。会从串口打印出一个二维码。接下来就遇到问题了,据AI和乐鑫说,Android 10 以上都默认支持,可是我的手机是Android15(IQOO), 却找不到所说的扫码入口
官方文档
https://github.com/espressif/esp-idf/tree/fb14a3e7/examples/wifi/wifi_easy_connect/dpp-enrollee
To run the example with an Android 10+ device follow below steps -
Compile and flash the example on ESP device, a QR code will appear on your console.
Connect your phone to the network, say named "Example-AP".
Now go to Settings->WiFi & Internet->Wi-Fi->Example-AP->Advanced->Add Device.
Scan QR Code using the scanner, which will make ESP device connect to Example-AP.
然后就此事问了谷歌ai。谷歌说,确实DPP的推广不利,在iOS上根本不被支持。而且苹果不支持WiFi联盟的配网协议,包括上一代配网协议WPS是老传统了。
所以这个网最后也没配起来。
从手机端向设备端传出WiFi信号,走的是专用的一个配网的信道,设备端监听,由手机端发送过去。似乎在二维码中会填写频段和信道,以供手机端发送。
乐鑫的统一配网Provisioning
同样,我在C3上运行起来了,也是通过串口打印了二维码。
通过乐鑫官方的APP ESP BLE Prov也成功配网了。另一个APP ESP Soft AP Prov应该是给没有蓝牙的设备用的。
真的,这个操作略显蛋疼,就是本来通过BluFi已经可以扫描到周围的设备了。统一配网却还需要额外的信道,也就是打印出来二维码,通过摄像头去扫描来传输信息。这整个过程对于生产来说也是很麻烦的。
唯一的好处就是之前我做培训的时候遇到的配网的问题,多个学员同时去做配网的话。配网的话,会扫出来太多的设备,不知道哪个是自己的。不过这种的话也同样可以解决,如果统一配网和DPP可以打印二维码,那我也可以打印,甚至我只需要打印出来MAC地址的尾号就可以。
乐鑫统一配网的示例还不在idf默认的examples里面,而是在 idf-extra-components中, 位置:
https://github.com/espressif/idf-extra-components/tree/master/network_provisioning
所以还是不如BluFi好用。
matter
据某个AI说,matter也支持配网,所以想安装matter环境编译试一下。
然而esp-matter仅支持linux和macos, 我在WSL(Ubuntu 24.04)上安装测试,还要先装idf再装matter,安装matter到编译这一步的时候,就会导致wsl崩溃退出。
Done. Made 13083 targets from 819 files in 14765ms
ninja: Entering directory/home/a/esp/esp-matter/connectedhomeip/connectedhomeip/out/host' [0/49] c++ obj/examples/common/tracing/commandline.TracingCommandLineArgument.cpp.oTerminated a@J:~/esp/esp-matter$ ninja: build stopped: interrupted by user. 发现是ninja使用了所有CPU内核和内存导致系统卡死被系统杀进程了。每个ninja编译线程占用1个CPU和约1.5~2G内存。如果内存不足,需要限制CPU的核心数。否则几个ninja线程之间抢内存和swap虚拟内存,最后一个都没编译。 在用户目录下修改.wslconfig`, 增加:[wsl2] processors=2 memory=6GB就可以编译过了。
通过后又遇到ubuntu24不允许pip安装系统包的问题:Installing python dependencies for Matter
Installing requirements from requirements.txt
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.
See /usr/share/doc/python3.12/README.venv for more information.
google ai建议:
設定全域允許 pip 安裝(推薦)在終端機執行以下指令,為你的 Linux 用戶建立 pip 設定檔,允許覆蓋系統套件限制:
```bash
mkdir -p ~/.config/pip
echo -e "[global]\nbreak-system-packages = true" > ~/.config/pip/pip.conf
git repo: https://github.com/espressif/esp-matter
doc: https://docs.espressif.com/projects/esp-matter/en/latest/esp32/developing.html#host-setup
文档中确实示例了如何配网,并且演示了三种配网方式:
Use chip-tool in interactive mode to commission the device:
chip-tool interactive start pairing ble-wifi 0x7283 <ssid> <passphrase> 20202021 3840
In the above commands:
0x7283 is the randomly chosen node_id
20202021 is the setup_passcode
3840 is the discriminator
Above method commissions the device using setup passcode and discriminator. Device can also be commissioned using manual pairing code or QR code.
To Commission the device using manual pairing code 34970112332pairing code-wifi 0x7283 <ssid> <passphrase> 34970112332Above default manual pairing code contains following values:
Version: 0
Custom flow: 0 (STANDARD)
Discriminator: 3840
Passcode: 20202021
To commission the device using QR code MT:Y.K9042C00KA0648G00pairing code-wifi 0x7283 <ssid> <passphrase> MT:Y.K9042C00KA0648G00