hi everyone,
My hotspot can be connected via a mobile phone, but it cannot be connected via a computer. I want to know why. I want to implement the microcontroller as a server and send the information to any device connected to it. How can I do it?
#include "WiFi_AP_thread.h"
#include "nx_api.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 = 11;
nx_system_initialize();
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,100)
#define END_IP_ADDRESS_LIST IP_ADDRESS(192,168,1,154)
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,2), IP_ADDRESS(192,168,1,4));
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 udp()
{
}
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,1,2),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_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);
}