Microchip® Advanced Software Framework

main.c File Reference

SAME70 Weather Client Demo Example.

Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.

#include "asf.h"
#include "image.h"
#include "main_wifi.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "bsp/include/nm_bsp.h"
#include "driver/include/m2m_wifi.h"
#include "socket/include/socket.h"

Macros

#define ASCII_BS   0x7F
 ASCII char definition for backspace. More...
 
#define ASCII_CR   13
 ASCII char definition for carriage return. More...
 
#define STRING_EOL   "\r\n"
 
#define STRING_HEADER
 

Functions

static void configure_console (void)
 Configure UART console. More...
 
void configure_rtt (void)
 RTT configuration function. More...
 
void ili9488_draw_number (uint32_t ul_x, uint32_t ul_y, uint8_t index)
 
void ili9488_draw_temperature (uint32_t ul_x, uint32_t ul_y, char *temperature)
 
int main (void)
 Main application function. More...
 
static uint8_t parse_weather_icon (char *pcWeather)
 
static void refresh_display ()
 
static void resolve_cb (uint8_t *hostName, uint32_t hostIp)
 Callback function of IP address. More...
 
void RTT_Handler (void)
 Interrupt handler for the RTT. More...
 
static void socket_cb (SOCKET sock, uint8_t u8Msg, void *pvMsg)
 Callback function of TCP client socket. More...
 
static void wifi_cb (uint8_t u8MsgType, void *pvMsg)
 Callback to get the Wi-Fi status update. More...
 
void wifi_connect (void)
 
static void wifi_handle_events (void)
 
static void wifi_init (void)
 
void wifi_recieve_packet (void)
 
static void wifi_require_weather (char *city_name)
 

Variables

bool city_is_sha = true
 
bool display_is_sha = true
 
struct ili9488_opt_t g_ili9488_display_opt
 
uint32_t g_ul_sec_ticks = 0
 
static uint8_t gau8ReceivedBuffer [MAIN_WIFI_M2M_BUFFER_SIZE] = {0}
 Receive buffer definition. More...
 
static bool gbConnectedWifi = false
 Wi-Fi status variable. More...
 
static bool gbContinueReceive = false
 Continue Receive status variable. More...
 
static bool gbFinishedGetWeather = false
 Weather client status variable. More...
 
static bool gbHostIpByName = false
 Get host IP status variable. More...
 
static bool gbRequireWeather = false
 
static bool gbTcpConnection = false
 TCP Connection status variable. More...
 
static char gcWeatherInfo [2048] = {0}
 
uint32_t gu32HostIp = 0
 IP address of host. More...
 
char * gWeatherIcon [4]
 
const uint8_t mark [11] = {'S', 'A', 'M', 'E','7', '0', 'D', 'E', 'M','O'}
 
char * pcCity = NULL
 
char * pcTemperature = NULL
 
char * pcWeather = NULL
 
static char server_host_name [] = MAIN_WEATHER_SERVER_NAME
 Server host name. More...
 
static SOCKET tcp_client_socket = -1
 TCP client socket handlers. More...
 
char Temperature_seoul [30]
 
char Temperature_sha [30]
 
uint8_t ucWeatherNum = 0
 
uint8_t ucWeatherNum_seoul
 
uint8_t ucWeatherNum_sha
 
char Weather_seoul [30]
 
char Weather_sha [30]
 

#define ASCII_BS   0x7F

ASCII char definition for backspace.

Referenced by wifi_connect().

#define ASCII_CR   13

ASCII char definition for carriage return.

Referenced by wifi_connect().

#define STRING_EOL   "\r\n"
#define STRING_HEADER
Value:
"-- SAME70 Weather Client Demo --"STRING_EOL \
"-- "BOARD_NAME " --"STRING_EOL \
"-- Compiled: "__DATE__ " "__TIME__ " --"STRING_EOL
#define BOARD_NAME
Name of the board.
Definition: same70_xplained.h:75
#define STRING_EOL
Definition: main.c:136

Referenced by main().

static void configure_console ( void  )
static
void configure_rtt ( void  )

RTT configuration function.

Configure the RTT to generate a one second tick, which triggers the RTTINC interrupt.

References rtt_enable_interrupt(), rtt_init(), and rtt_sel_source().

Referenced by resolve_cb().

void ili9488_draw_number ( uint32_t  ul_x,
uint32_t  ul_y,
uint8_t  index 
)
void ili9488_draw_temperature ( uint32_t  ul_x,
uint32_t  ul_y,
char *  temperature 
)

References ili9488_draw_number().

Referenced by refresh_display().

static uint8_t parse_weather_icon ( char *  pcWeather)
static

References NULL, and pcWeather.

