【XR806开发板试用】BLE试用之二:mesh&&PB-GATT配网
-
本文以 PB-GATT 方式对 Mesh 的配网场景进行演示说明。通过演示移动设备给 Mesh 节点配网场景,简要介绍 mesh 命令的基本使用方法。
对于XR806原生SDK用户,Mesh 命令集成在 cmd_mesh.c 文件中,烧录相应demo,通过 ble_demo 工程可以完成 mesh 节点配网场景演示,ble_demo 工程位于 XR806 SDK 的/project/demo/bluetooth/ble_demo 目录。具体可参考文档XR806_Mesh控制台命令_使用指南.pdf 。
对于XR806鸿蒙SDK用户,执行以下操作:
cd device/xradio/xr806/xr_skylark cp project/demo/wlan_ble_demo/gcc/deconfig .config make menuconfig
进入图像化配置界面,打开ble mesh的相关选项。
可以看到图形化配置界面:
在BLE host中可见配置:
进入mesh配置可见:
配置后保存退出。
继续执行
make build_clen make lib -j cd - hb build -f
可能遇到以下问题
问题1:可能会遇到空间不足报错的问题。
解决方案可以参考:
也可以取消
device\xradio\xr806\BUILD.gn
中其他内容的编译:
问题2:鸿蒙SDK没有BLE接口。
直接注释掉编译选项:
device/xradio/xr806/adapter/hals/BUILD.gn
编译完成后烧录镜像到开发板,通过串口打开命令行。
输入:
$ble init $mesh init
可见:
== XRadio BLE HOST V2.5.0 == [cmd] Mesh initialized [cmd] Use "pb-adv on" or "pb-gatt on" to enable advertising <ACK> 200 OK
选用 PB-GATT 的承载方式:
$mesh pb-gatt on
可见:
[bt] [INF] bt_mesh_prov_enable: Device UUID: 00000000-0000-0000-0000-00000000dddd [cmd] PB-GATT enabled <ACK> 200 OK $ ************************************************* [RandomAddress 57:F1:07:D8:B6:91 ]
同时需要手机提前下载安装nRF Mesh软件。
打开软件配网:
配网成功后,可以看到 nRF Mesh 网络列表看到该节点的信息,如下图。
点击红色方框,进入节点配置页面,可以看到节点的元素、模型等信息。
选择“Genenic On Off Server”模型进行操作:点击该模型选项,进入模型操作界面,如下图。进行模 型操作需要先进行“APP Key”绑定,点击“BIND KEY”,然后选择 App Key。
进行“Genenic On Off”:点击“ON”,就可以通过串口看到设备的 On/ Off 状态开了:
[cmd] onoff get(0) [cmd] onoff set(1) [cmd] onoff get(1) [cmd] onoff get(1) [cmd] onoff set(0) [cmd] onoff set(0)
说明:Genenic On Off 操作会先去获取 OnOff 状态,然后再配置,配置完成后再获取一次状态。
完整log如下:
target thread = main usage = 21, fragment = 0, maxFreeSize = 92740, totalFreeSize = 92740, waterLine = 26932 ==================================================================== Hello! OpenHarmony! System tag : OpenHarmony 1.1.2_LTS ==================================================================== target thread = pm usage = 23, fragment = 0, maxFreeSize = 90660, totalFreeSize = 90660, waterLine = 29012 use default flash chip mJedec 0x0 [FD I]: mode: 0x10, freq: 96000000Hz, drv: 0 [FD I]: jedec: 0x0, suspend_support: 1 target thread = Looper usage = 25, fragment = 1, maxFreeSize = 86836, totalFreeSize = 87636, waterLine = 32836 mode select:e target thread = tcpip usage = 27, fragment = 1, maxFreeSize = 84776, totalFreeSize = 85252, waterLine = 34420 target thread = umac usage = 29, fragment = 1, maxFreeSize = 82716, totalFreeSize = 83020, waterLine = 36652 target thread = workqueue usage = 31, fragment = 1, maxFreeSize = 80360, totalFreeSize = 80440, waterLine = 39320 target thread = rx_proc usage = 34, fragment = 1, maxFreeSize = 77524, totalFreeSize = 77604, waterLine = 42068 target thread = BH usage = 36, fragment = 1, maxFreeSize = 75464, totalFreeSize = 75544, waterLine = 44128 wlan information =================================================== firmware: version : R0-XR_C07.08.52.65_02.84 May 27 2021 11:41:33-Y02.84 buffer : 8 driver: version : XR_V02.05 mac address: in use : 0c:6e:88:3e:12:01 in use : 0c:6e:88:3e:12:02 ==================================================================== target thread = wpas usage = 40, fragment = 1, maxFreeSize = 69996, totalFreeSize = 70288, waterLine = 53648 wlan mode:a [VFS INF] SPIFFS mount success. platform information =============================================== XR806 SDK v1.2.0 Jan 19 2022 10:44:04 heap space [0x22a884, 0x247c00), size 119676 cpu clock 160000000 Hz HF clock 40000000 Hz sdk option: XIP : enable INT LF OSC : enable SIP flash : enable mac address: efuse : 80:74:84:05:ba:a0 in use : 0c:6e:88:3e:12:01 ==================================================================== target thread = MainThread usage = 49, fragment = 0, maxFreeSize = 60068, totalFreeSize = 60068, waterLine = 59604 target thread = hiview usage = 52, fragment = 0, maxFreeSize = 55504, totalFreeSize = 55504, waterLine = 64168 console init success hiview init success.target thread = console usage = 54, fragment = 1, maxFreeSize = 53444, totalFreeSize = 53468, waterLine = 66228 $ $ ble init target thread = LogMemTask usage = 51, fragment = 11, maxFreeSize = 51384, totalFreeSize = 57576, waterLine = 66228 ble controller open version : 9.1.19 build sha1 : v9.1.19-20210601 build date : Jun 1 2021 build time : 19:32:17 platform : xr806 ble rf_init done! target thread = LinkLayer usage = 58, fragment = 4, maxFreeSize = 47752, totalFreeSize = 49292, waterLine = 70380 target thread = LinkLayerHwEvent usage = 60, fragment = 4, maxFreeSize = 44668, totalFreeSize = 46208, waterLine = 73464 target thread = CoexEvent usage = 61, fragment = 4, maxFreeSize = 43632, totalFreeSize = 45172, waterLine = 74500 BLE INIT ALL DONE! BT Coex. Init. OK. == XRadio BLE HOST V2.5.0 == target thread = Zephyr usage = 69, fragment = 2, maxFreeSize = 35484, totalFreeSize = 36096, waterLine = 83576 target thread = Zephyr usage = 72, fragment = 2, maxFreeSize = 31376, totalFreeSize = 31988, waterLine = 87700 target thread = Zephyr usage = 74, fragment = 3, maxFreeSize = 29316, totalFreeSize = 29928, waterLine = 89744 target thread = Zephyr usage = 81, fragment = 3, maxFreeSize = 20504, totalFreeSize = 21116, waterLine = 98556 [bt] [WRN] set_flow_control: Controller to host flow control not supported [bt] [INF] bt_init: No ID address. App must call settings_load() [cmd] Bluetooth initialized [bt] [INF] bt_dev_show_info: Identity: C6:42:D9:8F:39:BB (random) [bt] [INF] bt_dev_show_info: HCI: version 5.0 (0x09) revision 0x0113, manufacturer 0x063d [bt] [INF] bt_dev_show_info: LMP: version 5.0 (0x09) subver 0x0113 [cmd] Settings Loaded <ACK> 200 OK $ mesh init == XRadio BLE HOST V2.5.0 == target thread = Zephyr usage = 84, fragment = 4, maxFreeSize = 16396, totalFreeSize = 17008, waterLine = 102680 [cmd] Mesh initialized [cmd] Use "pb-adv on" or "pb-gatt on" to enable advertising <ACK> 200 OK $ mesh pb-gatt on [bt] [INF] bt_mesh_prov_enable: Device UUID: 00000000-0000-0000-0000-00000000dddd [cmd] PB-GATT enabled <ACK> 200 OK $ ************************************************* [RandomAddress 57:F1:07:D8:B6:91 ] ************************************************* [cmd] Connected: 78:C4:1B:66:EC:45 (random) [cmd] Remote LMP version 5.0 (0x09) subversion 0x0000 manufacturer 0x0046 [cmd] LE Features: 0x00000000000179fd [cmd] LE conn param updated: int 0x0006 lat 0 to 500 [cmd] Provisioning link opened on PB-GATT [cmd] LE conn param updated: int 0x0027 lat 0 to 500 [cmd] LE data len updated: TX (len: 251 time: 17040) RX (len: 69 time: 5392) [bt] [INF] bt_mesh_provision: Primary Element: 0x0003: [cmd] Provisioning link closed on PB-GATT [cmd] Local node provisioned, net_idx 0x0000 address 0x0003 [cmd] Disconnected: 78:C4:1B:66:EC:45 (random) (reason 0x13) [cmd] Connected: 78:C4:1B:66:EC:45 (random) [cmd] Remote LMP version 5.0 (0x09) subversion 0x0000 manufacturer 0x0046 [cmd] LE Features: 0x00000000000179fd [cmd] LE conn param updated: int 0x0006 lat 0 to 500 [cmd] LE conn param updated: int 0x0027 lat 0 to 500 [cmd] LE data len updated: TX (len: 251 time: 17040) RX (len: 69 time: 5392) [bt] [WRN] trans_ack: No matching TX context for ack [cmd] onoff get(0) [cmd] onoff set(1) [cmd] onoff get(1) [cmd] onoff get(1) [cmd] onoff set(0) [cmd] onoff get(0) [cmd] onoff get(0) [cmd] onoff set(1) [cmd] onoff get(1) [cmd] onoff get(1) [cmd] onoff set(0) [cmd] onoff get(0)
Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号