【星闪开发连载】SLE_UUID_Server和SLE_UUID_Client程序测试

引言

前一篇博文介绍了SLE_UUID_Server和SLE_UUID_Client程序的基本结构,这篇介绍如何进行测试,从而实现两块星闪开发板之间的连接。

服务器的构建

在sdk根目录下(即src目录)打开集成终端台,执行 python build.py -c ws63-liteos-app menuconfig 命令,会出现选择弹窗。menuconfig这种方式是Linux及很多操作系统使用的配置方式。

选择路径"Application/Enable Sample/Enable the Sample of BT/SLE Sample",如果选择编译server端,选中"support SLE_UUID_SERVER Sample";如果选择编译client端,选中"support SLE_UUID_CLIENT Sample"。客户端例子和服务器例子是互斥的。BLE例子和SLE例子是互斥的。需要准备两块开发板,选择不同的编译选项,烧录不同的镜像。此次海思的评测提供了两块开发板,一个是单独的开发板,另一个是个套件。可以把单独的开发板当做服务器,而套件用作客户端,因为可以在客户端上采集数据或者显示结果。

按S键保存配置后,此时会提示保存路径,直接确认即可。

保存配置并退出menuconfig后,选择"工程|重新构建"。然后经过漫长的编译和链接就生成了镜像。

在HiSpark Studio工具中点击"工程配置"按钮,选择"程序加载",就可以将镜像烧写到服务器中。

客户端的构建

客户端的构建和服务器差不多。只是在menuconfig中选中"support SLE_UUID_CLIENT Sample"。

保存配置后,必须选择"工程|重新构建"。如果选择构建是不行的,仍然生成服务器程序。

其他步骤和服务器相同,不赘述了。

测试结果

接下来就是给两块板加电进行测试了。先启动客户端还是服务器是无所谓的,因为客户端一直在查找服务器,如果服务器后启动,客户端会立刻连接上。下面的测试结果是先启动服务器,后启动客户端得到的。

服务器侧

从串口工具看,服务器的日志如下。

boot.
Flash Init Fail! ret = 0x80001341
verify_public_rootkey secure verify disable!
verify_params_key_area secure verify disable!
verify_params_area_info secure verify disable!
verify_image_key_area secure verify disable!
verify_image_code_info secure verify disable!
SSB Uart Init Succ!
SSB Flash Init Succ!
verify_image_key_area secure verify disable!
verify_image_code_info secure verify disable!
Flashboot Uart Init Succ!
Flashboot Malloc Init Succ!
Flash Init Succ!
No need to fix SR!
flashboot version : 1.10.101
[UPG] upgrade init OK!
No need to upgrade...
flash_encrypt disable.
verify_image_key_area secure verify disable!
verify_image_code_info secure verify disable!
APP|Debug uart init succ.
[UPG] upgrade init OK!
APP|init_dev_addr, mac_addr:0x26,0x 0,0x73,0xe1,0x**,0x**,
xo_trim_temp_comp val:0 0
APP|AT uart init succ.
los_at_plt_cmd_register EXCUTE
APP|WARNING: main_initialise::thread[11] func is null
cpu 0 entering scheduler
                        APP|btc open
[RADAR_LOG] alg ctrl read from nv [1][2][0][0][1][1][20]
device_main_init: 0!
===hal_initialize_phy===225===
device_module_init:: succ!
cali_set_cali_mask:old[0x0] -> new[0x1fa2]

fe_rf_initialize
cali_offline_cali_entry enter
cali_set_cali_done_flag:old[0x0] -> new[0x1]

