network/uart_tcp_client/variables.c

/*
* EVALUATION AND USE OF THIS SOFTWARE IS SUBJECT TO THE TERMS AND
* CONDITIONS OF THE CONTROLLING LICENSE AGREEMENT FOUND AT LICENSE.md
* IN THIS SDK. IF YOU DO NOT AGREE TO THE LICENSE TERMS AND CONDITIONS,
* PLEASE RETURN ALL SOURCE FILES TO SILICON LABORATORIES.
* (c) Copyright 2018, Silicon Laboratories Inc. All rights reserved.
*/
#include "gos.h"
#include "nvm_settings.h"
GOS_CMD_CREATE_GETTER_SETTER(uart_tcp_client, host, "utcp_client.host", SC2('u','t','h'), 0, 1);
GOS_CMD_CREATE_GETTER_SETTER(uart_tcp_client, port, "utcp_client.port", SC2('u','t','p'), 0, 1);
GOS_CMD_CREATE_GETTER_SETTER(uart_tcp_client, interface, "utcp_client.interface", SC2('u','t','i'), 0, 1);
GOS_CMD_CREATE_GETTER_SETTER(uart_tcp_client, uart_id, "utcp_client.uart.id", SC3('u','t','u','i'), 0, 1);
GOS_CMD_CREATE_GETTER_SETTER(uart_tcp_client, uart_baud, "utcp_client.uart.baud", SC3('u','t','u','b'), 0, 1);
GOS_CMD_CREATE_GETTER_SETTER(uart_tcp_client, uart_flow, "utcp_client.uart.flow", SC3('u','t','u','f'), 0, 1);
GOS_CMD_CREATE_GETTER_SETTER(uart_tcp_client, uart_rx_buffer_size, "utcp_client.uart.rx_buffer_size", SC3('u','t','u','r'), 0, 1);
uart_tcp_client_settings_t *uart_tcp_client_settings;
/*************************************************************************************************/
GOS_DEFINE_GETTER(uart_tcp_client, host)
{
return gos_cmd_print_str_response(uart_tcp_client_settings->tcp.host);
}
/*************************************************************************************************/
GOS_DEFINE_SETTER(uart_tcp_client, host)
{
return gos_cmd_set_str(argc, argv, uart_tcp_client_settings->tcp.host, sizeof(uart_tcp_client_settings->tcp.host));
}
/*************************************************************************************************/
GOS_DEFINE_GETTER(uart_tcp_client, port)
{
return gos_cmd_print_uint32_response(uart_tcp_client_settings->tcp.port);
}
/*************************************************************************************************/
GOS_DEFINE_SETTER(uart_tcp_client, port)
{
GOS_CMD_PARSE_INT_ARG_WITH_VAR(uint16_t, uart_tcp_client_settings->tcp.port, argv[1],
1, UINT16_MAX);
}
/*************************************************************************************************/
GOS_DEFINE_GETTER(uart_tcp_client, interface)
{
const gos_interface_t interface = uart_tcp_client_settings->tcp.interface;
const char *interface_str = (interface == GOS_INTERFACE_WLAN) ? "wlan" :
(interface == GOS_INTERFACE_SOFTAP) ? "softap" :
(interface == GOS_INTERFACE_ETHERNET) ? "ethernet" : "unknown";
return gos_cmd_print_str_response(interface_str);
}
/*************************************************************************************************/
GOS_DEFINE_SETTER(uart_tcp_client, interface)
{
if(strcmp(argv[1], "wlan") == 0)
{
uart_tcp_client_settings->tcp.interface = GOS_INTERFACE_WLAN;
}
else if(strcmp(argv[1], "softap") == 0)
{
uart_tcp_client_settings->tcp.interface = GOS_INTERFACE_SOFTAP;
}
else if(strcmp(argv[1], "ethernet") == 0)
{
uart_tcp_client_settings->tcp.interface = GOS_INTERFACE_ETHERNET;
}
else
{
}
}
/*************************************************************************************************/
GOS_DEFINE_GETTER(uart_tcp_client, uart_baud)
{
return gos_cmd_print_uint32_response(uart_tcp_client_settings->uart.baud);
}
/*************************************************************************************************/
GOS_DEFINE_SETTER(uart_tcp_client, uart_baud)
{
GOS_CMD_PARSE_INT_ARG_WITH_VAR(uint32_t, uart_tcp_client_settings->uart.baud, argv[1], 1, 18000000);
}
/*************************************************************************************************/
GOS_DEFINE_GETTER(uart_tcp_client, uart_flow)
{
return gos_cmd_print_uint32_response(uart_tcp_client_settings->uart.flow_control_enabled);
}
/*************************************************************************************************/
GOS_DEFINE_SETTER(uart_tcp_client, uart_flow)
{
return gos_cmd_set_bool(argc, argv, &uart_tcp_client_settings->uart.flow_control_enabled);
}
/*************************************************************************************************/
GOS_DEFINE_GETTER(uart_tcp_client, uart_id)
{
return gos_cmd_print_uint32_response(uart_tcp_client_settings->uart.id);
}
/*************************************************************************************************/
GOS_DEFINE_SETTER(uart_tcp_client, uart_id)
{
GOS_CMD_PARSE_INT_ARG_WITH_VAR(gos_uart_t, uart_tcp_client_settings->uart.id, argv[1], 0, GOS_UART_MAX-1);
}
/*************************************************************************************************/
GOS_DEFINE_GETTER(uart_tcp_client, uart_rx_buffer_size)
{
return gos_cmd_print_uint32_response(uart_tcp_client_settings->uart.rx_buffer_size);
}
/*************************************************************************************************/
GOS_DEFINE_SETTER(uart_tcp_client, uart_rx_buffer_size)
{
GOS_CMD_PARSE_INT_ARG_WITH_VAR(uint16_t, uart_tcp_client_settings->uart.rx_buffer_size, argv[1], 1, 16*1024);
}