WINC1500 locate IP address example.
Copyright (c) 2016-2021 Microchip Technology Inc. and its subsidiaries.
#include "asf.h"
#include "main.h"
#include "driver/include/m2m_wifi.h"
#include "socket/include/socket.h"
#include "stdio_serial.h"
#include <errno.h>
#include "iot/http/http_client.h"
#include "iot/json.h"
Macros | |
#define | STRING_EOL "\r\n" |
#define | STRING_HEADER |
Functions | |
static void | configure_console (void) |
Configure UART console. More... | |
static void | configure_http_client (void) |
Configure HTTP client module. More... | |
static void | configure_timer (void) |
Configure Timer module. More... | |
static void | http_client_callback (struct http_client_module *module_inst, int type, union http_client_data *data) |
Callback of the HTTP client. More... | |
int | main (void) |
Main application function. More... | |
static void | socket_event_handler (SOCKET sock, uint8_t msg_type, void *msg_data) |
Callback to get the Socket event. More... | |
static void | socket_resolve_handler (uint8_t *domain_name, uint32_t server_ip) |
Callback of gethostbyname function. More... | |
static void | wifi_callback (uint8_t msg_type, void *msg_data) |
Callback to get the Wi-Fi status update. More... | |
Variables | |
static struct usart_module | cdc_uart_module |
UART module for debug. More... | |
struct http_client_module | http_client_module_inst |
Instance of HTTP client module. More... | |
struct sw_timer_module | swt_module_inst |
Instance of Timer module. More... | |
#define STRING_EOL "\r\n" |
#define STRING_HEADER |
Referenced by main().
|
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 |
Configure HTTP client module.
References http_client_callback(), http_client_get_config_defaults(), http_client_init(), http_client_module_inst, http_client_register_callback(), printf, http_client_config::recv_buffer_size, ret, swt_module_inst, http_client_config::timer_inst, and http_client_config::user_agent.
Referenced by main().
|
static |
Configure Timer module.
References sw_timer_enable(), sw_timer_get_config_defaults(), sw_timer_init(), and swt_module_inst.
Referenced by main().
|
static |
Callback of the HTTP client.
[in] | module_inst | Module instance of HTTP client module. |
[in] | type | Type of event. |
[in] | data | Data structure of the event. http_client_data |
References http_client_data_recv_response::content, http_client_data_recv_response::content_length, http_client_data::disconnected, HTTP_CLIENT_CALLBACK_DISCONNECTED, HTTP_CLIENT_CALLBACK_RECV_RESPONSE, HTTP_CLIENT_CALLBACK_REQUESTED, HTTP_CLIENT_CALLBACK_SOCK_CONNECTED, http_client_module_inst, http_client_send_request(), json_create(), json_find(), MAIN_HTTP_CLIENT_TEST_METHOD, MAIN_HTTP_CLIENT_TEST_URL, NULL, printf, http_client_data_disconnected::reason, http_client_data::recv_response, http_client_data_recv_response::response_code, json_obj::s, and json_obj::value.
Referenced by configure_http_client().
int main | ( | void | ) |
Main application function.
Initializing the board and connect to wireless router. And event handling the Wi-Fi and SW timer.
References configure_console(), configure_http_client(), configure_timer(), 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, nm_bsp_init(), NULL, tstrWifiInitParam::pfAppWifiCb, printf, registerSocketCallback(), ret, socket_event_handler(), socket_resolve_handler(), socketInit(), STRING_HEADER, sw_timer_task(), swt_module_inst, system_init(), and wifi_callback().
|
static |
Callback to get the Socket event.
[in] | Socket | descriptor. |
[in] | msg_type | type of Socket notification. Possible types are: |
[in] | msg_data | A structure contains notification informations. |
References http_client_socket_event_handler().
Referenced by main().
|
static |
Callback of gethostbyname function.
[in] | doamin_name | Domain name. |
[in] | server_ip | IP of server. |
References http_client_socket_resolve_handler().
Referenced by main().
|
static |
Callback to get the Wi-Fi status update.
[in] | msg_type | 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. Existing types are:
|
References http_client_module_inst, http_client_send_request(), 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, MAIN_HTTP_CLIENT_TEST_METHOD, MAIN_HTTP_CLIENT_TEST_URL, MAIN_WLAN_AUTH, MAIN_WLAN_PSK, MAIN_WLAN_SSID, NULL, printf, and tstrM2mWifiStateChanged::u8CurrState.
Referenced by main().
|
static |
UART module for debug.
struct http_client_module http_client_module_inst |
Instance of HTTP client module.
struct sw_timer_module swt_module_inst |
Instance of Timer module.