rf cali OK. time cost:23, ret:0
[ACore] sle enable cbk in, result:0
sle enable
[uuid server] sle uuid add service in
[uuid server] sle uuid add service, server_id:1, service_handle:1, property_handle:2
[uuid server] start service cbk server_id:1, handle:1, status:0
[uuid server] sle uuid add service out
sle_uuid_server_adv_init in
[ACore] sle set announce param, handle:1, mode:3, min_interval:c8, max_interval:c8, tx_power: 0
[ACore] sle set announce param, own addr:0x00:**:**:**:00:00
[ACore] sle set announce param, peer addr:0x00:**:**:**:00:00
set adv data default
local_name[0] = 0x73
local_name[1] = 0x6c
local_name[2] = 0x65
local_name[3] = 0x5f
local_name[4] = 0x75
local_name[5] = 0x75
local_name[6] = 0x69
local_name[7] = 0x64
local_name[8] = 0x5f
local_name[9] = 0x73
local_name[10] = 0x65
local_name[11] = 0x72
local_name[12] = 0x76
local_name[13] = 0x65
local_name[14] = 0x72
local_name[15] = 0xff
local_name[16] = 0x37
local_name[17] = 0xbe
local_name[18] = 0xa8
local_name[19] = 0x80
local_name[20] = 0xfc
local_name[21] = 0x70
local_name[22] = 0x11
local_name[23] = 0xea
local_name[24] = 0xb7
local_name[25] = 0x20
[SLE DD SDK] set announce data success.[ACore] sle start announce in, adv_id:1
[ACore] sle adv cbk in, event:0 status:0
[ACore] sle adv cbk in, event:1 status:0
[ACore] sle adv cbk in, event:2 status:0
[ACore] sle adv cbk in, event:3 status:0
sle announce enable id:01, state:00
sle_uuid_server_adv_init out
[uuid server] init ok
APP|Hello world!
xo update temp:4,diff:0,xo:0x3083c
APP|[SYS INFO] mem: used:90016, free:274004; log: drop/all[0/0], at_recv 0.

其中的"Hello world!" 是我们在第一次测试时加上的,和SLE无关。从日志看,服务器启动后会立即发送广播信息。

一旦客户端连接上服务器,会打印如下信息。

[Connected]
addr:ee:**:**:**:8d:5c, handle:00
[ACore] sle adv cbk in, event:7 status:0
[uuid server] connect state changed conn_id:0x00, conn_state:0x1, pair_state:0x1,         disc_reason:0x0
[uuid server] connect state changed addr:ee:**:**:**:8d:5c
sle announce terminal id:01
[uuid server] pair complete conn_id:00, status:0
[uuid server] pair complete addr:ee:**:**:**:8d:5c
[uuid server] ssaps write request cbk server_id:0, conn_id:0, mtu_size:12c, status:0
[uuid server] ssaps write request cbk server_id:1, conn_id:0, handle:1, status:0
[uuid server] ssaps read request cbk server_id:1, conn_id:0, handle:1, status:0
APP|[SYS INFO] mem: used:91108, free:272912; log: drop/all[0/0], at_recv 0.

从日志可以看到客户端的信息。

如果断开客户端,服务器的日志如下。

[Disconnected]
addr:ee:**:**:**:8d:5c, handle:00
[uuid server] connect state changed conn_id:0x00, conn_state:0x2, pair_state:0x3,         disc_reason:0x7
[uuid server] connect state changed addr:ee:**:**:**:8d:5c
APP|[SYS INFO] mem: used:90028, free:273992; log: drop/all[0/0], at_recv 0.

由于手上只有两块开发板,无法测试多客户端的情况。

客户端侧

从串口工具看,客户端的日志如下。

