update atcmd_server from v1265
Change-Id: Ic2ce53afc20d0c72cd7b29e8cb7cc9ebc502c37a
diff --git a/marvell/lte-telephony/apps/atcmd_server_ss/Makefile b/marvell/lte-telephony/apps/atcmd_server_ss/Makefile
old mode 100644
new mode 100755
index 2b486c6..4583416
--- a/marvell/lte-telephony/apps/atcmd_server_ss/Makefile
+++ b/marvell/lte-telephony/apps/atcmd_server_ss/Makefile
@@ -364,7 +364,10 @@
endif
endif
-CFLAGS += $(LOCAL_C_INCLUDES)
+# Add by liubin
+include $(MBTK_HOME_DIR)/mbtk_at/rules.make
+
+CFLAGS += $(LOCAL_C_INCLUDES) $(MBTK_COMMON_INCLUDE)
CFLAGS += $(LOCAL_CFLAGS)
$(eval $(call add-many-objects-rule, atcmd_server_src, $(LOCAL_SRC_FILES),,))
diff --git a/marvell/lte-telephony/apps/atcmd_server_ss/inc/teldbg.h b/marvell/lte-telephony/apps/atcmd_server_ss/inc/teldbg.h
old mode 100644
new mode 100755
index 045ddf1..ea76e32
--- a/marvell/lte-telephony/apps/atcmd_server_ss/inc/teldbg.h
+++ b/marvell/lte-telephony/apps/atcmd_server_ss/inc/teldbg.h
@@ -53,6 +53,17 @@
RETURNCODE_T ciGPSState(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);
RETURNCODE_T ciGPSSetting(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);
RETURNCODE_T ciAGnssCfg(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);
+#else
+//mbtk for gps add
+RETURNCODE_T mbtk_GPSInit(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);
+RETURNCODE_T mbtk_GPSDeInit(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);
+RETURNCODE_T mbtk_GPSSleep(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);
+RETURNCODE_T mbtk_AGnssGet(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);
+RETURNCODE_T mbtk_AGnssCfg(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);
+RETURNCODE_T mbtk_AGnssSet(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);
+RETURNCODE_T mbtk_GPSState(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);
+RETURNCODE_T mbtk_GPSSetting(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);
+RETURNCODE_T mbtk_GPSFwdl(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);
#endif
RETURNCODE_T ciCMTLRA(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);
diff --git a/marvell/lte-telephony/apps/atcmd_server_ss/inc/teldef.h b/marvell/lte-telephony/apps/atcmd_server_ss/inc/teldef.h
old mode 100644
new mode 100755
index 3310d0b..87a75d8
--- a/marvell/lte-telephony/apps/atcmd_server_ss/inc/teldef.h
+++ b/marvell/lte-telephony/apps/atcmd_server_ss/inc/teldef.h
@@ -86,7 +86,7 @@
TEL_AT_CMD_ATP_0_1,
#endif
TEL_SOCKET_AT_CMD_ATP_BEGIN,
- NUM_OF_TEL_ATP = 20
+ NUM_OF_TEL_ATP = 25 // Change by liubin
}
TelAtParserID;
diff --git a/marvell/lte-telephony/apps/atcmd_server_ss/src/main.c b/marvell/lte-telephony/apps/atcmd_server_ss/src/main.c
old mode 100644
new mode 100755
index 59f63da..ed742bc
--- a/marvell/lte-telephony/apps/atcmd_server_ss/src/main.c
+++ b/marvell/lte-telephony/apps/atcmd_server_ss/src/main.c
@@ -298,7 +298,8 @@
fclose(fp);
#endif
}
-
+// Add by liubin
+int mbtk_lib_init();
/*******************************************************************
* FUNCTION: main()
*
@@ -344,8 +345,12 @@
*/
handleArg(argc, argv);
DBGMSG(arcmd_main, "External Serial Deivce: %s\n.", acExtSerialPath);
-
-
+ // Add by liubin
+ if(mbtk_lib_init())
+ {
+ ERRMSG(atcmd_main, "%s: mbtk_lib_init() failed\n", __FUNCTION__);
+ exit(1);
+ }
#ifdef MBTK_AT_SUPPORT //LYNQ_MODFIY for ext_at
start_at_extension_loop();
#endif
diff --git a/marvell/lte-telephony/apps/atcmd_server_ss/src/mm_api.c b/marvell/lte-telephony/apps/atcmd_server_ss/src/mm_api.c
old mode 100644
new mode 100755
index a86919d..aee47ee
--- a/marvell/lte-telephony/apps/atcmd_server_ss/src/mm_api.c
+++ b/marvell/lte-telephony/apps/atcmd_server_ss/src/mm_api.c
@@ -194,6 +194,9 @@
LTE_WCDMA_GSM_ORDER = 3,
};
+// Add by liubin
+// 0: Cell time 1:GNSS time 2:NTP time
+int mbtk_time_type = 0;
static int gSyncCompleted = 0;
static int gTZ = 0;
static int gDstInd = 0;
@@ -6103,21 +6106,34 @@
}
}
+ // Change by liubin
+ char time_type[10] = {0};
+ property_get("persist.mbtk.time_type", time_type, "0");
+ mbtk_time_type = atoi(time_type);
if (gSyncNITZ && GetSyncFlag() == 1) {
- struct timeval get_tv;
- struct timezone get_tz;
+ if(mbtk_time_type == 0)
+ {
+ struct timeval get_tv;
+ struct timezone get_tz;
- if(settimeofday(&tv, &tz) != 0)
- {
- ERRMSG(processNitzInfoInd1, "processNitzInfoInd: Error to set time");
+ if(settimeofday(&tv, NULL) != 0)
+ {
+ ERRMSG(processNitzInfoInd1, "processNitzInfoInd: Error to set time tv");
+ }
+ if(settimeofday(NULL, &tz) != 0)
+ {
+ ERRMSG(processNitzInfoInd1, "processNitzInfoInd: Error to set time tz");
+ }
+ gSyncCompleted = 1;
+ ERRMSG(processNitzInfoInd4549, "processNitzInfoInd: update time from nitz done, timezone %d", tz.tz_minuteswest );
+ if(gettimeofday(&get_tv, &get_tz) == 0)
+ {
+ ERRMSG(processNitzInfoInd5510, "processNitzInfoInd: get timezone with gettimeofday %d", get_tz.tz_minuteswest );
+ }
+ system("hwclock -w rtc0");
}
- gSyncCompleted = 1;
- ERRMSG(processNitzInfoInd4549, "processNitzInfoInd: [settimeofday] update time from nitz done, tz_minuteswest %d, tv_sec %u", tz.tz_minuteswest, tv.tv_sec);
- if(gettimeofday(&get_tv, &get_tz) == 0)
- {
- ERRMSG(processNitzInfoInd5510, "processNitzInfoInd: [gettimeofday] get tz_minuteswest with gettimeofday %d, tv_sec %u", get_tz.tz_minuteswest, get_tv.tv_sec);
- }
}
+ // End by liubin
if (gSyncCompleted)
{
diff --git a/marvell/lte-telephony/apps/atcmd_server_ss/src/telcontroller.c b/marvell/lte-telephony/apps/atcmd_server_ss/src/telcontroller.c
old mode 100644
new mode 100755
index 33b828b..d2e7bde
--- a/marvell/lte-telephony/apps/atcmd_server_ss/src/telcontroller.c
+++ b/marvell/lte-telephony/apps/atcmd_server_ss/src/telcontroller.c
@@ -2093,6 +2093,40 @@
utlDEFINE_STRING_AT_PARAMETER(utlAT_PARAMETER_ACCESS_READ_WRITE, utlAT_PARAMETER_PRESENCE_REQUIRED),
};
+
+#else
+//mbtk for gps add
+static utlAtParameter_T mbtk_gpsInit_params[] = {
+ utlDEFINE_DECIMAL_AT_PARAMETER(utlAT_PARAMETER_ACCESS_READ_WRITE, utlAT_PARAMETER_PRESENCE_REQUIRED),
+};
+
+static utlAtParameter_T mbtk_gpsSleep_params[] = {
+ utlDEFINE_DECIMAL_AT_PARAMETER(utlAT_PARAMETER_ACCESS_READ_WRITE, utlAT_PARAMETER_PRESENCE_REQUIRED),
+};
+
+static utlAtParameter_T mbtk_agnssGet_params[] = {
+ utlDEFINE_DECIMAL_AT_PARAMETER(utlAT_PARAMETER_ACCESS_READ_WRITE, utlAT_PARAMETER_PRESENCE_REQUIRED),
+ utlDEFINE_DECIMAL_AT_PARAMETER(utlAT_PARAMETER_ACCESS_READ_WRITE, utlAT_PARAMETER_PRESENCE_OPTIONAL),
+};
+
+static utlAtParameter_T mbtk_agnssCfg_params[] = {
+ utlDEFINE_STRING_AT_PARAMETER(utlAT_PARAMETER_ACCESS_READ_WRITE, utlAT_PARAMETER_PRESENCE_REQUIRED), //server
+ utlDEFINE_DECIMAL_AT_PARAMETER(utlAT_PARAMETER_ACCESS_READ_WRITE, utlAT_PARAMETER_PRESENCE_REQUIRED), //port
+ utlDEFINE_STRING_AT_PARAMETER(utlAT_PARAMETER_ACCESS_READ_WRITE, utlAT_PARAMETER_PRESENCE_OPTIONAL), //username
+ utlDEFINE_STRING_AT_PARAMETER(utlAT_PARAMETER_ACCESS_READ_WRITE, utlAT_PARAMETER_PRESENCE_OPTIONAL), //password
+ utlDEFINE_DECIMAL_AT_PARAMETER(utlAT_PARAMETER_ACCESS_READ_WRITE, utlAT_PARAMETER_PRESENCE_REQUIRED), //day
+ utlDEFINE_DECIMAL_AT_PARAMETER(utlAT_PARAMETER_ACCESS_READ_WRITE, utlAT_PARAMETER_PRESENCE_REQUIRED), //force
+};
+
+static utlAtParameter_T mbtk_gpsSet_params[] = {
+ utlDEFINE_STRING_AT_PARAMETER(utlAT_PARAMETER_ACCESS_READ_WRITE, utlAT_PARAMETER_PRESENCE_REQUIRED),
+};
+
+static utlAtParameter_T mbtk_gpsFwdl_params[] = {
+ utlDEFINE_STRING_AT_PARAMETER(utlAT_PARAMETER_ACCESS_READ_WRITE, utlAT_PARAMETER_PRESENCE_REQUIRED),
+};
+//mbtk for gnss add
+
#endif
static utlAtParameter_T plusCMTLRA_params[] = {
@@ -3365,6 +3399,18 @@
utlDEFINE_EXACTION_AT_COMMAND("+AGNSSSET", NULL, NULL, ciAGnssSet),
utlDEFINE_EXACTION_AT_COMMAND("+GPSST", NULL, NULL, ciGPSState),
utlDEFINE_EXTENDED_AT_COMMAND("+GPSSETTING", gpsSet_params, "+GPSSETTING: <string>", ciGPSSetting, ciGPSSetting),
+#else
+//mbtk for gps add
+ //0-close 1-uart1 2-USB_NAME 3-USB_AT 4-tty_gnss_name
+ utlDEFINE_EXTENDED_AT_COMMAND("+GPSINIT", mbtk_gpsInit_params, "+GPSINIT: (0-15)", mbtk_GPSInit, mbtk_GPSInit),
+ utlDEFINE_EXACTION_AT_COMMAND("+GPSDEINIT", NULL, NULL, mbtk_GPSDeInit),
+ utlDEFINE_EXTENDED_AT_COMMAND("+GPSSLEEP", mbtk_gpsSleep_params, "+GPSSLEEP: (0,1)", mbtk_GPSSleep, mbtk_GPSSleep),
+ utlDEFINE_EXTENDED_AT_COMMAND("+AGNSSGET", mbtk_agnssGet_params, "+AGNSSGET: <supl_server_addr>, <alam_flag>", mbtk_AGnssGet, mbtk_AGnssGet),
+ utlDEFINE_EXTENDED_AT_COMMAND("+AGNSSCFG", mbtk_agnssCfg_params, "+AGNSSCFG: <server>,<port>,<user>,<pass>,<day>,<force>", mbtk_AGnssCfg, mbtk_AGnssCfg),
+ utlDEFINE_EXACTION_AT_COMMAND("+AGNSSSET", NULL, NULL, mbtk_AGnssSet),
+ utlDEFINE_EXACTION_AT_COMMAND("+GPSST", NULL, NULL, mbtk_GPSState),
+ utlDEFINE_EXTENDED_AT_COMMAND("+GPSSETTING", mbtk_gpsSet_params, "+GPSSETTING: <string>", mbtk_GPSSetting, mbtk_GPSSetting),
+ utlDEFINE_EXTENDED_MBTK_AT_COMMAND("+GPSFWDL", mbtk_gpsFwdl_params, "+GPSFWDL: <string>", mbtk_GPSFwdl, mbtk_GPSFwdl),
#endif
utlDEFINE_EXTENDED_AT_COMMAND("*FACTORY", NULL, "*FACTORY", ciFactoryReset, ciFactoryReset),
@@ -3528,6 +3574,9 @@
{"+CCFC", {155, utlAT_AWAIT_ASYNC_TIMEOUT_TIME, utlAT_AWAIT_ASYNC_TIMEOUT_TIME}},
{"+CCWA", {155, utlAT_AWAIT_ASYNC_TIMEOUT_TIME, utlAT_AWAIT_ASYNC_TIMEOUT_TIME}},
{"+CGLA", {150, utlAT_AWAIT_ASYNC_TIMEOUT_TIME, utlAT_AWAIT_ASYNC_TIMEOUT_TIME}},
+ // Add by mbtk
+ {"+GPSINIT",{120, utlAT_AWAIT_ASYNC_TIMEOUT_TIME, utlAT_AWAIT_ASYNC_TIMEOUT_TIME}},
+ {"+GPSFWDL",{120, utlAT_AWAIT_ASYNC_TIMEOUT_TIME, utlAT_AWAIT_ASYNC_TIMEOUT_TIME}},
{"+CSIM", {150, utlAT_AWAIT_ASYNC_TIMEOUT_TIME, utlAT_AWAIT_ASYNC_TIMEOUT_TIME}},
{"+CFUN", {120, utlAT_AWAIT_ASYNC_TIMEOUT_TIME, utlAT_AWAIT_ASYNC_TIMEOUT_TIME}},
{"+CGDATA", {155, utlAT_AWAIT_ASYNC_TIMEOUT_TIME, utlAT_AWAIT_ASYNC_TIMEOUT_TIME}},
@@ -4575,6 +4624,13 @@
#ifdef MBTK_AT_SUPPORT
DEFINE_MASTER_SIM_CHANEL_DESC(TEL_SOCKET_AT_CMD_ATP_BEGIN, "atcmdmbtk", FALSE),
#endif
+
+// Add by liubin
+ DEFINE_SIM1_CHANEL_DESC(TEL_SOCKET_AT_CMD_ATP_BEGIN, "atcmd_urc", FALSE),
+ DEFINE_SIM1_NO_INDICATION_CHANEL_DESC(TEL_SOCKET_AT_CMD_ATP_BEGIN, "atcmd_at", FALSE),
+ DEFINE_SIM1_NO_INDICATION_CHANEL_DESC(TEL_SOCKET_AT_CMD_ATP_BEGIN, "atcmd_at_1", FALSE),
+ DEFINE_SIM1_NO_INDICATION_CHANEL_DESC(TEL_SOCKET_AT_CMD_ATP_BEGIN, "atcmd_at_2", FALSE),
+// End by liubin
};
unsigned int i;
diff --git a/marvell/lte-telephony/apps/atcmd_server_ss/src/teldbg.c b/marvell/lte-telephony/apps/atcmd_server_ss/src/teldbg.c
old mode 100644
new mode 100755
index 9e10f4a..631470c
--- a/marvell/lte-telephony/apps/atcmd_server_ss/src/teldbg.c
+++ b/marvell/lte-telephony/apps/atcmd_server_ss/src/teldbg.c
@@ -13,6 +13,16 @@
#include <teldef.h>
#include <fcntl.h>
+// Add by mbtk
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <netinet/in.h>
+#include <pthread.h>
+#include <sys/epoll.h>
+// End by mbtk
#if defined (BIONIC)
#include <cutils/properties.h>
#endif
@@ -2000,6 +2010,1022 @@
return(rc);
}
+#else
+#define MBTK_IND_START_FLAG 0xFF
+#define MBTK_IND_END_FLAG 0xEE
+#define SUPL_SERVER_ADDR_LEN 256
+#define MBTK_CMD_RSP_LEN 256
+#define GNSS_SOCK_PATH "/tmp/mbtk_gnss_sock"
+
+static int sock_listen_fd = -1;
+static char cmd_rsp[MBTK_CMD_RSP_LEN] = {0};
+
+typedef enum {
+ GNSS_CMD_INIT = 0,
+ GNSS_CMD_DEINIT,
+ GNSS_CMD_SETTING,
+ GNSS_CMD_DL,
+ GNSS_CMD_AGNSS_GET,
+ GNSS_CMD_AGNSS_SET
+} gnss_cmd_enum;
+
+typedef enum {
+ GNSS_ERR_OK,
+ GNSS_ERR_CLI_FULL,
+ GNSS_ERR_UNKNOWN_HANDLE,
+ GNSS_ERR_UNSUPPORT,
+ GNSS_ERR_TIMEOUT,
+ GNSS_ERR_ARG,
+ GNSS_ERR_CHECKSUM,
+ GNSS_ERR_SET_BUSY,
+ GNSS_ERR_DL_FW,
+ GNSS_ERR_OPEN_DEV,
+ GNSS_ERR_FORMAT,
+ GNSS_ERR_BUSY,
+ GNSS_ERR_EPH_GET_FAIL,
+ GNSS_ERR_EPH_INJECT_FAIL,
+ GNSS_ERR_UNKNOWN
+} gnss_err_enum;
+
+#if 1
+#include <dlfcn.h>
+
+#define MBTK_LIB_PATH "/lib/libmbtk_lib.so"
+
+typedef unsigned char boolean; /* Boolean value type. */
+// typedef unsigned char bool; /* Boolean value type. */
+typedef unsigned long long uint64; /* Unsigned 64 bit value */
+typedef unsigned long long uint64_t; /* Unsigned 64 bit value */
+typedef unsigned int uint32; /* Unsigned 32 bit value */
+typedef unsigned int uint32_t; /* Unsigned 32 bit value */
+typedef unsigned short uint16; /* Unsigned 16 bit value */
+typedef unsigned short uint16_t;
+typedef unsigned char uint8; /* Unsigned 8 bit value */
+typedef unsigned char uint8_t;
+typedef signed long long int64; /* Signed 64 bit value */
+typedef signed long long sint64; /* Signed 64 bit value */
+typedef signed int int32; /* Signed 32 bit value */
+typedef signed int sint32; /* Signed 32 bit value */
+typedef signed short int16; /* Signed 16 bit value */
+typedef signed short sint16; /* Signed 16 bit value */
+typedef signed char int8; /* Signed 8 bit value */
+typedef signed char sint8; /* Signed 8 bit value */
+typedef unsigned char byte; /* byte type */
+
+typedef enum {
+ MBTK_MODEM_BAND_AREA_ALL,
+ MBTK_MODEM_BAND_AREA_CN,
+ MBTK_MODEM_BAND_AREA_EU,
+ MBTK_MODEM_BAND_AREA_SA
+} mbtk_modem_band_area_enum;
+
+typedef enum {
+ MBTK_REBOOT_FLAG_NORMAL = 0,
+ MBTK_REBOOT_FLAG_DOWNLOAD
+} mbtk_device_info_reboot_flag_enum;
+
+typedef enum {
+ MBTK_DEVICE_INFO_ITEM_BASIC = 0,
+ MBTK_DEVICE_INFO_ITEM_FOTA,
+ MBTK_DEVICE_INFO_ITEM_MODEM,
+ MBTK_DEVICE_INFO_ITEM_LOG,
+
+ MBTK_DEVICE_INFO_ITEM_NUM
+} mbtk_device_info_item_enum;
+
+typedef struct {
+ uint8 name[16];
+ uint32 version; // Default : 0x01
+ uint8 project[16]; // T108 / L508_X6
+ uint8 project_cust[16]; // T108_C1 / L508_X6_C1 (Refer to: Custom_Model in blf file.)
+ uint32 ab_support; // 1 for ab
+ mbtk_device_info_reboot_flag_enum reboot_flag;
+ uint8 revision_out[48]; // L508_X6v01.01b04.00
+ uint8 revision_in[64];
+ uint8 build_time[64];
+} mbtk_device_info_basic_t;
+
+typedef struct {
+ uint8 name[16];
+ uint32 version; // Default : 0x01
+ mbtk_modem_band_area_enum band_area;
+ uint32 band_gsm;
+ uint32 band_wcdma;
+ uint32 band_tdlte;
+ uint32 band_fddlte;
+ uint32 band_lte_ext;
+} mbtk_device_info_modem_t;
+
+static bool dev_info_inited = FALSE;
+static mbtk_device_info_basic_t info_basic;
+static mbtk_device_info_modem_t info_modem;
+
+typedef int (*mbtk_dev_info_read_func)(mbtk_device_info_item_enum, void *, int);
+
+static int dev_info_get()
+{
+ if(dev_info_inited) {
+ return 0;
+ }
+ void *handle = dlopen(MBTK_LIB_PATH , RTLD_LAZY);
+ if(handle == NULL)
+ {
+ DBGMSG(dev_info_get_S, "dlopen() %s fail : %d", MBTK_LIB_PATH, errno);
+ return -1;
+ }
+
+ mbtk_dev_info_read_func dev_info_read = (mbtk_dev_info_read_func)dlsym(handle, "mbtk_dev_info_read");
+ if(dev_info_read == NULL)
+ {
+ DBGMSG(dev_info_read_S, "dlsym(mbtk_dev_info_read) fail : %d", errno);
+ return -1;
+ }
+
+ memset(&info_basic, 0, sizeof(mbtk_device_info_basic_t));
+ memset(&info_modem, 0, sizeof(mbtk_device_info_modem_t));
+
+ // mbtk_dev_info_read()
+ int result = dev_info_read(MBTK_DEVICE_INFO_ITEM_BASIC, &info_basic, sizeof(mbtk_device_info_basic_t));
+ if(result) {
+ DBGMSG(dev_info_read_S, "mbtk_dev_info_read(BASIC) fail.");
+ return -1;
+ }
+
+ result = dev_info_read(MBTK_DEVICE_INFO_ITEM_MODEM, &info_modem, sizeof(mbtk_device_info_modem_t));
+ if(result) {
+ DBGMSG(dev_info_read_S, "mbtk_dev_info_read(MODEM) fail.");
+ return -1;
+ }
+
+ dev_info_inited = TRUE;
+ return 0;
+}
+
+static char* band_area_2_str(mbtk_modem_band_area_enum band_area)
+{
+ switch(band_area) {
+ case MBTK_MODEM_BAND_AREA_CN:
+ return "CN";
+ case MBTK_MODEM_BAND_AREA_EU:
+ return "EU";
+ case MBTK_MODEM_BAND_AREA_SA:
+ return "SA";
+ default:
+ return "DEF";
+ }
+}
+
+#endif
+
+//buf: %cgnss_setting:%d %s%c
+static int mbtk_gnss_info_parse(char *data, int len)
+{
+ if(data == NULL || len == 0 || len > MBTK_CMD_RSP_LEN)
+ {
+ ERRMSG(mbtk_gnss_parse_1,"[AT_MBTK_GNSS] param error.\n");
+ return -1;
+ }
+
+ data[len - 1] = 0x0;
+ char *p = data + 1;
+ int result = 0;
+ char temp[MBTK_CMD_RSP_LEN] = {0};
+
+ memset(cmd_rsp, 0x0, MBTK_CMD_RSP_LEN);
+ if(2 == sscanf(p, "gnss_setting:%d %s", &result, temp))
+ {
+ if(memcmp(temp, "NULL", 4))
+ {
+ memcpy(cmd_rsp, temp, strlen(temp));
+ }
+ }
+ else
+ {
+ ERRMSG(mbtk_gnss_parse_2,"[AT_MBTK_GNSS] parse error.\n");
+ return -1;
+ }
+
+ return result;
+}
+
+static CiReturnCode mbtk_gps_err(gnss_err_enum result, UINT32 atHandle)
+{
+ CiReturnCode ret = CIRC_FAIL;
+ switch(result)
+ {
+ case GNSS_ERR_CLI_FULL:
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: client full.\r\n");
+ break;
+ }
+ case GNSS_ERR_UNKNOWN_HANDLE:
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: unknown handle.\r\n");
+ break;
+ }
+ case GNSS_ERR_UNSUPPORT:
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: unsupport.\r\n");
+ break;
+ }
+ case GNSS_ERR_TIMEOUT:
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: timeout.\r\n");
+ break;
+ }
+ case GNSS_ERR_ARG:
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: param error.\r\n");
+ break;
+ }
+ case GNSS_ERR_CHECKSUM:
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: checksum error.\r\n");
+ break;
+ }
+ case GNSS_ERR_SET_BUSY:
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: set busy.\r\n");
+ break;
+ }
+ case GNSS_ERR_DL_FW:
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: download fail.\r\n");
+ break;
+ }
+ case GNSS_ERR_OPEN_DEV:
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: open dev fail.\r\n");
+ break;
+ }
+ case GNSS_ERR_FORMAT:
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: format error.\r\n");
+ break;
+ }
+ case GNSS_ERR_BUSY:
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: busy.\r\n");
+ break;
+ }
+ case GNSS_ERR_EPH_GET_FAIL:
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: eph ser get fail.\r\n");
+ break;
+ }
+ case GNSS_ERR_EPH_INJECT_FAIL:
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: agps ser inject fail.\r\n");
+ break;
+ }
+ case GNSS_ERR_UNKNOWN:
+ default:
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: unknown error.\r\n");
+ break;
+ }
+ }
+
+ return ret;
+}
+
+static int mbtk_GPS_process(gnss_cmd_enum cmd, void *arg)
+{
+ if(sock_listen_fd < 0) {
+ sock_listen_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
+ if(sock_listen_fd < 0)
+ {
+ ERRMSG(mbtk_GPS_process_0,"[AT_MBTK_GNSS] socket() fail[%d].\n", errno);
+ return -1;
+ }
+
+ struct sockaddr_un cli_addr;
+ memset(&cli_addr, 0, sizeof(cli_addr));
+ cli_addr.sun_family = AF_LOCAL;
+ strcpy(cli_addr.sun_path, GNSS_SOCK_PATH);
+ if(connect(sock_listen_fd, (struct sockaddr *)&cli_addr, sizeof(cli_addr)))
+ {
+ ERRMSG(mbtk_GPS_process_1,"[AT_MBTK_GNSS] connect() fail[%d].\n", errno);
+ close(sock_listen_fd);
+ sock_listen_fd = -1;
+ return -1;
+ }
+ }
+
+ char buff[100] = {0};
+ char *ptr = NULL;
+ int len = 0;
+ int ret_len = 0;
+ if(cmd == GNSS_CMD_INIT) {
+ if(arg) {
+ sprintf(buff, "gnss_init:%d", *(int*)arg);
+ } else {
+ return -1;
+ }
+ } else if(cmd == GNSS_CMD_DEINIT) {
+ sprintf(buff, "gnss_deinit");
+ } else if(cmd == GNSS_CMD_SETTING) {
+ sprintf(buff, "gnss_setting:%s", (char *)arg);
+ } else if(cmd == GNSS_CMD_DL) {
+ sprintf(buff, "gnss_dl:%s", (char *)arg);
+ } else if(cmd == GNSS_CMD_AGNSS_GET) {
+ sprintf(buff, "gnss_agnss_get:%s", (char *)arg);
+ } else if(cmd == GNSS_CMD_AGNSS_SET) {
+ sprintf(buff, "gnss_agnss_set");
+ } else {
+ printf("Unknown cmd.\n");
+ return -1;
+ }
+
+ ret_len = write(sock_listen_fd, buff, strlen(buff));
+ if(ret_len < 0)
+ {
+ ERRMSG(mbtk_GPS_process_2,"[AT_MBTK_GNSS] write() fail[%d].\n", errno);
+ return -1;
+ }
+
+ while(1) {
+ memset(buff, 0, sizeof(buff));
+ len = read(sock_listen_fd, buff, sizeof(buff));
+ if(len > 0) {
+ //buf: %cgnss_init:%d%c
+ ERRMSG(mbtk_GPS_process_3,"[AT_MBTK_GNSS] RSP : %s\n", buff);
+ buff[len] = 0;
+ ptr = buff + 1;
+ if(cmd == GNSS_CMD_INIT) {
+ if(memcmp(ptr, "gnss_init", 9) == 0) {
+ return atoi(ptr + 10);
+ } else {
+ ERRMSG(mbtk_GPS_process_4,"[AT_MBTK_GNSS] gnss_init response error.\n");
+ return -1;
+ }
+ } else if(cmd == GNSS_CMD_DEINIT) {
+ if(memcmp(ptr, "gnss_deinit", 11) == 0) {
+ return atoi(ptr + 12);
+ } else {
+ ERRMSG(mbtk_GPS_process_5,"[AT_MBTK_GNSS] gnss_deinit response error.\n");
+ return -1;
+ }
+ } else if(cmd == GNSS_CMD_SETTING) {
+ if(memcmp(ptr, "gnss_setting", 12) == 0) { //buf: %cgnss_setting:%d %s%c
+ return mbtk_gnss_info_parse(buff, len);
+ } else {
+ ERRMSG(mbtk_GPS_process_6,"[AT_MBTK_GNSS] gnss_setting response error.\n");
+ return -1;
+ }
+ } else if(cmd == GNSS_CMD_DL) {
+ if(memcmp(ptr, "gnss_dl", 7) == 0) {
+ return atoi(ptr + 8);
+ } else {
+ ERRMSG(mbtk_GPS_process_7,"[AT_MBTK_GNSS] gnss_dl response error.\n");
+ return -1;
+ }
+ } else if(cmd == GNSS_CMD_AGNSS_GET) {
+ if(memcmp(ptr, "gnss_agnss_get", 14) == 0) {
+ return atoi(ptr + 15);
+ } else {
+ ERRMSG(mbtk_GPS_process_8,"[AT_MBTK_GNSS] gnss_dl response error.\n");
+ return -1;
+ }
+ } else if(cmd == GNSS_CMD_AGNSS_SET) {
+ if(memcmp(ptr, "gnss_agnss_set", 14) == 0) {
+ return atoi(ptr + 15);
+ } else {
+ ERRMSG(mbtk_GPS_process_9,"[AT_MBTK_GNSS] gnss_dl response error.\n");
+ return -1;
+ }
+ } else {
+ ERRMSG(mbtk_GPS_process_10,"[AT_MBTK_GNSS] Unknown response.\n");
+ return -1;
+ }
+ } else if(len == 0) {
+ ERRMSG(mbtk_GPS_process_11,"[AT_MBTK_GNSS] RSP is null.\n");
+ return -1;
+ } else {
+ ERRMSG(mbtk_GPS_process_12,"[AT_MBTK_GNSS] read = %d:errno = %d\n", len, errno);
+ }
+ }
+}
+
+RETURNCODE_T mbtk_GPSInit(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)
+
+ RETURNCODE_T rc = INITIAL_RETURN_CODE;
+ CiReturnCode ret = CIRC_FAIL;
+ UINT32 atHandle = MAKE_AT_HANDLE(* (TelAtParserID *) arg_p);
+ *xid_p = atHandle;
+ TelAtParserID origParserId = *(TelAtParserID *)arg_p;
+
+ //DBGMSG("%s: atHandle = %d.\n", __FUNCTION__, atHandle);
+
+ /*
+ ** Check the format of the request.
+ */
+ switch(op)
+ {
+ case TEL_EXT_TEST_CMD: /* AT+GPSINIT=? */
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_OK, 0, (char *)"+GPSINIT: (0-15)\r\n");
+ break;
+ }
+ case TEL_EXT_SET_CMD: /* AT+GPSINIT= */
+ {
+ INT32 gps_init_val;
+ //0-close 1-uart1 2-USB_NAME 4-USB_AT 8-tty_gnss_name
+ if (getExtValue(parameter_values_p, 0, (int *)&gps_init_val, 0, 15, 0) == TRUE)
+ {
+ int result = 0;
+ result = mbtk_GPS_process(GNSS_CMD_INIT, &gps_init_val);
+ if (result < 0)
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: init fail.\r\n");
+ }
+ else if((gnss_err_enum)result == GNSS_ERR_OK)
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_OK, 0, "+GPS: init success.\r\n");
+ }
+ else
+ {
+ ret = mbtk_gps_err((gnss_err_enum)result, atHandle);
+ }
+ }
+ else
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_CME_ERROR, CME_INVALID_PARAM, NULL);
+ }
+ break;
+ }
+ case TEL_EXT_GET_CMD: /* AT+GPSINIT? */
+ case TEL_EXT_ACTION_CMD: /* AT+GPSINIT */
+ default:
+ {
+ ret = ATRESP(atHandle,ATCI_RESULT_CODE_CME_ERROR,CME_OPERATION_NOT_SUPPORTED,NULL);
+ break;
+ }
+ }
+
+ /* handle the return value */
+ rc = HANDLE_RETURN_VALUE(ret);
+ return(rc);
+
+}
+
+RETURNCODE_T mbtk_GPSDeInit(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)
+
+ RETURNCODE_T rc = INITIAL_RETURN_CODE;
+ CiReturnCode ret = CIRC_FAIL;
+ UINT32 atHandle = MAKE_AT_HANDLE(* (TelAtParserID *) arg_p);
+ *xid_p = atHandle;
+ TelAtParserID origParserId = *(TelAtParserID *)arg_p;
+
+ //DBGMSG("%s: atHandle = %d.\n", __FUNCTION__, atHandle);
+
+ /*
+ ** Check the format of the request.
+ */
+ switch(op)
+ {
+ case TEL_EXT_ACTION_CMD: /* AT+GPSDEINIT */
+ {
+ int result = 0;
+ result = mbtk_GPS_process(GNSS_CMD_DEINIT, NULL);
+ if (result < 0)
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: deinit fail.\r\n");
+ }
+ else if((gnss_err_enum)result == GNSS_ERR_OK)
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_OK, 0, "+GPS: deinit success.\r\n");
+ }
+ else
+ {
+ ret = mbtk_gps_err((gnss_err_enum)result, atHandle);
+ }
+ break;
+ }
+ case TEL_EXT_TEST_CMD: /* AT+GPSDEINIT=? */
+ case TEL_EXT_GET_CMD: /* AT+GPSDEINIT? */
+ case TEL_EXT_SET_CMD: /* AT+GPSDEINIT= */
+ default:
+ {
+ ret = ATRESP(atHandle,ATCI_RESULT_CODE_CME_ERROR,CME_OPERATION_NOT_SUPPORTED,NULL);
+ break;
+ }
+ }
+
+ /* handle the return value */
+ rc = HANDLE_RETURN_VALUE(ret);
+ return(rc);
+}
+
+RETURNCODE_T mbtk_GPSSleep(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)
+
+ RETURNCODE_T rc = INITIAL_RETURN_CODE;
+ CiReturnCode ret = CIRC_FAIL;
+ UINT32 atHandle = MAKE_AT_HANDLE(* (TelAtParserID *) arg_p);
+ *xid_p = atHandle;
+ TelAtParserID origParserId = *(TelAtParserID *)arg_p;
+
+ //DBGMSG("%s: atHandle = %d.\n", __FUNCTION__, atHandle);
+
+ /*
+ ** Check the format of the request.
+ */
+ switch(op)
+ {
+ case TEL_EXT_TEST_CMD: /* AT+GPSSLEEP=? */
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_OK, 0, (char *)"+GPSSLEEP: (0,1)\r\n");
+ break;
+ }
+
+ case TEL_EXT_SET_CMD: /* AT+GPSSLEEP= */
+ {
+ INT32 gps_sleep_val;
+ /* Extract the arguments starting with the functionality. */
+ if (getExtValue(parameter_values_p, 0, (int *)&gps_sleep_val, 0, 1, 0) == TRUE)
+ {
+ ret = mbtk_gps_err(GNSS_ERR_UNSUPPORT, atHandle);
+ }
+ else
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_CME_ERROR, CME_INVALID_PARAM, NULL);
+ }
+ break;
+ }
+ case TEL_EXT_GET_CMD: /* AT+GPSSLEEP? */
+ case TEL_EXT_ACTION_CMD: /* AT+GPSSLEEP */
+ default:
+ {
+ ret = ATRESP(atHandle,ATCI_RESULT_CODE_CME_ERROR,CME_OPERATION_NOT_SUPPORTED,NULL);
+ break;
+ }
+ }
+
+ /* handle the return value */
+ rc = HANDLE_RETURN_VALUE(ret);
+ return(rc);
+}
+
+RETURNCODE_T mbtk_AGnssGet(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)
+
+ RETURNCODE_T rc = INITIAL_RETURN_CODE;
+ CiReturnCode ret = CIRC_FAIL;
+ UINT32 atHandle = MAKE_AT_HANDLE(* (TelAtParserID *) arg_p);
+ *xid_p = atHandle;
+ TelAtParserID origParserId = *(TelAtParserID *)arg_p;
+
+ //DBGMSG("%s: atHandle = %d.\n", __FUNCTION__, atHandle);
+
+ /*
+ ** Check the format of the request.
+ */
+ switch(op)
+ {
+ case TEL_EXT_TEST_CMD: /* AT+AGNSSGET=? */
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_OK, 0, (char *)"+AGNSSGET: <eph_type>, <alam_flag>\r\n");
+ break;
+ }
+ case TEL_EXT_SET_CMD: /* AT+AGNSSGET= */
+ {
+ int eph_type = 0;
+ int alm_flag = 0;
+ char param[128] = {0};
+
+ /* Extract the arguments starting with the functionality. */
+ if (getExtValue(parameter_values_p, 0, &eph_type, 0, 6, 0) == TRUE)
+ {
+ if (getExtValue(parameter_values_p, 1, &alm_flag, 0, 1, 0) == TRUE)
+ {
+ int result = 0;
+ snprintf(param, 128, "%d,%d", eph_type, alm_flag);
+ result = mbtk_GPS_process(GNSS_CMD_AGNSS_GET, param);
+ if (result < 0)
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: agps get eph fail.\r\n");
+ }
+ else if((gnss_err_enum)result == GNSS_ERR_OK)
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_OK, 0, "+GPS: agps get eph success.\r\n");
+ }
+ else
+ {
+ ret = mbtk_gps_err((gnss_err_enum)result, atHandle);
+ }
+ }
+ else
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_CME_ERROR, CME_INVALID_PARAM, NULL);
+ }
+ }
+ else
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_CME_ERROR, CME_INVALID_PARAM, NULL);
+ }
+
+
+ break;
+ }
+ case TEL_EXT_GET_CMD: /* AT+AGNSSGET? */
+ case TEL_EXT_ACTION_CMD: /* AT+AGNSSGET */
+ default:
+ {
+ ret = ATRESP(atHandle,ATCI_RESULT_CODE_CME_ERROR,CME_OPERATION_NOT_SUPPORTED,NULL);
+ break;
+ }
+ }
+
+ /* handle the return value */
+ rc = HANDLE_RETURN_VALUE(ret);
+ return(rc);
+}
+
+RETURNCODE_T mbtk_AGnssCfg(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)
+
+ RETURNCODE_T rc = INITIAL_RETURN_CODE;
+ CiReturnCode ret = CIRC_FAIL;
+ int i = 0;
+ UINT32 atHandle = MAKE_AT_HANDLE(* (TelAtParserID *) arg_p);
+ *xid_p = atHandle;
+
+ //DBGMSG("%s: atHandle = %d.\n", __FUNCTION__, atHandle);
+ /*
+ ** Check the format of the request.
+ */
+ switch(op)
+ {
+ case TEL_EXT_TEST_CMD: /* AT+AGNSSCFG=? */
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_OK, 0, (char *)"+AGNSSCFG: <server>,<port>,<usr>,<passwd>,<day>,<force>\r\n");
+ break;
+ }
+ case TEL_EXT_GET_CMD: /* AT+AGNSSCFG? */
+ case TEL_EXT_SET_CMD: /* AT+AGNSSCFG= */
+ case TEL_EXT_ACTION_CMD: /* AT+AGNSSCFG */
+ default:
+ {
+ ret = ATRESP(atHandle,ATCI_RESULT_CODE_CME_ERROR,CME_OPERATION_NOT_SUPPORTED,NULL);
+ break;
+ }
+ }
+
+ /* handle the return value */
+ rc = HANDLE_RETURN_VALUE(ret);
+ return(rc);
+}
+
+RETURNCODE_T mbtk_AGnssSet(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)
+
+ RETURNCODE_T rc = INITIAL_RETURN_CODE;
+ CiReturnCode ret = CIRC_FAIL;
+ UINT32 atHandle = MAKE_AT_HANDLE(* (TelAtParserID *) arg_p);
+ *xid_p = atHandle;
+ TelAtParserID origParserId = *(TelAtParserID *)arg_p;
+
+ //DBGMSG("%s: atHandle = %d.\n", __FUNCTION__, atHandle);
+
+ /*
+ ** Check the format of the request.
+ */
+ switch(op)
+ {
+ case TEL_EXT_ACTION_CMD: /* AT+AGNSSSET */
+ {
+ int result = 0;
+ result = mbtk_GPS_process(GNSS_CMD_AGNSS_SET, NULL);
+ if (result < 0)
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: agps inject fail.\r\n");
+ }
+ else if((gnss_err_enum)result == GNSS_ERR_OK)
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_OK, 0, "+GPS: agps inject success.\r\n");
+ }
+ else
+ {
+ ret = mbtk_gps_err((gnss_err_enum)result, atHandle);
+ }
+ break;
+ }
+ case TEL_EXT_TEST_CMD: /* AT+AGNSSSET=? */
+ case TEL_EXT_GET_CMD: /* AT+AGNSSSET? */
+ case TEL_EXT_SET_CMD: /* AT+AGNSSSET= */
+ default:
+ {
+ ret = ATRESP(atHandle,ATCI_RESULT_CODE_CME_ERROR,CME_OPERATION_NOT_SUPPORTED,NULL);
+ break;
+ }
+ }
+
+ /* handle the return value */
+ rc = HANDLE_RETURN_VALUE(ret);
+ return(rc);
+
+}
+
+RETURNCODE_T mbtk_GPSState(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)
+
+ RETURNCODE_T rc = INITIAL_RETURN_CODE;
+ CiReturnCode ret = CIRC_FAIL;
+ UINT32 atHandle = MAKE_AT_HANDLE(* (TelAtParserID *) arg_p);
+ *xid_p = atHandle;
+ TelAtParserID origParserId = *(TelAtParserID *)arg_p;
+
+ //DBGMSG("%s: atHandle = %d.\n", __FUNCTION__, atHandle);
+
+ /*
+ ** Check the format of the request.
+ */
+ switch(op)
+ {
+ case TEL_EXT_ACTION_CMD: /* AT+GPSST */
+ {
+ ret = mbtk_gps_err(GNSS_ERR_UNSUPPORT, atHandle);
+ break;
+ }
+ case TEL_EXT_TEST_CMD: /* AT+AGNSSCFG=? */
+ case TEL_EXT_GET_CMD: /* AT+AGNSSCFG? */
+ case TEL_EXT_SET_CMD: /* AT+AGNSSCFG= */
+ default:
+ {
+ ret = ATRESP(atHandle,ATCI_RESULT_CODE_CME_ERROR,CME_OPERATION_NOT_SUPPORTED,NULL);
+ break;
+ }
+ }
+
+ /* handle the return value */
+ rc = HANDLE_RETURN_VALUE(ret);
+ return(rc);
+}
+
+
+RETURNCODE_T mbtk_GPSSetting(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)
+
+ RETURNCODE_T rc = INITIAL_RETURN_CODE;
+ CiReturnCode ret = CIRC_FAIL;
+ UINT32 atHandle = MAKE_AT_HANDLE(* (TelAtParserID *) arg_p);
+ *xid_p = atHandle;
+ TelAtParserID origParserId = *(TelAtParserID *)arg_p;
+ char gps_str[128];
+ INT16 gps_str_len;
+ memset(gps_str, 0, 128);
+
+ //DBGMSG("%s: atHandle = %d.\n", __FUNCTION__, atHandle);
+
+ /*
+ ** Check the format of the request.
+ */
+ switch(op)
+ {
+ case TEL_EXT_TEST_CMD: /* AT+GPSSETTING=? */
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_OK, 0, (char *)"+GPSSETTING: <string>\r\n");
+ break;
+ }
+ case TEL_EXT_SET_CMD: /* AT+GPSSETTING= */
+ {
+ /* Extract the arguments starting with the functionality. */
+ if (getExtString(parameter_values_p, 0, gps_str, 127, &gps_str_len, NULL) == TRUE)
+ {
+ int result = 0;
+ result = mbtk_GPS_process(GNSS_CMD_SETTING, gps_str);
+ if (result < 0)
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: setting fail.\r\n");
+ }
+ else if((gnss_err_enum)result == GNSS_ERR_OK)
+ {
+ char temp[512] = {0};
+ if(strlen(cmd_rsp))
+ {
+ snprintf(temp, 512, "+GPS INFO: %s\r\n", cmd_rsp);
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_OK, 0, temp);
+ }
+ else
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_OK, 0, "+GPS: setting success.\r\n");
+ }
+ }
+ else
+ {
+ ret = mbtk_gps_err((gnss_err_enum)result, atHandle);
+ }
+ }
+ else
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_CME_ERROR, CME_INVALID_PARAM, NULL);
+ }
+ break;
+ }
+ case TEL_EXT_GET_CMD: /* AT+GPSSETTING? */
+ case TEL_EXT_ACTION_CMD: /* AT+GPSSETTING */
+ default:
+ {
+ ret = ATRESP(atHandle,ATCI_RESULT_CODE_CME_ERROR,CME_OPERATION_NOT_SUPPORTED,NULL);
+ break;
+ }
+ }
+
+ /* handle the return value */
+ rc = HANDLE_RETURN_VALUE(ret);
+ return(rc);
+}
+
+RETURNCODE_T mbtk_GPSFwdl(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)
+
+ RETURNCODE_T rc = INITIAL_RETURN_CODE;
+ CiReturnCode ret = CIRC_FAIL;
+ UINT32 atHandle = MAKE_AT_HANDLE(* (TelAtParserID *) arg_p);
+ *xid_p = atHandle;
+ TelAtParserID origParserId = *(TelAtParserID *)arg_p;
+ char gps_str[128];
+ INT16 gps_str_len;
+ memset(gps_str, 0, 128);
+
+ int band = -1;
+ char* bd = "gp_bd_ga";
+ char* gl = "gp_gl_ga";
+ /*
+ ** Check the format of the request.
+ */
+ if(InProduction_Mode() == 0)
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: fwdl mode fail.\r\n");
+ rc = HANDLE_RETURN_VALUE(ret);
+ return(rc);
+ }
+
+ switch(op)
+ {
+ case TEL_EXT_TEST_CMD: /* AT+GPSFWDL=? */
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_OK, 0, (char *)"+GPSFWDL: <string>\r\n");
+ break;
+ }
+ case TEL_EXT_ACTION_CMD: /* AT+GPSFWDL */
+ {
+ if(!dev_info_get())
+ {
+ //Default bd
+ band = info_modem.band_area;
+ if(band == MBTK_MODEM_BAND_AREA_EU)
+ strncpy(gps_str, gl, strlen(gl));
+ else
+ strncpy(gps_str, bd, strlen(bd));
+ }
+ //ATRESP(atHandle, ATCI_RESULT_CODE_NULL, 0, gps_str);
+ if (band != -1)
+ {
+ int result = 0;
+ result = mbtk_GPS_process(GNSS_CMD_DL, gps_str);
+ if (result < 0)
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: fwdl fail.\r\n");
+ }
+ else if((gnss_err_enum)result == GNSS_ERR_OK)
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_OK, 0, "+GPS: fwdl success.\r\n");
+ }
+ else
+ {
+ ret = mbtk_gps_err((gnss_err_enum)result, atHandle);
+ }
+ }
+ else
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_CME_ERROR, CME_INVALID_PARAM, NULL);
+ }
+ break;
+ }
+ case TEL_EXT_SET_CMD: /* AT+GPSFWDL= */
+ {
+ /* Extract the arguments starting with the functionality. */
+ if (getExtString(parameter_values_p, 0, gps_str, 127, &gps_str_len, NULL) == TRUE)
+ {
+ int result = 0;
+ result = mbtk_GPS_process(GNSS_CMD_DL, gps_str);
+ if (result < 0)
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_ERROR, 0, "+GPS: fwdl fail.\r\n");
+ }
+ else if((gnss_err_enum)result == GNSS_ERR_OK)
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_OK, 0, "+GPS: fwdl success.\r\n");
+ }
+ else
+ {
+ ret = mbtk_gps_err((gnss_err_enum)result, atHandle);
+ }
+ }
+ else
+ {
+ ret = ATRESP(atHandle, ATCI_RESULT_CODE_CME_ERROR, CME_INVALID_PARAM, NULL);
+ }
+ break;
+ }
+ case TEL_EXT_GET_CMD: /* AT+GPSFWDL? */
+ default:
+ {
+ ret = ATRESP(atHandle,ATCI_RESULT_CODE_CME_ERROR,CME_OPERATION_NOT_SUPPORTED,NULL);
+ break;
+ }
+ }
+
+ /* handle the return value */
+ rc = HANDLE_RETURN_VALUE(ret);
+ return(rc);
+}
+
#endif
RETURNCODE_T ciCMTLRA(const utlAtParameterOp_T op,