联盛德W801基于SDK全功能Demo项目开启和功能测试

Posted perseverance52

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了联盛德W801基于SDK全功能Demo项目开启和功能测试相关的知识,希望对你有一定的参考价值。

联盛德W801基于SDK全功能Demo项目开启和功能测试


  • 最新的SDK Demo程序:https://www.winnermicro.com/html/1/156/158/558.html
  • Demo程序的详细测试可以参考官方的《WM-W800 SDK DEMO 运行指南V1.3.》(资料在上方的官网链接中有)
  • 当前版本信息:W800 SDK v1.00.08
  • 全功能Demo项目开启测试
  • 找到 wm_demo.h,将所有Demo配置选项配置为DEMO_ON ,(默认情况下是关闭的)

#ifndef __WM_DEMO_H__
#define __WM_DEMO_H__

#define DEMO_ON		1
#define DEMO_OFF	0

//demo console
#define DEMO_CONSOLE				DEMO_ON

//socket demo
#define DEMO_STD_SOCKET_CLIENT	    (DEMO_OFF && DEMO_CONSOLE)
#define DEMO_STD_SOCKET_SERVER	    (DEMO_OFF && DEMO_CONSOLE)

#define DEMO_UDP                    (DEMO_OFF && DEMO_CONSOLE)

//connect demo
#define DEMO_CONNECT_NET			(DEMO_OFF && DEMO_CONSOLE)

#define DEMO_SOCKET_CLIENT_SERVER   (DEMO_OFF && DEMO_CONSOLE)

//apsta demo
#define DEMO_APSTA   		  		(DEMO_OFF && DEMO_CONSOLE)

//Uart rx&tx demo
#define DEMO_UARTx   		  		(DEMO_OFF && DEMO_CONSOLE)

//AP dmeo
#define DEMO_SOFT_AP   		  		(DEMO_OFF && DEMO_CONSOLE)

//WPS demo
#define DEMO_WPS					(DEMO_OFF && DEMO_CONSOLE && TLS_CONFIG_WPS && TLS_IEEE8021X_EAPOL)

//gpio demo
#define DEMO_GPIO					(DEMO_OFF && DEMO_CONSOLE)

//flash demo
#define DEMO_FLASH					(DEMO_OFF && DEMO_CONSOLE)

//master spi demo
#define DEMO_MASTER_SPI				(DEMO_OFF && DEMO_CONSOLE)

//Encryption&Decryption demo
#define DEMO_ENCRYPT				(DEMO_OFF && DEMO_CONSOLE)

//rsa demo
#define DEMO_RSA					(DEMO_OFF && DEMO_CONSOLE)

//rtc demo
#define DEMO_RTC					(DEMO_OFF && DEMO_CONSOLE)

//timer demo
#define DEMO_TIMER					(DEMO_OFF && DEMO_CONSOLE)

//i2c demo
#define DEMO_I2C					(DEMO_OFF && DEMO_CONSOLE)

//pwm demo
#define DEMO_PWM					(DEMO_OFF && DEMO_CONSOLE)

//pmu demo
#define DEMO_PMU					(DEMO_OFF && DEMO_CONSOLE)

//ntp demo
#define DEMO_NTP					(DEMO_OFF && DEMO_CONSOLE)

//i2s demo
#define DEMO_I2S					(DEMO_OFF && DEMO_CONSOLE)

//adc demo
#define DEMO_ADC					(DEMO_OFF && DEMO_CONSOLE)

//slave spi demo
#define DEMO_SLAVE_SPI				(DEMO_OFF && DEMO_CONSOLE)

//7816
#define DEMO_7816					(DEMO_OFF && DEMO_CONSOLE)

//touch sensor
#define DEMO_TOUCHSENSOR           (DEMO_OFF && DEMO_CONSOLE)

//ssl server demo
#define DEMO_SSL_SERVER				(DEMO_OFF && DEMO_CONSOLE)

//websocket demo
#define DEMO_WEBSOCKETS				(DEMO_OFF && DEMO_CONSOLE)

//http demo
#define DEMO_HTTP					(DEMO_OFF && DEMO_CONSOLE)

