IoT Temperature Sensor Demo.
Copyright (c) 2016-2018 Microchip Technology Inc. and its subsidiaries.
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include "asf.h"
#include "demo.h"
#include "driver/include/m2m_wifi.h"
#include "socket/include/socket.h"
#include "conf_winc.h"
Data Structures | |
struct | s_msg_temp_keepalive |
struct | s_msg_temp_report |
struct | s_msg_user_input |
Message format definitions. More... | |
Macros | |
#define | TEST_BUFFER_SIZE 1460 |
Receive buffer definition. More... | |
Typedefs | |
typedef struct s_msg_temp_keepalive | t_msg_temp_keepalive |
typedef struct s_msg_temp_report | t_msg_temp_report |
typedef struct s_msg_user_input | t_msg_user_input |
Message format definitions. More... | |
Functions | |
static int32_t | button_press_duration (bool current_button_state) |
Get duration of the button pressed. More... | |
void | demo_start (void) |
Demo main function. More... | |
static void | demo_wifi_socket_handler (SOCKET sock, uint8 u8Msg, void *pvMsg) |
Callback to get the Data from socket. More... | |
static void | demo_wifi_state (uint8 u8MsgType, void *pvMsg) |
Callback to get the WiFi status update. More... | |
static void | parse_user_input (char *user_input) |
Parse user input data. More... | |
static void | print_provisioning_details (void) |
Print provisioning information. More... | |
Variables | |
tstrM2MAPConfig | ap_config |
Configure and enable access point mode with provisioning page. More... | |
static uint32_t | delay = 0 |
Global counter delay for timer. More... | |
char | gacHttpProvDomainName [] = DEMO_WLAN_AP_DOMAIN_NAME |
uint8 | gau8HttpProvServerIP [] = DEMO_WLAN_AP_IP_ADDRESS |
static uint8 | gau8SocketTestBuffer [TEST_BUFFER_SIZE] |
uint32_t | ms_ticks |
SysTick counter for non busy wait delay. More... | |
static t_msg_temp_keepalive | msg_temp_keepalive |
Message format declarations. More... | |
static t_msg_temp_report | msg_temp_report |
char | provision_pwd [30] |
char | provision_ssid [70] |
static SOCKET | rx_socket = -1 |
RX and TX socket descriptors. More... | |
static uint32_t | toggle_led_ms = 0 |
Global counters for LED toggling. More... | |
static SOCKET | tx_socket = -1 |
char | user_credentials [108] |
static t_msg_user_input | user_data |
static volatile uint8 | wifi_connected = 0 |
WiFi status variable. More... | |
static uint8 | wifi_provisioned = 1 |
#define TEST_BUFFER_SIZE 1460 |
Receive buffer definition.
Referenced by demo_wifi_socket_handler().
typedef struct s_msg_temp_keepalive t_msg_temp_keepalive |
typedef struct s_msg_temp_report t_msg_temp_report |
typedef struct s_msg_user_input t_msg_user_input |
Message format definitions.
|
static |
Get duration of the button pressed.
References ms_ticks.
Referenced by demo_start().
void demo_start | ( | void | ) |
Demo main function.
References _htons, AF_INET, at30tse_init(), at30tse_read_temperature(), bind(), button_press_duration(), s_msg_user_input::channel, delay, delay_ms, DEMO_REPORT_INTERVAL, DEMO_SERVER_PORT, demo_wifi_socket_handler(), demo_wifi_state(), gacHttpProvDomainName, s_msg_temp_report::led, LED_0_PIN, M2M_SUCCESS, m2m_wifi_connect(), m2m_wifi_default_connect(), m2m_wifi_disable_ap(), m2m_wifi_handle_events(), m2m_wifi_init(), m2m_wifi_start_provision_mode(), ms_ticks, nm_bsp_init(), NULL, parse_user_input(), s_msg_user_input::password, tstrWifiInitParam::pfAppWifiCb, port_pin_get_input_level(), port_pin_get_output_level(), port_pin_toggle_output_level(), print_provisioning_details(), registerSocketCallback(), rx_socket, in_addr::s_addr, s_msg_user_input::security, sendto(), sockaddr_in::sin_addr, sockaddr_in::sin_family, sockaddr_in::sin_port, SOCK_DGRAM, socket(), socketInit(), s_msg_user_input::SSID, s_msg_temp_report::temp, toggle_led_ms, tx_socket, user_credentials, wifi_connected, and wifi_provisioned.
Referenced by main().
Callback to get the Data from socket.
[in] | sock | socket handler. |
[in] | u8Msg | socket event type. Possible values are:
|
[in] | pvMsg | is a pointer to message structure. Existing types are: |
References delay, DEMO_PRODUCT_NAME, gau8SocketTestBuffer, s_msg_temp_report::id0, s_msg_temp_report::id1, s_msg_temp_report::led, LED_0_PIN, s_msg_temp_report::name, port_pin_set_output_level(), tstrSocketRecvMsg::pu8Buffer, recvfrom(), rx_socket, tstrSocketRecvMsg::s16BufferSize, SOCK_ERR_TIMEOUT, SOCKET_MSG_BIND, SOCKET_MSG_RECVFROM, tstrSocketBindMsg::status, and TEST_BUFFER_SIZE.
Referenced by demo_start().
|
static |
Callback to get the WiFi status update.
[in] | u8MsgType | type of WiFi 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. Existing types are:
|
References tstrM2MConnInfo::acSSID, tstrM2MProvisionInfo::au8Password, tstrM2MProvisionInfo::au8SSID, s_msg_user_input::channel, gacHttpProvDomainName, LED_0_PIN, M2M_DEFAULT_CONN_EMPTY_LIST, M2M_DEFAULT_CONN_SCAN_MISMATCH, M2M_SUCCESS, M2M_WIFI_CH_ALL, m2m_wifi_connect(), M2M_WIFI_CONNECTED, M2M_WIFI_DISCONNECTED, m2m_wifi_get_connection_info(), M2M_WIFI_REQ_DHCP_CONF, m2m_wifi_request_dhcp_client(), M2M_WIFI_RESP_CON_STATE_CHANGED, M2M_WIFI_RESP_CONN_INFO, M2M_WIFI_RESP_DEFAULT_CONNECT, M2M_WIFI_RESP_PROVISION_INFO, M2M_WIFI_SEC_OPEN, m2m_wifi_start_provision_mode(), s_msg_user_input::password, port_pin_set_output_level(), print_provisioning_details(), provision_pwd, provision_ssid, tstrM2MDefaultConnResp::s8ErrorCode, s_msg_user_input::security, s_msg_user_input::SSID, tstrM2mWifiStateChanged::u8CurrState, tstrM2MProvisionInfo::u8SecType, tstrM2MProvisionInfo::u8Status, wifi_connected, and wifi_provisioned.
Referenced by demo_start().
|
static |
Parse user input data.
References s_msg_user_input::channel, DEFAULT_AUTH, DEFAULT_CHANNEL, DEFAULT_PWD, DEFAULT_SSID, NULL, s_msg_user_input::password, s_msg_user_input::security, and s_msg_user_input::SSID.
Referenced by demo_start().
|
static |
Print provisioning information.
References DEMO_WLAN_AP_NAME.
Referenced by demo_start(), and demo_wifi_state().
tstrM2MAPConfig ap_config |
Configure and enable access point mode with provisioning page.
|
static |
Global counter delay for timer.
Referenced by demo_start(), and demo_wifi_socket_handler().
char gacHttpProvDomainName[] = DEMO_WLAN_AP_DOMAIN_NAME |
Referenced by demo_start(), and demo_wifi_state().
uint8 gau8HttpProvServerIP[] = DEMO_WLAN_AP_IP_ADDRESS |
|
static |
Referenced by demo_wifi_socket_handler().
uint32_t ms_ticks |
SysTick counter for non busy wait delay.
SysTick counter for non busy wait delay.
Referenced by button_press_duration(), demo_start(), and SysTick_Handler().
|
static |
Message format declarations.
|
static |
char provision_pwd[30] |
Referenced by demo_wifi_state().
char provision_ssid[70] |
Referenced by demo_wifi_state().
|
static |
RX and TX socket descriptors.
Referenced by demo_start(), and demo_wifi_socket_handler().
|
static |
Global counters for LED toggling.
Referenced by demo_start().
|
static |
Referenced by demo_start().
char user_credentials[108] |
Referenced by demo_start().
|
static |
|
static |
WiFi status variable.
Referenced by demo_start(), and demo_wifi_state().
|
static |
Referenced by demo_start(), and demo_wifi_state().