3.1.8.1 Execution
main.c - Initialize the ATWINC15x0, set PS Mode and get the RSSI for the connected AP.
- Code summary:
- Configure the network
parameters in
main.h.
/** Wi-Fi Settings */ #define MAIN_WLAN_SSID "DEMO_AP" /* < Destination SSID */ #define MAIN_WLAN_AUTH M2M_WIFI_SEC_WPA_PSK /* < Security manner */ #define MAIN_WLAN_PSK "12345678" /* < Password for Destination SSID */
- Configure the Power Save
parameters in main.h.
/** PowerSave mode Settings */ #define MAIN_PS_SLEEP_MODE M2M_PS_MANUAL /* M2M_NO_PS / M2M_PS_DEEP_AUTOMATIC / M2M_PS_MANUAL */
- In the
main()
function, set the Power Save mode, based on the define above./* Set defined sleep mode */ if (MAIN_PS_SLEEP_MODE == M2M_PS_MANUAL) { printf("M2M_PS_MANUAL\r\n"); m2m_wifi_set_sleep_mode(MAIN_PS_SLEEP_MODE, 1); } else if (MAIN_PS_SLEEP_MODE == M2M_PS_DEEP_AUTOMATIC) { printf("M2M_PS_DEEP_AUTOMATIC\r\n"); tstrM2mLsnInt strM2mLsnInt; m2m_wifi_set_sleep_mode(M2M_PS_DEEP_AUTOMATIC, 1); strM2mLsnInt.u16LsnInt = M2M_LISTEN_INTERVAL; m2m_wifi_set_lsn_int(&strM2mLsnInt); }
- Connect to the AP.
/* Connect to defined AP. */ m2m_wifi_connect((char *)MAIN_WLAN_SSID, sizeof(MAIN_WLAN_SSID), MAIN_WLAN_AUTH, (void *)MAIN_WLAN_PSK, M2M_WIFI_CH_ALL);
- The ATWINC15x0 goes to
Sleep automatically if Power Save is configured for the
M2M_PS_DEEP_AUTOMATIC
mode. The ATWINC15x0 will wake up upon any request/callback (Wi-Fi/SOCKET) and the host driver will allow the SoC to sleep again after handling the request. However, if Power Save is configured for theM2M_PS_MANUAL
mode, then the application is responsible for explicitly requesting the ATWINC15x0 to enter sleep while specifying the expected sleep time./* Request sleep mode */ if (gu8SleepStatus == MAIN_PS_REQ_SLEEP) { if (MAIN_PS_SLEEP_MODE == M2M_PS_MANUAL) { m2m_wifi_request_sleep(MAIN_REQUEST_SLEEP_TIME); gu8SleepStatus = MAIN_PS_SLEEP; } }
- Configure the network
parameters in
main.h.
- Build the program and download it into the board.
- Start the application.