WiFi shows connection but cannot ping

 hello everyone,

  I have a problem.I want to use gt202wifi module to be a hotspot that can continuously send information.Now, I can connect it with other devices, but I can't ping IP. The following is my code and configuration, I hope to get help, thank you very much.

#include "WiFi_AP_thread.h"

void my_ap_wifi_callback(sf_wifi_callback_args_t * p_args)
{

}
;
static int wifi_module_provision(void)
{
sf_wifi_provisioning_t g_provision_info;
ssp_err_t ssp_err = SSP_SUCCESS;

/** Set other provisioning configuration */
g_provision_info.mode = SF_WIFI_INTERFACE_MODE_AP;
g_provision_info.security = SF_WIFI_SECURITY_TYPE_WPA2; /* change this setting to work with other Security types*/
g_provision_info.encryption = SF_WIFI_ENCRYPTION_TYPE_AUTO;
g_provision_info.p_callback = my_ap_wifi_callback;
g_provision_info.channel = 10;


strcpy((char *)&g_provision_info.ssid, "YYK_ap");
strcpy((char *)&g_provision_info.key, "12345678");

/*call the Wi-Fi module provision API*/
ssp_err = g_sf_wifi0.p_api->provisioningSet(g_sf_wifi0.p_ctrl, &g_provision_info);

if(ssp_err)
{

return 1;
}
else
{
return 0;
}

}
#define START_IP_ADDRESS_LIST IP_ADDRESS(192,168,1,1)
#define END_IP_ADDRESS_LIST IP_ADDRESS(192,168,1,10)
static UINT status;
static void DHCP_Server_Start(void)
{
UINT addresses_added;
status = nx_dhcp_create_server_ip_address_list(
&g_dhcp_server0,
0,
START_IP_ADDRESS_LIST,
END_IP_ADDRESS_LIST,
&addresses_added
);
if(status !=0 )
{
while(1)tx_thread_sleep (10);
}
status = nx_dhcp_set_interface_network_parameters(&g_dhcp_server0, 0,NX_DHCP_SUBNET_MASK,IP_ADDRESS(192,168,1,0), IP_ADDRESS(192,168,1,0));
if(status !=0 )
{
while(1)tx_thread_sleep (10);
}
/* Start the DHCP Server. */
status = nx_dhcp_server_start(&g_dhcp_server0);
if(status !=0 )
{
while(1)tx_thread_sleep (10);
}
}
/* WiFi AP Thread entry function */
//extern int wait_for_link(void);
void WiFi_AP_thread_entry(void)
{
/* TODO: add your own code here */
int returnstatus = 0;
g_ioport.p_api->pinWrite(IOPORT_PORT_06_PIN_00, IOPORT_LEVEL_HIGH);
g_ioport.p_api->pinWrite(IOPORT_PORT_06_PIN_01, IOPORT_LEVEL_HIGH);
g_ioport.p_api->pinWrite(IOPORT_PORT_06_PIN_02, IOPORT_LEVEL_HIGH);
tx_thread_sleep(3000);
status = nx_ip_address_set(&g_ip0,IP_ADDRESS(192,168,0,1),NX_DHCP_SUBNET_MASK);
g_ioport.p_api->pinWrite(IOPORT_PORT_06_PIN_00, IOPORT_LEVEL_LOW);
g_ioport.p_api->pinWrite(IOPORT_PORT_06_PIN_01, IOPORT_LEVEL_LOW);
g_ioport.p_api->pinWrite(IOPORT_PORT_06_PIN_02, IOPORT_LEVEL_LOW);
if(status !=0 )
{
while(1)tx_thread_sleep (10);
}
dhcp_server_init0();

if (returnstatus == 0) /* network link is established */
{
returnstatus = wifi_module_provision(); /*provision the Wi-Fi module */
g_ioport.p_api->pinWrite(IOPORT_PORT_06_PIN_00, IOPORT_LEVEL_HIGH);
g_ioport.p_api->pinWrite(IOPORT_PORT_06_PIN_01, IOPORT_LEVEL_HIGH);
g_ioport.p_api->pinWrite(IOPORT_PORT_06_PIN_02, IOPORT_LEVEL_HIGH);
if (returnstatus == 0)
{
DHCP_Server_Start();
while (1)
{
tx_thread_sleep (10);
}
}

}
while (1)
{
tx_thread_sleep (10);
}
}
void tx_application_define_user(void * first_unused_memory)
{
R_BSP_SoftwareDelay(2,BSP_DELAY_UNITS_SECONDS);
}

  • Hi ghg,

    Please try using a different IP address than 192.168.0.0 (and 192.168.0.255). For example 192.168.0.1 should be fine, then configure DHCP server to assign addresses starting from 192.168.0.2.

    Regards,
    adboc
  • You have set the IP address of the Wifi interface to 192.168.0.1 :-

    status = nx_ip_address_set(&g_ip0,IP_ADDRESS(192,168,0,1),NX_DHCP_SUBNET_MASK);

    but you are using the ip address range :-

    #define START_IP_ADDRESS_LIST IP_ADDRESS(192,168,1,1)
    #define END_IP_ADDRESS_LIST IP_ADDRESS(192,168,1,10)

    for the DHCP server.

    Also, you are setting the default gateway and dns server addresses to 192.168.1.0

    nx_dhcp_set_interface_network_parameters(&g_dhcp_server0, 0,NX_DHCP_SUBNET_MASK,IP_ADDRESS(192,168,1,0), IP_ADDRESS(192,168,1,0));
  • In reply to Jeremy:

    Hi adboc and Jeremy,

    Thank you very much for your reply. I will think carefully about your proposal. If there are follow-up questions in this area, I hope you can answer it for me.

    Best regards,
    ghg