2024-10-06 19:27:42:781 -> boot.
2024-10-06 19:27:42:831 -> Flash Init Fail! ret = 0x80001341
2024-10-06 19:27:42:838 -> verify_public_rootkey secure verify disable!
2024-10-06 19:27:42:839 -> verify_params_key_area secure verify disable!
2024-10-06 19:27:42:843 -> verify_params_area_info secure verify disable!
2024-10-06 19:27:42:846 -> verify_image_key_area secure verify disable!
2024-10-06 19:27:42:853 -> verify_image_code_info secure verify disable!
2024-10-06 19:27:42:921 -> SSB Uart Init Succ!
2024-10-06 19:27:42:923 -> SSB Flash Init Succ!
2024-10-06 19:27:42:926 -> verify_image_key_area secure verify disable!
2024-10-06 19:27:42:927 -> verify_image_code_info secure verify disable!
2024-10-06 19:27:42:959 -> Flashboot Uart Init Succ!
2024-10-06 19:27:42:960 -> Flashboot Malloc Init Succ!
2024-10-06 19:27:42:960 -> Flash Init Succ!
2024-10-06 19:27:42:960 -> No need to fix SR!
2024-10-06 19:27:42:960 -> flashboot version : 1.10.101
2024-10-06 19:27:42:960 -> [UPG] upgrade init OK!
2024-10-06 19:27:42:977 -> No need to upgrade...
2024-10-06 19:27:42:978 -> flash_encrypt disable.
2024-10-06 19:27:42:978 -> verify_image_key_area secure verify disable!
2024-10-06 19:27:42:978 -> verify_image_code_info secure verify disable!
2024-10-06 19:27:43:389 -> APP|Debug uart init succ.
2024-10-06 19:27:43:392 -> [UPG] upgrade init OK!
2024-10-06 19:27:43:400 -> APP|init_dev_addr, mac_addr:0x 0,0x16,0x3e,0x2b,0x**,0x**,
2024-10-06 19:27:43:401 -> xo_trim_temp_comp val:0 0
2024-10-06 19:27:43:407 -> APP|AT uart init succ.
2024-10-06 19:27:43:409 -> los_at_plt_cmd_register EXCUTE
2024-10-06 19:27:43:413 -> APP|WARNING: main_initialise::thread[11] func is null
2024-10-06 19:27:43:482 -> cpu 0 entering scheduler
APP|btc open
2024-10-06 19:27:43:490 -> [RADAR_LOG] alg ctrl read from nv [1][2][0][0][1][1][20]
2024-10-06 19:27:43:490 -> device_main_init: 0!
2024-10-06 19:27:43:490 -> ===hal_initialize_phy===225===
2024-10-06 19:27:43:509 -> device_module_init:: succ!
2024-10-06 19:27:43:513 -> cali_set_cali_mask:old[0x0] -> new[0x1fa2]
2024-10-06 19:27:43:513 -> fe_rf_initialize
2024-10-06 19:27:43:513 -> cali_offline_cali_entry enter
2024-10-06 19:27:43:534 -> cali_set_cali_done_flag:old[0x0] -> new[0x1]
2024-10-06 19:27:43:534 -> rf cali OK. time cost:23, ret:0
2024-10-06 19:27:43:534 -> [ACore] sle enable cbk in, result:0
2024-10-06 19:27:43:534 -> sle enable
2024-10-06 19:27:43:565 -> [adv_report] event_type: 0x03, addr_type: 0x0000, addr: 00:**:**:**:00:00
2024-10-06 19:27:43:567 -> [adv_report] data length: 6, data: 0x02 0x01 0x01 0x02 0x02 0x00
2024-10-06 19:27:43:624 -> [Connected]
2024-10-06 19:27:43:626 -> addr:00:**:**:**:00:00, handle:00
2024-10-06 19:27:43:927 -> [ssap client] conn state changed conn_id:0, addr:00***0000
[ssap client] conn state changed disc_reason:0x0
[ssap client] pair complete conn_id:0, addr:00***0000
ssapc exchange info, conn_id:0, err_code:0
2024-10-06 19:27:43:953 -> [ssap client] pair complete client id:0 status:0
[ssap client] exchange mtu, mtu size: 300, version: 1.
discovery character cbk complete in
2024-10-06 19:27:43:966 -> [ssap client] find structure cbk client: 0 conn_id:0 status: 0 
[ssap client] find structure start_hdl:[0x01], end_hdl:[0x02], uuid len:2
2024-10-06 19:27:43:997 -> [ssap client] structure uuid:[0xcd][0xab]
2024-10-06 19:27:44:040 -> [ssap client] find structure cmp cbk client id:0 status:0 type:1 uuid len:0 
2024-10-06 19:27:44:042 -> [ssap client] find structure cmp cbk structure uuid[0]:[0x00]
2024-10-06 19:27:44:042 -> [ssap client] find structure cmp cbk structure uuid[1]:[0x00]
2024-10-06 19:27:44:043 -> [ssap client] find structure cmp cbk structure uuid[2]:[0x00]
2024-10-06 19:27:44:058 -> [ssap client] find structure cmp cbk structure uuid[3]:[0x00]
2024-10-06 19:27:44:059 -> [ssap client] find structurructure cmp cbk structure uuid[5]:[0x00]
2024-10-06 19:27:44:059 -> [ssap client] find structure cmp cbk structure uuid[6]:[0x00]
2024-10-06 19:27:44:059 -> [ssap client] find structure cmp cbk structure uuid[7]:[0x00]
2024-10-06 19:27:44:059 -> [ssap client] find structure cmp cbk structure uuid[8]:[0x00]
2024-10-06 19:27:44:065 -> [ssap client] find structd[9]:[0x00]
2024-10-06 19:27:44:102 -> [ssap client] find structure cmp cbk structure uuidcture cmp cbk structure uuid[15]ssapc write rsp handle:1
2024-10-06 19:27:44:105 -> [sle write_req_complete_cbk]conn_id:0, err_code:0
2024-10-06 19:27:44:127 -> [ssap client] write cfm cbk, client id: 0 status:0.
ssapc read rsp handle:0, data len:4
2024-10-06 19:27:44:144 -> [ssap client] read cfm cbk client id: 0 conn id: 0 status: 0
[ssap client] read cfm cbk handle: 0, type: 10 , len: 4
[ssap client] read cfm cbk[0] 0x11
2024-10-06 19:27:44:536 -> [ssap client] read cfm cbk[1] 0x22APP|Hello world!
2024-10-06 19:27:47:411 -> xo update temp:4,diff:0,xo:0x3083c
2024-10-06 19:27:54:538 -> APP|[SYS INFO] mem: used:90472, free:273468; log: drop/all[0/0], at_recv 0.
2024-10-06 19:28:04:521 -> APP|[SYS INFO] mem: used:90416, free:273524; log: drop/all[0/0], at_recv 0.
2024-10-06 19:28:14:526 -> APP|[SYS INFO] mem: used:90472, free:273468; log: drop/all[0/0], at_recv 0.
2024-10-06 19:28:24:527 -> APP|[SYS INFO] mem: used:90480, free:273460; log: drop/all[0/0], at_recv 0.
2024-10-06 19:28:34:840 -> APP|[SYS INFO] mem: used:90408, free:273532; log: drop/all[0/0], at_recv 0.
2024-10-06 19:28:44:682 -> APP|[SYS INFO] mem: used:90464, free:273476; log: drop/all[0/0], at_recv 0.
2024-10-06 19:28:54:520 -> APP|[SYS INFO] mem: used:90408, free:273532; log: drop/all[0/0], at_recv 0.
2024-10-06 19:29:04:521 -> APP|[SYS INFO] mem: used:90472, free:273468; log: drop/all[0/0], at_recv 0.

