forked from xuos/xiuos
support zigbee on nuttx stm32f4discovery
This commit is contained in:
parent
74683ed165
commit
316798e98c
|
@ -0,0 +1,7 @@
|
|||
############################################################################
|
||||
# APP_Framework/Framework/connection/Make.defs
|
||||
############################################################################
|
||||
ifneq ($(CONFIG_SUPPORT_CONNECTION_FRAMEWORK),)
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/connection/
|
||||
endif
|
||||
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/connection/*/Make.defs)
|
|
@ -1,47 +1,58 @@
|
|||
SRC_FILES := adapter.c adapter_agent.c
|
||||
include $(KERNEL_ROOT)/.config
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += adapter.c adapter_agent.c
|
||||
include $(APPDIR)/Application.mk
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_INDUSTRIAL_ETHERNET),y)
|
||||
SRC_DIR += industrial_ethernet
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_INDUSTRIAL_FIELDBUS),y)
|
||||
SRC_DIR += industrial_fieldbus
|
||||
endif
|
||||
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y)
|
||||
SRC_FILES := adapter.c adapter_agent.c
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_INDUSTRIAL_WLAN),y)
|
||||
SRC_DIR += industrial_wlan
|
||||
endif
|
||||
ifeq ($(CONFIG_CONNECTION_INDUSTRIAL_ETHERNET),y)
|
||||
SRC_DIR += industrial_ethernet
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_LORA),y)
|
||||
SRC_DIR += lora
|
||||
endif
|
||||
ifeq ($(CONFIG_CONNECTION_INDUSTRIAL_FIELDBUS),y)
|
||||
SRC_DIR += industrial_fieldbus
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_4G),y)
|
||||
SRC_DIR += 4g
|
||||
endif
|
||||
ifeq ($(CONFIG_CONNECTION_INDUSTRIAL_WLAN),y)
|
||||
SRC_DIR += industrial_wlan
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_NB),y)
|
||||
SRC_DIR += nbiot
|
||||
endif
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_LORA),y)
|
||||
SRC_DIR += lora
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_WIFI),y)
|
||||
SRC_DIR += wifi
|
||||
endif
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_4G),y)
|
||||
SRC_DIR += 4g
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_ETHERNET),y)
|
||||
SRC_DIR += ethernet
|
||||
endif
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_NB),y)
|
||||
SRC_DIR += nbiot
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_BLUETOOTH),y)
|
||||
SRC_DIR += bluetooth
|
||||
endif
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_WIFI),y)
|
||||
SRC_DIR += wifi
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_ZIGBEE),y)
|
||||
SRC_DIR += zigbee
|
||||
endif
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_ETHERNET),y)
|
||||
SRC_DIR += ethernet
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_5G),y)
|
||||
SRC_DIR += 5g
|
||||
endif
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_BLUETOOTH),y)
|
||||
SRC_DIR += bluetooth
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_ZIGBEE),y)
|
||||
SRC_DIR += zigbee
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CONNECTION_ADAPTER_5G),y)
|
||||
SRC_DIR += 5g
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
||||
endif
|
|
@ -26,7 +26,9 @@
|
|||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <user_api.h>
|
||||
#ifdef ADD_XIUOS_FETURES
|
||||
# include <user_api.h>
|
||||
#endif
|
||||
|
||||
#define AT_CMD_MAX_LEN 128
|
||||
#define AT_AGENT_MAX 2
|
||||
|
@ -159,9 +161,9 @@ int ATOrderSend(ATAgentType agent, uint32 timeout_s, ATReplyType reply, const ch
|
|||
ATSprintf(agent->fd, cmd_expr, params);
|
||||
va_end(params);
|
||||
PrivMutexAbandon(&agent->lock);
|
||||
if (PrivSemaphoreObtainWait(&agent->rsp_sem, &abstime) != EOK) {
|
||||
if (PrivSemaphoreObtainWait(&agent->rsp_sem, &abstime) != 0) {
|
||||
printf("take sem %d timeout\n",agent->rsp_sem);
|
||||
result = -ETIMEOUT;
|
||||
result = -2;
|
||||
goto __out;
|
||||
}
|
||||
} else {
|
||||
|
@ -277,7 +279,7 @@ int EntmSend(ATAgentType agent, const char *data, int len)
|
|||
PrivWrite(agent->fd, send_buf, len);
|
||||
PrivMutexAbandon(&agent->lock);
|
||||
printf("entm send %s length %d\n",send_buf, len);
|
||||
return EOK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s)
|
||||
|
@ -507,9 +509,16 @@ static int ATAgentInit(ATAgentType agent)
|
|||
|
||||
agent->receive_mode = DEFAULT_MODE;
|
||||
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER;
|
||||
attr.priority = 18;
|
||||
attr.stacksize = 4096;
|
||||
|
||||
#else
|
||||
pthread_attr_t attr;
|
||||
attr.schedparam.sched_priority = 18;
|
||||
attr.stacksize = 4096;
|
||||
#endif
|
||||
|
||||
PrivTaskCreate(&agent->at_handler, &attr, ATAgentReceiveProcess, agent);
|
||||
printf("create agent->at_handler = %d\n",agent->at_handler);
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
############################################################################
|
||||
# APP_Framework/Framework/connection/zigbee/Make.defs
|
||||
############################################################################
|
||||
ifneq ($(CONFIG_CONNECTION_ADAPTER_ZIGBEE),)
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/connection/zigbee
|
||||
endif
|
||||
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/connection/zigbee/*/Make.defs)
|
|
@ -1,7 +1,18 @@
|
|||
SRC_FILES := adapter_zigbee.c
|
||||
include $(KERNEL_ROOT)/.config
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += adapter_zigbee.c
|
||||
include $(APPDIR)/Application.mk
|
||||
|
||||
ifeq ($(CONFIG_ADAPTER_E18),y)
|
||||
SRC_DIR += e18
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||
SRC_FILES := adapter_zigbee.c
|
||||
|
||||
ifeq ($(CONFIG_ADAPTER_E18),y)
|
||||
SRC_DIR += e18
|
||||
endif
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
||||
endif
|
||||
|
|
|
@ -120,7 +120,10 @@ int openzigbee(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef ADD_XIUOS_FETURES
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, openzigbee, openzigbee, show adapter zigbee information);
|
||||
#endif
|
||||
|
||||
int sendzigbee(int argc, char *argv[])
|
||||
{
|
||||
|
@ -140,7 +143,9 @@ int sendzigbee(int argc, char *argv[])
|
|||
|
||||
return 0;
|
||||
}
|
||||
#ifdef ADD_XIUOS_FETURES
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_PARAM_NUM(2)|SHELL_CMD_DISABLE_RETURN, sendzigbee, sendzigbee, show adapter zigbee information);
|
||||
#endif
|
||||
|
||||
int recvzigbee(void)
|
||||
{
|
||||
|
@ -153,5 +158,7 @@ int recvzigbee(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#ifdef ADD_XIUOS_FETURES
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, recvzigbee, recvzigbee, show adapter zigbee information);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -40,7 +40,11 @@ if ADD_XIZI_FETURES
|
|||
endif
|
||||
|
||||
if ADD_NUTTX_FETURES
|
||||
|
||||
config ADAPTER_E18_DRIVER
|
||||
string "E18 device uart driver path"
|
||||
default "/dev/ttyS1"
|
||||
---help---
|
||||
If USART1 is selected, then fill in /dev/ttyS1 here.
|
||||
endif
|
||||
|
||||
if ADD_RTTHREAD_FETURES
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
############################################################################
|
||||
# APP_Framework/Framework/connection/zigbee/e18/Make.defs
|
||||
############################################################################
|
||||
ifneq ($(CONFIG_ADAPTER_ZIGBEE_E18),)
|
||||
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/connection/zigbee/e18
|
||||
endif
|
|
@ -1,3 +1,13 @@
|
|||
SRC_FILES := e18.c
|
||||
include $(KERNEL_ROOT)/.config
|
||||
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||
include $(APPDIR)/Make.defs
|
||||
CSRCS += e18.c
|
||||
include $(APPDIR)/Application.mk
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||
SRC_FILES := e18.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
endif
|
|
@ -37,6 +37,19 @@ char *cmd_role_as_e = "AT+DEV=E"; /*set device type for end device*/
|
|||
char *cmd_role_as_r = "AT+DEV=R"; /*set device type for router*/
|
||||
char *cmd_set_ch = "AT+CH=11"; /*set channel as 11*/
|
||||
|
||||
|
||||
#ifdef ADD_NUTTX_FETURES
|
||||
static int E18UartOpen(struct Adapter *adapter)
|
||||
{
|
||||
adapter->fd = PrivOpen(ADAPTER_E18_DRIVER, O_RDWR);
|
||||
if (adapter->fd < 0) {
|
||||
printf("E18UartSetUp get serial %s fd error\n", ADAPTER_E18_DRIVER);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return adapter->fd;
|
||||
}
|
||||
#else
|
||||
static int E18UartOpen(struct Adapter *adapter)
|
||||
{
|
||||
if (NULL == adapter) {
|
||||
|
@ -78,6 +91,7 @@ static int E18UartOpen(struct Adapter *adapter)
|
|||
printf("Zigbee uart config ready\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int E18NetworkModeConfig(struct Adapter *adapter)
|
||||
{
|
||||
|
@ -204,7 +218,7 @@ static int E18Open(struct Adapter *adapter)
|
|||
/*step2: init AT agent*/
|
||||
if (!adapter->agent) {
|
||||
char *agent_name = "zigbee_device";
|
||||
if (EOK != InitATAgent(agent_name, adapter->fd, 512)) {
|
||||
if (0 != InitATAgent(agent_name, adapter->fd, 512)) {
|
||||
printf("at agent init failed !\n");
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue