Microchip® Advanced Software Framework

common/components/wifi/winc1500/exosite_demo/main.c File Reference
#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_infop_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"
#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

Referenced by main(), and parsing_http_response_data().

state enum value for sequence

Enumerator
MAIN_NEED_TO_CHECK_AP_INFORMATION 
MAIN_CHECKING_AP_INFORMATION 
MAIN_NEED_HTTP_PROVISIONING 
MAIN_DOING_AP_HTTP_PROVISIONING 
MAIN_AP_CONNECTION 

int main ( void  )

Main application function.

Application entry point.

Returns
program return value.

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(), mac_addr, 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(), ret, 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 void set_dev_name_to_mac ( uint8 name,
uint8 mac_addr 
)
static

Copy MAC address to string.

References HEX2ASCII, len, and m2m_strlen().

Referenced by main().

static void wifi_cb ( uint8_t  u8MsgType,
void *  pvMsg 
)
static

exosite_connect_state ap_exosite_connection_state = MAIN_NEED_TO_CHECK_AP_INFORMATION
static

AP Connection state.

Referenced by main(), and wifi_cb().

struct usart_module cdc_uart_module
static

UART module for debug.

uint32_t exosite_translate_state
static

Exosite send state.

Referenced by main(), and parsing_http_response_data().

sint8 gacDeviceName[] = MAIN_M2M_DEVICE_NAME
static

Device name for AP mode.

Referenced by main().

CONST char gacHttpProvDomainName[] = MAIN_HTTP_PROV_SERVER_DOMAIN_NAME
static

Doname name for AP mode.

uint8 gau8MacAddr[] = MAIN_MAC_ADDRESS
static

If mac address in the board doesn't exist, used it.

Referenced by main().

tstrM2MAPConfig gstrM2MAPConfig
static
Initial value:
= {
1,
0,
}
#define MAIN_M2M_DEVICE_NAME
Definition: common/components/wifi/winc1500/exosite_demo/main.c:92
#define WEP_40_KEY_STRING_SIZE
Definition: winc3400/wifi_drv/driver/include/m2m_types.h:351
#define MAIN_M2M_AP_SEC
Definition: common/components/wifi/winc1500/exosite_demo/main.c:85
#define MAIN_M2M_AP_SSID_MODE
Definition: common/components/wifi/winc1500/exosite_demo/main.c:87
#define MAIN_M2M_AP_WEP_KEY
Definition: common/components/wifi/winc1500/exosite_demo/main.c:86
#define MAIN_M2M_DHCP_SERVER_IP
Definition: common/components/wifi/winc1500/exosite_demo/main.c:88
io1_board_info* p_board_info = NULL
static