从日志可以看到,客户端和服务器成功配对。有了日志,再看程序的逻辑就容易了。

相关推荐
光路科技9 小时前
八大网络安全策略:如何防范物联网(IoT)设备带来的安全风险
物联网·安全·web安全
委员14 小时前
基于NodeMCU的物联网空调控制系统设计
单片机·mcu·物联网·智能家居
逝灮16 小时前
【蓝桥杯——物联网设计与开发】拓展模块3 - 温度传感器模块
驱动开发·stm32·单片机·嵌入式硬件·物联网·蓝桥杯·温度传感器
邓校长的编程课堂16 小时前
基于树莓派Pico和声音传感器实现声控风扇的技术分享
物联网·嵌入式开发·树莓派pico·编程入门·c++编程·声音传感器·c++趣味编程
有续技术19 小时前
工厂常用软件系统大全中英文全称对照表及功能介绍应用场景ERP MES WMS SCADA IOT SAP等软件系统介绍
物联网
嗯? 嗯。1 天前
遇见物联网
物联网
神一样的老师2 天前
物联网:全面概述、架构、应用、仿真工具、挑战和未来方向
物联网
深圳博达智联2 天前
V900新功能-电脑不在旁边,通过手机给PLC远程调试网关配置WIFI联网
物联网
TDengine (老段)2 天前
TDengine 新功能 通过 UID 删除不可见表
大数据·数据库·物联网·时序数据库·tdengine
美迅物联网 MesoonRF2 天前
HC04,HC05,HC06,HC08蓝牙模块可替换产品的优势
嵌入式硬件·物联网