#define DEMO_SCAN					(DEMO_OFF && DEMO_CONSOLE)
#define DEMO_HTTPS                  (DEMO_OFF && DEMO_CONSOLE)
#define DEMO_MQTT                   (DEMO_OFF && DEMO_CONSOLE)
#define DEMO_SDIO_HOST              (DEMO_OFF && DEMO_CONSOLE)
#define DEMO_FATFS                  (DEMO_OFF && DEMO_CONSOLE)
#define DEMO_MBEDTLS                (DEMO_OFF && DEMO_CONSOLE)


#define DEMO_DSP					(DEMO_OFF && DEMO_CONSOLE)

#define DEMO_BT                     (DEMO_OFF && DEMO_CONSOLE)



// user prio 32 - 60
#define  DEMO_TASK_PRIO			                32
#define  DEMO_SOCKET_C_TASK_PRIO	            (DEMO_TASK_PRIO + 1)
#define  DEMO_SOCKET_S_TASK_PRIO	            (DEMO_SOCKET_C_TASK_PRIO + 1)
#define  DEMO_SOCKET_RECEIVE_TASK_PRIO	        (DEMO_SOCKET_S_TASK_PRIO + 1)
#define  DEMO_SOCKET_S_SEND_TASK_PRIO    	    (DEMO_SOCKET_RECEIVE_TASK_PRIO + 1)
#define  DEMO_SOCKET_S_RECEIVE_TASK_PRIO    	(DEMO_SOCKET_S_SEND_TASK_PRIO + 1)
#define  DEMO_UDP_TASK_PRIO                     (DEMO_SOCKET_S_RECEIVE_TASK_PRIO + 1)
#define  DEMO_UDP_RECEIVE_TASK_PRIO             (DEMO_UDP_TASK_PRIO + 1)
#define  DEMO_MCAST_TASK_PRIO	                (DEMO_UDP_RECEIVE_TASK_PRIO + 1)
#define  DEMO_SOCK_FWUP_TASK_PRIO	            (DEMO_MCAST_TASK_PRIO + 1)
#define  DEMO_UART_TASK_PRIO	                (DEMO_SOCK_FWUP_TASK_PRIO + 1)
#define  DEMO_SSL_SERVER_TASK_PRIO	            (DEMO_UART_TASK_PRIO + 1)
#define  DEMO_WEBSOCKETS_TASK_PRIO              (DEMO_SSL_SERVER_TASK_PRIO + 1)

#define DEMO_QUEUE_SIZE	32

#define DEMO_BUF_SIZE		TLS_UART_RX_BUF_SIZE


/*Message Definition used for Demo task*/
#define	DEMO_MSG_WJOIN_FAILD	            1
#define	DEMO_MSG_WJOIN_SUCCESS	            2
#define DEMO_MSG_SOCKET_RECEIVE_DATA		3
#define	DEMO_MSG_UART_RECEIVE_DATA			4
#define	DEMO_MSG_SOCKET_ERR					5
#define DEMO_MSG_SOCKET_CREATE				6
#define DEMO_MSG_SOCKET_TEST				7
#define DEMO_MSG_OPEN_UART					8
#define DEMO_MSG_UART_CMD_DATA				9

typedef struct demo_sys

    char *rxbuf;		   /*uart rx*/
    char *txbuf;		   /*uart tx*/
    u16 wptr;
    u16 rptr;
    u8 dummy1;		      /*not used*/
    u8 MsgNum;


    bool socket_ok;
    int socket_num;
    char *sock_rx;
    u16 sock_data_len;

    int recvlen;		/*socket rx length, used to debug*/
    int translen;		/*socket tx length, used to debug*/
    u8 dummy2; 			/*not used*/
 ST_Demo_Sys;

void CreateDemoTask(void);

extern int wm_printf(const char *fmt,...) ;

#endif

  • 程序烧录后会打印如下信息:
 user task 

