|
|
|
|
@@ -36,6 +36,8 @@
|
|
|
|
|
#define EC200T_CREG_REPLY ",1"
|
|
|
|
|
#define EC200T_CONNECT_REPLY "CONNECT"
|
|
|
|
|
|
|
|
|
|
#define TRY_TIMES 10
|
|
|
|
|
|
|
|
|
|
#ifdef ADD_NUTTX_FETURES
|
|
|
|
|
static void Ec200tPowerSet(void){ return; }
|
|
|
|
|
#else
|
|
|
|
|
@@ -120,6 +122,7 @@ static int Ec200tClose(struct Adapter *adapter)
|
|
|
|
|
/*step2: 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);
|
|
|
|
|
|
|
|
|
|
ret = AtCmdConfigAndCheck(adapter->agent, ec200t_cmd, EC200T_OK_REPLY);
|
|
|
|
|
if (ret < 0) {
|
|
|
|
|
goto out;
|
|
|
|
|
@@ -179,78 +182,10 @@ static int Ec200tIoctl(struct Adapter *adapter, int cmd, void *args)
|
|
|
|
|
}
|
|
|
|
|
#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)
|
|
|
|
|
{
|
|
|
|
|
int ret = 0;
|
|
|
|
|
int try = 0;
|
|
|
|
|
uint8_t ec200t_cmd[64];
|
|
|
|
|
|
|
|
|
|
AtSetReplyEndChar(adapter->agent, 0x4F, 0x4B);
|
|
|
|
|
@@ -259,19 +194,34 @@ static int Ec200tConnect(struct Adapter *adapter, enum NetRoleType net_role, con
|
|
|
|
|
ATOrderSend(adapter->agent, REPLY_TIME_OUT, NULL, "+++");
|
|
|
|
|
|
|
|
|
|
/*step2: serial write "AT+CCID", get SIM ID*/
|
|
|
|
|
ret = AtCmdConfigAndCheck(adapter->agent, EC200T_GET_CCID_CMD, EC200T_OK_REPLY);
|
|
|
|
|
for(try = 0; try < TRY_TIMES; try++){
|
|
|
|
|
ret = AtCmdConfigAndCheck(adapter->agent, EC200T_GET_CCID_CMD, EC200T_OK_REPLY);
|
|
|
|
|
if (ret == 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ret < 0) {
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*step3: serial write "AT+CPIN?", check SIM status*/
|
|
|
|
|
ret = AtCmdConfigAndCheck(adapter->agent, EC200T_GET_CPIN_CMD, EC200T_READY_REPLY);
|
|
|
|
|
for(try = 0; try < TRY_TIMES; try++){
|
|
|
|
|
ret = AtCmdConfigAndCheck(adapter->agent, EC200T_GET_CPIN_CMD, EC200T_READY_REPLY);
|
|
|
|
|
if (ret == 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ret < 0) {
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*step4: serial write "AT+CREG?", check whether registered to GSM net*/
|
|
|
|
|
ret = AtCmdConfigAndCheck(adapter->agent, EC200T_GET_CREG_CMD, EC200T_CREG_REPLY);
|
|
|
|
|
for(try = 0; try < TRY_TIMES; try++){
|
|
|
|
|
ret = AtCmdConfigAndCheck(adapter->agent, EC200T_GET_CREG_CMD, EC200T_CREG_REPLY);
|
|
|
|
|
if (ret == 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ret < 0) {
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
@@ -285,7 +235,12 @@ static int Ec200tConnect(struct Adapter *adapter, enum NetRoleType net_role, con
|
|
|
|
|
strcpy(ec200t_cmd, "AT+QICSGP=1,2,\"CMNET\",\"\",\"\",1\r\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ret = AtCmdConfigAndCheck(adapter->agent, ec200t_cmd, EC200T_OK_REPLY);
|
|
|
|
|
for(try = 0; try < TRY_TIMES; try++){
|
|
|
|
|
ret = AtCmdConfigAndCheck(adapter->agent, ec200t_cmd, EC200T_OK_REPLY);
|
|
|
|
|
if (ret == 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ret < 0) {
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
@@ -293,19 +248,34 @@ static int Ec200tConnect(struct Adapter *adapter, enum NetRoleType net_role, con
|
|
|
|
|
/*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);
|
|
|
|
|
ret = AtCmdConfigAndCheck(adapter->agent, ec200t_cmd, EC200T_OK_REPLY);
|
|
|
|
|
for(try = 0; try < TRY_TIMES; try++){
|
|
|
|
|
ret = AtCmdConfigAndCheck(adapter->agent, ec200t_cmd, EC200T_OK_REPLY);
|
|
|
|
|
if (ret == 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ret < 0) {
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*step7: serial write "AT+QIDEACT", close TCP net before open socket*/
|
|
|
|
|
ret = AtCmdConfigAndCheck(adapter->agent, EC200T_DEACTIVE_PDP_CMD, EC200T_OK_REPLY);
|
|
|
|
|
for(try = 0; try < TRY_TIMES; try++){
|
|
|
|
|
ret = AtCmdConfigAndCheck(adapter->agent, EC200T_DEACTIVE_PDP_CMD, EC200T_OK_REPLY);
|
|
|
|
|
if (ret == 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ret < 0) {
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*step8: serial write "AT+QIACT", open TCP net*/
|
|
|
|
|
ret = AtCmdConfigAndCheck(adapter->agent, EC200T_ACTIVE_PDP_CMD, EC200T_OK_REPLY);
|
|
|
|
|
for(try = 0; try < TRY_TIMES; try++){
|
|
|
|
|
ret = AtCmdConfigAndCheck(adapter->agent, EC200T_ACTIVE_PDP_CMD, EC200T_OK_REPLY);
|
|
|
|
|
if (ret == 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ret < 0) {
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
@@ -321,7 +291,12 @@ static int Ec200tConnect(struct Adapter *adapter, enum NetRoleType net_role, con
|
|
|
|
|
|
|
|
|
|
AtSetReplyEndChar(adapter->agent, 0x43, 0x54);
|
|
|
|
|
|
|
|
|
|
ret = AtCmdConfigAndCheck(adapter->agent, ec200t_cmd, EC200T_CONNECT_REPLY);
|
|
|
|
|
for(try = 0; try < TRY_TIMES; try++){
|
|
|
|
|
ret = AtCmdConfigAndCheck(adapter->agent, ec200t_cmd, EC200T_CONNECT_REPLY);
|
|
|
|
|
if (ret == 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ret < 0) {
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
@@ -335,7 +310,6 @@ out:
|
|
|
|
|
Ec200tPowerSet();
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static int Ec200tSend(struct Adapter *adapter, const void *buf, size_t len)
|
|
|
|
|
{
|
|
|
|
|
|