blob: 8b38c7ddd31c2e5762af68c799a4cc4d62536461 [file] [log] [blame]
#include "mbtk_at.h"
//#include <sys/statfs.h>
#include <sys/vfs.h>
#include <errno.h>
#include <linux/magic.h>
#include <time.h>
#include <sys/time.h>
#include <signal.h>
#include <pthread.h>
#include <time.h>
#include <sys/time.h>
#include <cutils/properties.h>
#include "configwrapper.h"
#include<linux/msg.h>
#include "atcmdsvr_ubus.h"
//mbtk_ftp
struct my_msg //消息队列结构体
{
long int my_msg_type;
char *ptr;
}mbtk_at_msg;
void mbtk_at_printf()
{
int msgid;
mbtk_at_msg.my_msg_type=3;
msgid=msgget(12,0666|IPC_CREAT);
MBTK_FUNC(mbtk_at_msgid)(&msgid);
//char read_buf[MAXMSG];
while(1)
{
msgrcv(msgid,&mbtk_at_msg,4,mbtk_at_msg.my_msg_type,0);
if(strncmp(mbtk_at_msg.ptr,"end",3)==0)
break;
ATRESP(IND_REQ_HANDLE , ATCI_RESULT_CODE_NULL, 0, mbtk_at_msg.ptr);
free(mbtk_at_msg.ptr);
mbtk_at_msg.ptr=NULL;
}
msgctl(msgid,IPC_RMID,0);
}
utlReturnCode_T MBTK_AT_CFTPPORT_PROCESS(const utlAtParameterOp_T op,
const char *command_name_p,
const utlAtParameterValue_P2c parameter_values_p,
const size_t num_parameters,
const char *info_text_p,
unsigned int *xid_p,
void *arg_p)
{
UNUSEDPARAM(command_name_p);
UNUSEDPARAM(num_parameters);
UNUSEDPARAM(info_text_p);
utlReturnCode_T ret = utlFAILED;
TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index);
*xid_p = At_handle;
char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
static int arg1 = 0;
LOG("MBTK_AT_MTEST_PROCESS enter with command_op [%s]", op2str(op));
switch(op)
{
case TEL_EXT_GET_CMD :
{
MBTK_FUNC(mbtk_at_get_ftp_info)(0,&arg1, NULL, NULL, NULL, NULL, NULL, NULL);
sprintf(resp_buf, "+CFTPPORT: <%d>\r\n", arg1);
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
break;
}
case TEL_EXT_SET_CMD :
{
if(!getExtValue(parameter_values_p, 0, &arg1, 1, 65535, 21))
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
break;
}
MBTK_FUNC(mbtk_at_ftp)(0,arg1, NULL, NULL, NULL, NULL, NULL, NULL);
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL);
break;
}
default:
{
break;
}
}
return ret;
}
utlReturnCode_T MBTK_AT_CFTPUN_PROCESS(const utlAtParameterOp_T op,
const char *command_name_p,
const utlAtParameterValue_P2c parameter_values_p,
const size_t num_parameters,
const char *info_text_p,
unsigned int *xid_p,
void *arg_p)
{
UNUSEDPARAM(command_name_p);
UNUSEDPARAM(num_parameters);
UNUSEDPARAM(info_text_p);
utlReturnCode_T ret = utlFAILED;
TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index);
*xid_p = At_handle;
char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
LOG("MBTK_AT_MTEST_PROCESS enter with command_op [%s]", op2str(op));
switch(op)
{
case TEL_EXT_GET_CMD :
{
static char name[MBTK_AT_FTP_NAME_LEN_MAX];
MBTK_FUNC(mbtk_at_get_ftp_info)(3,NULL, NULL, NULL, name, NULL, NULL, NULL);
sprintf(resp_buf, "+CFTPUN: \"<%s>\"\r\n",name);
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
break;
}
case TEL_EXT_SET_CMD :
{
const static int name_len_max = MBTK_AT_FTP_NAME_LEN_MAX;
static char name[MBTK_AT_FTP_NAME_LEN_MAX];
int len = 0;
memset(name, 0x0, MBTK_AT_FTP_NAME_LEN_MAX);
if(!getExtString(parameter_values_p, 0, name, name_len_max, &len, ""))
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
LOG("Get FTP NAME Fail.");
break;
}
MBTK_FUNC(mbtk_at_ftp)(3,NULL, NULL, NULL, name, NULL, NULL, NULL);
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL);
break;
}
default:
{
break;
}
}
return ret;
}
utlReturnCode_T MBTK_AT_CFTPPW_PROCESS(const utlAtParameterOp_T op,
const char *command_name_p,
const utlAtParameterValue_P2c parameter_values_p,
const size_t num_parameters,
const char *info_text_p,
unsigned int *xid_p,
void *arg_p)
{
UNUSEDPARAM(command_name_p);
UNUSEDPARAM(num_parameters);
UNUSEDPARAM(info_text_p);
utlReturnCode_T ret = utlFAILED;
TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index);
*xid_p = At_handle;
char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
LOG("MBTK_AT_MTEST_PROCESS enter with command_op [%s]", op2str(op));
switch(op)
{
case TEL_EXT_GET_CMD :
{
static char pass[MBTK_AT_FTP_PASS_LEN_MAX];
MBTK_FUNC(mbtk_at_get_ftp_info)(2,NULL, NULL, pass, NULL, NULL, NULL, NULL);
sprintf(resp_buf, "+CFTPPW: \"<%s>\"\r\n",pass);
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
break;
}
case TEL_EXT_SET_CMD :
{
const static int pass_len_max = MBTK_AT_FTP_PASS_LEN_MAX;
static char pass[MBTK_AT_FTP_PASS_LEN_MAX];
int len = 0;
memset(pass, 0x0, MBTK_AT_FTP_PASS_LEN_MAX);
if(!getExtString(parameter_values_p, 0, pass, pass_len_max, &len, ""))
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
LOG("Get FTP PASS Fail.");
break;
}
MBTK_FUNC(mbtk_at_ftp)(2,NULL, NULL, pass, NULL, NULL, NULL, NULL);
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL);
break;
}
default:
{
break;
}
}
return ret;
}
utlReturnCode_T MBTK_AT_CFTPTLS_PROCESS(const utlAtParameterOp_T op,
const char *command_name_p,
const utlAtParameterValue_P2c parameter_values_p,
const size_t num_parameters,
const char *info_text_p,
unsigned int *xid_p,
void *arg_p)
{
UNUSEDPARAM(command_name_p);
UNUSEDPARAM(num_parameters);
UNUSEDPARAM(info_text_p);
utlReturnCode_T ret = utlFAILED;
TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index);
*xid_p = At_handle;
char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
static int mode = 0;
static int cert = 0;
LOG("MBTK_AT_MTEST_PROCESS enter with command_op [%s]", op2str(op));
switch(op)
{
case TEL_EXT_GET_CMD :
{
MBTK_FUNC(mbtk_at_get_ftp_info)(4,NULL, NULL, NULL, NULL, &mode, NULL, &cert);
sprintf(resp_buf, "+CFTPTLS: <%d>,<%d>\r\n", mode, cert);
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
break;
}
case TEL_EXT_SET_CMD :
{
if(!getExtValue(parameter_values_p, 0, &mode, 0, 2, 0))
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
break;
}
if(!getExtValue(parameter_values_p, 1, &cert, 0, 1, 0))
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
break;
}
MBTK_FUNC(mbtk_at_ftp)(4,NULL, NULL, NULL, NULL, mode, NULL, cert);
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL);
break;
}
default:
{
break;
}
}
return ret;
}
utlReturnCode_T MBTK_AT_CFTPSERV_PROCESS(const utlAtParameterOp_T op,
const char *command_name_p,
const utlAtParameterValue_P2c parameter_values_p,
const size_t num_parameters,
const char *info_text_p,
unsigned int *xid_p,
void *arg_p)
{
UNUSEDPARAM(command_name_p);
UNUSEDPARAM(num_parameters);
UNUSEDPARAM(info_text_p);
utlReturnCode_T ret = utlFAILED;
TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index);
*xid_p = At_handle;
char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
LOG("MBTK_AT_MTEST_PROCESS enter with command_op [%s]", op2str(op));
switch(op)
{
case TEL_EXT_GET_CMD :
{
static char addr[MBTK_AT_FTP_ADDR_LEN_MAX];
MBTK_FUNC(mbtk_at_get_ftp_info)(1,NULL, addr, NULL, NULL, NULL, NULL, NULL);
sprintf(resp_buf, "+CFTPSERV: %s", addr);
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
break;
}
case TEL_EXT_SET_CMD :
{
const static int addr_len_max = MBTK_AT_FTP_ADDR_LEN_MAX;
static char addr[MBTK_AT_FTP_ADDR_LEN_MAX];
int len = 0;
memset(addr, 0x0, MBTK_AT_FTP_ADDR_LEN_MAX);
if(!getExtString(parameter_values_p, 0, addr, addr_len_max, &len, ""))
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
LOG("Get FTP ADDR Fail.");
break;
}
MBTK_FUNC(mbtk_at_ftp)(1,NULL, addr, NULL, NULL, NULL, NULL, NULL);
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL);
break;
}
default:
{
break;
}
}
return ret;
}
utlReturnCode_T MBTK_AT_CFTPTYPE_PROCESS(const utlAtParameterOp_T op,
const char *command_name_p,
const utlAtParameterValue_P2c parameter_values_p,
const size_t num_parameters,
const char *info_text_p,
unsigned int *xid_p,
void *arg_p)
{
UNUSEDPARAM(command_name_p);
UNUSEDPARAM(num_parameters);
UNUSEDPARAM(info_text_p);
utlReturnCode_T ret = utlFAILED;
TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index);
*xid_p = At_handle;
char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
LOG("MBTK_AT_MTEST_PROCESS enter with command_op [%s]", op2str(op));
switch(op)
{
case TEL_EXT_GET_CMD :
{
int mbtk_ftp_type = -1;
static char ftp_type;
MBTK_FUNC(mbtk_at_get_ftp_info)(5,NULL, NULL, NULL, NULL, NULL, &mbtk_ftp_type, NULL);
if(mbtk_ftp_type == 0)
ftp_type='A';
else if(mbtk_ftp_type == 1)
ftp_type='I';
else
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, resp_buf);
break;
}
sprintf(resp_buf, "+CFTPTYPE:\"%c\"",ftp_type);
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
break;
}
case TEL_EXT_SET_CMD :
{
static char ftp_type[2];
int addr_len_max = 2;
int len = 0;
int mbtk_ftp_type = -1;
if(!getExtString(parameter_values_p, 0, ftp_type, addr_len_max, &len, ""))
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
LOG("Get FTP PASS Fail.");
break;
}
//FTP_DATA_TYPE_I = 2 FTP_DATA_TYPE_A = 0
if(strstr(ftp_type,"A") != NULL)
mbtk_ftp_type = 0;
else if(strstr(ftp_type,"I") != NULL)
mbtk_ftp_type = 2;
else
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
LOG("Get FTP PASS Fail.");
break;
}
MBTK_FUNC(mbtk_at_ftp)(5,NULL, NULL, NULL, NULL, NULL, mbtk_ftp_type, NULL);
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL);
break;
}
default:
{
break;
}
}
return ret;
}
utlReturnCode_T MBTK_AT_CFTPMKD_PROCESS(const utlAtParameterOp_T op,
const char *command_name_p,
const utlAtParameterValue_P2c parameter_values_p,
const size_t num_parameters,
const char *info_text_p,
unsigned int *xid_p,
void *arg_p)
{
UNUSEDPARAM(command_name_p);
UNUSEDPARAM(num_parameters);
UNUSEDPARAM(info_text_p);
utlReturnCode_T ret = utlFAILED;
TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index);
*xid_p = At_handle;
char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
LOG("MBTK_AT_MTEST_PROCESS enter with command_op [%s]", op2str(op));
pthread_t mbtk_at_thread_ID; //定义线程id
pthread_create(&mbtk_at_thread_ID, NULL, &mbtk_at_printf, NULL);
pthread_detach(mbtk_at_thread_ID); //设置线程结束收
switch(op)
{
case TEL_EXT_GET_CMD :
{
static char remote_size[MBTK_AT_FTP_DIR_LEN_MAX+1];
memset(remote_size, 0x0, MBTK_AT_FTP_DIR_LEN_MAX+1);
MBTK_FUNC(mbtk_at_get_ftp_data_info)(remote_size,NULL,NULL,NULL,NULL);
sprintf(resp_buf, "+CFTPLIST: \"%s\"\r\n",remote_size);
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
break;
}
case TEL_EXT_SET_CMD :
{
static char dir[MBTK_AT_FTP_DIR_LEN_MAX];
int dir_len_max = MBTK_AT_FTP_DIR_LEN_MAX;
int len = 0;
memset(dir, 0x0, MBTK_AT_FTP_DIR_LEN_MAX);
if(!getExtString(parameter_values_p, 0, dir, dir_len_max, &len, ""))
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
LOG("Get FTP MKDIR Fail.");
break;
}
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL);
MBTK_FUNC(mbtk_at_ftp_mkrmdel)(0,dir);
break;
}
default:
{
break;
}
}
return ret;
}
utlReturnCode_T MBTK_AT_CFTPRMD_PROCESS(const utlAtParameterOp_T op,
const char *command_name_p,
const utlAtParameterValue_P2c parameter_values_p,
const size_t num_parameters,
const char *info_text_p,
unsigned int *xid_p,
void *arg_p)
{
UNUSEDPARAM(command_name_p);
UNUSEDPARAM(num_parameters);
UNUSEDPARAM(info_text_p);
utlReturnCode_T ret = utlFAILED;
TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index);
*xid_p = At_handle;
char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
LOG("MBTK_AT_MTEST_PROCESS enter with command_op [%s]", op2str(op));
pthread_t mbtk_at_thread_ID; //定义线程id
pthread_create(&mbtk_at_thread_ID, NULL, &mbtk_at_printf, NULL);
pthread_detach(mbtk_at_thread_ID); //设置线程结束收
switch(op)
{
case TEL_EXT_GET_CMD :
{
static char remote_size[MBTK_AT_FTP_DIR_LEN_MAX+1];
memset(remote_size, 0x0, MBTK_AT_FTP_DIR_LEN_MAX+1);
MBTK_FUNC(mbtk_at_get_ftp_data_info)(remote_size,NULL,NULL,NULL,NULL);
sprintf(resp_buf, "+CFTPMKD: \"%s\"\r\n",remote_size);
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
break;
}
case TEL_EXT_SET_CMD :
{
static char dir[MBTK_AT_FTP_DIR_LEN_MAX];
int dir_len_max = MBTK_AT_FTP_DIR_LEN_MAX;
int len = 0;
memset(dir, 0x0, MBTK_AT_FTP_DIR_LEN_MAX);
if(!getExtString(parameter_values_p, 0, dir, dir_len_max, &len, ""))
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
LOG("Get FTP RMDIR Fail.");
break;
}
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL);
MBTK_FUNC(mbtk_at_ftp_mkrmdel)(1,dir);
break;
}
default:
{
break;
}
}
return ret;
}
utlReturnCode_T MBTK_AT_CFTPDEL_PROCESS(const utlAtParameterOp_T op,
const char *command_name_p,
const utlAtParameterValue_P2c parameter_values_p,
const size_t num_parameters,
const char *info_text_p,
unsigned int *xid_p,
void *arg_p)
{
UNUSEDPARAM(command_name_p);
UNUSEDPARAM(num_parameters);
UNUSEDPARAM(info_text_p);
utlReturnCode_T ret = utlFAILED;
TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index);
*xid_p = At_handle;
char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
LOG("MBTK_AT_MTEST_PROCESS enter with command_op [%s]", op2str(op));
pthread_t mbtk_at_thread_ID; //定义线程id
pthread_create(&mbtk_at_thread_ID, NULL, &mbtk_at_printf, NULL);
pthread_detach(mbtk_at_thread_ID); //设置线程结束收
switch(op)
{
case TEL_EXT_GET_CMD :
{
static char remote_size[MBTK_AT_FTP_DIR_LEN_MAX+1];
memset(remote_size, 0x0, MBTK_AT_FTP_DIR_LEN_MAX+1);
MBTK_FUNC(mbtk_at_get_ftp_data_info)(remote_size,NULL,NULL,NULL,NULL);
sprintf(resp_buf, "+CFTPDELE: \"%s\"\r\n",remote_size);
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
break;
}
case TEL_EXT_SET_CMD :
{
static char dir[MBTK_AT_FTP_DIR_LEN_MAX];
int dir_len_max = MBTK_AT_FTP_DIR_LEN_MAX;
int len = 0;
memset(dir, 0x0, MBTK_AT_FTP_DIR_LEN_MAX);
if(!getExtString(parameter_values_p, 0, dir, dir_len_max, &len, ""))
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
LOG("Get FTP DEL FILE Fail.");
break;
}
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL);
MBTK_FUNC(mbtk_at_ftp_mkrmdel)(2,dir);
break;
}
default:
{
break;
}
}
return ret;
}
utlReturnCode_T MBTK_AT_CFTPPUTFILE_PROCESS(const utlAtParameterOp_T op,
const char *command_name_p,
const utlAtParameterValue_P2c parameter_values_p,
const size_t num_parameters,
const char *info_text_p,
unsigned int *xid_p,
void *arg_p)
{
UNUSEDPARAM(command_name_p);
UNUSEDPARAM(num_parameters);
UNUSEDPARAM(info_text_p);
utlReturnCode_T ret = utlFAILED;
TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index);
*xid_p = At_handle;
char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
LOG("MBTK_AT_MTEST_PROCESS enter with command_op [%s]", op2str(op));
pthread_t mbtk_at_thread_ID; //定义线程id
pthread_create(&mbtk_at_thread_ID, NULL, &mbtk_at_printf, NULL);
pthread_detach(mbtk_at_thread_ID); //设置线程结束收
switch(op)
{
case TEL_EXT_GET_CMD :
{
int rest_size = -1;
static char remote_size[MBTK_AT_FTP_DIR_LEN_MAX+1];
static char local_path[MBTK_AT_FTP_DIR_LEN_MAX+1];
memset(remote_size, 0x0, MBTK_AT_FTP_DIR_LEN_MAX+1);
memset(local_path, 0x0, MBTK_AT_FTP_DIR_LEN_MAX+1);
MBTK_FUNC(mbtk_at_get_ftp_data_info)(remote_size,local_path,&rest_size,NULL,NULL);
sprintf(resp_buf, "+CFTPPUTFILE: \"%s\", \"%s\",<%d>\r\n",remote_size,local_path,rest_size);
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
break;
}
case TEL_EXT_SET_CMD :
{
int rest_size;
static char remote_path[MBTK_AT_FTP_DIR_LEN_MAX+1];
static char local_path[MBTK_AT_FTP_DIR_LEN_MAX+1];
int dir_len_max = MBTK_AT_FTP_DIR_LEN_MAX;
int len = 0;
memset(remote_path, 0x0, MBTK_AT_FTP_DIR_LEN_MAX+1);
memset(local_path, 0x0, MBTK_AT_FTP_DIR_LEN_MAX+1);
if(!getExtString(parameter_values_p, 0, remote_path, dir_len_max, &len, ""))
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
LOG("Get FTP DEL FILE Fail.");
break;
}
if(!getExtString(parameter_values_p, 1, local_path, dir_len_max, &len, ""))
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
LOG("Get FTP DEL FILE Fail.");
break;
}
if(!getExtValue(parameter_values_p, 2, &rest_size, 0, 2147483647, 0))
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
break;
}
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL);
MBTK_FUNC(mbtk_at_ftp_upload)(remote_path,local_path,0,rest_size);
break;
}
default:
{
break;
}
}
return ret;
}
utlReturnCode_T MBTK_AT_CFTPPUT_PROCESS(const utlAtParameterOp_T op,
const char *command_name_p,
const utlAtParameterValue_P2c parameter_values_p,
const size_t num_parameters,
const char *info_text_p,
unsigned int *xid_p,
void *arg_p)
{
UNUSEDPARAM(command_name_p);
UNUSEDPARAM(num_parameters);
UNUSEDPARAM(info_text_p);
utlReturnCode_T ret = utlFAILED;
TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index);
*xid_p = At_handle;
char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
LOG("MBTK_AT_MTEST_PROCESS enter with command_op [%s]", op2str(op));
pthread_t mbtk_at_thread_ID; //定义线程id
pthread_create(&mbtk_at_thread_ID, NULL, &mbtk_at_printf, NULL);
pthread_detach(mbtk_at_thread_ID); //设置线程结束收
switch(op)
{
case TEL_EXT_GET_CMD :
{
int rest_size = -1;
int put_len = -1;
static char remote_size[MBTK_AT_FTP_DIR_LEN_MAX+1];
memset(remote_size, 0x0, MBTK_AT_FTP_DIR_LEN_MAX+1);
MBTK_FUNC(mbtk_at_get_ftp_data_info)(remote_size,NULL,&rest_size,NULL,&put_len);
sprintf(resp_buf, "+CFTPPUT: \"%s\",<%d>,<%d>\r\n",remote_size,rest_size,put_len);
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
break;
}
case TEL_EXT_SET_CMD :
{
static char remote_path[MBTK_AT_FTP_DIR_LEN_MAX];
int dir_len_max = MBTK_AT_FTP_DIR_LEN_MAX;
int len = 0;
int rest_size;
int put_len;
memset(remote_path, 0x0, MBTK_AT_FTP_DIR_LEN_MAX);
if(!getExtString(parameter_values_p, 0, remote_path, dir_len_max, &len, ""))
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
LOG("Get FTP DEL FILE Fail.");
break;
}
if(!getExtValue(parameter_values_p, 1, &rest_size, 0, 2147483647, 0))
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
break;
}
if(!getExtValue(parameter_values_p, 2, &put_len, 1, 1500, 0))
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
break;
}
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL);
MBTK_FUNC(mbtk_at_ftp_upload)(remote_path,NULL,put_len,rest_size);
break;
}
default:
{
break;
}
}
return ret;
}
utlReturnCode_T MBTK_AT_CFTPGETFILE_PROCESS(const utlAtParameterOp_T op,
const char *command_name_p,
const utlAtParameterValue_P2c parameter_values_p,
const size_t num_parameters,
const char *info_text_p,
unsigned int *xid_p,
void *arg_p)
{
UNUSEDPARAM(command_name_p);
UNUSEDPARAM(num_parameters);
UNUSEDPARAM(info_text_p);
utlReturnCode_T ret = utlFAILED;
TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index);
*xid_p = At_handle;
char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
LOG("MBTK_AT_MTEST_PROCESS enter with command_op [%s]", op2str(op));
pthread_t mbtk_at_thread_ID; //定义线程id
pthread_create(&mbtk_at_thread_ID, NULL, &mbtk_at_printf, NULL);
pthread_detach(mbtk_at_thread_ID); //设置线程结束收
switch(op)
{
case TEL_EXT_GET_CMD :
{
int rest_size = -1;
int read_size = -1;
static char remote_size[MBTK_AT_FTP_DIR_LEN_MAX+1];
static char local_path[MBTK_AT_FTP_DIR_LEN_MAX+1];
memset(remote_size, 0x0, MBTK_AT_FTP_DIR_LEN_MAX+1);
memset(local_path, 0x0, MBTK_AT_FTP_DIR_LEN_MAX+1);
MBTK_FUNC(mbtk_at_get_ftp_data_info)(remote_size,local_path,&rest_size,&read_size,NULL);
sprintf(resp_buf, "+CFTPGETFILE: \"%s\", \"%s\",<%d>, <%d>\r\n",remote_size,local_path,rest_size,read_size);
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
break;
}
case TEL_EXT_SET_CMD :
{
static char remote_path[MBTK_AT_FTP_DIR_LEN_MAX+1];
static char local_path[MBTK_AT_FTP_DIR_LEN_MAX+1];
int dir_len_max = MBTK_AT_FTP_DIR_LEN_MAX;
int len = 0;
int rest_size;
int read_size;
memset(remote_path, 0x0, MBTK_AT_FTP_DIR_LEN_MAX+1);
memset(local_path, 0x0, MBTK_AT_FTP_DIR_LEN_MAX+1);
if(!getExtString(parameter_values_p, 0, remote_path, dir_len_max, &len, ""))
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
LOG("Get FTP DEL FILE Fail.");
break;
}
if(!getExtString(parameter_values_p, 1, local_path, dir_len_max, &len, ""))
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
LOG("Get FTP DEL FILE Fail.");
break;
}
if(!getExtValue(parameter_values_p, 2, &rest_size, 0, 2147483647, 0))
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
break;
}
if(!getExtValue(parameter_values_p, 3, &read_size, 0, 524288, 0))
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
break;
}
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL);
MBTK_FUNC(mbtk_at_ftp_download)(remote_path,local_path,0,rest_size,read_size);
break;
}
default:
{
break;
}
}
return ret;
}
utlReturnCode_T MBTK_AT_CFTPGET_PROCESS(const utlAtParameterOp_T op,
const char *command_name_p,
const utlAtParameterValue_P2c parameter_values_p,
const size_t num_parameters,
const char *info_text_p,
unsigned int *xid_p,
void *arg_p)
{
UNUSEDPARAM(command_name_p);
UNUSEDPARAM(num_parameters);
UNUSEDPARAM(info_text_p);
utlReturnCode_T ret = utlFAILED;
TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index);
*xid_p = At_handle;
char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
LOG("MBTK_AT_MTEST_PROCESS enter with command_op [%s]", op2str(op));
pthread_t mbtk_at_thread_ID; //定义线程id
pthread_create(&mbtk_at_thread_ID, NULL, &mbtk_at_printf, NULL);
pthread_detach(mbtk_at_thread_ID); //设置线程结束收
switch(op)
{
case TEL_EXT_GET_CMD :
{
int rest_size = -1;
static char remote_size[MBTK_AT_FTP_DIR_LEN_MAX+1];
memset(remote_size, 0x0, MBTK_AT_FTP_DIR_LEN_MAX+1);
MBTK_FUNC(mbtk_at_get_ftp_data_info)(remote_size,NULL,&rest_size,NULL,NULL);
sprintf(resp_buf, "+CFTPGET: \"%s\",<%d>\r\n",remote_size,rest_size);
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
break;
}
case TEL_EXT_SET_CMD :
{
static char remote_path[MBTK_AT_FTP_DIR_LEN_MAX+1];
int dir_len_max = MBTK_AT_FTP_DIR_LEN_MAX;
int len = 0;
int rest_size;
int read_size;
memset(remote_path, 0x0, MBTK_AT_FTP_DIR_LEN_MAX+1);
if(!getExtString(parameter_values_p, 0, remote_path, dir_len_max, &len, ""))
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
LOG("Get FTP DEL FILE Fail.");
break;
}
if(!getExtValue(parameter_values_p, 1, &rest_size, 0, 2147483647, 0))
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
break;
}
if(!getExtValue(parameter_values_p, 2, &read_size, 0, 524288, 0))
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
break;
}
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL);
MBTK_FUNC(mbtk_at_ftp_download)(remote_path,NULL,1,rest_size,read_size);
break;
}
default:
{
break;
}
}
return ret;
}
utlReturnCode_T MBTK_AT_CFTPLIST_PROCESS(const utlAtParameterOp_T op,
const char *command_name_p,
const utlAtParameterValue_P2c parameter_values_p,
const size_t num_parameters,
const char *info_text_p,
unsigned int *xid_p,
void *arg_p)
{
UNUSEDPARAM(command_name_p);
UNUSEDPARAM(num_parameters);
UNUSEDPARAM(info_text_p);
utlReturnCode_T ret = utlFAILED;
TelAtParserID sAtp_index = *(TelAtParserID *)arg_p;
unsigned int At_handle = MAKE_AT_HANDLE(sAtp_index);
*xid_p = At_handle;
char resp_buf[MBTK_AT_RESP_LEN_MAX] = {0};
LOG("MBTK_AT_MTEST_PROCESS enter with command_op [%s]", op2str(op));
pthread_t mbtk_at_thread_ID; //定义线程id
pthread_create(&mbtk_at_thread_ID, NULL, &mbtk_at_printf, NULL);
pthread_detach(mbtk_at_thread_ID); //设置线程结束收尸
switch(op)
{
case TEL_EXT_GET_CMD :
{
int rest_size = -1;
static char remote_size[MBTK_AT_FTP_DIR_LEN_MAX+1];
memset(remote_size, 0x0, MBTK_AT_FTP_DIR_LEN_MAX+1);
MBTK_FUNC(mbtk_at_get_ftp_data_info)(remote_size,NULL,NULL,NULL,NULL);
sprintf(resp_buf, "+CFTPLIST: \"%s\"\r\n",remote_size);
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, resp_buf);
break;
}
case TEL_EXT_SET_CMD :
{
static char dir[MBTK_AT_FTP_DIR_LEN_MAX+1];
int dir_len_max = MBTK_AT_FTP_DIR_LEN_MAX;
int len = 0;
memset(dir, 0x0, MBTK_AT_FTP_DIR_LEN_MAX+1);
if(!getExtString(parameter_values_p, 0, dir, dir_len_max, &len, ""))
{
ret = ATRESP(At_handle, ATCI_RESULT_CODE_ERROR, 0, NULL);
LOG("Get FTP RMDIR Fail.");
break;
}
ret = ATRESP(At_handle, ATCI_RESULT_CODE_OK, 0, NULL);
MBTK_FUNC(mbtk_at_ftp_list)(dir);
break;
}
default:
{
break;
}
}
return ret;
}