3.1.5.1 Execution
main.c - Initialize the ATWINC15x0/ATWINC3400 and act as an AP.
- Code summary:
- Configure the network
parameters in
main.h.
/** Security mode Supported */ #define USE_WPAPSK 1 /* WPA/WPA2 PSK Security Mode*/ // #define USE_WEP 2 /* WEP Security Mode*/ // #define USE_OPEN 3 /* No Security or OPEN Authentication Mode*/ /** AP mode Settings */ #define MAIN_WLAN_SSID "WINC1500_AP" /* < SSID */ #if (defined USE_WPAPSK) #define MAIN_WLAN_AUTH M2M_WIFI_SEC_WPA_PSK /* < Security type */ #define MAIN_WLAN_WPA_PSK "1234567890" /* < Security Key in WPA PSK Mode */ #elif (defined USE_WEP) #define MAIN_WLAN_AUTH M2M_WIFI_SEC_WEP /* < Security type */ #define MAIN_WLAN_WEP_KEY "1234567890" /* < Security Key in WEP Mode */ #define MAIN_WLAN_WEP_KEY_INDEX (0) #elif (defined USE_OPEN) #define MAIN_WLAN_AUTH M2M_WIFI_SEC_OPEN /* < Security type */ #endif #define MAIN_WLAN_CHANNEL (M2M_WIFI_CH_6) /* < Channel number */
- In the
main() function, initializes the AP mode
configuration structure (
strM2MAPConfig
) , see the following example. User can enable the AP mode viam2m_wifi_enable_ap()
function. Users may choose any of the available security methods according to the requirements./* Initialize AP mode parameters structure with SSID, channel and OPEN security type. */ memset(&strM2MAPConfig, 0x00, sizeof(tstrM2MAPConfig)); strcpy((char *)&strM2MAPConfig.au8SSID, MAIN_WLAN_SSID); strM2MAPConfig.u8ListenChannel = MAIN_WLAN_CHANNEL; strM2MAPConfig.u8SecType = MAIN_WLAN_AUTH; strM2MAPConfig.au8DHCPServerIP[0] = 192; strM2MAPConfig.au8DHCPServerIP[1] = 168; strM2MAPConfig.au8DHCPServerIP[2] = 1; strM2MAPConfig.au8DHCPServerIP[3] = 1; #if USE_WEP strcpy((char *)&strM2MAPConfig.au8WepKey, MAIN_WLAN_WEP_KEY); strM2MAPConfig.u8KeySz = strlen(MAIN_WLAN_WEP_KEY); strM2MAPConfig.u8KeyIndx = MAIN_WLAN_WEP_KEY_INDEX; #endif #if USE_WPAPSK strcpy((char *)&strM2MAPConfig.au8Key, MAIN_WLAN_WPA_PSK); strM2MAPConfig.u8KeySz = strlen(MAIN_WLAN_WPA_PSK); #endif /* Bring up AP mode with parameters structure. */ ret = m2m_wifi_enable_ap(&strM2MAPConfig); printf("AP mode started. You can connect to %s.\r\n", (char *)MAIN_WLAN_SSID);
- Configure the network
parameters in
main.h.
- Build the program and download it into the board.
- Start the application.