3.1.3.1 Execution
main.c - Initialize the ATWINC15x0/ATWINC3400 and connect to the AP as a station.
- 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 type */ #define MAIN_WLAN_PSK "12345678" /* < Password for Destination SSID */
- Connect the
ATWINC15x0/ATWINC3400 to the AP via the
m2m_wifi_connect()
function.
/* 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);
- Call
m2m_wifi_req_curr_rssi()
to request the current RSSI.static void wifi_cb(uint8_t u8MsgType, void *pvMsg) { case M2M_WIFI_REQ_DHCP_CONF: { /* Request RSSI for the connected AP. */ m2m_wifi_req_curr_rssi();
- The application will get
the RSSI value when the
wifi_cb()
function is called with aM2M_WIFI_RESP_CURRENT_RSSI
message.static void wifi_cb(uint8_t u8MsgType, void *pvMsg) { case M2M_WIFI_RESP_CURRENT_RSSI: { /* This message type is triggered by "m2m_wifi_req_curr_rssi()" function. */ int8_t *rssi = (int8_t *)pvMsg; printf("RSSI for the current connected AP (%d)\r\n", (int8_t)(*rssi));
- Configure the network
parameters in
main.h.
- Build the program and download it into the board.
- Start the application.