Exemplo n.º 1
0
void tls_sys_task(void *data)
{
    u8 err;
    u32 *msg ;
    //u8 oneshotflag = 0;
    //u8 auto_mode = 0;
    for (;;) {
        err = tls_os_queue_receive(msg_queue, (void **)&msg, 0, 0);
        if (!err) {
            switch((u32)msg) {
                case SYS_MSG_NET_UP:
                    sys_net_up();
                    break;

                case SYS_MSG_NET_DOWN:
                    sys_net_down();
                    break;
				case SYS_MSG_CONNECT_FAILED:
					tls_auto_reconnect();
					break;
               case SYS_MSG_AUTO_MODE_RUN:	
			   		tls_auto_reconnect();
			   break;				
               default:
		            break;
            }
        } else {

        }
    }
}
Exemplo n.º 2
0
static void
sd_down_thread(void *arg)
{
    void * msg;
    while(TRUE)
    {
        tls_os_queue_receive(sd_down_mbox, &msg, 0, 0);
        spitocodec();
    }
}
Exemplo n.º 3
0
static void demo_sock_fwup_task(void *sdata)
{
//	ST_Demo_Sys *sys = (ST_Demo_Sys *)sdata;
	void *msg;
	struct tls_ethif * ethif = tls_netif_get_ethif();

	printf("\nsock fwup task\n");
	if(ethif->status)	//已经在网
	{
		tls_os_queue_send(demo_sock_fwup_q, (void *)DEMO_MSG_SOCKET_CREATE, 0);
	}
	else
	{
		struct tls_param_ip ip_param;
		
		tls_param_get(TLS_PARAM_ID_IP, &ip_param, TRUE);
		ip_param.dhcp_enable = true;
		tls_param_set(TLS_PARAM_ID_IP, &ip_param, TRUE);
		tls_wifi_set_oneshot_flag(1);		/*一键配置使能*/
		printf("\nwait one shot......\n");
	}
	tls_netif_add_status_event(sock_fwup_net_status_changed_event);

	for(;;) 
	{
		tls_os_queue_receive(demo_sock_fwup_q, (void **)&msg, 0, 0);
		//printf("\n msg =%d\n",msg);
		switch((u32)msg)
		{
			case DEMO_MSG_WJOIN_SUCCESS:
				break;
				
			case DEMO_MSG_SOCKET_CREATE:
				create_socket_fwup_demo();
				break;
				
			case DEMO_MSG_WJOIN_FAILD:
				break;

			case DEMO_MSG_SOCKET_ERR:
				printf("\nsocket err\n");
				break;

			default:
				break;
		}
	}

}
Exemplo n.º 4
0
static void demo_oneshot_task(void *sdata)
{
	//ST_Demo_Sys *sys = (ST_Demo_Sys *)sdata;
	void *msg;
	struct tls_param_ip ip_param;

	tls_param_get(TLS_PARAM_ID_IP, &ip_param, TRUE);
	ip_param.dhcp_enable = true;
	tls_param_set(TLS_PARAM_ID_IP, &ip_param, TRUE);

	tls_wifi_set_oneshot_flag(1);		/*一键配置使能*/
	tls_netif_add_status_event(con_net_status_changed_event);
	printf("\nwait one shot......\n");
	for(;;) 
	{
		tls_os_queue_receive(demo_oneshot_q, (void **)&msg, 0, 0);
		//printf("\n msg =%d\n",msg);
		switch((u32)msg)
		{
			case DEMO_MSG_WJOIN_SUCCESS:
				break;
				
			case DEMO_MSG_SOCKET_CREATE:
#if TLS_CONFIG_SOCKET_STD
				DemoStdSockOneshotSendMac();		//任选一个		
#endif
#if TLS_CONFIG_SOCKET_RAW
				//DemoRawSockOneshotSendMac();
#endif //TLS_CONFIG_SOCKET_RAW
				break;
				
			case DEMO_MSG_WJOIN_FAILD:
				break;
			default:
				break;
		}
	}

}
static void demo_raw_sock_s_task(void *sdata)
{
	ST_Demo_Sys *sys = (ST_Demo_Sys *)sdata;
	void *msg;
	struct tls_ethif * ethif = tls_netif_get_ethif();
	
	printf("\nraw sock s task\n");
//用于socket接收数据使用
	sys->sock_rx = tls_mem_alloc(DEMO_BUF_SIZE);
	if(NULL == sys->sock_rx)
	{
		printf("\nmalloc socket rx fail\n");
		return;
	}
	memset(sys->sock_rx, 0, DEMO_BUF_SIZE);	
//////	
	if(ethif->status)	//已经在网
	{
		tls_os_queue_send(demo_raw_sock_s_q, (void *)DEMO_MSG_SOCKET_CREATE, 0);
	}
	else
	{
		struct tls_param_ip ip_param;
		
		tls_param_get(TLS_PARAM_ID_IP, &ip_param, TRUE);
		ip_param.dhcp_enable = true;
		tls_param_set(TLS_PARAM_ID_IP, &ip_param, TRUE);

		tls_wifi_set_oneshot_flag(1);		/*一键配置使能*/
		printf("\nwait one shot......\n");
	}
	tls_netif_add_status_event(raw_sock_s_net_status_changed_event);
	for(;;) 
	{
		tls_os_queue_receive(demo_raw_sock_s_q, (void **)&msg, 0, 0);
		//printf("\n msg =%d\n",msg);
		switch((u32)msg)
		{
			case DEMO_MSG_WJOIN_SUCCESS:
				break;
				
			case DEMO_MSG_SOCKET_CREATE:
				create_raw_socket_server_demo();
				break;
				
			case DEMO_MSG_WJOIN_FAILD:
				if(sys->socket_num > 0)
				{
					sys->socket_num = 0;
					sys->socket_ok = FALSE;
				}
				break;

			case DEMO_MSG_SOCKET_RECEIVE_DATA:
				/*收到数据,自行处理*/
#if	(TLS_CONFIG_UART)
				tls_uart_tx(sys->sock_rx,sys->sock_data_len);	/*发到串口上显示*/
#endif
				break;

			case DEMO_MSG_SOCKET_ERR:
				tls_os_time_delay(200);
				printf("\nsocket err\n");
				tls_socket_create(&socket_desc);
				break;

			default:
				break;
		}
	}

}