Microchip® Advanced Software Framework

main21.c File Reference

AWS RSA Example.

Copyright (c) 2017-2019 Microchip Technology Inc. and its subsidiaries.

Macros

#define CLIENT_ID   "WINC3400_Pub"
 
#define PUBLISH_BUTTON   SW0_PIN
 
#define PUBLISH_CHANNEL   "WINC3400_IOT/sub"
 
#define PUBLISHER
 
#define STRING_EOL   "\r\n"
 
#define STRING_HEADER
 
#define SUBSCRIBE_CHANNEL   "WINC3400_IOT/pub"
 

Functions

static int32_t button_press_duration (bool current_button_state)
 
static void configure_console (void)
 Configure UART console. More...
 
static void disconnectCallbackHandler (void)
 
int main (void)
 Main application function. More...
 
static int32_t MQTTcallbackHandler (MQTTCallbackParams params)
 
void SysTick_Handler (void)
 SysTick handler used to measure precise delay. More...
 
static void wifi_cb (uint8_t u8MsgType, void *pvMsg)
 Callback to get the Wi-Fi status update. More...
 

Variables

static struct usart_module cdc_uart_module
 UART module for debug. More...
 
static bool gbConnectedWifi = false
 Wi-Fi status variable. More...
 
char HostAddress [255] = AWS_IOT_MQTT_HOST
 Default MQTT HOST URL is pulled from the aws_iot_config.h. More...
 
volatile uint32_t ms_ticks = 0
 SysTick counter to avoid busy wait delay. More...
 
uint32_t port = AWS_IOT_MQTT_PORT
 Default MQTT port is pulled from the aws_iot_config.h. More...
 
uint32_t publishCount = 0
 This parameter will avoid infinite loop of publish and exit the program after certain number of publishes. More...
 
static bool receivedTime = false
 
static bool toggle = false
 

#define CLIENT_ID   "WINC3400_Pub"

Referenced by main().

#define PUBLISH_BUTTON   SW0_PIN

Referenced by main().

#define PUBLISH_CHANNEL   "WINC3400_IOT/sub"

Referenced by main().

#define PUBLISHER
#define STRING_EOL   "\r\n"
#define STRING_HEADER
Value:
"-- AWS IoT Demo --"STRING_EOL \
"-- "BOARD_NAME " --"STRING_EOL \
"-- Compiled: "__DATE__ " "__TIME__ " --"STRING_EOL
#define BOARD_NAME
Name string macro.
Definition: samd21_xplained_pro.h:65
#define STRING_EOL
Definition: main21.c:119

Referenced by main().

#define SUBSCRIBE_CHANNEL   "WINC3400_IOT/pub"

Referenced by main().

static int32_t button_press_duration ( bool  current_button_state)
static

References ms_ticks.

Referenced by main().

static void disconnectCallbackHandler ( void  )
static
int main ( void  )

Main application function.

Application entry point.

Returns
program return value.

References aws_iot_mqtt_autoreconnect_set_status(), aws_iot_mqtt_connect(), aws_iot_mqtt_publish(), aws_iot_mqtt_subscribe(), aws_iot_mqtt_yield(), button_press_duration(), CLIENT_ID, configure_console(), delay_init(), delay_ms, disconnectCallbackHandler(), MQTTConnectParams::disconnectHandler, gbConnectedWifi, HostAddress, MQTTConnectParams::isCleansession, MQTTConnectParams::isSSLHostnameVerify, MQTTConnectParams::isWillMsgPresent, MQTTConnectParams::KeepAliveInterval_sec, M2M_SUCCESS, M2M_WIFI_CH_ALL, m2m_wifi_connect(), m2m_wifi_handle_events(), m2m_wifi_init(), MAIN_WLAN_AUTH, MAIN_WLAN_PSK, MAIN_WLAN_SSID, MQTTPublishParams::MessageParams, MQTTSubscribeParams::mHandler, MQTT_3_1_1, MQTTcallbackHandler(), MQTTConnectParams::mqttCommandTimeout_ms, MQTTConnectParamsDefault, MQTTMessageParamsDefault, MQTTPublishParamsDefault, MQTTSubscribeParamsDefault, MQTTConnectParams::MQTTVersion, NETWORK_ATTEMPTING_RECONNECT, nm_bsp_init(), NONE_ERROR, NULL, MQTTMessageParams::PayloadLen, MQTTConnectParams::pClientID, MQTTConnectParams::pDeviceCertLocation, MQTTConnectParams::pDevicePrivateKeyLocation, tstrWifiInitParam::pfAppWifiCb, MQTTConnectParams::pHostURL, MQTTConnectParams::port, port, port_pin_get_input_level(), MQTTMessageParams::pPayload, MQTTConnectParams::pRootCALocation, MQTTSubscribeParams::pTopic, MQTTPublishParams::pTopic, PUBLISH_BUTTON, PUBLISH_CHANNEL, publishCount, MQTTMessageParams::qos, MQTTSubscribeParams::qos, QOS_0, receivedTime, RECONNECT_SUCCESSFUL, STRING_HEADER, SUBSCRIBE_CHANNEL, system_cpu_clock_get_hz(), system_init(), MQTTConnectParams::tlsHandshakeTimeout_ms, and wifi_cb().

void SysTick_Handler ( void  )

SysTick handler used to measure precise delay.

References ms_ticks.

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

Callback to get the Wi-Fi status update.

Parameters
[in]u8MsgTypetype of Wi-Fi notification. Possible types are:
[in]pvMsgA 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 gbConnectedWifi, gethostbyname(), HostAddress, M2M_WIFI_CH_ALL, m2m_wifi_connect(), M2M_WIFI_CONNECTED, M2M_WIFI_DISCONNECTED, M2M_WIFI_REQ_DHCP_CONF, M2M_WIFI_RESP_CON_STATE_CHANGED, M2M_WIFI_RESP_GET_SYS_TIME, MAIN_WLAN_AUTH, MAIN_WLAN_PSK, MAIN_WLAN_SSID, receivedTime, and tstrM2mWifiStateChanged::u8CurrState.

Referenced by main().

struct usart_module cdc_uart_module
static

UART module for debug.

Referenced by configure_console().

bool gbConnectedWifi = false
static

Wi-Fi status variable.

Referenced by main(), and wifi_cb().

char HostAddress[255] = AWS_IOT_MQTT_HOST

Default MQTT HOST URL is pulled from the aws_iot_config.h.

Referenced by main(), and wifi_cb().

volatile uint32_t ms_ticks = 0

SysTick counter to avoid busy wait delay.

TLS read functionality.

Referenced by button_press_duration(), getTimeInMillis(), and SysTick_Handler().

uint32_t publishCount = 0

This parameter will avoid infinite loop of publish and exit the program after certain number of publishes.

Referenced by main().

bool receivedTime = false
static

Referenced by main(), and wifi_cb().

bool toggle = false
static

Referenced by MQTTcallbackHandler().