Пример #1
0
void application_thread_main( ULONG thread_input )
{
    UNUSED_PARAMETER( thread_input);

#ifndef WICED_DISABLE_WATCHDOG
    /* Start the watchdog kicking thread */
    wiced_rtos_create_thread( &system_monitor_thread_handle, RTOS_HIGHEST_PRIORITY, "system monitor", (wiced_thread_function_t)system_monitor_thread_main, SYSTEM_MONITOR_THREAD_STACK_SIZE, NULL );
#endif /* WICED_DISABLE_WATCHDOG */

#ifdef TX_ENABLE_EVENT_TRACE
    {
        wiced_result_t        result;
        wiced_tracex_config_t tracex_config;

        tracex_config.loop_rec = WICED_FALSE;
        tracex_config.filter = 0;
        tracex_config.tcp_server.enable = WICED_FALSE;
        tracex_config.tcp_server.port = WICED_TRACEX_TCP_SERVER_PORT;
        tracex_config.tcp_server.max_data_len = WICED_TRACEX_TCP_MAX_PACKET_LENGTH;
        tracex_config.tcp_server.timeout = WICED_TRACEX_TCP_CONNECT_TIMEOUT;
        tracex_config.tcp_server.num_retries = WICED_TRACEX_TCP_CONNECTION_NUM_RETRIES;
        SET_IPV4_ADDRESS(tracex_config.tcp_server.ip, WICED_TRACEX_TCP_SERVER_IP);
        tracex_config.buf.addr = WICED_TRACEX_BUFFER_ADDRESS;
        tracex_config.buf.size = WICED_TRACEX_BUFFER_SIZE;
        tracex_config.buf.obj_cnt = WICED_TRACEX_OBJECT_COUNT;

        result = wiced_tracex_enable(&tracex_config);
        wiced_assert( "TraceX enable failed", result == WICED_SUCCESS );
        REFERENCE_DEBUG_ONLY_VARIABLE( result );
    }
#endif /* TX_ENABLE_EVENT_TRACE */

    application_start( );
    malloc_leak_check(NULL, LEAK_CHECK_THREAD);
}
// Some APs will not stay attached if you don't talk periodically.
// This thread will ping every 60 seconds
void pingAP (wiced_thread_arg_t arg)
{
    uint32_t time_elapsed;
    wiced_ip_address_t routerAddress;
    wiced_result_t result;

    while(1)
    {
        SET_IPV4_ADDRESS(routerAddress,MAKE_IPV4_ADDRESS( 198, 51, 100,  1 ));
        result = wiced_ping (INTERFACE, &routerAddress, 500, &time_elapsed);
        if(result != WICED_SUCCESS)
        {
            WPRINT_APP_INFO(("Ping Failed\n"));
        }

        wiced_rtos_delay_milliseconds(60000);
    }
}
Пример #3
0
/*
 * Function:    wilddog_gethostbyname
 * Description: wilddog gethostbyname function, it use the interface in wiced platform.
 * Input:        host: The pointer of host string.
 * Output:      addr: The pointer of the Wilddog_Address_T.
 * Return:      If success, return 0; else return -1.
*/
int wilddog_gethostbyname( Wilddog_Address_T* addr, char* host )
{
    wiced_ip_address_t address;
    uint32_t tmpIp = 0;
    uint32_t dns_ip;

    addr->len = 4;
    /* Add free DNS server (114.114.114.114) */
    dns_ip = WILDDOG_MAKE_IPV4(114,114,114,114);
    SET_IPV4_ADDRESS( address, &dns_ip );
    dns_client_add_server_address( address );
    if ( wiced_hostname_lookup( host, &address, 4000 ) != WICED_SUCCESS )
    {
        return -1;
    }
    tmpIp = address.ip.v4;
    tmpIp = wilddog_htonl(tmpIp);
    memcpy( addr->ip, &tmpIp, 4 );

    return 0;
}