123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- #define USR_PLATFORM_QL_ASR1606 0
- #define PLATFORM_TYPE USR_PLATFORM_QL_ASR1606
- #include "w_poc.h"
- #if(USR_PLATFORM_QL_ASR1606==USR_PLATFORM_QL_ASR1606)
- #include "ql_application.h"
- #include "ql_uart.h"
- #include "ql_rtos.h"
- char quec_uart=0;
- void quec_usbcdc_callback(QL_UART_PORT_NUMBER_E port, void *para)
- {
- }
- void hlog_init(void){
- if(0!=ql_uart_open(QL_USB_CDC_PORT, QL_UART_BAUD_115200, QL_FC_NONE)) return;
- ql_uart_register_cb(QL_USB_CDC_PORT, quec_usbcdc_callback); //use callback to read uart data
- quec_uart=1;
- }
- void hlog_show(char *msg){
- if(quec_uart==0) return;
- ql_uart_write(QL_USB_CDC_PORT, msg, strlen(msg));
- }
- char msgCmp(char *msg, char *target){
- char *p1=target, *p2=msg;
- while(*p1 != 0){
- if(*p1 != *p2) return 0;
- p1++;p2++;
- }
- return 1;
- }
- #define wlog_app(...) OEM_sys_log_print("WAPP","info", ##__VA_ARGS__)
- #define MSG_METHOD 0 //0 AT命令方式 1 API调用方式
- unsigned char loginStatus=0;
- void wpoc_msg_rx_at(char *msg){
- const char *marker="+WPTT:";
- if(!msgCmp(msg, marker)) return;
- wlog_app("%s", msg);
- msg+=strlen(marker);
- if(msgCmp(msg, "LOGIN=")){
- if(msg[6]=='0') loginStatus=0;
- else if(msg[6]=='1') loginStatus=1;
- }
- }
- void wpoc_msg_rx_event(WPOC_EVENT_RX event, unsigned char *data, int datalen){
- WPOC_LOGINACK_DEF *uinfo;
- switch(event){
- case WPOC_RX_EVENT_LOGIN:
- uinfo=(WPOC_LOGINACK_DEF *)data;
- wlog_app("login done");
- wlog_app("uid:%08x,name:%s", uinfo->user_id, uinfo->user_name);
- wlog_app("group:%08x,unum:%d,name:%s", uinfo->be_group_id, uinfo->user_num_in_group, uinfo->be_group_name);
- loginStatus=1;
- break;
- case WPOC_RX_EVENT_LINEOFF:
- wlog_app("line off");
- loginStatus=0;
- break;
- case WPOC_RX_EVENT_TIMES:
- wlog_app("time ack:%s", (char *)data);
- break;
- default:wlog_app("unhandle event:%d", event);break;
- }
- }
- WPOC_MSG_RX_DEF msg_rx_fun={
- #if MSG_METHOD==0
- .wpoc_msg_rx_at_fun=wpoc_msg_rx_at,
- .wpoc_msg_rx_event_fun=NULL
- #else
- .wpoc_msg_rx_at_fun=NULL,
- .wpoc_msg_rx_event_fun=wpoc_msg_rx_event
- #endif
- };
- static int test_task(void *param){
- unsigned int psn=241200001;
- int ret;
- int tick=0;
- WPOC_REQ_GROUP_DEF groupQuery={
- .startIndex=0,
- .totalNum=-1
- };
- ql_rtos_task_sleep_ms(10000);
- ql_set_auto_connect(1, TRUE);
- ql_start_data_call(1, 0, NULL, NULL, NULL, 0);
-
- hlog_init();
- wpoc_param_set(WPOC_MSG_RX_FUN, &msg_rx_fun);
- wpoc_param_set(WPOC_PARAM_ACCOUNT_PSN, &psn);
- wpoc_param_set(WPOC_PARAM_ACCOUNT_PASS, "123456");
- wpoc_param_set(WPOC_PARAM_DNS, "106.12.172.105");
- wpoc_param_set(WPOC_PARAM_PLATFORM, "EC600M");
- wpoc_param_set(WPOC_PARAM_GROUPNUMS, 100);
- wpoc_param_set(WPOC_PARAM_USERNUMS, 100);
- ret=wpoc_init(hlog_show);
- for(;;){
- ql_rtos_task_sleep_ms(1000);
- if(loginStatus==0) continue;
- //查询时间
- if(++tick<30) continue;
- tick=0;
- if(tick==5){
- #if MSG_METHOD==0
- wpoc_msg_at_tx("AT+WPTT:GROUPS=0,-1\r\n");
- #else
- wpoc_msg_event_tx(WPOC_TX_EVENT_REQGOUPS, &groupQuery, sizeof(WPOC_REQ_GROUP_DEF));
- #endif
- }else if(tick==30){
- #if MSG_METHOD==0
- wpoc_msg_at_tx("AT+WPTT:REQTIME\r\n");
- #else
- wpoc_msg_event_tx(WPOC_TX_EVENT_REQTIME, NULL, NULL);
- #endif
- }
- }
- return 0;
- }
- static int platform_entry(void *param){
- ql_task_t thisTask;
- return ql_rtos_task_create(&thisTask, 16*1024, 100,"test_task", test_task, NULL, 0);
- }
- application_init(platform_entry, "platform_entry", 64,1);
- #endif
|