Referenced by wifi_recieve_packet().

static void resolve_cb ( uint8_t *  hostName,
uint32_t  hostIp 
)
static

Callback function of IP address.

Parameters
[in]hostNameDomain name.
[in]hostIpServer IP.
Returns
None.

References configure_rtt(), gbHostIpByName, gu32HostIp, and IPV4_BYTE.

Referenced by wifi_init().

void RTT_Handler ( void  )

Interrupt handler for the RTT.

Display the current time on the terminal.

References g_ul_sec_ticks, and rtt_get_status().

static void socket_cb ( SOCKET  sock,
uint8_t  u8Msg,
void *  pvMsg 
)
static

Callback function of TCP client socket.

Parameters
[in]socksocket handler.
[in]u8MsgType of Socket notification
[in]pvMsgA structure contains notification informations.
Returns
None.

References close(), g_ul_sec_ticks, gbFinishedGetWeather, gbRequireWeather, gbTcpConnection, gcWeatherInfo, tstrSocketRecvMsg::pu8Buffer, tstrSocketRecvMsg::s16BufferSize, tstrSocketConnectMsg::s8Error, SOCK_ERR_NO_ERROR, SOCKET_MSG_CONNECT, SOCKET_MSG_RECV, and tcp_client_socket.

Referenced by wifi_init().

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.
[in]pvMsgA pointer to a buffer containing the notification parameters.
Returns
None.

References gbConnectedWifi, gethostbyname(), M2M_WIFI_CONNECTED, M2M_WIFI_DISCONNECTED, M2M_WIFI_REQ_DHCP_CONF, m2m_wifi_request_dhcp_client(), M2M_WIFI_RESP_CON_STATE_CHANGED, server_host_name, tstrM2mWifiStateChanged::u8CurrState, and wifi_connect().

Referenced by wifi_init().

static void wifi_handle_events ( void  )
static

References m2m_wifi_handle_events(), and NULL.

Referenced by main().

static void wifi_require_weather ( char *  city_name)
static

bool city_is_sha = true

Referenced by main().

bool display_is_sha = true
struct ili9488_opt_t g_ili9488_display_opt

Referenced by main().

uint32_t g_ul_sec_ticks = 0

Referenced by main(), RTT_Handler(), and socket_cb().

uint8_t gau8ReceivedBuffer[MAIN_WIFI_M2M_BUFFER_SIZE] = {0}
static

Receive buffer definition.

Referenced by wifi_recieve_packet(), and wifi_require_weather().

bool gbConnectedWifi = false
static

Wi-Fi status variable.

Referenced by main(), and wifi_cb().

bool gbContinueReceive = false
static

Continue Receive status variable.

Referenced by wifi_recieve_packet().

bool gbFinishedGetWeather = false
static

Weather client status variable.

Referenced by main(), and socket_cb().

bool gbHostIpByName = false
static

Get host IP status variable.

Referenced by main(), and resolve_cb().

bool gbRequireWeather = false
static

Referenced by main(), and socket_cb().

bool gbTcpConnection = false
static

TCP Connection status variable.

Referenced by main(), socket_cb(), and wifi_recieve_packet().

char gcWeatherInfo[2048] = {0}
static

Referenced by socket_cb(), and wifi_recieve_packet().

uint32_t gu32HostIp = 0

IP address of host.

Referenced by main(), and resolve_cb().

char* gWeatherIcon[4]
Initial value:
= {
}
const ili9488_color_t gImage_cloud[]
Definition: image.h:4964
const ili9488_color_t gImage_snow[]
Definition: image.h:10370
const ili9488_color_t gImage_rain[]
Definition: image.h:7667
const ili9488_color_t gImage_sun[]
Definition: image.h:2261

Referenced by refresh_display().

const uint8_t mark[11] = {'S', 'A', 'M', 'E','7', '0', 'D', 'E', 'M','O'}

Referenced by wifi_connect().

char* pcCity = NULL

Referenced by wifi_recieve_packet().

char* pcTemperature = NULL

Referenced by wifi_recieve_packet().

char* pcWeather = NULL
char server_host_name[] = MAIN_WEATHER_SERVER_NAME
static

Server host name.

Referenced by wifi_cb().

SOCKET tcp_client_socket = -1
static

TCP client socket handlers.

Referenced by main(), socket_cb(), wifi_recieve_packet(), and wifi_require_weather().

char Temperature_seoul[30]
char Temperature_sha[30]
uint8_t ucWeatherNum = 0

Referenced by wifi_recieve_packet().

uint8_t ucWeatherNum_seoul
uint8_t ucWeatherNum_sha
char Weather_seoul[30]
char Weather_sha[30]