AWS RSA Example.
Copyright (c) 2017-2018 Microchip Technology Inc. and its subsidiaries.
#include "asf.h"
#include "main.h"
#include "driver/include/m2m_wifi.h"
#include "socket/include/socket.h"
#include "AWS_SDK/aws_iot_src/utils/aws_iot_log.h"
#include "AWS_SDK/aws_iot_src/utils/aws_iot_version.h"
#include "AWS_SDK/aws_iot_src/protocol/mqtt/aws_iot_mqtt_interface.h"
#include "aws_iot_config.h"
Macros | |
#define | CLIENT_ID "WINC1500_Pub" |
#define | PUBLISH_BUTTON SW0_PIN |
#define | PUBLISH_CHANNEL "WINC1500_IOT/sub" |
#define | PUBLISHER |
#define | STRING_EOL "\r\n" |
#define | STRING_HEADER |
#define | SUBSCRIBE_CHANNEL "WINC1500_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 "WINC1500_Pub" |
Referenced by main().
#define PUBLISH_BUTTON SW0_PIN |
Referenced by main().
#define PUBLISH_CHANNEL "WINC1500_IOT/sub" |
Referenced by main().
#define PUBLISHER |
#define STRING_EOL "\r\n" |
#define STRING_HEADER |
Referenced by main().
#define SUBSCRIBE_CHANNEL "WINC1500_IOT/pub" |
Referenced by main().
|
static |
|
static |
Configure UART console.
References usart_config::baudrate, cdc_uart_module, 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().
|
static |
References aws_iot_is_autoreconnect_enabled(), aws_iot_mqtt_attempt_reconnect(), NONE_ERROR, printf, and RECONNECT_SUCCESSFUL.
Referenced by main().
int main | ( | void | ) |
Main application function.
Application entry point.
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, i, 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, printf, MQTTConnectParams::pRootCALocation, MQTTSubscribeParams::pTopic, MQTTPublishParams::pTopic, PUBLISH_BUTTON, PUBLISH_CHANNEL, publishCount, MQTTMessageParams::qos, MQTTSubscribeParams::qos, QOS_0, receivedTime, RECONNECT_SUCCESSFUL, ret, STRING_HEADER, SUBSCRIBE_CHANNEL, system_cpu_clock_get_hz(), system_init(), MQTTConnectParams::tlsHandshakeTimeout_ms, and wifi_cb().
|
static |
void SysTick_Handler | ( | void | ) |
SysTick handler used to measure precise delay.
References ms_ticks.
|
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 gbConnectedWifi, gethostbyname(), HostAddress, 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_GET_SYS_TIME, MAIN_WLAN_AUTH, MAIN_WLAN_PSK, MAIN_WLAN_SSID, printf, receivedTime, and tstrM2mWifiStateChanged::u8CurrState.
Referenced by main().
|
static |
UART module for debug.
char HostAddress[255] = AWS_IOT_MQTT_HOST |
volatile uint32_t ms_ticks = 0 |
SysTick counter to avoid busy wait delay.
TLS read functionality.
SysTick counter for non busy wait delay.
uint32_t port = AWS_IOT_MQTT_PORT |
Default MQTT port is pulled from the aws_iot_config.h.
Referenced by arch_ioport_port_to_base(), event(), main(), parse_url(), start_get(), start_request(), system_pinmux_pin_get_mux_position(), system_pinmux_pin_set_config(), system_pinmux_pin_set_input_sample_mode(), system_pinmux_pin_set_output_strength(), tcp_socket_listen(), udi_cdc_comm_enable(), udi_cdc_comm_setup(), udi_cdc_ctrl_state_change(), udi_cdc_ctrl_state_notify(), udi_cdc_data_disable(), udi_cdc_data_enable(), udi_cdc_data_received(), udi_cdc_data_sent(), udi_cdc_line_coding_received(), udi_cdc_multi_get_free_tx_buffer(), udi_cdc_multi_get_nb_received_data(), udi_cdc_multi_getc(), udi_cdc_multi_putc(), udi_cdc_multi_read_buf(), udi_cdc_multi_read_no_polling(), udi_cdc_multi_write_buf(), udi_cdc_rx_start(), udi_cdc_serial_state_msg_sent(), udi_cdc_setup_to_port(), udi_cdc_tx_send(), uhi_cdc_rx_received(), uhi_cdc_sof(), uhi_cdc_tx_send(), and websocket_http_client_get().
uint32_t publishCount = 0 |
This parameter will avoid infinite loop of publish and exit the program after certain number of publishes.
Referenced by main().
Referenced by MQTTcallbackHandler().