#include "asf.h"
#include "debug_conf.h"
#include "driver/include/m2m_wifi.h"
#include "driver/source/nmasic.h"
#include "socket/include/socket.h"
#include "tick_counter.h"
#include "io1_board.h"
#include "exosite_example.h"
Macros | |
#define | HEX2ASCII(x) (((x) >= 10) ? (((x) - 10) + 'A') : ((x) + '0')) |
#define | MAIN_ACTIVITE_STATE 1 |
#define | MAIN_CIK_KEY_STRING "cik" |
#define | MAIN_EXOSITE_ACTIVATE_DATA_FORMAT "vendor=%s&model=%s&sn=%s" |
#define | MAIN_HTTP_PROV_SERVER_DOMAIN_NAME "atmelconfig.com" |
#define | MAIN_LED_KEY_STRING "led" |
#define | MAIN_M2M_AP_SEC M2M_WIFI_SEC_OPEN |
#define | MAIN_M2M_AP_SSID_MODE SSID_MODE_VISIBLE |
#define | MAIN_M2M_AP_WEP_KEY "1234567890" |
#define | MAIN_M2M_DEVICE_NAME "WINC1500_00:00" |
#define | MAIN_M2M_DHCP_SERVER_IP {192, 168, 1, 1} |
#define | MAIN_MAC_ADDRESS {0xf8, 0xf0, 0x05, 0x45, 0xD4, 0x84} |
#define | MAIN_RES_HTTP_CODE_200 200 |
#define | MAIN_RES_HTTP_CODE_204 204 |
#define | MAIN_RES_HTTP_CODE_401 401 |
#define | MAIN_RES_HTTP_CODE_404 404 |
#define | MAIN_RES_HTTP_CODE_409 409 |
#define | MAIN_SENSOR_DATA_TRANSLATE_STATE 0 |
Enumerations | |
enum | exosite_connect_state { MAIN_NEED_TO_CHECK_AP_INFORMATION, MAIN_CHECKING_AP_INFORMATION, MAIN_NEED_HTTP_PROVISIONING, MAIN_DOING_AP_HTTP_PROVISIONING, MAIN_AP_CONNECTION } |
state enum value for sequence More... | |
Functions | |
static void | configure_console (void) |
Configure UART console. More... | |
int | main (void) |
Main application function. More... | |
static void | main_http_client_callback (struct http_client_module *module_inst, int type, union http_client_data *data) |
Callback of the HTTP client. More... | |
static void | parsing_http_response_data (int response_code, char *response_data, int response_length) |
static void | set_dev_name_to_mac (uint8 *name, uint8 *mac_addr) |
Copy MAC address to string. More... | |
static void | wifi_cb (uint8_t u8MsgType, void *pvMsg) |
Callback to get the Wi-Fi status update. More... | |
Variables | |
static exosite_connect_state | ap_exosite_connection_state = MAIN_NEED_TO_CHECK_AP_INFORMATION |
AP Connection state. More... | |
static struct usart_module | cdc_uart_module |
UART module for debug. More... | |
static uint32_t | exosite_translate_state |
Exosite send state. More... | |
static sint8 | gacDeviceName [] = MAIN_M2M_DEVICE_NAME |
Device name for AP mode. More... | |
static CONST char | gacHttpProvDomainName [] = MAIN_HTTP_PROV_SERVER_DOMAIN_NAME |
Doname name for AP mode. More... | |
static uint8 | gau8MacAddr [] = MAIN_MAC_ADDRESS |
If mac address in the board doesn't exist, used it. More... | |
static tstrM2MAPConfig | gstrM2MAPConfig |
static io1_board_info * | p_board_info = NULL |
#define HEX2ASCII | ( | x | ) | (((x) >= 10) ? (((x) - 10) + 'A') : ((x) + '0')) |
Referenced by set_dev_name_to_mac().
#define MAIN_ACTIVITE_STATE 1 |
Referenced by main(), and parsing_http_response_data().
#define MAIN_CIK_KEY_STRING "cik" |
#define MAIN_EXOSITE_ACTIVATE_DATA_FORMAT "vendor=%s&model=%s&sn=%s" |
Referenced by main().
#define MAIN_HTTP_PROV_SERVER_DOMAIN_NAME "atmelconfig.com" |
#define MAIN_LED_KEY_STRING "led" |
Referenced by parsing_http_response_data().
#define MAIN_M2M_AP_SEC M2M_WIFI_SEC_OPEN |
#define MAIN_M2M_AP_SSID_MODE SSID_MODE_VISIBLE |
#define MAIN_M2M_AP_WEP_KEY "1234567890" |
#define MAIN_M2M_DEVICE_NAME "WINC1500_00:00" |
#define MAIN_M2M_DHCP_SERVER_IP {192, 168, 1, 1} |
#define MAIN_MAC_ADDRESS {0xf8, 0xf0, 0x05, 0x45, 0xD4, 0x84} |
#define MAIN_RES_HTTP_CODE_200 200 |
Referenced by parsing_http_response_data().
#define MAIN_RES_HTTP_CODE_204 204 |
Referenced by parsing_http_response_data().
#define MAIN_RES_HTTP_CODE_401 401 |
Referenced by parsing_http_response_data().
#define MAIN_RES_HTTP_CODE_404 404 |
Referenced by parsing_http_response_data().
#define MAIN_RES_HTTP_CODE_409 409 |
Referenced by parsing_http_response_data().
#define MAIN_SENSOR_DATA_TRANSLATE_STATE 0 |
Referenced by main(), and parsing_http_response_data().
|
static |
Configure UART console.
References usart_config::baudrate, cdc_uart_module, EDBG_CDC_MODULE, EDBG_CDC_SERCOM_MUX_SETTING, EDBG_CDC_SERCOM_PINMUX_PAD0, EDBG_CDC_SERCOM_PINMUX_PAD1, EDBG_CDC_SERCOM_PINMUX_PAD2, EDBG_CDC_SERCOM_PINMUX_PAD3, usart_config::mux_setting, usart_config::pinmux_pad0, usart_config::pinmux_pad1, usart_config::pinmux_pad2, usart_config::pinmux_pad3, usart_enable(), and usart_get_config_defaults().
Referenced by main().
int main | ( | void | ) |
Main application function.
Application entry point.
References ap_exosite_connection_state, tstrM2MAPConfig::au8SSID, _io1_board_info::board_id, _io1_board_info::board_sn, _io1_board_info::board_vendor, _io1_board_info::cik, configure_console(), DEBUG, DEBUG_CONF_WIFI, DEBUG_EOL, DEBUG_STRING_HEADER, exosite_example_activiate(), exosite_example_init(), exosite_example_read_and_write(), exosite_translate_state, gacDeviceName, gacHttpProvDomainName, gau8MacAddr, http_client_socket_event_handler(), http_client_socket_resolve_handler(), io1_board_get_info(), io1_board_get_lightvalue(), io1_board_get_temperature(), io1_board_init(), io1_board_prepare_to_get_info(), _io1_board_info::is_activate, M2M_PS_AUTOMATIC, m2m_strlen(), M2M_SUCCESS, m2m_wifi_default_connect(), m2m_wifi_get_mac_address(), m2m_wifi_get_otp_mac_address(), m2m_wifi_handle_events(), m2m_wifi_init(), m2m_wifi_set_device_name(), m2m_wifi_set_mac_address(), m2m_wifi_set_sleep_mode(), m2m_wifi_start_provision_mode(), MAIN_ACTIVITE_STATE, MAIN_AP_CONNECTION, MAIN_CHECKING_AP_INFORMATION, MAIN_DOING_AP_HTTP_PROVISIONING, MAIN_EXOSITE_ACTIVATE_DATA_FORMAT, main_http_client_callback(), MAIN_NEED_HTTP_PROVISIONING, MAIN_NEED_TO_CHECK_AP_INFORMATION, MAIN_SENSOR_DATA_TRANSLATE_STATE, nm_bsp_init(), NULL, tstrWifiInitParam::pfAppWifiCb, registerSocketCallback(), set_dev_name_to_mac(), socketInit(), system_cpu_clock_get_hz(), system_init(), system_set_sleepmode(), system_sleep(), SYSTEM_SLEEPMODE_IDLE_0, tick_counter_check_timer(), and wifi_cb().
|
static |
Callback of the HTTP client.
[in] | module_inst | Module instance of HTTP client module. |
[in] | type | Type of event. |
[in] | data | Data structure of the event. http_client_data |
References http_client_data_recv_response::content, http_client_data_recv_response::content_length, DEBUG, DEBUG_CONF_EXOSITE, DEBUG_EOL, http_client_data::disconnected, HTTP_CLIENT_CALLBACK_DISCONNECTED, HTTP_CLIENT_CALLBACK_RECV_RESPONSE, HTTP_CLIENT_CALLBACK_REQUESTED, HTTP_CLIENT_CALLBACK_SOCK_CONNECTED, parsing_http_response_data(), http_client_data_disconnected::reason, http_client_data::recv_response, http_client_data_recv_response::response_code, TICK_COUNTER_INTERVAL, and tick_counter_reset_timer().
Referenced by main().
|
static |
References DEBUG, DEBUG_CONF_EXOSITE, DEBUG_EOL, exosite_translate_state, io1_board_reset_cik_value(), io1_board_save_cik_value_to_sd(), io1_board_set_led(), MAIN_ACTIVITE_STATE, MAIN_LED_KEY_STRING, MAIN_RES_HTTP_CODE_200, MAIN_RES_HTTP_CODE_204, MAIN_RES_HTTP_CODE_401, MAIN_RES_HTTP_CODE_404, MAIN_RES_HTTP_CODE_409, MAIN_SENSOR_DATA_TRANSLATE_STATE, and NULL.
Referenced by main_http_client_callback().
|
static |
Callback to get the Wi-Fi status update.
[in] | u8MsgType | type of Wi-Fi notification. Possible types are: |
[in] | pvMsg | A pointer to a buffer containing the notification parameters (if any). It should be casted to the correct data type corresponding to the notification type. |
References ap_exosite_connection_state, tstrM2MProvisionInfo::au8Password, tstrM2MProvisionInfo::au8SSID, DEBUG, DEBUG_CONF_SOCKET, DEBUG_CONF_WIFI, DEBUG_EOL, M2M_SUCCESS, M2M_WIFI_CH_ALL, m2m_wifi_connect(), M2M_WIFI_CONNECTED, M2M_WIFI_DISCONNECTED, M2M_WIFI_REQ_DHCP_CONF, m2m_wifi_request_dhcp_client(), M2M_WIFI_RESP_CON_STATE_CHANGED, M2M_WIFI_RESP_DEFAULT_CONNECT, M2M_WIFI_RESP_PROVISION_INFO, MAIN_AP_CONNECTION, MAIN_NEED_HTTP_PROVISIONING, tstrM2MDefaultConnResp::s8ErrorCode, tick_counter_reset_timer(), tstrM2mWifiStateChanged::u8CurrState, tstrM2MProvisionInfo::u8SecType, and tstrM2MProvisionInfo::u8Status.
Referenced by main().
|
static |
|
static |
UART module for debug.
Referenced by configure_console().
|
static |
Exosite send state.
Referenced by main(), and parsing_http_response_data().
|
static |
Device name for AP mode.
Referenced by main().
|
static |
Doname name for AP mode.
Referenced by main().
|
static |
If mac address in the board doesn't exist, used it.
Referenced by main().
|
static |
|
static |