Sequence  Command             Description
------------------------------------------------------------------------------------
1         t-connect           Test connecting ap;t-connect("ssid","pwd"); For open ap, pwd should be empty
2         t-oneshot           Test Oneshot  configuration
3         t-webcfg            Test web server configuration
4         t-blecfg            Test ble mode configuration
5         t-apsta             Test connecting with AP by apsta mode;
6         t-asskt             Test socket communication in apsta mode;
7         t-softap            Test softap create & station join monitor;
8         t-scan              Test wifi scan
9         t-uart              Test uart tx/rx; For example t-uart=(9600,0,0),baudrate 9600 ,parity none and 1 stop bit
10        t-gpioirq           Test gpio interrupt services
11        t-gpio              Test gpio read and write
12        t-flash             Test Read/Write Flash 
13        t-crypt             Test Encryption/Decryption API
14        t-rsa               Test RSA Encryption/Decryption API
15        t-rtc               Test rtc
16        t-timer             Test timer
17        t-pwm               Test PWM output, for example t-pwm=(0,20,99,1,0) to test ALLSYC mode.
18        t-pmuT0             Test power management unit with timer0
19        t-pmuT1             Test power management unit with timer1
20        t-i2c               Test I2C module, for example t-i2c to W&R AT24CXX.
21        t-i2sioinit         Initialize I2S IO.
22        t-i2s               Test I2S module, for example t-i2s=(0,1,44100,16,0,0) to send data.
23        t-mspi-s            Test SPI Master sending data(Note: need another module acts as a client device)
24        t-mspi-r            Test SPI Master receiving data(Note: need another module acts as a client device)
25        t-sspi              Test slave HSPI,t-sspi=(0),(Note: need another module support as a master device)
26        t-sdh               Test sdio host write & read sd card
27        t-adctemp           (ADC)Test chip temperature
28        t-adcvolt           (ADC)Test input voltage,0-PA1(chan0), 1-PA4(chan1),8-different
29        t-adcpower          (ADC)Sample power supply voltage
30        t-7816              Test 7816 tx/rx function
31        t-sockc             Test data stream as [STANDARD SOCKET] CLIENT(working after connecting with AP successfully)
32        t-skcsnd            Test socket client send data, len:send len, uart_trans: is or not use uart retransmission
33        t-socks             Test data stream as [STANDARD SOCKET] SERVER(working after connecting with AP successfully)
34        t-skssnd            Test socket server send data skt_no:socket num, len:send len, uart_trans: is or not use uart retransmission
35        t-client            Test socket client; t-client("ssid","pwd",port,"ip")
36        t-server            Test socket server; t-server("ssid","pwd",port,)
37        t-udp               Test data stream as UDP(working after connecting with AP successfully)
38        t-sndudp            Test udp send data
39        t-ntp               Test NTP
40        t-setntps           Set NTP server ip;For example:t-setntps("cn.ntp.org.cn", "ntp.sjtu.edu.cn", "192.168.1.101"),max server num is 3
41        t-queryntps         Query the NTP server domain
42        t-httpfwup          Test firmware update via HTTP, like this t-httpfwup=(http://192.168.1.100:8080/WM_W600_SEC.img)
43        t-httpget           Test HTTP get method, like this t-httpget
44        t-httppost          Test HTTP post method, like this t-httppost=(user=winnermicro)
45        t-httpput           Test HTTP put method, like this t-httpput=(user=winnermicro)
46        t-ssl-server        Test ssl server,remember to turn on TLS_CONFIG_SERVER_SIDE_SSL
47        t-websockets        websockets demo test
48        t-https             Test https request
49        t-mbedtls           Test mbedtls ssl
50        t-mqtt              Test mqtt
51        t-fatfs             Test fatfs on sd card
52        t-dsp               DSP demo:0-fir,1-matrix,2-rfft,3-sin,4-variance
53        t-bt-on             Test enable bt system
54        t-bt-off            Test destroy bt system
55        t-ble-server-on     Test enable ble server
56        t-ble-server-off    Test disable ble server
57        t-ble-client-on     Test enable ble client
58        t-ble-client-off    Test disable ble client
59        t-ble-adv           Test start connectable/unconnectable/stop ble advertisement,eg: t-ble-adv=(1/2/0)
60        t-ble-scan          Test start/stop ble scan,eg: t-ble-scan=(1/0)
61        t-touch             Test Touch sensor function,0:all, 1:touch sensor 1... 15:touch sensor 15
62        t-lcd               Test LCD output, eg: t-lcd
63        t-avoidcopy         Test Avoid Copy function
64        demohelp            Display Help information
------------------------------------------------------------------------------------

注意:以下命令行都不需要勾选换行选项。

  • 串口配网:t-connect(ssid_name, password)

  • 网页AP配网:t-webcfg

  • 通过手机端或者电脑端连接下面的AP网络

    连接上后会自动跳转到配网界面:

    连接成功后,串口会打印下面的信息
  • oneshot或AirKiss配网:t-oneshot此命令没有配网成功过。
  • 使用oneshot APP配网没成功:

使用AirKiss配网也没成功:


  • 开启AP模式:t-softap("SoftAp","123456789",6,4,1)

其中的 5 个参数分别表示 ap 的名称,密码,所用信道,加密方式和密码的格式;
加密方式:/0:open, 1:wep64, 2:wep128,3:TKIP WPA ,4: CCMP WPA, 5:TKIP WPA2 ,6: CCMP WPA2/
密码格式:/key’s format:0-HEX, 1-ASCII/


可以搜索到下面该网络

  • WPS配网指令( t-wps-start-pbct-wps-start-pin

不仅需要路由器支持 wps,还需要单独索取支持 WPS 的库。WPS 的库官方没有提供,没有库的情况下开启该功能,编译会报错,所以没法测试该命令。

#define  TLS_CONFIG_WPS       				CFG_WIFI_ON /* WPS&EAPOL should be enabled together */
#define  TLS_IEEE8021X_EAPOL   				CFG_WIFI_ON
  • WIFI扫描:t-scan
  • 串口1波特率设置命令:t-uart=(9600,0,0)

可以对串口1(PB6、 PB7)串口波特率设置。


  • GPIO口测试:t-gpio

  • GPIO中断:t-gpioirq指定的是PA1引脚。
  • flash指令:t-flash
  • 相关哈希值:t-crypt
  • 不同长度的RSA算法测试:t-rsa
  • 实时时钟查询打印:t-rtc该命令会一直串口间隔0.33333秒打印一次本地时间,并且会阻塞串口接收,如需继续使用串口命令需要点击复位才行。
  • NTP时间查询:t-ntp此命令需要在联网状态下,才能查询到时间。没联网状态一下一直打印:waiting for wifi connected......
t-connect(WIFI帐号,WIFI密码)//可以先执行这条,命令
t-ntp

  • 修改默认的NTP服务器地址:
t-setntps(ntp1.aliyun.com,ntp2.aliyun.com,ntp3.aliyun.com)
或者
t-setntps(120.25.108.11,ntp.sjtu.edu.cn,us.pool.ntp.org)


  • 查询NTP地址:t-queryntps

  • 开启定时器中断:t-timer

  • 开启PWM IO引脚输出:t-pwm=(1,250,99,4,0)

第一个参数为通道序号,包含两组复用,序号 0-4 分别对应 demo 中的 PB00、PB01、PB02、PB03、PA07 共五路,5-9 对应 PB19、PB20、PA00、PA01、PA04;第二个参数是期望输出的 pwm频率;第三个参数是占空比,比如此处是 99 则表示实际占空比为 99/255;第四个参数表示当前模式,其中 4表示独立模式,即只此路 pwm 输出波形;第 5 个参数表示输出的波形周期数,其中 0 表示持续输出波形。


PB1引脚波形(t-pwm=(1,250,127,4,0)


PB1引脚波形(t-pwm=(1,250,99,4,0)

  • standby 的低功耗模式并定时器0唤醒:t-pmuT0
  • standby 的低功耗模式并定时器1唤醒:t-pmuT1
    - http get 方法获取数据:t-httpget=(http://192.168.0.113:280/package_w80x_index.json)此命令需要利用HFS架设本地服务器。

在接入网络的情况下才能使用.


与之相关的还有:

  • http put 方法获取数据:t-httpput=(http://192.168.0.113:280/package_w80x_index.json)
  • http post方法获取数据:t-httppost
  • Http OTA固件升级:t-httpfwup=(http://192.168.0.113:280/w800.img)没有测试成功。需要借助HFS软件
  • tls服务连接:t-ssl-server,需要使用 openssl工具(需要自己安装)连接 ssl server 成功后的命令行页面信息。
  • 获取本地连接信息:t-https
  • MQTT服务:t-mqtt 需要借助工具搭建MQTT服务器才能实现这里不做演示。
  • websockets加密数据通信:t-websockets 需要调整相应的代码,打开宏定义 DEMO_WEBSOCKETS
    DEMO_CONNECT_NET,关闭 LWS_USE_SSL

以上是关于联盛德W801基于SDK全功能Demo项目开启和功能测试的主要内容,如果未能解决你的问题,请参考以下文章

联盛德W801开发板流水灯示例

Arduino框架下联盛德W801实现流水灯示例

联盛德 HLK-W806 : 兼容开发板 LuatOS Air103

联盛德 HLK-W801开发板串口下载复位问题的分析和解决方法

W800芯片平台进入OpenHarmony主干

运行银联支付系统demo