mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-02-04 17:05:46 +00:00
W800 hostname+uart (#1508)
* Set hostname to device name add uart driver * fix warnings
This commit is contained in:
@ -35,6 +35,7 @@ CSRCS += $(_SHARED_APP)/hal/w800/hal_generic_w800.c
|
||||
CSRCS += $(_SHARED_APP)/hal/w800/hal_main_w800.c
|
||||
CSRCS += $(_SHARED_APP)/hal/w800/hal_pins_w800.c
|
||||
CSRCS += $(_SHARED_APP)/hal/w800/hal_wifi_w800.c
|
||||
CSRCS += $(_SHARED_APP)/hal/w800/hal_uart_w800.c
|
||||
CSRCS += $(_SHARED_APP)/hal/generic/hal_adc_generic.c
|
||||
CSRCS += $(_SHARED_APP)/hal/generic/hal_flashConfig_generic.c
|
||||
CSRCS += $(_SHARED_APP)/hal/generic/hal_flashVars_generic.c
|
||||
@ -97,6 +98,7 @@ CSRCS += $(_SHARED_APP)/driver/drv_ssdp.c
|
||||
CSRCS += $(_SHARED_APP)/driver/drv_ds1820_simple.c
|
||||
CSRCS += $(_SHARED_APP)/driver/drv_charts.c
|
||||
CSRCS += $(_SHARED_APP)/driver/drv_dht.c
|
||||
CSRCS += $(_SHARED_APP)/driver/drv_uart.c
|
||||
CSRCS += $(_SHARED_APP)/i2c/drv_i2c_main.c
|
||||
CSRCS += $(_SHARED_APP)/i2c/drv_i2c_tc74.c
|
||||
CSRCS += $(_SHARED_APP)/i2c/drv_i2c_ads1115.c
|
||||
|
||||
60
src/hal/w800/hal_uart_w800.c
Normal file
60
src/hal/w800/hal_uart_w800.c
Normal file
@ -0,0 +1,60 @@
|
||||
#if defined(PLATFORM_W800) || defined(PLATFORM_W600)
|
||||
|
||||
#include "../hal_generic.h"
|
||||
#include "../hal_uart.h"
|
||||
#include "../../logging/logging.h"
|
||||
|
||||
#include "wm_include.h"
|
||||
#include "wm_uart.h"
|
||||
#include "wm_gpio_afsel.h" // for wm_uart1_rx_config and wm_uart1_tx_config
|
||||
#define UART_DEV_NAME "uart1"
|
||||
#define READ_BUF_SIZE 256
|
||||
static s16 obk_uart_rx(u16 len)
|
||||
{
|
||||
|
||||
//addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER, "W800 obk_uart_rx - len=%i\r\n",len);
|
||||
u8 *buf=malloc(READ_BUF_SIZE);
|
||||
int i;
|
||||
if (! buf ){
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER, "W800 obk_uart_rx - malloc failed!\r\n");
|
||||
return WM_FAILED;
|
||||
}
|
||||
while(len){
|
||||
int ml=tls_uart_read(TLS_UART_1, buf,READ_BUF_SIZE-1 );
|
||||
//addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER, "W800 obk_uart_rx - ml=%i\r\n",ml);
|
||||
buf[READ_BUF_SIZE-1]=0;
|
||||
//addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER, "W800 obk_uart_rx - read=%s - len=%i - READ_BUF=%i\r\n",buf,len,READ_BUF_SIZE);
|
||||
for(i = 0; i < len && i < ml; i++)
|
||||
{
|
||||
UART_AppendByteToReceiveRingBuffer(buf[i]);
|
||||
}
|
||||
len -=i;
|
||||
}
|
||||
free(buf);
|
||||
return WM_SUCCESS;
|
||||
}
|
||||
|
||||
void HAL_UART_SendByte(byte b)
|
||||
{
|
||||
tls_uart_write(TLS_UART_1, (char*)&b, 1);
|
||||
}
|
||||
|
||||
int HAL_UART_Init(int baud, int parity)
|
||||
{
|
||||
struct tls_uart_options uart_opts;
|
||||
uart_opts.baudrate = baud;
|
||||
uart_opts.charlength = TLS_UART_CHSIZE_8BIT;
|
||||
uart_opts.flow_ctrl = TLS_UART_FLOW_CTRL_NONE;
|
||||
uart_opts.paritytype = parity;
|
||||
uart_opts.stopbits = TLS_UART_ONE_STOPBITS;
|
||||
wm_uart1_rx_config(WM_IO_PB_07);
|
||||
wm_uart1_tx_config(WM_IO_PB_06);
|
||||
|
||||
if (WM_SUCCESS != tls_uart_port_init(TLS_UART_1, &uart_opts, 1))
|
||||
return;
|
||||
tls_uart_rx_callback_register((u16) TLS_UART_1, (s16(*)(u16, void*))obk_uart_rx, NULL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@ -176,7 +176,15 @@ static int connect_wifi_demo(char* ssid, char* pwd, obkStaticIP_t *ip)
|
||||
int ret;
|
||||
struct tls_param_ip* ip_param = NULL;
|
||||
u8 wireless_protocol = 0;
|
||||
|
||||
|
||||
#if LWIP_NETIF_HOSTNAME
|
||||
extern const char *CFG_GetDeviceName(); // including "../../../../sharedAppContainer/sharedApp/src/new_cfg.h" only for CFG_GetDeviceName() leads to errors
|
||||
struct netif* netif = tls_get_netif();
|
||||
char *tmpPtr = CFG_GetDeviceName();
|
||||
if(tmpPtr != 0 && tmpPtr[0] != 0) {
|
||||
netif->hostname = tmpPtr;
|
||||
}
|
||||
#endif
|
||||
tls_wifi_disconnect();
|
||||
tls_wifi_softap_destroy();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user