WINC3400 WiFi BLE Provisioning Profile Demo Example.
Copyright (c) 2019 Microchip Technology Inc. and its subsidiaries.
#include <asf.h>
#include "main.h"
#include "ble_manager.h"
#include "driver/include/m2m_wifi.h"
#include "driver/include/m2m_periph.h"
#include "m2m_ble.h"
#include "at_ble_api.h"
#include "provisioning_app.h"
#include "ble_profiles/wifi_provisioning/wifi_provisioning.h"
Macros | |
#define | APP_BTN_EVENT_BTN1_LONG_PRESS 2 |
#define | APP_BTN_EVENT_BTN1_SHORT_PRESS 1 |
#define | APP_BTN_EVENT_BTN2_LONG_PRESS 8 |
#define | APP_BTN_EVENT_BTN2_SHORT_PRESS 4 |
#define | APP_STATE_COMPLETE 6 |
#define | APP_STATE_IDLE 0 |
#define | APP_STATE_PROVISIONING 2 |
#define | APP_STATE_WAITING_FOR_BUTTON_PRESS 3 |
#define | APP_STATE_WAITING_FOR_PROFIFE_SWITCH 5 |
#define | APP_STATE_WAITING_FOR_WIFI_CONNECTION 4 |
#define | APP_STATE_WAITING_FOR_WIFI_DISCONNECTION 1 |
#define | APP_WIFI_PROV_DISPLAY_NAME ("3400 DEMO") |
#define | CONNECTION_ATTEMPT_CONNECTED 1 |
#define | CONNECTION_ATTEMPT_CONNECTING 0 |
#define | CONNECTION_ATTEMPT_DISCONNECTED 3 |
#define | CONNECTION_ATTEMPT_FAILED 4 |
#define | CONNECTION_ATTEMPT_PROVISIONED 2 |
#define | HEX2ASCII(x) (((x)>=10)? (((x)-10)+'A') : ((x)+'0')) |
#define | STRING_HEADER |
#define | WIFI_CONNECT_TIMEOUT 15000 |
Functions | |
static at_ble_event_parameter_t gu8BleParam | __aligned (4) |
static void | app_ble_wifi_provisioning (void) |
static void | app_button_press_callback (uint8 btn, uint8 press) |
static void | app_main (void) |
static void | app_wifi_handle_event (uint8 u8MsgType, void *pvMsg) |
static void | app_wifi_init (tpfAppWifiCb wifi_cb_func) |
static void | configure_console (void) |
int | main (void) |
uint32 | nmi_inet_addr (char *pcIpAddr) |
static void | wifi_connect_timeout (void) |
Variables | |
uint8_t | app_state = APP_STATE_WAITING_FOR_WIFI_DISCONNECTION |
static volatile uint8 | gu8BtnEvent |
static uint8_t | gu8ConnectionAttempt |
static uint8 | gu8ScanIndex |
static volatile uint8 | gu8WiFiConnectionState = M2M_WIFI_UNDEF |
static uint8_t | led_toggle |
bool volatile | timer_cb_done |
#define APP_BTN_EVENT_BTN1_LONG_PRESS 2 |
Referenced by app_ble_wifi_provisioning(), and app_button_press_callback().
#define APP_BTN_EVENT_BTN1_SHORT_PRESS 1 |
Referenced by app_button_press_callback().
#define APP_BTN_EVENT_BTN2_LONG_PRESS 8 |
Referenced by app_button_press_callback().
#define APP_BTN_EVENT_BTN2_SHORT_PRESS 4 |
Referenced by app_button_press_callback().
#define APP_STATE_COMPLETE 6 |
#define APP_STATE_IDLE 0 |
Referenced by app_ble_wifi_provisioning().
#define APP_STATE_PROVISIONING 2 |
Referenced by app_ble_wifi_provisioning().
#define APP_STATE_WAITING_FOR_BUTTON_PRESS 3 |
#define APP_STATE_WAITING_FOR_PROFIFE_SWITCH 5 |
#define APP_STATE_WAITING_FOR_WIFI_CONNECTION 4 |
Referenced by app_ble_wifi_provisioning().
#define APP_STATE_WAITING_FOR_WIFI_DISCONNECTION 1 |
Referenced by app_ble_wifi_provisioning().
#define APP_WIFI_PROV_DISPLAY_NAME ("3400 DEMO") |
#define CONNECTION_ATTEMPT_CONNECTED 1 |
Referenced by app_ble_wifi_provisioning(), and app_wifi_handle_event().
#define CONNECTION_ATTEMPT_CONNECTING 0 |
Referenced by app_ble_wifi_provisioning(), and app_wifi_handle_event().
#define CONNECTION_ATTEMPT_DISCONNECTED 3 |
Referenced by app_ble_wifi_provisioning(), and app_wifi_handle_event().
#define CONNECTION_ATTEMPT_FAILED 4 |
Referenced by app_ble_wifi_provisioning(), app_wifi_handle_event(), and wifi_connect_timeout().
#define CONNECTION_ATTEMPT_PROVISIONED 2 |
Referenced by app_ble_wifi_provisioning(), and app_wifi_handle_event().
#define HEX2ASCII | ( | x | ) | (((x)>=10)? (((x)-10)+'A') : ((x)+'0')) |
Referenced by app_wifi_init().
#define STRING_HEADER |
Referenced by main().
#define WIFI_CONNECT_TIMEOUT 15000 |
Referenced by app_ble_wifi_provisioning().
|
static |
|
static |
References APP_BTN_EVENT_BTN1_LONG_PRESS, app_state, APP_STATE_IDLE, APP_STATE_PROVISIONING, APP_STATE_WAITING_FOR_WIFI_CONNECTION, APP_STATE_WAITING_FOR_WIFI_DISCONNECTION, AT_BLE_SUCCESS, ble_device_init(), ble_event_manager(), CONNECTION_ATTEMPT_CONNECTED, CONNECTION_ATTEMPT_CONNECTING, CONNECTION_ATTEMPT_DISCONNECTED, CONNECTION_ATTEMPT_FAILED, CONNECTION_ATTEMPT_PROVISIONED, CREDENTIALS_VALID, DEFAULT_AUTH, DEFAULT_KEY, DEFAULT_SSID, gu8BtnEvent, gu8ConnectionAttempt, gu8WiFiConnectionState, initialise_provisioning_app(), m2m_ble_event_get(), m2m_ble_init(), M2M_INFO, M2M_WIFI_CH_ALL, m2m_wifi_connect(), M2M_WIFI_DISCONNECTED, M2M_WIFI_UNDEF, nm_bsp_sleep(), nm_bsp_start_timer(), nm_bsp_stop_timer(), NULL, credentials::passphrase, provision_app_ble_disconnect(), provisioning_app_processing(), retrieve_credentials(), credentials::sec_type, credentials::ssid, credentials::ssid_length, start_provisioning_app(), WIFI_CONNECT_TIMEOUT, wifi_connect_timeout(), WIFI_CONNECTION_STATE_CONNECTING, WIFI_CONNECTION_STATE_PROVISIONED, WIFI_CONNECTION_STATE_PROVISIONFAILED, WIFI_PROVISION_STATE_FAILED, WIFI_PROVISION_STATE_HAVE_CREDENTIAL, and wifi_state_update().
Referenced by app_main().
References APP_BTN_EVENT_BTN1_LONG_PRESS, APP_BTN_EVENT_BTN1_SHORT_PRESS, APP_BTN_EVENT_BTN2_LONG_PRESS, APP_BTN_EVENT_BTN2_SHORT_PRESS, gu8BtnEvent, SW1, and SW2.
Referenced by app_main().
|
static |
References app_ble_wifi_provisioning(), app_button_press_callback(), app_wifi_handle_event(), app_wifi_init(), and nm_bsp_btn_init().
Referenced by main().
|
static |
References CONNECTION_ATTEMPT_CONNECTED, CONNECTION_ATTEMPT_CONNECTING, CONNECTION_ATTEMPT_DISCONNECTED, CONNECTION_ATTEMPT_FAILED, CONNECTION_ATTEMPT_PROVISIONED, gu8ConnectionAttempt, gu8ScanIndex, gu8WiFiConnectionState, M2M_ERR, M2M_INFO, M2M_WIFI_CONNECTED, M2M_WIFI_DISCONNECTED, m2m_wifi_get_num_ap_found(), M2M_WIFI_REQ_DHCP_CONF, m2m_wifi_req_scan_result(), M2M_WIFI_RESP_CON_STATE_CHANGED, M2M_WIFI_RESP_CURRENT_RSSI, M2M_WIFI_RESP_SCAN_DONE, M2M_WIFI_RESP_SCAN_RESULT, M2M_WIFI_RESP_SET_GAIN_TABLE, NM_BSP_TIME_MSEC, tstrM2MGainTableRsp::s8ErrorCode, send_scan_result(), tstrM2MIPConfig::u32StaticIP, tstrM2mWifiStateChanged::u8CurrState, and tstrM2mScanDone::u8NumofCh.
Referenced by app_main().
|
static |
References tstrEthInitParam::au8ethRcvBuf, HEX2ASCII, m2m_ble_wifi_init(), M2M_DEVICE_NAME, M2M_ERR, M2M_INFO, M2M_LISTEN_INTERVAL, m2m_memset(), M2M_NO_PS, m2m_periph_pullup_ctrl(), M2M_PERIPH_PULLUP_DIS_HOST_WAKEUP, M2M_PERIPH_PULLUP_DIS_SD_CMD_SPI_SCK, M2M_PERIPH_PULLUP_DIS_SD_DAT0_SPI_TXD, M2M_PS_DEEP_AUTOMATIC, M2M_PS_MANUAL, m2m_strlen(), M2M_SUCCESS, m2m_wifi_get_mac_address(), m2m_wifi_get_otp_mac_address(), m2m_wifi_set_device_name(), m2m_wifi_set_lsn_int(), m2m_wifi_set_mac_address(), m2m_wifi_set_sleep_mode(), MAC_ADDRESS, tstrEthInitParam::pfAppEthCb, tstrWifiInitParam::pfAppWifiCb, PS_SLEEP_TIME_MS, tstrWifiInitParam::strEthInitParam, tstrEthInitParam::u16ethRcvBufSize, and tstrM2mLsnInt::u16LsnInt.
Referenced by app_main().
|
static |
References uart_rs232_options::baudrate, CONF_UART, CONF_UART_BAUDRATE, CONF_UART_CHAR_LENGTH, CONF_UART_PARITY, CONF_UART_STOP_BITS, CONSOLE_UART_ID, stdio_serial_init(), and sysclk_enable_peripheral_clock().
Referenced by main().
int main | ( | void | ) |
References app_main(), board_init(), configure_console(), F_CPU, nm_bsp_app_init(), nm_bsp_init(), STRING_HEADER, and sysclk_init().
uint32 nmi_inet_addr | ( | char * | pcIpAddr | ) |
Synchronous function which returns a BSD socket compliant Internet Protocol (IPv4) socket address. This IPv4 address in the input string parameter could either be specified as a hostname, or as a numeric string representation like n.n.n.n known as the IPv4 dotted-decimal format (i.e. "192.168.10.1"). This function is used whenever an ip address needs to be set in the proper format (i.e. for the @ref tstrM2MIPConfig structure).
[in] | pcIpAddr | A null terminated string containing the IP address in IPv4 dotted-decimal address. |
|
static |
References CONNECTION_ATTEMPT_FAILED, gu8ConnectionAttempt, M2M_INFO, and nm_bsp_stop_timer().
Referenced by app_ble_wifi_provisioning().
uint8_t app_state = APP_STATE_WAITING_FOR_WIFI_DISCONNECTION |
Referenced by app_ble_wifi_provisioning().
|
static |
Referenced by app_ble_wifi_provisioning(), and app_button_press_callback().
|
static |
Referenced by app_ble_wifi_provisioning(), app_wifi_handle_event(), and wifi_connect_timeout().
|
static |
Referenced by app_wifi_handle_event().
|
static |
Referenced by app_ble_wifi_provisioning(), and app_wifi_handle_event().
|
static |
bool volatile timer_cb_done |