forked from xuos/xiuos
add lcd driver for xidatong-arm
It is OK
This commit is contained in:
@@ -89,7 +89,7 @@ int Adapter4GTest(void)
|
||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_4G_NAME);
|
||||
|
||||
#ifdef ADAPTER_EC200T
|
||||
//Using Hang Xiao server to test 4G Socket connection
|
||||
/* Using Public TCP server to test 4G Socket connection */
|
||||
uint8 server_addr[64] = "120.76.100.197";
|
||||
uint8 server_port[64] = "10002";
|
||||
|
||||
|
||||
7
APP_Framework/Framework/connection/bluetooth/Make.defs
Normal file
7
APP_Framework/Framework/connection/bluetooth/Make.defs
Normal file
@@ -0,0 +1,7 @@
|
||||
############################################################################
|
||||
# APP_Framework/Framework/connection/bluetooth/Make.defs
|
||||
############################################################################
|
||||
ifneq ($(CONFIG_CONNECTION_ADAPTER_BLUETOOTH),)
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/connection/bluetooth
|
||||
endif
|
||||
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/connection/bluetooth/*/Make.defs)
|
||||
@@ -1,7 +1,17 @@
|
||||
SRC_FILES := adapter_bluetooth.c
|
||||
include $(KERNEL_ROOT)/.config
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += adapter_bluetooth.c
|
||||
include $(APPDIR)/Application.mk
|
||||
|
||||
ifeq ($(CONFIG_ADAPTER_HC08),y)
|
||||
SRC_DIR += hc08
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||
SRC_FILES := adapter_bluetooth.c
|
||||
|
||||
ifeq ($(CONFIG_ADAPTER_HC08),y)
|
||||
SRC_DIR += hc08
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
||||
|
||||
@@ -33,6 +33,25 @@ endif
|
||||
|
||||
if ADD_NUTTX_FETURES
|
||||
|
||||
config ADAPTER_HC08_WORK_ROLE
|
||||
string "HC08 work role M(MASTER) or S(SLAVER)"
|
||||
default "M"
|
||||
|
||||
config ADAPTER_HC08_DRIVER_EXTUART
|
||||
bool "Using extra uart to support bluetooth"
|
||||
default y
|
||||
|
||||
config ADAPTER_HC08_DRIVER
|
||||
string "HC08 device uart driver path"
|
||||
default "/dev/ttyS2"
|
||||
depends on !ADAPTER_HC08_DRIVER_EXTUART
|
||||
|
||||
if ADAPTER_HC08_DRIVER_EXTUART
|
||||
config ADAPTER_HC08_DRIVER
|
||||
string "HC08 device extra uart driver path"
|
||||
default "/dev/extuart_dev2"
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
if ADD_RTTHREAD_FETURES
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
############################################################################
|
||||
# APP_Framework/Framework/connection/bluetooth/hc08/Make.defs
|
||||
############################################################################
|
||||
ifneq ($(CONFIG_ADAPTER_HC08),)
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/connection/bluetooth/hc08
|
||||
endif
|
||||
@@ -1,3 +1,13 @@
|
||||
SRC_FILES := hc08.c
|
||||
include $(KERNEL_ROOT)/.config
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += hc08.c
|
||||
include $(APPDIR)/Application.mk
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||
SRC_FILES := hc08.c
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
||||
endif
|
||||
|
||||
@@ -21,27 +21,27 @@
|
||||
#include <adapter.h>
|
||||
#include <at_agent.h>
|
||||
|
||||
#define HC08_DETECT_CMD "AT"
|
||||
#define HC08_DEFAULT_CMD "AT+DEFAULT"
|
||||
#define HC08_RESET_CMD "AT+RESET"
|
||||
#define HC08_CLEAR_CMD "AT+CLEAR"
|
||||
#define HC08_GET_DEVICE_INFO "AT+RX"
|
||||
#define HC08_DETECT_CMD "AT"
|
||||
#define HC08_DEFAULT_CMD "AT+DEFAULT"
|
||||
#define HC08_RESET_CMD "AT+RESET"
|
||||
#define HC08_CLEAR_CMD "AT+CLEAR"
|
||||
#define HC08_GET_DEVICE_INFO "AT+RX"
|
||||
|
||||
#define HC08_GET_BAUDRATE_CMD "AT+BAUD=?"
|
||||
#define HC08_SET_BAUDRATE_CMD "AT+BAUD=%u"
|
||||
#define HC08_GET_CONNECTABLE "AT+CONT=?"
|
||||
#define HC08_SET_CONNECTABLE "AT+CONT=%s"
|
||||
#define HC08_GET_ROLE_CMD "AT+ROLE=?"
|
||||
#define HC08_SET_ROLE_CMD "AT+ROLE=%s"
|
||||
#define HC08_GET_ADDR_CMD "AT+ADDR=?"
|
||||
#define HC08_SET_ADDR_CMD "AT+ADDR=%s"
|
||||
#define HC08_GET_BAUDRATE_CMD "AT+BAUD=?"
|
||||
#define HC08_SET_BAUDRATE_CMD "AT+BAUD=%u"
|
||||
#define HC08_GET_CONNECTABLE "AT+CONT=?"
|
||||
#define HC08_SET_CONNECTABLE "AT+CONT=%s"
|
||||
#define HC08_GET_ROLE_CMD "AT+ROLE=?"
|
||||
#define HC08_SET_ROLE_CMD "AT+ROLE=%s"
|
||||
#define HC08_GET_ADDR_CMD "AT+ADDR=?"
|
||||
#define HC08_SET_ADDR_CMD "AT+ADDR=%s"
|
||||
#define HC08_GET_NAME_CMD "AT+NAME=%s"
|
||||
#define HC08_SET_NAME_CMD "AT+NAME=?"
|
||||
|
||||
#define HC08_OK_RESP "OK"
|
||||
#define HC08_OK_RESP "OK"
|
||||
|
||||
#define HC08_CMD_STR_DEFAULT_SIZE 64
|
||||
#define HC08_RESP_DEFAULT_SIZE 64
|
||||
#define HC08_CMD_STR_DEFAULT_SIZE 64
|
||||
#define HC08_RESP_DEFAULT_SIZE 64
|
||||
|
||||
enum Hc08AtCmd
|
||||
{
|
||||
@@ -232,6 +232,41 @@ static int Hc08Close(struct Adapter *adapter)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
static int Hc08Ioctl(struct Adapter *adapter, int cmd, void *args)
|
||||
{
|
||||
if (OPE_INT != cmd) {
|
||||
printf("Hc08Ioctl only support OPE_INT, do not support %d\n", cmd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t baud_rate = *((uint32_t *)args);
|
||||
|
||||
PrivIoctl(adapter->fd, OPE_INT, baud_rate);
|
||||
|
||||
//Step1 : detect hc08 serial function
|
||||
if (Hc08AtConfigure(adapter->agent, HC08_AT_CMD_DETECT, NULL, NULL) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Step2 : set hc08 device serial baud, hc08_set_baud send "AT+BAUD=%s"
|
||||
if (Hc08AtConfigure(adapter->agent, HC08_AT_CMD_SET_BAUDRATE, args, NULL) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
PrivTaskDelay(200);
|
||||
|
||||
//Step3 : show hc08 device info, hc08_get send "AT+RX" response device info
|
||||
char device_info[HC08_RESP_DEFAULT_SIZE * 2] = {0};
|
||||
if (Hc08AtConfigure(adapter->agent, HC08_AT_CMD_GET_DEVICE_INFO, NULL, device_info) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ADAPTER_DEBUG("Hc08 ioctl done\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
static int Hc08Ioctl(struct Adapter *adapter, int cmd, void *args)
|
||||
{
|
||||
if (OPE_INT != cmd) {
|
||||
@@ -283,6 +318,7 @@ static int Hc08Ioctl(struct Adapter *adapter, int cmd, void *args)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int Hc08SetAddr(struct Adapter *adapter, const char *ip, const char *gateway, const char *netmask)
|
||||
{
|
||||
@@ -348,7 +384,7 @@ static int Hc08Send(struct Adapter *adapter, const void *buf, size_t len)
|
||||
EntmSend(adapter->agent, (const char *)buf, len);
|
||||
} else {
|
||||
printf("Hc08Send can not find agent\n");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -358,7 +394,7 @@ static int Hc08Recv(struct Adapter *adapter, void *buf, size_t len)
|
||||
return EntmRecv(adapter->agent, (char *)buf, len, 40);
|
||||
} else {
|
||||
printf("Hc08Recv can not find agent\n");
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
############################################################################
|
||||
# APP_Framework/Framework/connection/lora/Make.defs
|
||||
############################################################################
|
||||
ifneq ($(CONFIG_ADAPTER_SX1278),)
|
||||
ifneq ($(CONFIG_CONNECTION_ADAPTER_LORA),)
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/connection/lora
|
||||
endif
|
||||
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/connection/lora/*/Make.defs)
|
||||
|
||||
@@ -50,6 +50,8 @@ extern AdapterProductInfoType E220Attach(struct Adapter *adapter);
|
||||
|
||||
#define ADAPTER_LORA_RECEIVE_ERROR_CNT 1
|
||||
|
||||
#define DEFAULT_SEM_TIMEOUT 10
|
||||
|
||||
//need to change status if the lora client wants to quit the net when timeout or a certain event
|
||||
//eg.can also use sem to trigger quit function
|
||||
static int g_adapter_lora_quit_flag = 0;
|
||||
@@ -453,7 +455,10 @@ static int LoraClientDataAnalyze(struct Adapter *adapter, void *send_buf, int le
|
||||
int ret = 0;
|
||||
uint8_t client_id = adapter->net_role_id;
|
||||
|
||||
ret = PrivSemaphoreObtainWait(&adapter->sem, NULL);
|
||||
struct timespec abstime;
|
||||
abstime.tv_sec = DEFAULT_SEM_TIMEOUT;
|
||||
|
||||
ret = PrivSemaphoreObtainWait(&adapter->sem, &abstime);
|
||||
if (0 == ret) {
|
||||
//only handle this client_id information from gateway
|
||||
if ((client_recv_data_format[client_id - 1].client_id == adapter->net_role_id) &&
|
||||
@@ -681,6 +686,8 @@ static void *LoraReceiveTask(void *parameter)
|
||||
void LoraGatewayProcess(struct Adapter *lora_adapter, struct LoraGatewayParam *gateway)
|
||||
{
|
||||
int i, ret = 0;
|
||||
struct timespec abstime;
|
||||
abstime.tv_sec = DEFAULT_SEM_TIMEOUT;
|
||||
|
||||
#ifdef GATEWAY_CMD_MODE
|
||||
for (i = 0; i < gateway->client_num; i ++) {
|
||||
@@ -692,7 +699,7 @@ void LoraGatewayProcess(struct Adapter *lora_adapter, struct LoraGatewayParam *g
|
||||
continue;
|
||||
}
|
||||
|
||||
ret = PrivSemaphoreObtainWait(&gateway_recv_data_sem, NULL);
|
||||
ret = PrivSemaphoreObtainWait(&gateway_recv_data_sem, &abstime);
|
||||
if (0 == ret) {
|
||||
printf("LoraGatewayProcess receive client %d data done\n", gateway->client_id[i]);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,30 @@ endif
|
||||
|
||||
if ADD_NUTTX_FETURES
|
||||
|
||||
config ADAPTER_E220_M0_PATH
|
||||
string "E220 M0 pin device"
|
||||
default "/dev/gpout0"
|
||||
|
||||
config ADAPTER_E220_M1_PATH
|
||||
string "E220 M1 pin device"
|
||||
default "/dev/gpout1"
|
||||
|
||||
config ADAPTER_E220_DRIVER_EXTUART
|
||||
bool "Using extra uart to support lora"
|
||||
default y
|
||||
|
||||
config ADAPTER_E220_DRIVER
|
||||
string "E220 device uart driver path"
|
||||
default "/dev/ttyS3"
|
||||
depends on !ADAPTER_E220_DRIVER_EXTUART
|
||||
|
||||
if ADAPTER_E220_DRIVER_EXTUART
|
||||
config ADAPTER_E220_DRIVER
|
||||
string "E220 device extra uart driver path"
|
||||
default "/dev/extuart_dev3"
|
||||
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
if ADD_RTTHREAD_FETURES
|
||||
|
||||
6
APP_Framework/Framework/connection/lora/e220/Make.defs
Normal file
6
APP_Framework/Framework/connection/lora/e220/Make.defs
Normal file
@@ -0,0 +1,6 @@
|
||||
############################################################################
|
||||
# APP_Framework/Framework/connection/lora/e220/Make.defs
|
||||
############################################################################
|
||||
ifneq ($(CONFIG_ADAPTER_E220),)
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/connection/lora/e220
|
||||
endif
|
||||
@@ -1,3 +1,13 @@
|
||||
SRC_FILES := e220.c
|
||||
include $(KERNEL_ROOT)/.config
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += e220.c
|
||||
include $(APPDIR)/Application.mk
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||
SRC_FILES := e220.c
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
||||
endif
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <adapter.h>
|
||||
|
||||
#define E220_GATEWAY_ADDRESS 0xFFFF
|
||||
#define E220_CHANNEL 0x04
|
||||
#define E220_CHANNEL 0x05
|
||||
|
||||
#ifdef AS_LORA_GATEWAY_ROLE
|
||||
#define E220_ADDRESS E220_GATEWAY_ADDRESS
|
||||
@@ -46,6 +46,60 @@ enum E220LoraMode
|
||||
* @param mode Lora working mode
|
||||
* @return NULL
|
||||
*/
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
static void E220LoraModeConfig(enum E220LoraMode mode)
|
||||
{
|
||||
int m0_fd, m1_fd;
|
||||
|
||||
//delay 1s , wait AUX ready
|
||||
PrivTaskDelay(1000);
|
||||
m0_fd = PrivOpen(ADAPTER_E220_M0_PATH, O_RDWR);
|
||||
if (m0_fd < 0) {
|
||||
printf("open %s error\n", ADAPTER_E220_M0_PATH);
|
||||
return;
|
||||
}
|
||||
|
||||
m1_fd = PrivOpen(ADAPTER_E220_M1_PATH, O_RDWR);
|
||||
if (m1_fd < 0) {
|
||||
printf("open %s error\n", ADAPTER_E220_M1_PATH);
|
||||
return;
|
||||
}
|
||||
|
||||
//Both M0 and M1 GPIO are outputs mode, set M0 and M1 high or low
|
||||
switch (mode)
|
||||
{
|
||||
case DATA_TRANSFER_MODE:
|
||||
PrivIoctl(m1_fd, GPIOC_WRITE, (unsigned long)GPIO_LOW);
|
||||
PrivIoctl(m0_fd, GPIOC_WRITE, (unsigned long)GPIO_LOW);
|
||||
break;
|
||||
|
||||
case WOR_SEND_MODE:
|
||||
PrivIoctl(m1_fd, GPIOC_WRITE, (unsigned long)GPIO_LOW);
|
||||
PrivIoctl(m0_fd, GPIOC_WRITE, (unsigned long)GPIO_HIGH);
|
||||
break;
|
||||
|
||||
case WOR_RECEIVE_MODE:
|
||||
PrivIoctl(m1_fd, GPIOC_WRITE, (unsigned long)GPIO_HIGH);
|
||||
|
||||
PrivIoctl(m0_fd, GPIOC_WRITE,(unsigned long)GPIO_LOW);
|
||||
break;
|
||||
|
||||
case CONFIGURE_MODE_MODE:
|
||||
PrivIoctl(m1_fd, GPIOC_WRITE, (unsigned long)GPIO_HIGH);
|
||||
PrivIoctl(m0_fd, GPIOC_WRITE, (unsigned long)GPIO_HIGH);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
PrivClose(m0_fd);
|
||||
PrivClose(m1_fd);
|
||||
|
||||
//delay 20ms , wait mode switch done
|
||||
PrivTaskDelay(20);
|
||||
}
|
||||
#else
|
||||
static void E220LoraModeConfig(enum E220LoraMode mode)
|
||||
{
|
||||
//delay 1s , wait AUX ready
|
||||
@@ -126,6 +180,7 @@ static void E220LoraModeConfig(enum E220LoraMode mode)
|
||||
//delay 20ms , wait mode switch done
|
||||
PrivTaskDelay(20);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @description: Switch baud rate to register bit
|
||||
@@ -263,6 +318,25 @@ static int E220GetRegisterParam(uint8 *buf)
|
||||
* @param adapter - Lora device pointer
|
||||
* @return success: 0, failure: -1
|
||||
*/
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
static int E220Open(struct Adapter *adapter)
|
||||
{
|
||||
/*step1: open e220 uart port*/
|
||||
adapter->fd = PrivOpen(ADAPTER_E220_DRIVER, O_RDWR);
|
||||
if (adapter->fd < 0) {
|
||||
printf("E220Open get uart %s fd error\n", ADAPTER_E220_DRIVER);
|
||||
return -1;
|
||||
}
|
||||
|
||||
PrivIoctl(adapter->fd, OPE_INT, (unsigned long)BAUD_RATE_9600);
|
||||
E220SetRegisterParam(adapter, E220_ADDRESS, E220_CHANNEL, E220_UART_BAUD_RATE);
|
||||
PrivIoctl(adapter->fd, OPE_INT, (unsigned long)E220_UART_BAUD_RATE);
|
||||
|
||||
ADAPTER_DEBUG("E220Open done\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
static int E220Open(struct Adapter *adapter)
|
||||
{
|
||||
/*step1: open e220 uart port*/
|
||||
@@ -316,6 +390,7 @@ static int E220Open(struct Adapter *adapter)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @description: Close E220 uart function
|
||||
@@ -520,6 +595,7 @@ static void LoraRead(void *parameter)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
static void LoraTest(void)
|
||||
{
|
||||
int ret;
|
||||
@@ -554,3 +630,40 @@ static void LoraSend(int argc, char *argv[])
|
||||
}
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
|
||||
LoraSend, LoraSend, lora send message);
|
||||
#endif
|
||||
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
void E220LoraReceive(void)
|
||||
{
|
||||
int ret;
|
||||
pthread_t thread;
|
||||
pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER;
|
||||
attr.priority = 80;
|
||||
attr.stacksize = 2048;
|
||||
|
||||
LoraOpen();
|
||||
|
||||
ret = PrivTaskCreate(&thread, &attr, (void*)LoraRead, NULL);
|
||||
if (ret < 0) {
|
||||
printf("task lora read create failed, status=%d\n", ret);
|
||||
return;
|
||||
}
|
||||
}
|
||||
void E220LoraSend(int argc, char *argv[])
|
||||
{
|
||||
struct Adapter *adapter = AdapterDeviceFindByName(ADAPTER_LORA_NAME);
|
||||
if (NULL == adapter) {
|
||||
printf("LoraRead find lora adapter error\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (argc == 2) {
|
||||
char Msg[256] = {0};
|
||||
strncpy(Msg, argv[1], 256);
|
||||
|
||||
E220Open(adapter);
|
||||
E220Send(adapter, Msg, strlen(Msg));
|
||||
E220Close(adapter);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
7
APP_Framework/Framework/connection/wifi/Make.defs
Executable file
7
APP_Framework/Framework/connection/wifi/Make.defs
Executable file
@@ -0,0 +1,7 @@
|
||||
############################################################################
|
||||
# APP_Framework/Framework/connection/zigbee/Make.defs
|
||||
############################################################################
|
||||
ifneq ($(CONFIG_CONNECTION_ADAPTER_WIFI),)
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/connection/wifi
|
||||
endif
|
||||
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/connection/wifi/*/Make.defs)
|
||||
@@ -1,3 +1,12 @@
|
||||
include $(KERNEL_ROOT)/.config
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += adapter_wifi.c
|
||||
include $(APPDIR)/Application.mk
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||
SRC_FILES := adapter_wifi.c
|
||||
|
||||
ifeq ($(CONFIG_ADAPTER_HFA21_WIFI),y)
|
||||
@@ -9,3 +18,4 @@ ifeq ($(CONFIG_ADAPTER_ESP07S_WIFI),y)
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
||||
|
||||
@@ -100,6 +100,7 @@ int AdapterWifiInit(void)
|
||||
}
|
||||
|
||||
/******************wifi TEST*********************/
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
int AdapterWifiTest(void)
|
||||
{
|
||||
char cmd[64];
|
||||
@@ -107,29 +108,28 @@ int AdapterWifiTest(void)
|
||||
|
||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME);
|
||||
|
||||
|
||||
#ifdef ADAPTER_HFA21_DRIVER_EXT_PORT
|
||||
static BusType ch438_pin;
|
||||
ch438_pin = PinBusInitGet();
|
||||
struct PinParam pin_cfg;
|
||||
int ret = 0;
|
||||
struct PinParam pin_cfg;
|
||||
int ret = 0;
|
||||
|
||||
struct BusConfigureInfo configure_info;
|
||||
configure_info.configure_cmd = OPE_CFG;
|
||||
configure_info.private_data = (void *)&pin_cfg;
|
||||
struct BusConfigureInfo configure_info;
|
||||
configure_info.configure_cmd = OPE_CFG;
|
||||
configure_info.private_data = (void *)&pin_cfg;
|
||||
|
||||
pin_cfg.cmd = GPIO_CONFIG_MODE;
|
||||
pin_cfg.pin = 22;
|
||||
pin_cfg.mode = GPIO_CFG_OUTPUT;
|
||||
|
||||
ret = BusDrvConfigure(ch438_pin->owner_driver, &configure_info);
|
||||
ret = BusDrvConfigure(ch438_pin->owner_driver, &configure_info);
|
||||
|
||||
struct PinStat pin_stat;
|
||||
struct BusBlockWriteParam write_param;
|
||||
struct BusBlockReadParam read_param;
|
||||
write_param.buffer = (void *)&pin_stat;
|
||||
|
||||
pin_stat.val = GPIO_HIGH;
|
||||
struct BusBlockWriteParam write_param;
|
||||
struct BusBlockReadParam read_param;
|
||||
write_param.buffer = (void *)&pin_stat;
|
||||
|
||||
pin_stat.val = GPIO_HIGH;
|
||||
|
||||
pin_stat.pin = 22;
|
||||
BusDevWriteData(ch438_pin->owner_haldev, &write_param);
|
||||
@@ -155,7 +155,6 @@ int AdapterWifiTest(void)
|
||||
PrivClose(pin_fd);
|
||||
#endif
|
||||
|
||||
|
||||
AdapterDeviceOpen(adapter);
|
||||
// AdapterDeviceControl(adapter, OPE_INT, &baud_rate);
|
||||
|
||||
@@ -182,8 +181,8 @@ int AdapterWifiTest(void)
|
||||
AdapterDeviceRecv(adapter, wifi_recv_msg, 128);
|
||||
PrivTaskDelay(1000);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ADD_RTTHREAD_FETURES
|
||||
MSH_CMD_EXPORT(AdapterWifiTest,a wifi adpter sample);
|
||||
@@ -195,8 +194,7 @@ SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHE
|
||||
int wifiopen(void)
|
||||
{
|
||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME);
|
||||
|
||||
AdapterDeviceOpen(adapter);
|
||||
return AdapterDeviceOpen(adapter);
|
||||
}
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, wifiopen, wifiopen, open adapter wifi );
|
||||
@@ -204,8 +202,7 @@ SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHE
|
||||
int wificlose(void)
|
||||
{
|
||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME);
|
||||
|
||||
AdapterDeviceClose(adapter);
|
||||
return AdapterDeviceClose(adapter);
|
||||
}
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, wificlose, wificlose, close adapter wifi );
|
||||
@@ -215,12 +212,12 @@ int wifisetup(int argc, char *argv[])
|
||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME);
|
||||
struct WifiParam param;
|
||||
memset(¶m,0,sizeof(struct WifiParam));
|
||||
strncpy(param.wifi_ssid, argv[1], strlen(argv[1]));
|
||||
strncpy(param.wifi_pwd, argv[2], strlen(argv[2]));
|
||||
strncpy((char *)param.wifi_ssid, argv[1], strlen(argv[1]));
|
||||
strncpy((char *)param.wifi_pwd, argv[2], strlen(argv[2]));
|
||||
|
||||
adapter->adapter_param = ¶m;
|
||||
|
||||
AdapterDeviceSetUp(adapter);
|
||||
return AdapterDeviceSetUp(adapter);
|
||||
}
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(3)|SHELL_CMD_DISABLE_RETURN, wifisetup, wifisetup, setup adapter wifi );
|
||||
@@ -234,7 +231,7 @@ int wifiaddrset(int argc, char *argv[])
|
||||
|
||||
AdapterDeviceSetAddr(adapter, ip, gateway, netmask);
|
||||
AdapterDevicePing(adapter, "36.152.44.95");///< ping www.baidu.com
|
||||
AdapterDeviceNetstat(adapter);
|
||||
return AdapterDeviceNetstat(adapter);
|
||||
}
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(4)|SHELL_CMD_DISABLE_RETURN, wifiaddrset, wifiaddrset, addrset adapter wifi);
|
||||
@@ -243,7 +240,7 @@ int wifiping(int argc, char *argv[])
|
||||
{
|
||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME);
|
||||
printf("ping %s\n",argv[1]);
|
||||
AdapterDevicePing(adapter, argv[1]);
|
||||
return AdapterDevicePing(adapter, argv[1]);
|
||||
}
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(3), wifiping, wifiping, wifiping adapter );
|
||||
@@ -264,7 +261,7 @@ int wificonnect(int argc, char *argv[])
|
||||
adapter->socket.protocal = SOCKET_PROTOCOL_UDP;
|
||||
}
|
||||
|
||||
AdapterDeviceConnect(adapter, net_role, ip, port, ip_type);
|
||||
return AdapterDeviceConnect(adapter, net_role, ip, port, ip_type);
|
||||
}
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(4)|SHELL_CMD_DISABLE_RETURN, wificonnect, wificonnect, wificonnect adapter);
|
||||
@@ -279,6 +276,7 @@ int wifisend(int argc, char *argv[])
|
||||
AdapterDeviceSend(adapter, wifi_msg, len);
|
||||
PrivTaskDelay(1000);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(3)|SHELL_CMD_DISABLE_RETURN, wifisend, wifisend, wifisend adapter wifi information);
|
||||
@@ -297,3 +295,117 @@ int wifirecv(int argc, char *argv[])
|
||||
#ifdef ADD_XIZI_FETURES
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(3)|SHELL_CMD_DISABLE_RETURN, wifirecv, wifirecv, wifirecv adapter wifi information);
|
||||
#endif
|
||||
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
|
||||
enum
|
||||
{
|
||||
APT_WIFI_PARAM_IP,
|
||||
APT_WIFI_PARAM_PORT,
|
||||
APT_WIFI_PARAM_SSID,
|
||||
APT_WIFI_PARAM_PWD,
|
||||
APT_WIFI_PARAM_GW,
|
||||
APT_WIFI_PARAM_SERVER,
|
||||
APT_WIFI_PARAM_MASK,
|
||||
APT_WIFI_PARAM_PING,
|
||||
APT_WIFI_PARAM_NUM
|
||||
};
|
||||
|
||||
#define APT_WIFI_PARAM_LEN 20
|
||||
|
||||
char wifi_param[APT_WIFI_PARAM_NUM][APT_WIFI_PARAM_LEN] = {0};
|
||||
|
||||
#define CHECK_RET(__func) \
|
||||
ret = __func; \
|
||||
if(ret != 0){ \
|
||||
printf("%s %d failed\n", __func__, __LINE__); \
|
||||
AdapterDeviceClose(adapter); \
|
||||
return ret; \
|
||||
};
|
||||
|
||||
void AdapterWifiGetParam(int argc, char *argv[])
|
||||
{
|
||||
int i, j;
|
||||
char *param_str[] = {"ip", "port", "ssid", "pwd", "gw", "server", "mask", "ping"};
|
||||
char *default_str[] =
|
||||
{"192.168.137.34", "12345", "test", "tttttttt", "192.168.137.71", "192.168.137.1", "255.255.255.0", "220.181.38.251"};
|
||||
|
||||
for(i = 0; i < APT_WIFI_PARAM_NUM; i ++)
|
||||
{
|
||||
memset(wifi_param[i], 0, APT_WIFI_PARAM_LEN);
|
||||
strcpy(wifi_param[i], default_str[i]);
|
||||
}
|
||||
|
||||
for(i = 0; i < argc; i ++)
|
||||
{
|
||||
for(j = 0; j < APT_WIFI_PARAM_NUM; j ++)
|
||||
{
|
||||
if(strncmp(argv[i], param_str[j], strlen(param_str[j])) == 0)
|
||||
{
|
||||
printf("wifi %d: %s\n", j, argv[i] + strlen(param_str[j]) + 1);
|
||||
strcpy(wifi_param[j], argv[i] + strlen(param_str[j]) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("--- wifi parameter ---\n");
|
||||
for(i = 0; i < APT_WIFI_PARAM_NUM; i ++)
|
||||
{
|
||||
printf("%7.7s = %s\n", param_str[i], wifi_param[i]);
|
||||
}
|
||||
printf("----------------------\n");
|
||||
}
|
||||
|
||||
|
||||
int AdapterWifiTest(int argc, char *argv[])
|
||||
{
|
||||
int i, ret;
|
||||
|
||||
struct Adapter* adapter = AdapterDeviceFindByName(ADAPTER_WIFI_NAME);
|
||||
AdapterWifiGetParam(argc, argv);
|
||||
|
||||
enum NetRoleType net_role = CLIENT;
|
||||
enum IpType ip_type = IPV4;
|
||||
struct WifiParam param;
|
||||
memset(¶m, 0, sizeof(struct WifiParam));
|
||||
strncpy((char *)param.wifi_ssid, wifi_param[APT_WIFI_PARAM_SSID], strlen(wifi_param[APT_WIFI_PARAM_SSID]));
|
||||
strncpy((char *)param.wifi_pwd, wifi_param[APT_WIFI_PARAM_PWD], strlen(wifi_param[APT_WIFI_PARAM_PWD]));
|
||||
|
||||
adapter->adapter_param = ¶m;
|
||||
|
||||
CHECK_RET(AdapterDeviceOpen(adapter));
|
||||
CHECK_RET(AdapterDeviceSetUp(adapter));
|
||||
|
||||
CHECK_RET(AdapterDeviceSetAddr(adapter, wifi_param[APT_WIFI_PARAM_IP], wifi_param[APT_WIFI_PARAM_GW],
|
||||
wifi_param[APT_WIFI_PARAM_MASK]));
|
||||
|
||||
CHECK_RET(AdapterDeviceNetstat(adapter));
|
||||
|
||||
adapter->socket.protocal = SOCKET_PROTOCOL_TCP;
|
||||
CHECK_RET(AdapterDeviceConnect(adapter, net_role, wifi_param[APT_WIFI_PARAM_SERVER],
|
||||
wifi_param[APT_WIFI_PARAM_PORT], ip_type));
|
||||
|
||||
const char *wifi_msg = "Wifi Test";
|
||||
for(i = 0; i < 10; i++)
|
||||
{
|
||||
AdapterDeviceSend(adapter, wifi_msg, strlen(wifi_msg));
|
||||
PrivTaskDelay(4000);
|
||||
}
|
||||
|
||||
char wifi_recv_msg[128];
|
||||
for(i = 0; i < 10; i ++)
|
||||
{
|
||||
AdapterDeviceRecv(adapter, wifi_recv_msg, 128);
|
||||
PrivTaskDelay(1000);
|
||||
}
|
||||
|
||||
// printf("ping %s\n", wifi_param[APT_WIFI_PARAM_PING]);
|
||||
//
|
||||
// CHECK_RET(AdapterDevicePing(adapter, wifi_param[APT_WIFI_PARAM_PING]));
|
||||
// AdapterDeviceDisconnect(adapter, NULL);
|
||||
ret = AdapterDeviceClose(adapter);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -10,10 +10,10 @@ if ADD_XIZI_FETURES
|
||||
|
||||
config ADAPTER_ESP07S_DRIVER
|
||||
string "ESP07S device uart driver path"
|
||||
default "/dev/uart2_dev2"
|
||||
default "/dev/ttyS2"
|
||||
depends on !ADAPTER_ESP07S_DRIVER_EXTUART
|
||||
|
||||
if ADAPTER_ESP07S_DRIVER_EXTUART
|
||||
if ADAPTER_ESP07S_DRIVER_EXTUART
|
||||
config ADAPTER_ESP07S_DRIVER
|
||||
string "ESP07S device extra uart driver path"
|
||||
default "/dev/extuart_dev6"
|
||||
@@ -25,7 +25,24 @@ if ADD_XIZI_FETURES
|
||||
endif
|
||||
|
||||
if ADD_NUTTX_FETURES
|
||||
config ADAPTER_ESP07S_DRIVER_EXTUART
|
||||
bool "Using extra uart to support wifi"
|
||||
default n
|
||||
|
||||
config ADAPTER_ESP07S_DRIVER
|
||||
string "ESP07S device uart driver path"
|
||||
default "/dev/uart2_dev2"
|
||||
depends on !ADAPTER_ESP07S_DRIVER_EXTUART
|
||||
|
||||
if ADAPTER_ESP07S_DRIVER_EXTUART
|
||||
config ADAPTER_ESP07S_DRIVER
|
||||
string "ESP07S device extra uart driver path"
|
||||
default "/dev/extuart_dev6"
|
||||
|
||||
config ADAPTER_ESP07S_DRIVER_EXT_PORT
|
||||
int "if ESP07S device using extuart, choose port"
|
||||
default "6"
|
||||
endif
|
||||
endif
|
||||
|
||||
if ADD_RTTHREAD_FETURES
|
||||
|
||||
6
APP_Framework/Framework/connection/wifi/esp07s_wifi/Make.defs
Executable file
6
APP_Framework/Framework/connection/wifi/esp07s_wifi/Make.defs
Executable file
@@ -0,0 +1,6 @@
|
||||
############################################################################
|
||||
# APP_Framework/Framework/connection/zigbee/e18/Make.defs
|
||||
############################################################################
|
||||
ifneq ($(CONFIG_ADAPTER_ESP07S_WIFI),)
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/connection/wifi/esp07s_wifi
|
||||
endif
|
||||
@@ -1,3 +1,13 @@
|
||||
include $(KERNEL_ROOT)/.config
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += esp07s_wifi.c
|
||||
include $(APPDIR)/Application.mk
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||
SRC_FILES := esp07s_wifi.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
||||
|
||||
@@ -25,6 +25,11 @@
|
||||
|
||||
#define LEN_PARA_BUF 128
|
||||
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
#define EOK 0
|
||||
#define x_err_t int
|
||||
#endif
|
||||
|
||||
static int Esp07sWifiSetDown(struct Adapter *adapter_at);
|
||||
|
||||
/**
|
||||
@@ -116,7 +121,7 @@ static int Esp07sWifiOpen(struct Adapter *adapter)
|
||||
|
||||
AtSetReplyEndChar(adapter->agent,'O','K');
|
||||
|
||||
ADAPTER_DEBUG("Esp07sWifi open done\n");
|
||||
ADAPTER_DEBUG("Esp07sWifi open done\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -196,13 +201,13 @@ static int Esp07sWifiSetUp(struct Adapter *adapter)
|
||||
}
|
||||
PrivTaskDelay(2000);
|
||||
/* config as softAP+station mode */
|
||||
ret = AtCmdConfigAndCheck(agent, "AT+CWMODE=3\r\n", "OK");
|
||||
ret = AtCmdConfigAndCheck(agent, "AT+CWMODE=3\r\n", "OK");
|
||||
if(ret < 0) {
|
||||
printf("%s %d cmd[AT+CWMODE=3] config failed!\n",__func__,__LINE__);
|
||||
return -1;
|
||||
}
|
||||
PrivTaskDelay(2000);
|
||||
/* connect the router */
|
||||
/* connect the router */
|
||||
memset(cmd,0,sizeof(cmd));
|
||||
strncpy(cmd,"AT+CWJAP=",strlen("AT+CWJAP="));
|
||||
strncat(cmd,"\"",1);
|
||||
@@ -222,7 +227,7 @@ static int Esp07sWifiSetUp(struct Adapter *adapter)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* check the wifi ip address */
|
||||
/* check the wifi ip address */
|
||||
ATReplyType reply = CreateATReply(256);
|
||||
if (NULL == reply) {
|
||||
printf("%s %d at_create_resp failed!\n",__func__,__LINE__);
|
||||
@@ -291,7 +296,7 @@ static int Esp07sWifiSetAddr(struct Adapter *adapter, const char *ip, const char
|
||||
strncat(cmd,"\"",1);
|
||||
strcat(cmd,"\r\n");
|
||||
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, cmd, "OK");
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, cmd, "OK");
|
||||
if(ret < 0) {
|
||||
printf("%s %d cmd[%s] config ip failed!\n",__func__,__LINE__,cmd);
|
||||
return -1;
|
||||
@@ -339,7 +344,7 @@ static int Esp07sWifiNetstat(struct Adapter *adapter)
|
||||
int ret = 0;
|
||||
char *result = NULL;
|
||||
|
||||
/* check the wifi ip address */
|
||||
/* check the wifi ip address */
|
||||
ATReplyType reply = CreateATReply(256);
|
||||
if (NULL == reply) {
|
||||
printf("%s %d at_create_resp failed!\n",__func__,__LINE__);
|
||||
@@ -359,7 +364,7 @@ static int Esp07sWifiNetstat(struct Adapter *adapter)
|
||||
goto __exit;
|
||||
}
|
||||
printf("[%s]\n", result);
|
||||
|
||||
|
||||
__exit:
|
||||
DeleteATReply(reply);
|
||||
|
||||
@@ -380,7 +385,7 @@ static int Esp07sWifiConnect(struct Adapter *adapter, enum NetRoleType net_role,
|
||||
int ret = EOK;
|
||||
char cmd[LEN_PARA_BUF];
|
||||
struct ATAgent *agent = adapter->agent;
|
||||
|
||||
|
||||
memset(cmd,0,sizeof(cmd));
|
||||
if(adapter->socket.protocal == SOCKET_PROTOCOL_TCP && net_role == CLIENT) //esp07s as tcp client to connect server
|
||||
{
|
||||
@@ -397,13 +402,13 @@ static int Esp07sWifiConnect(struct Adapter *adapter, enum NetRoleType net_role,
|
||||
strncat(cmd, port, strlen(port));
|
||||
strcat(cmd,"\r\n");
|
||||
|
||||
ret = AtCmdConfigAndCheck(agent, cmd, "OK");
|
||||
ret = AtCmdConfigAndCheck(agent, cmd, "OK");
|
||||
if(ret < 0) {
|
||||
printf("%s %d tcp connect [%s] failed!\n",__func__,__LINE__,ip);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if(adapter->socket.protocal == SOCKET_PROTOCOL_UDP)
|
||||
}
|
||||
else if(adapter->socket.protocal == SOCKET_PROTOCOL_UDP)
|
||||
{
|
||||
//e.g. AT+CIPSTART="UDP","192.168.3.116",8080,2233,0 UDP protocol, server IP, port,local port,udp mode
|
||||
strncpy(cmd,"AT+CIPSTART=",strlen("AT+CIPSTART="));
|
||||
@@ -422,7 +427,7 @@ static int Esp07sWifiConnect(struct Adapter *adapter, enum NetRoleType net_role,
|
||||
strncat(cmd, "0", 1); ///< udp transparent transmission mode must be 0
|
||||
strcat(cmd,"\r\n");
|
||||
|
||||
ret = AtCmdConfigAndCheck(agent, cmd, "OK");
|
||||
ret = AtCmdConfigAndCheck(agent, cmd, "OK");
|
||||
if(ret < 0) {
|
||||
printf("%s %d udp connect [%s] failed!\n",__func__,__LINE__,ip);
|
||||
return -1;
|
||||
@@ -455,17 +460,17 @@ static int Esp07sWifiDisconnect(struct Adapter *adapter)
|
||||
memset(cmd,0,sizeof(cmd));
|
||||
|
||||
/* step1: stop transparent transmission mode */
|
||||
ATOrderSend(agent, REPLY_TIME_OUT, NULL, "+++\r\n");
|
||||
ATOrderSend(agent, REPLY_TIME_OUT, NULL, "+++\r\n");
|
||||
|
||||
/* step2: exit transparent transmission mode */
|
||||
ret = AtCmdConfigAndCheck(agent, "AT+CIPMODE=0\r\n", "OK");
|
||||
ret = AtCmdConfigAndCheck(agent, "AT+CIPMODE=0\r\n", "OK");
|
||||
if(ret < 0) {
|
||||
printf("%s %d cmd[AT+CIPMODE=0] exit failed!\n",__func__,__LINE__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* step3: disconnect */
|
||||
ret = AtCmdConfigAndCheck(agent, "AT+CIPCLOSE\r\n", "OK");
|
||||
ret = AtCmdConfigAndCheck(agent, "AT+CIPCLOSE\r\n", "OK");
|
||||
if(ret < 0) {
|
||||
printf("%s %d cmd [AT+CIPCLOSE] disconnect failed!\n",__func__,__LINE__);
|
||||
return -1;
|
||||
@@ -490,7 +495,7 @@ static int Esp07sWifiIoctl(struct Adapter *adapter, int cmd, void *args)
|
||||
case CONFIG_WIFI_RESTORE: /* resore wifi */
|
||||
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "AT+RESTORE\r\n");
|
||||
break;
|
||||
case CONFIG_WIFI_BAUDRATE:
|
||||
case CONFIG_WIFI_BAUDRATE:
|
||||
/* step1: config mcu uart*/
|
||||
baud_rate = *((uint32_t *)args);
|
||||
|
||||
@@ -525,14 +530,14 @@ static int Esp07sWifiIoctl(struct Adapter *adapter, int cmd, void *args)
|
||||
strncat(at_cmd, ",", 1);
|
||||
strncat(at_cmd, "8", 1);
|
||||
strncat(at_cmd, ",", 1);
|
||||
strncat(at_cmd, "1", 1);
|
||||
strncat(at_cmd, "1", 1);
|
||||
strncat(at_cmd, ",", 1);
|
||||
strncat(at_cmd, "0", 1);
|
||||
strncat(at_cmd, ",", 1);
|
||||
strncat(at_cmd, "3", 1);
|
||||
strcat(at_cmd,"\r\n");
|
||||
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, at_cmd, "OK");
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, at_cmd, "OK");
|
||||
if(ret < 0) {
|
||||
printf("%s %d cmd [%s] config uart failed!\n",__func__,__LINE__,at_cmd);
|
||||
ret = -1;
|
||||
@@ -541,7 +546,7 @@ static int Esp07sWifiIoctl(struct Adapter *adapter, int cmd, void *args)
|
||||
break;
|
||||
default:
|
||||
ret = -1;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -572,7 +577,7 @@ static const struct IpProtocolDone esp07s_wifi_done =
|
||||
AdapterProductInfoType Esp07sWifiAttach(struct Adapter *adapter)
|
||||
{
|
||||
struct AdapterProductInfo *product_info = PrivMalloc(sizeof(struct AdapterProductInfo));
|
||||
if (!product_info)
|
||||
if (!product_info)
|
||||
{
|
||||
printf("Esp07sWifiAttach Attach malloc product_info error\n");
|
||||
PrivFree(product_info);
|
||||
@@ -584,4 +589,4 @@ AdapterProductInfoType Esp07sWifiAttach(struct Adapter *adapter)
|
||||
product_info->model_done = (void *)&esp07s_wifi_done;
|
||||
|
||||
return product_info;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
config ADAPTER_ZIGBEE_E18
|
||||
string "E18 adapter name"
|
||||
default "e18"
|
||||
|
||||
choice
|
||||
|
||||
choice
|
||||
prompt "E18 adapter select net role type "
|
||||
default AS_END_DEVICE_ROLE
|
||||
|
||||
@@ -11,7 +11,7 @@ choice
|
||||
|
||||
config AS_ROUTER_ROLE
|
||||
bool "config as a router"
|
||||
|
||||
|
||||
config AS_END_DEVICE_ROLE
|
||||
bool "config as an end device"
|
||||
endchoice
|
||||
@@ -22,8 +22,8 @@ if ADD_XIZI_FETURES
|
||||
int "E18 MODE pin number"
|
||||
default "61"
|
||||
|
||||
config ADAPTER_BC28_PIN_DRIVER
|
||||
string "BC28 device pin driver path"
|
||||
config ADAPTER_E18_PIN_DRIVER
|
||||
string "E18 device pin driver path"
|
||||
default "/dev/pin_dev"
|
||||
|
||||
config ADAPTER_E18_DRIVER_EXTUART
|
||||
@@ -35,7 +35,7 @@ if ADD_XIZI_FETURES
|
||||
default "/dev/uart2_dev2"
|
||||
depends on !ADAPTER_E18_DRIVER_EXTUART
|
||||
|
||||
if ADAPTER_E18_DRIVER_EXTUART
|
||||
if ADAPTER_E18_DRIVER_EXTUART
|
||||
config ADAPTER_E18_DRIVER
|
||||
string "E18 device extra uart driver path"
|
||||
default "/dev/extuart_dev0"
|
||||
@@ -47,11 +47,31 @@ if ADD_XIZI_FETURES
|
||||
endif
|
||||
|
||||
if ADD_NUTTX_FETURES
|
||||
config ADAPTER_E18_MODEPIN
|
||||
int "E18 MODE pin number"
|
||||
default "61"
|
||||
|
||||
config ADAPTER_E18_PIN_DRIVER
|
||||
string "E18 device pin driver path"
|
||||
default "/dev/pin_dev"
|
||||
|
||||
config ADAPTER_E18_DRIVER
|
||||
string "E18 device uart driver path"
|
||||
default "/dev/ttyS1"
|
||||
depends on !ADAPTER_E18_DRIVER_EXTUART
|
||||
---help---
|
||||
If USART1 is selected, then fill in /dev/ttyS1 here.
|
||||
|
||||
if ADAPTER_E18_DRIVER_EXTUART
|
||||
config ADAPTER_E18_DRIVER
|
||||
string "E18 device extra uart driver path"
|
||||
default "/dev/extuart_dev1"
|
||||
|
||||
config ADAPTER_E18_DRIVER_EXT_PORT
|
||||
int "if E18 device using extuart, choose port"
|
||||
default "1"
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
if ADD_RTTHREAD_FETURES
|
||||
|
||||
@@ -45,7 +45,7 @@ static int E18HardwareModeGet()
|
||||
int ret = 0;
|
||||
int pin_fd;
|
||||
|
||||
pin_fd = PrivOpen(ADAPTER_BC28_PIN_DRIVER, O_RDWR);
|
||||
pin_fd = PrivOpen(ADAPTER_E18_PIN_DRIVER, O_RDWR);
|
||||
|
||||
struct PinStat pin_stat;
|
||||
pin_stat.pin = ADAPTER_E18_MODEPIN;
|
||||
@@ -175,7 +175,7 @@ static int E18NetworkModeConfig(struct Adapter *adapter)
|
||||
}
|
||||
|
||||
out:
|
||||
if(E18_AS_HEX_MODE == mode){
|
||||
if(E18_AS_AT_MODE == mode){
|
||||
AtCmdConfigAndCheck(adapter->agent, cmd_exit, "+OK");
|
||||
}
|
||||
|
||||
@@ -203,7 +203,9 @@ static int E18NetRoleConfig(struct Adapter *adapter)
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//wait 2second
|
||||
PrivTaskDelay(2000);
|
||||
|
||||
switch (adapter->net_role)
|
||||
{
|
||||
@@ -240,7 +242,7 @@ static int E18NetRoleConfig(struct Adapter *adapter)
|
||||
}
|
||||
|
||||
out:
|
||||
if(E18_AS_HEX_MODE == mode) {
|
||||
if(E18_AS_AT_MODE == mode) {
|
||||
AtCmdConfigAndCheck(adapter->agent, cmd_exit, "+OK");
|
||||
}
|
||||
|
||||
@@ -382,7 +384,7 @@ static int E18Join(struct Adapter *adapter, unsigned char *priv_net_group)
|
||||
|
||||
// }
|
||||
if(!ret){
|
||||
if(E18_AS_HEX_MODE == mode) {
|
||||
if(E18_AS_AT_MODE == mode) {
|
||||
ret = AtCmdConfigAndCheck(adapter->agent, cmd_exit, "+OK");
|
||||
if(ret < 0) {
|
||||
printf("%s %d cmd[%s] config failed!\n",__func__,__LINE__,cmd_exit);
|
||||
|
||||
@@ -55,17 +55,19 @@ int PrivSemaphoreDelete(sem_t *sem)
|
||||
|
||||
int PrivSemaphoreObtainWait(sem_t *sem, const struct timespec *abstime)
|
||||
{
|
||||
/* if the timeout is not set, it will be blocked all the time. */
|
||||
if(!abstime)
|
||||
{
|
||||
return sem_wait(sem);
|
||||
}
|
||||
|
||||
/* if the timeout time is set, it will be executed downward after the timeout, and will not be blocked. */
|
||||
struct timespec timeout;
|
||||
clock_gettime(CLOCK_REALTIME, &timeout);
|
||||
timeout.tv_sec += abstime->tv_sec;
|
||||
return sem_timedwait(sem, &timeout);
|
||||
}
|
||||
|
||||
int PrivSemaphoreObtainWaitForever(sem_t *sem)
|
||||
{
|
||||
return sem_wait(sem);
|
||||
}
|
||||
|
||||
int PrivSemaphoreObtainNoWait(sem_t *sem)
|
||||
{
|
||||
return sem_trywait(sem);
|
||||
@@ -133,40 +135,9 @@ int PrivWrite(int fd, const void *buf, size_t len)
|
||||
return write(fd, buf, len);
|
||||
}
|
||||
|
||||
static int PrivSerialIoctl(int fd, int cmd, void *args)
|
||||
int PrivIoctl(int fd, int cmd, unsigned long args)
|
||||
{
|
||||
struct SerialDataCfg *serial_cfg = (struct SerialDataCfg *)args;
|
||||
return ioctl(fd, cmd, serial_cfg);
|
||||
}
|
||||
|
||||
static int PrivPinIoctl(int fd, int cmd, void *args)
|
||||
{
|
||||
struct PinParam *pin_cfg = (struct PinParam *)args;
|
||||
|
||||
return ioctl(fd, cmd, pin_cfg);
|
||||
}
|
||||
|
||||
int PrivIoctl(int fd, int cmd, void *args)
|
||||
{
|
||||
int ret = 0;
|
||||
struct PrivIoctlCfg *ioctl_cfg = (struct PrivIoctlCfg *)args;
|
||||
|
||||
switch (ioctl_cfg->ioctl_driver_type)
|
||||
{
|
||||
case SERIAL_TYPE:
|
||||
ret = PrivSerialIoctl(fd, cmd, ioctl_cfg->args);
|
||||
break;
|
||||
case PIN_TYPE:
|
||||
ret = PrivPinIoctl(fd, cmd, ioctl_cfg->args);
|
||||
break;
|
||||
case I2C_TYPE:
|
||||
ret = ioctl(fd, cmd, ioctl_cfg->args);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ioctl(fd, cmd, args);
|
||||
}
|
||||
|
||||
/********************memory api************/
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <nuttx/wireless/lpwan/sx127x.h>
|
||||
#include <nuttx/ioexpander/gpio.h>
|
||||
#include <termios.h>
|
||||
|
||||
typedef uint8_t uint8;
|
||||
typedef uint16_t uint16;
|
||||
@@ -43,22 +45,23 @@ typedef int64_t int64;
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define OPE_INT 0x0000
|
||||
#define OPE_CFG 0x0001
|
||||
#define OPE_INT 0x0000
|
||||
#define OPE_CFG 0x0001
|
||||
|
||||
#define NAME_NUM_MAX 32
|
||||
|
||||
#define NAME_NUM_MAX 32
|
||||
|
||||
/*********************GPIO define*********************/
|
||||
#define GPIO_LOW 0x00
|
||||
#define GPIO_HIGH 0x01
|
||||
|
||||
#define GPIO_CFG_OUTPUT 0x00
|
||||
#define GPIO_CFG_INPUT 0x01
|
||||
#define GPIO_CFG_INPUT_PULLUP 0x02
|
||||
#define GPIO_CFG_OUTPUT 0x00
|
||||
#define GPIO_CFG_INPUT 0x01
|
||||
#define GPIO_CFG_INPUT_PULLUP 0x02
|
||||
#define GPIO_CFG_INPUT_PULLDOWN 0x03
|
||||
#define GPIO_CFG_OUTPUT_OD 0x04
|
||||
#define GPIO_CFG_OUTPUT_OD 0x04
|
||||
|
||||
#define GPIO_CONFIG_MODE 0xffffffff
|
||||
#define GPIO_CONFIG_MODE 0xffffffff
|
||||
|
||||
/********************SERIAL define*******************/
|
||||
#define BAUD_RATE_2400 2400
|
||||
@@ -172,15 +175,11 @@ int PrivMutexDelete(pthread_mutex_t *p_mutex);
|
||||
int PrivMutexObtain(pthread_mutex_t *p_mutex);
|
||||
int PrivMutexAbandon(pthread_mutex_t *p_mutex);
|
||||
|
||||
|
||||
|
||||
|
||||
/*********************semaphore**********************/
|
||||
|
||||
int PrivSemaphoreCreate(sem_t *sem, int pshared, unsigned int value);
|
||||
int PrivSemaphoreDelete(sem_t *sem);
|
||||
int PrivSemaphoreObtainWait(sem_t *sem, const struct timespec *abstime);
|
||||
int PrivSemaphoreObtainWaitForever(sem_t *sem);
|
||||
int PrivSemaphoreObtainNoWait(sem_t *sem);
|
||||
int PrivSemaphoreAbandon(sem_t *sem);
|
||||
int32_t PrivSemaphoreSetValue(int32_t sem, uint16_t val);
|
||||
@@ -201,7 +200,7 @@ int PrivOpen(const char *path, int flags);
|
||||
int PrivRead(int fd, void *buf, size_t len);
|
||||
int PrivWrite(int fd, const void *buf, size_t len);
|
||||
int PrivClose(int fd);
|
||||
int PrivIoctl(int fd, int cmd, void *args);
|
||||
int PrivIoctl(int fd, int cmd, unsigned long args);
|
||||
|
||||
/*********************memory***********************/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user