static wiced_result_t send_ping( void ) { const uint32_t ping_timeout = 1000; uint32_t elapsed_ms; wiced_result_t status; wiced_ip_address_t ping_target_ip; wiced_ip_get_gateway_address( WICED_STA_INTERFACE, &ping_target_ip ); status = wiced_ping( WICED_STA_INTERFACE, &ping_target_ip, ping_timeout, &elapsed_ms ); if ( status == WICED_SUCCESS ) { WPRINT_APP_INFO(( "Ping Reply %lums\r\n", elapsed_ms )); } else if ( status == WICED_TIMEOUT ) { WPRINT_APP_INFO(( "Ping timeout\r\n" )); } else { WPRINT_APP_INFO(( "Ping error\r\n" )); } return WICED_SUCCESS; }
// 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); } }