forked from xuos/xiuos
support 4g on xidatong
This commit is contained in:
parent
f693fa78af
commit
7f12a1892b
|
@ -0,0 +1,7 @@
|
||||||
|
############################################################################
|
||||||
|
# APP_Framework/Framework/connection/4g/Make.defs
|
||||||
|
############################################################################
|
||||||
|
ifneq ($(CONFIG_CONNECTION_ADAPTER_4G),)
|
||||||
|
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/connection/4g
|
||||||
|
endif
|
||||||
|
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/connection/4g/*/Make.defs)
|
|
@ -1,3 +1,12 @@
|
||||||
|
include $(KERNEL_ROOT)/.config
|
||||||
|
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||||
|
include $(APPDIR)/Make.defs
|
||||||
|
CSRCS += adapter_4g.c
|
||||||
|
include $(APPDIR)/Application.mk
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||||
SRC_FILES := adapter_4g.c
|
SRC_FILES := adapter_4g.c
|
||||||
|
|
||||||
ifeq ($(CONFIG_ADAPTER_EC200T),y)
|
ifeq ($(CONFIG_ADAPTER_EC200T),y)
|
||||||
|
@ -5,3 +14,4 @@ ifeq ($(CONFIG_ADAPTER_EC200T),y)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
include $(KERNEL_ROOT)/compiler.mk
|
include $(KERNEL_ROOT)/compiler.mk
|
||||||
|
endif
|
|
@ -92,8 +92,8 @@ int Adapter4GTest(void)
|
||||||
|
|
||||||
#ifdef ADAPTER_EC200T
|
#ifdef ADAPTER_EC200T
|
||||||
//Using Hang Xiao server to test 4G Socket connection
|
//Using Hang Xiao server to test 4G Socket connection
|
||||||
uint8 server_addr[64] = "101.68.82.219";
|
uint8 server_addr[64] = "120.76.100.197";
|
||||||
uint8 server_port[64] = "9898";
|
uint8 server_port[64] = "10002";
|
||||||
|
|
||||||
adapter->socket.socket_id = 0;
|
adapter->socket.socket_id = 0;
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,9 @@ if ADD_XIZI_FETURES
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if ADD_NUTTX_FETURES
|
if ADD_NUTTX_FETURES
|
||||||
|
config ADAPTER_EC200T_DRIVER
|
||||||
|
string "EC200T device uart driver path"
|
||||||
|
default "/dev/ttyS8"
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
############################################################################
|
||||||
|
# APP_Framework/Framework/connection/4g/ec200t/Make.defs
|
||||||
|
############################################################################
|
||||||
|
ifneq ($(CONFIG_ADAPTER_4G_EC200T),)
|
||||||
|
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/connection/4g/ec200t
|
||||||
|
endif
|
|
@ -1,3 +1,14 @@
|
||||||
|
include $(KERNEL_ROOT)/.config
|
||||||
|
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
|
||||||
|
include $(APPDIR)/Make.defs
|
||||||
|
CSRCS += ec200t.c
|
||||||
|
include $(APPDIR)/Application.mk
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
|
||||||
SRC_FILES := ec200t.c
|
SRC_FILES := ec200t.c
|
||||||
|
|
||||||
include $(KERNEL_ROOT)/compiler.mk
|
include $(KERNEL_ROOT)/compiler.mk
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
|
@ -36,6 +36,9 @@
|
||||||
#define EC200T_CREG_REPLY ",1"
|
#define EC200T_CREG_REPLY ",1"
|
||||||
#define EC200T_CONNECT_REPLY "CONNECT"
|
#define EC200T_CONNECT_REPLY "CONNECT"
|
||||||
|
|
||||||
|
#ifdef ADD_NUTTX_FETURES
|
||||||
|
static void Ec200tPowerSet(void){ return; }
|
||||||
|
#else
|
||||||
static void Ec200tPowerSet(void)
|
static void Ec200tPowerSet(void)
|
||||||
{
|
{
|
||||||
int pin_fd;
|
int pin_fd;
|
||||||
|
@ -69,6 +72,7 @@ static void Ec200tPowerSet(void)
|
||||||
|
|
||||||
PrivTaskDelay(10000);
|
PrivTaskDelay(10000);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int Ec200tOpen(struct Adapter *adapter)
|
static int Ec200tOpen(struct Adapter *adapter)
|
||||||
{
|
{
|
||||||
|
@ -82,7 +86,7 @@ static int Ec200tOpen(struct Adapter *adapter)
|
||||||
/*step2: init AT agent*/
|
/*step2: init AT agent*/
|
||||||
if (!adapter->agent) {
|
if (!adapter->agent) {
|
||||||
char *agent_name = "4G_uart_client";
|
char *agent_name = "4G_uart_client";
|
||||||
if (EOK != InitATAgent(agent_name, adapter->fd, 512)) {
|
if (0 != InitATAgent(agent_name, adapter->fd, 512)) {
|
||||||
printf("at agent init failed !\n");
|
printf("at agent init failed !\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -137,6 +141,10 @@ out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef ADD_NUTTX_FETURES
|
||||||
|
static int Ec200tIoctl(struct Adapter *adapter, int cmd, void *args){ return 0;}
|
||||||
|
#else
|
||||||
static int Ec200tIoctl(struct Adapter *adapter, int cmd, void *args)
|
static int Ec200tIoctl(struct Adapter *adapter, int cmd, void *args)
|
||||||
{
|
{
|
||||||
if (OPE_INT != cmd) {
|
if (OPE_INT != cmd) {
|
||||||
|
@ -169,7 +177,77 @@ static int Ec200tIoctl(struct Adapter *adapter, int cmd, void *args)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ADD_NUTTX_FETURES
|
||||||
|
static int Ec200tConnect(struct Adapter *adapter, enum NetRoleType net_role, const char *ip, const char *port, enum IpType ip_type)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
uint8_t ec200t_cmd[64];
|
||||||
|
|
||||||
|
AtSetReplyEndChar(adapter->agent, 0x4F, 0x4B);
|
||||||
|
|
||||||
|
/*step1: serial write "+++", quit transparent mode*/
|
||||||
|
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "+++");
|
||||||
|
|
||||||
|
PrivTaskDelay(3000);
|
||||||
|
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "ATE0\r\n");
|
||||||
|
|
||||||
|
/*step2: serial write "AT+CCID", get SIM ID*/
|
||||||
|
PrivTaskDelay(3000);
|
||||||
|
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, EC200T_GET_CCID_CMD);
|
||||||
|
|
||||||
|
/*step3: serial write "AT+CPIN?", check SIM status*/
|
||||||
|
PrivTaskDelay(3000);
|
||||||
|
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, EC200T_GET_CPIN_CMD);
|
||||||
|
|
||||||
|
/*step4: serial write "AT+CREG?", check whether registered to GSM net*/
|
||||||
|
PrivTaskDelay(3000);
|
||||||
|
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, EC200T_GET_CREG_CMD);
|
||||||
|
|
||||||
|
/*step5: serial write "AT+QICSGP", connect to China Mobile using ipv4 or ipv6*/
|
||||||
|
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
|
||||||
|
|
||||||
|
if (IPV4 == ip_type) {
|
||||||
|
strcpy(ec200t_cmd, "AT+QICSGP=1,1,\"CMNET\",\"\",\"\",1\r\n");
|
||||||
|
} else if (IPV6 == ip_type) {
|
||||||
|
strcpy(ec200t_cmd, "AT+QICSGP=1,2,\"CMNET\",\"\",\"\",1\r\n");
|
||||||
|
}
|
||||||
|
PrivTaskDelay(3000);
|
||||||
|
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, ec200t_cmd);
|
||||||
|
|
||||||
|
/*step6: serial write "AT+QICLOSE", close socket connect before open socket*/
|
||||||
|
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
|
||||||
|
sprintf(ec200t_cmd, EC200T_CLOSE_SOCKET_CMD, adapter->socket.socket_id);
|
||||||
|
PrivTaskDelay(3000);
|
||||||
|
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, ec200t_cmd);
|
||||||
|
|
||||||
|
/*step7: serial write "AT+QIDEACT", close TCP net before open socket*/
|
||||||
|
PrivTaskDelay(3000);
|
||||||
|
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, EC200T_DEACTIVE_PDP_CMD);
|
||||||
|
|
||||||
|
/*step8: serial write "AT+QIACT", open TCP net*/
|
||||||
|
PrivTaskDelay(3000);
|
||||||
|
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, EC200T_ACTIVE_PDP_CMD);
|
||||||
|
|
||||||
|
/*step9: serial write "AT+QIOPEN", connect socket using TCP*/
|
||||||
|
memset(ec200t_cmd, 0, sizeof(ec200t_cmd));
|
||||||
|
sprintf(ec200t_cmd, EC200T_OPEN_SOCKET_CMD, adapter->socket.socket_id);
|
||||||
|
strcat(ec200t_cmd, ",\"TCP\",\"");
|
||||||
|
strcat(ec200t_cmd, ip);
|
||||||
|
strcat(ec200t_cmd, "\",");
|
||||||
|
strcat(ec200t_cmd, port);
|
||||||
|
strcat(ec200t_cmd, ",0,2\r\n");
|
||||||
|
|
||||||
|
AtSetReplyEndChar(adapter->agent, 0x43, 0x54);
|
||||||
|
PrivTaskDelay(3000);
|
||||||
|
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, ec200t_cmd);
|
||||||
|
|
||||||
|
ADAPTER_DEBUG("Ec200t connect TCP done\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#else
|
||||||
static int Ec200tConnect(struct Adapter *adapter, enum NetRoleType net_role, const char *ip, const char *port, enum IpType ip_type)
|
static int Ec200tConnect(struct Adapter *adapter, enum NetRoleType net_role, const char *ip, const char *port, enum IpType ip_type)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -257,10 +335,10 @@ out:
|
||||||
Ec200tPowerSet();
|
Ec200tPowerSet();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int Ec200tSend(struct Adapter *adapter, const void *buf, size_t len)
|
static int Ec200tSend(struct Adapter *adapter, const void *buf, size_t len)
|
||||||
{
|
{
|
||||||
x_err_t result = EOK;
|
|
||||||
if (adapter->agent) {
|
if (adapter->agent) {
|
||||||
EntmSend(adapter->agent, (const char *)buf, len);
|
EntmSend(adapter->agent, (const char *)buf, len);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -194,13 +194,15 @@ int AtCmdConfigAndCheck(ATAgentType agent, char *cmd, char *check)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto __exit;
|
goto __exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ATOrderSend(agent, REPLY_TIME_OUT, reply, cmd);
|
ret = ATOrderSend(agent, REPLY_TIME_OUT, reply, cmd);
|
||||||
if(ret < 0){
|
if(ret < 0){
|
||||||
printf("%s %d ATOrderSend failed.\n",__func__,__LINE__);
|
printf("%s %d ATOrderSend failed.\n",__func__,__LINE__);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto __exit;
|
goto __exit;
|
||||||
}
|
}
|
||||||
// PrivTaskDelay(3000);
|
|
||||||
|
PrivTaskDelay(3000);
|
||||||
|
|
||||||
result = GetReplyText(reply);
|
result = GetReplyText(reply);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
@ -295,7 +297,7 @@ int EntmRecv(ATAgentType agent, char *rev_buffer, int buffer_len, int timeout_s)
|
||||||
agent->receive_mode = ENTM_MODE;
|
agent->receive_mode = ENTM_MODE;
|
||||||
agent->read_len = buffer_len;
|
agent->read_len = buffer_len;
|
||||||
PrivMutexAbandon(&agent->lock);
|
PrivMutexAbandon(&agent->lock);
|
||||||
// PrivTaskDelay(1000);
|
PrivTaskDelay(1000);
|
||||||
if (PrivSemaphoreObtainWait(&agent->entm_rx_notice, &abstime)) {
|
if (PrivSemaphoreObtainWait(&agent->entm_rx_notice, &abstime)) {
|
||||||
printf("wait sem[%d] timeout\n",agent->entm_rx_notice);
|
printf("wait sem[%d] timeout\n",agent->entm_rx_notice);
|
||||||
return -ERROR;
|
return -ERROR;
|
||||||
|
@ -424,10 +426,17 @@ int DeleteATAgent(ATAgentType agent)
|
||||||
PrivClose(agent->fd);
|
PrivClose(agent->fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ADD_NUTTX_FETURES
|
||||||
|
if (agent->lock.sem.semcount > 0) {
|
||||||
|
printf("delete agent lock = %d\n",agent->lock.sem.semcount);
|
||||||
|
PrivMutexDelete(&agent->lock);
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (agent->lock) {
|
if (agent->lock) {
|
||||||
printf("delete agent lock = %d\n",agent->lock);
|
printf("delete agent lock = %d\n",agent->lock);
|
||||||
PrivMutexDelete(&agent->lock);
|
PrivMutexDelete(&agent->lock);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (agent->entm_rx_notice) {
|
if (agent->entm_rx_notice) {
|
||||||
printf("delete agent entm_rx_notice = %d\n",agent->entm_rx_notice);
|
printf("delete agent entm_rx_notice = %d\n",agent->entm_rx_notice);
|
||||||
|
|
|
@ -53,7 +53,11 @@ struct ATAgent
|
||||||
uint32 maintain_len;
|
uint32 maintain_len;
|
||||||
uint32 maintain_max;
|
uint32 maintain_max;
|
||||||
|
|
||||||
|
#ifdef ADD_NUTTX_FETURES
|
||||||
|
pthread_mutex_t lock;
|
||||||
|
#else
|
||||||
int lock;
|
int lock;
|
||||||
|
#endif
|
||||||
|
|
||||||
ATReplyType reply;
|
ATReplyType reply;
|
||||||
char reply_lr_end;
|
char reply_lr_end;
|
||||||
|
|
|
@ -655,6 +655,10 @@ config NSH_DISABLE_ADAPTER_LORATEST
|
||||||
bool "Disable sx1278 AdapterLoraTest."
|
bool "Disable sx1278 AdapterLoraTest."
|
||||||
default n
|
default n
|
||||||
|
|
||||||
|
config NSH_DISABLE_ADAPTER_4GTEST
|
||||||
|
bool "Disable ec200t Adapter4GTest."
|
||||||
|
default n
|
||||||
|
|
||||||
config NSH_DISABLE_K210_FFT
|
config NSH_DISABLE_K210_FFT
|
||||||
bool "Disable the K210 fft device."
|
bool "Disable the K210 fft device."
|
||||||
default n
|
default n
|
||||||
|
|
|
@ -1486,6 +1486,10 @@ int nsh_foreach_var(FAR struct nsh_vtbl_s *vtbl, nsh_foreach_var_t cb,
|
||||||
int cmd_AdapterLoraTest(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
int cmd_AdapterLoraTest(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_ADAPTER_4G_EC200T) && !defined(CONFIG_NSH_DISABLE_ADAPTER_4GTEST)
|
||||||
|
int cmd_Adapter4GTest(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_K210_FFT_TEST) && !defined(CONFIG_NSH_DISABLE_K210_FFT)
|
#if defined(CONFIG_K210_FFT_TEST) && !defined(CONFIG_NSH_DISABLE_K210_FFT)
|
||||||
int cmd_fft(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
int cmd_fft(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -283,6 +283,17 @@ int cmd_AdapterLoraTest(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_ADAPTER_4G_EC200T) && !defined(CONFIG_NSH_DISABLE_ADAPTER_4GTEST)
|
||||||
|
extern int Adapter4GTest(void);
|
||||||
|
int cmd_Adapter4GTest(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||||
|
{
|
||||||
|
nsh_output(vtbl, "Hello, world!\n");
|
||||||
|
FrameworkInit();
|
||||||
|
Adapter4GTest();
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_K210_FFT_TEST) && !defined(CONFIG_NSH_DISABLE_K210_FFT)
|
#if defined(CONFIG_K210_FFT_TEST) && !defined(CONFIG_NSH_DISABLE_K210_FFT)
|
||||||
extern void nuttx_k210_fft_test(void);
|
extern void nuttx_k210_fft_test(void);
|
||||||
int cmd_fft(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
int cmd_fft(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||||
|
|
|
@ -658,6 +658,10 @@ static const struct cmdmap_s g_cmdmap[] =
|
||||||
{ "AdapterLoraTest", cmd_AdapterLoraTest, 1, 1, "[Lora sx128 test.]" },
|
{ "AdapterLoraTest", cmd_AdapterLoraTest, 1, 1, "[Lora sx128 test.]" },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_ADAPTER_4G_EC200T) && !defined(CONFIG_NSH_DISABLE_ADAPTER_4GTEST)
|
||||||
|
{ "Adapter4GTest", cmd_Adapter4GTest, 1, 1, "[4G ec200t test.]" },
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_K210_FFT_TEST) && !defined(CONFIG_NSH_DISABLE_K210_FFT)
|
#if defined(CONFIG_K210_FFT_TEST) && !defined(CONFIG_NSH_DISABLE_K210_FFT)
|
||||||
{ "fft", cmd_fft, 1, 1, "[K210 fft function.]" },
|
{ "fft", cmd_fft, 1, 1, "[K210 fft function.]" },
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue