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.
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, ioport_set_pin_level(), s_msg_temp_report::led, 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, ioport_set_pin_level(), 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(), printf, provision_pwd, provision_ssid, tstrM2MDefaultConnResp::s8ErrorCode, s_msg_user_input::security, s_msg_user_input::SSID, strncpy(), 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, and printf.
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(), demo_wifi_socket_handler(), main(), make_neighbor(), make_route(), and tcc_callback_to_change_duty_cycle().
char gacHttpProvDomainName[] = DEMO_WLAN_AP_DOMAIN_NAME |
Referenced by demo_start(), demo_wifi_state(), m2m_wifi_state(), and main().
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(), getTimeInMillis(), m2m_wifi_socket_handler(), reset_start_time(), run_udp_client(), and SysTick_Handler().
|
static |
Message format declarations.
|
static |
char provision_pwd[30] |
Referenced by demo_wifi_state(), and m2m_wifi_state().
char provision_ssid[70] |
Referenced by demo_wifi_state(), and m2m_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().