gnss: add agps api
Change-Id: I8d778a303bc59b22f1ac31cfbe8439e98d94d448
diff --git a/mbtk/mbtk_gnssd/agps/8122_agnss.c b/mbtk/mbtk_gnssd/agps/8122_agnss.c
index 4acbe33..34eef09 100755
--- a/mbtk/mbtk_gnssd/agps/8122_agnss.c
+++ b/mbtk/mbtk_gnssd/agps/8122_agnss.c
@@ -200,7 +200,7 @@
int left_size = 0;
int total_size = 0;
int write_size = 0;
- int wait_time = 0;
+ //int wait_time = 0;
uint8_t *databuf = (uint8_t *)malloc(BUFFER_SIZE);
if(databuf == NULL)
{
@@ -225,7 +225,7 @@
packet_length = (databuf[i + 4] | (databuf[i + 5] << 8));
if (i + packet_length + 8 <= total_size)
{
- hd_set_eph_inject_status(HD_EPH_INJECT_STATUS_WAIT_RETURN);
+ //hd_set_eph_inject_status(HD_EPH_INJECT_STATUS_WAIT_RETURN);
write_size = hd_agnss_uart_write(databuf + i, packet_length + 8);
if(write_size < 0)
{
@@ -233,6 +233,8 @@
goto error;
}
LOGD("%s Write[%d]\r\n", __FUNCTION__, write_size);
+ hd_agnss_delay(50);
+#if 0
wait_time = 0;
while(1)
{
@@ -260,6 +262,7 @@
goto error;
}
}
+#endif
i = i + packet_length + 8;
}
else
diff --git a/mbtk/mbtk_gnssd/gnss_hd8122.c b/mbtk/mbtk_gnssd/gnss_hd8122.c
index 7416b19..005350c 100755
--- a/mbtk/mbtk_gnssd/gnss_hd8122.c
+++ b/mbtk/mbtk_gnssd/gnss_hd8122.c
@@ -59,7 +59,7 @@
static gnss_err_enum gnss_set_result = GNSS_ERR_OK;
static hd8122_msg_id_t msg_array[GNSS_MSG_NUM_MAX];
static char gnss_ctrl_path[128] = "/sys/devices/platform/mbtk-gnss/ctrl";
-
+static gnss_agps_info_t agps_info;
int gnss_write(int fd, const void *data, int data_len);
int OpenUart(char* UART_DEV);
@@ -654,6 +654,12 @@
{
snprintf(url, 256,AGNSS_URL, AGNSS_EPH_GPS_GLO);
}
+ else if((gnss_eph_data_enum)eph_type == GNSS_EPH_CFG)
+ {
+ snprintf(url, 256,"%s?compid=%s&token=%s", strlen(agps_info.host) > 0 ? agps_info.host : "http://uagnss.allystar.com:80/ephemeris/HD_GPS.hdb",
+ strlen(agps_info.id) > 0 ? agps_info.id : "yikecs1",
+ strlen(agps_info.passwd) > 0 ? agps_info.passwd : "Z38w5urAuawubTxi");
+ }
else
{
return GNSS_ERR_UNSUPPORT;
@@ -698,6 +704,7 @@
gnss_cmd_rsp_process(data, data_len);
}
+#if 0
if(hd_get_eph_inject_status() == HD_EPH_INJECT_STATUS_WAIT_RETURN)
{
log_hex("EPH_RSP", (const char*)data, data_len);
@@ -709,8 +716,9 @@
else
{
hd_set_eph_inject_status(HD_EPH_INJECT_STATUS_SUCCESS);
- }
+ }
}
+#endif
}
gnss_err_enum gnss_8122_set(int fd, const char *cmd, void *cmd_rsp, int cmd_rsp_len)
@@ -930,6 +938,40 @@
should_wait_rsp = TRUE;
}
+ else if(memcmp(cmd, "$AGPSCFG", 8) == 0) // $AGPSCFG,<host>,<id>,<passwd>
+ {
+ char host[GNSS_AGPS_LEN_MAX] = {0};
+ char id[GNSS_AGPS_LEN_MAX] = {0};
+ char passwd[GNSS_AGPS_LEN_MAX] = {0};
+ if(3 == sscanf(cmd, "$AGPSCFG,%[^,],%[^,],%s", host, id, passwd))
+ {
+ LOGD("agps: %s, %s, %s", host, id, passwd);
+ memset(agps_info.host, 0x0, GNSS_AGPS_LEN_MAX);
+ if(memcmp(host, "NULL", 4))
+ {
+ memcpy(agps_info.host, host, strlen(host));
+ }
+
+ memset(agps_info.id, 0x0, GNSS_AGPS_LEN_MAX);
+ if(memcmp(id, "NULL", 4))
+ {
+ memcpy(agps_info.id, id, strlen(id));
+ }
+
+ memset(agps_info.passwd, 0x0, GNSS_AGPS_LEN_MAX);
+ if(memcmp(passwd, "NULL", 4))
+ {
+ memcpy(agps_info.passwd, passwd, strlen(passwd));
+ }
+ }
+ else
+ {
+ gnss_set_result = GNSS_ERR_ARG;
+ goto set_fail;
+ }
+
+ should_wait_rsp = FALSE;
+ }
else if(memcmp(cmd, "$MINEL", 6) == 0) // $MINEL,<elev>
{
#if 0
diff --git a/mbtk/mbtk_gnssd/gnss_info.h b/mbtk/mbtk_gnssd/gnss_info.h
index f7e0ed2..8247d77 100755
--- a/mbtk/mbtk_gnssd/gnss_info.h
+++ b/mbtk/mbtk_gnssd/gnss_info.h
@@ -56,6 +56,8 @@
#define GNSS_SET_MSGCFG_ABNORMAL (1<<20)
#define GNSS_SET_MSGCFG_EPHABNORMAL (1<<21)
+#define GNSS_AGPS_LEN_MAX 128
+
typedef enum {
GNSS_RESET_TYPE_HOT = 1,
GNSS_RESET_TYPE_WARM,
@@ -91,7 +93,9 @@
GNSS_EPH_BDS,
GNSS_EPH_GLO,
GNSS_EPH_GPS_BDS,
- GNSS_EPH_GPS_GLO
+ GNSS_EPH_GPS_GLO,
+
+ GNSS_EPH_CFG = 10, //get eph data by cfg parameters
} gnss_eph_data_enum;
typedef enum {
@@ -102,6 +106,13 @@
GNSS_STATE_READY, // GNSS is ready.
} gnss_state_enum;
+typedef struct
+{
+ char host[GNSS_AGPS_LEN_MAX];
+ char id[GNSS_AGPS_LEN_MAX];
+ char passwd[GNSS_AGPS_LEN_MAX];
+}gnss_agps_info_t;
+
typedef struct {
int cli_fd;
uint32 ind_flag;