Fix code warning.
Change-Id: Ib11fb49f528d3688351ae349d5b4e307c28b3967
diff --git a/mbtk/mbtk_gnssd/agps/8122_agnss.c b/mbtk/mbtk_gnssd/agps/8122_agnss.c
index 34eef09..0bb7c5a 100755
--- a/mbtk/mbtk_gnssd/agps/8122_agnss.c
+++ b/mbtk/mbtk_gnssd/agps/8122_agnss.c
@@ -27,7 +27,7 @@
static int hd_agnss_uart_write(uint8_t *buf, uint32_t len)
{
- int TxLen;
+ int TxLen = -1;
if(hd_fd > 0)
{
TxLen = write(hd_fd,buf,len);
@@ -80,7 +80,7 @@
return src_len + 8;
}
-/************************************time inject*************************************/
+/************************************time inject*************************************/
static int gnss_inject_time(HD_AGNSS_UTC_TIME_TYPE *time)
{
uint8_t cmd[24] = {0}; /* packet head+payload */
@@ -185,7 +185,7 @@
return 0;
}
-/************************************eph data inject*************************************/
+/************************************eph data inject*************************************/
/**
* @brief get the eph frame and send to HD80xx
* @param data: the pointer of the eph data file
@@ -207,12 +207,12 @@
LOGE("malloc fail");
return INJECT_RESULT_FAIL;
}
-
+
eph_file_fd = open(eph_file_path, O_RDWR);
if (eph_file_fd <= 0)
{
LOGE("%s open file FAIL. errno:%d\n", __FUNCTION__, errno);
- goto error;
+ goto error;
}
while(0 < (size = read(eph_file_fd, (databuf + left_size), BUFFER_SIZE)))
{
@@ -230,7 +230,7 @@
if(write_size < 0)
{
LOGE("hd_agnss_uart_write fail");
- goto error;
+ goto error;
}
LOGD("%s Write[%d]\r\n", __FUNCTION__, write_size);
hd_agnss_delay(50);
@@ -281,7 +281,7 @@
}
}
}
-
+
if(databuf)
{
free(databuf);
@@ -326,17 +326,17 @@
HD_AGNSS_UTC_TIME_TYPE *UTC_time)
{
int ret = INJECT_RESULT_SUCCESS;
- if (UTC_time != NULL)
+ if (UTC_time != NULL)
{
gnss_inject_time(UTC_time);
}
- if ((latitude != 0) && (longitude != 0))
+ if ((latitude != 0) && (longitude != 0))
{
gnss_inject_location(latitude, longitude, altitude, accuracy);
}
- if (eph_file_path != NULL)
+ if (eph_file_path != NULL)
{
ret = gnss_eph_inject_data(eph_file_path);
if(ret < 0)
diff --git a/mbtk/mbtk_gnssd/gnss_6228.c b/mbtk/mbtk_gnssd/gnss_6228.c
index 9bbe8f4..17ecda1 100755
--- a/mbtk/mbtk_gnssd/gnss_6228.c
+++ b/mbtk/mbtk_gnssd/gnss_6228.c
Binary files differ
diff --git a/mbtk/mbtk_gnssd/gnss_asr5311.c b/mbtk/mbtk_gnssd/gnss_asr5311.c
index c3088bb..1f4d8db 100755
--- a/mbtk/mbtk_gnssd/gnss_asr5311.c
+++ b/mbtk/mbtk_gnssd/gnss_asr5311.c
@@ -37,8 +37,8 @@
#define GNSS_PLATFORM_STATUS_PATH "/sys/devices/platform/asr-gps/status"
static char config_msg_pm5[] = "PMTEST,5";
-static char config_msg_pm4[] = "PMTEST,4";
-static char config_msg_boot[] = "START,1";
+//static char config_msg_pm4[] = "PMTEST,4";
+//static char config_msg_boot[] = "START,1";
static pthread_cond_t read_cond;
static pthread_mutex_t read_mutex;
@@ -57,8 +57,8 @@
LOGD("aboot fw_download timeout");
gnss_fw_download_timeout_state = 1;
//log2file("%s: gnss fw download timeout\n", __func__);
-
- system("killall aboot-tiny");
+
+ mbtk_system("killall aboot-tiny");
}
static int gnss_fw_download_timer_init(void)
@@ -92,7 +92,7 @@
return -1;
}
}
-
+
struct itimerspec ts;
memset (&ts, 0x00, sizeof (struct itimerspec));
@@ -119,7 +119,7 @@
memset (&ts, 0x00, sizeof (struct itimerspec));
ts.it_value.tv_sec = 0;
ts.it_value.tv_nsec = 0;
- ts.it_interval.tv_sec = 0;
+ ts.it_interval.tv_sec = 0;
ts.it_interval.tv_nsec = 0;
rc = timer_settime(gnss_fw_download_timer_id, 0, &ts, NULL);
LOGD("fw_download timer stop %d", rc);
@@ -162,7 +162,7 @@
fd = open(GNSS_PLATFORM_CTRL_PATH, O_WRONLY);
if (fd >= 0) {
- write(fd, str, strlen(str));
+ mbtk_write(fd, str, strlen(str));
close(fd);
}
}
@@ -279,7 +279,7 @@
LOGD("aboot-tiny start");
retry_download:
gnss_fw_download_timer_start();
- system(cmd);
+ mbtk_system(cmd);
gnss_fw_download_timer_stop();
if(gnss_fw_download_timeout_state == 1)
{
@@ -315,7 +315,7 @@
}
}
}
-
+
LOGD("aboot-tiny stop");
return 0;
@@ -323,7 +323,7 @@
void gnss_5311_set_cb(const void *data, int data_len)
{
- const char *buff = (const char*)data;
+// const char *buff = (const char*)data;
if(setting_busy) { // Has setting cmd process.
gnss_cmd_rsp_process(data, data_len);
}
@@ -367,7 +367,7 @@
gnss_set_result = GNSS_ERR_ARG;
goto set_fail;
}
-
+
uint32 new_mode = 0;
if(ret_num >= 1)
{
@@ -486,7 +486,7 @@
}
should_wait_rsp = TRUE;
- }
+ }
else if(memcmp(cmd, "$MINEL", 6) == 0) //$MINEL,<elev>
{
uint32 elev = 0;
@@ -503,7 +503,7 @@
LOGD("cmd: %s", send_cmd);
gnss_send_cmd(fd, send_cmd, send_cmd_len);
should_wait_rsp = TRUE;
- }
+ }
else if(memcmp(cmd, "$NMEACFG", 8) == 0) // $NMEACFG,<ver>
{
uint32 mode,ver = 0;
@@ -536,7 +536,7 @@
goto set_fail;
}
-set_success:
+//set_success:
if(should_wait_rsp) {
setting_waitting = TRUE;
pthread_mutex_lock(&read_mutex);
diff --git a/mbtk/mbtk_gnssd/gnss_hd8122.c b/mbtk/mbtk_gnssd/gnss_hd8122.c
index e61bfe6..531bbcc 100755
--- a/mbtk/mbtk_gnssd/gnss_hd8122.c
+++ b/mbtk/mbtk_gnssd/gnss_hd8122.c
@@ -29,6 +29,9 @@
#include "hd8122_dl/hd8040_upgrade.h"
#include "agps/agnss_http_download.h"
#include "agps/8122_agnss.h"
+#include "mbtk_utils.h"
+// #include "hd8122_dl/port.h"
+
#define UART_BITRATE_NMEA_DEF_FW 115200 // Default bitrate.
#define GNSS_POWER_GPIO 43
@@ -64,7 +67,7 @@
static int gnss_cmd_rsp_len = 0;
int gnss_write(int fd, const void *data, int data_len);
-int OpenUart(char* UART_DEV);
+int OpenUart(const char* UART_DEV);
int uart_close(int fd);
int fw_update_boot(int uart_fd, uint8_t *data, uint32_t len);
@@ -150,6 +153,7 @@
}
}
+#if 0
static int msg_remove(uint8 gid, uint8 sid)
{
int i = msg_find(gid, sid);
@@ -165,6 +169,7 @@
return -1;
}
}
+#endif
static int msg_count()
{
@@ -382,7 +387,7 @@
static void gnss_cmd_rsp_process(const void *data, int data_len)
{
- const char *ptr = (const char*)data;
+// const char *ptr = (const char*)data;
log_hex("RSP", data, data_len);
hd8122_id_ack_enum ack_nak = HD8122_ID_ACK_ACK;
@@ -406,7 +411,7 @@
pthread_mutex_unlock(&read_mutex);
setting_waitting = FALSE;
}
-
+
}
else
{
@@ -557,7 +562,7 @@
return GNSS_ERR_OK;
}
-
+#if 0
static gnss_err_enum gnss_8122_nmeaver(int fd, uint8 ver)
{
uint8 buff[GNSS_PACK_BUFF_SIZE];
@@ -572,18 +577,19 @@
gnss_write(fd, buff, len);
return GNSS_ERR_OK;
}
+#endif
int gnss_8122_dev_open()
{
//return mbtk_gpio_value_set(GNSS_POWER_GPIO, MBTK_GPIO_DIRECT_OUT, 1);
- system("i2cset -y -f 2 0x31 0x15 0x86");
+ mbtk_system("i2cset -y -f 2 0x31 0x15 0x86");
return 0;
}
int gnss_8122_dev_close(int fd)
{
//return mbtk_gpio_value_set(GNSS_POWER_GPIO, MBTK_GPIO_DIRECT_OUT, 0);
- system("i2cset -y -f 2 0x31 0x15 0x00");
+ mbtk_system("i2cset -y -f 2 0x31 0x15 0x00");
return 0;
}
@@ -649,7 +655,7 @@
LOGE("gnss_fwdl_enable fail");
goto error;
}
-
+
int ret = fw_update_boot(uart_fd, g_bin_buff, len);
if (ret < 0)
{
@@ -665,7 +671,7 @@
LOGD("upgrade FAIL, fail style:%d", ret);
goto error;
}
-
+
if(gnss_8122_dev_close(0))
{
LOGE("close gnss device fail:%d", errno);
@@ -700,32 +706,32 @@
int eph_type = 0;
int alam_flag = 0;
int ret = -1;
- char url[256] = {0};
+ char url[1024] = {0};
if(2 == sscanf(param, "%d,%d", &eph_type, &alam_flag))
{
if((gnss_eph_data_enum)eph_type == GNSS_EPH_GPS)
{
- snprintf(url, 256,AGNSS_URL, AGNSS_EPH_GPS);
+ snprintf(url, sizeof(url),AGNSS_URL, AGNSS_EPH_GPS);
}
else if((gnss_eph_data_enum)eph_type == GNSS_EPH_BDS)
{
- snprintf(url, 256,AGNSS_URL, AGNSS_EPH_BDS);
+ snprintf(url, sizeof(url),AGNSS_URL, AGNSS_EPH_BDS);
}
else if((gnss_eph_data_enum)eph_type == GNSS_EPH_GLO)
{
- snprintf(url, 256,AGNSS_URL, AGNSS_EPH_GLO);
+ snprintf(url, sizeof(url),AGNSS_URL, AGNSS_EPH_GLO);
}
else if((gnss_eph_data_enum)eph_type == GNSS_EPH_GPS_BDS)
{
- snprintf(url, 256,AGNSS_URL, AGNSS_EPH_GPS_BDS);
+ snprintf(url, sizeof(url),AGNSS_URL, AGNSS_EPH_GPS_BDS);
}
else if((gnss_eph_data_enum)eph_type == GNSS_EPH_GPS_GLO)
{
- snprintf(url, 256,AGNSS_URL, AGNSS_EPH_GPS_GLO);
+ snprintf(url, sizeof(url),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",
+ snprintf(url, sizeof(url),"%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");
}
@@ -767,7 +773,7 @@
void gnss_8122_set_cb(const void *data, int data_len)
{
- const char *buff = (const char*)data;
+// const char *buff = (const char*)data;
if(setting_busy) // Has setting cmd process.
{
gnss_cmd_rsp_process(data, data_len);
@@ -1098,12 +1104,12 @@
0x00, 0x00, 0x00, 0x00, 0x30, 0x62, 0x9F, 0x37,
0x28, 0x29, 0x30, 0xB8, 0xBD, 0x37, 0x06, 0x36,
0x00, 0x00, 0x00, 0x00};
-
+
if(2 == sscanf(cmd, "$PZ90CONV,%d,%d", &local, &ref))
{
LOGD("set pz90conv: %d, %d", local, ref);
-
+
if(local == 1 && ref == 0) //PZ90
{
//
@@ -1168,7 +1174,7 @@
goto set_fail;
}
- set_success:
+// set_success:
if(should_wait_rsp)
{
setting_waitting = TRUE;
diff --git a/mbtk/mbtk_gnssd/gnss_ipc.c b/mbtk/mbtk_gnssd/gnss_ipc.c
index 65db6a3..3bb1442 100755
--- a/mbtk/mbtk_gnssd/gnss_ipc.c
+++ b/mbtk/mbtk_gnssd/gnss_ipc.c
@@ -36,6 +36,8 @@
static int sock_cli_fds[SOCK_CLIENT_MAX];
int gnss_write(int fd, const void* buf, unsigned int buf_len);
+int gnss_agnss_get_eph(const void* param);
+
static int gnss_cli_fd_find(int fd)
{
diff --git a/mbtk/mbtk_gnssd/gnss_log.c b/mbtk/mbtk_gnssd/gnss_log.c
index ef3204c..0e1ba35 100755
--- a/mbtk/mbtk_gnssd/gnss_log.c
+++ b/mbtk/mbtk_gnssd/gnss_log.c
@@ -27,11 +27,12 @@
#include "gnss_log.h"
#include "mbtk_log.h"
+#include "mbtk_utils.h"
#define GNSS_LOG_FOLDER_PATH "/user_data/mbtk_log"
#define GNSS_LOG_FILE_PATH "/user_data/mbtk_log/mbtk_gnss_log.txt"
#define GNSS_LOG_LAST_FILE_PATH "/user_data/mbtk_log/mbtk_gnss_last_log.txt"
-#define GNSS_LOG_GNSS_FILE_HEAD "\n[-------------------mbtk gnss log V1.0-------------------][%d]\n"
+#define GNSS_LOG_GNSS_FILE_HEAD "\n[-------------------mbtk gnss log V1.0-------------------][%ld]\n"
#define GNSS_LOG_FILE_MAX_SIZE 10485760 //10 * 1024 * 1024 10M
#define GNSS_TIME_CHECK_NUM 10
@@ -44,32 +45,32 @@
{
int head_len = 0;
int ret = -1;
- if(access(GNSS_LOG_FOLDER_PATH, F_OK) != 0)
+ if(access(GNSS_LOG_FOLDER_PATH, F_OK) != 0)
{
ret = mkdir(GNSS_LOG_FOLDER_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
- if (ret != 0)
+ if (ret != 0)
{
LOGE("Failed to create folder.");
return -1;
}
}
- if(access(GNSS_LOG_FILE_PATH, F_OK) == 0 && mv_flag)
+ if(access(GNSS_LOG_FILE_PATH, F_OK) == 0 && mv_flag)
{
char cmd[128] = {0};
memset(cmd, 0x0, 128);
snprintf(cmd, 128, "mv %s %s", GNSS_LOG_FILE_PATH, GNSS_LOG_LAST_FILE_PATH);
LOGE("cmd: [%s].", cmd);
- system(cmd);
+ mbtk_system(cmd);
}
*fd = open(GNSS_LOG_FILE_PATH, O_CREAT | O_WRONLY | O_APPEND | O_NONBLOCK, 0644);
- if(*fd < 0)
+ if(*fd < 0)
{
LOGE("Open file fail [errno = %d].", errno);
return -1;
}
- else
+ else
{
char temp[128] = {0};
struct stat st;
@@ -78,11 +79,11 @@
snprintf(temp, 128, GNSS_LOG_GNSS_FILE_HEAD, *size);
head_len = (int)strlen(temp);
ret = write(*fd, temp, head_len);
- if(ret == head_len)
+ if(ret == head_len)
{
*size += ret;
}
- else
+ else
{
LOGE("write head fail [errno = %d].", errno);
goto error;
@@ -115,7 +116,7 @@
{
diff = sys_time - gps_time;
}
-
+
gnss_test_log("sys time[%ld], gps time[%ld], diff time[%ld]", sys_time, gps_time, diff);
}
@@ -134,16 +135,16 @@
void gnss_test_log(const char* format, ...)
{
int ret;
-
- if(log_file_fd < 0)
+
+ if(log_file_fd < 0)
{
ret = log_file_init(&log_file_fd, &log_file_size, false);
- if(ret < 0)
+ if(ret < 0)
{
LOGE("log_file_init fail.");
return;
}
- else
+ else
{
LOGE("log fd: [%d], log size: [%ld].", log_file_fd, log_file_size);
}
@@ -154,15 +155,15 @@
int length = 0;
char write_buf[1096] = {0};
int write_length = 0;
-
+
va_list ap;
struct timeval log_time;
va_start(ap, format);
length = vsnprintf(param_buf, 1023, format, ap);
va_end(ap);
-
- if (length < 0 || 0 == length)
+
+ if (length < 0 || 0 == length)
{
LOGE("vsnprintf fail.");
return;
@@ -178,50 +179,50 @@
gettimeofday(&log_time, NULL);
struct tm* tm_t = localtime(&(log_time.tv_sec));
strftime(tmp, 50, "%F %T", tm_t);
-
+
write_length = snprintf(write_buf, 1096, "[%s %03d]--->%s", tmp, (int)(log_time.tv_usec / 1000), param_buf);
if(write_length <= 0)
{
LOGE("snprintf fail.");
return;
}
-
- if((log_file_size + write_length) > GNSS_LOG_FILE_MAX_SIZE)
+
+ if((log_file_size + write_length) > GNSS_LOG_FILE_MAX_SIZE)
{
close(log_file_fd);
log_file_fd = -1;
log_file_size = 0;
ret = log_file_init(&log_file_fd, &log_file_size, true);
- if(ret < 0)
+ if(ret < 0)
{
LOGE("log_file_init fail.");
goto error;
}
- else
+ else
{
LOGE("log fd: [%d], log size: [%ld].", log_file_fd, log_file_size);
}
}
-
+
ret = write(log_file_fd, write_buf, write_length);
- if(ret == write_length)
+ if(ret == write_length)
{
log_file_size += ret;
}
- else
+ else
{
goto error;
}
-
-
- if (log_file_fd > 2)
+
+
+ if (log_file_fd > 2)
{
fsync(log_file_fd);
- }
+ }
return;
error:
- if(log_file_fd > 0)
+ if(log_file_fd > 0)
{
close(log_file_fd);
log_file_fd = -1;
diff --git a/mbtk/mbtk_gnssd/gnss_main.c b/mbtk/mbtk_gnssd/gnss_main.c
index a495f4f..26f3a4d 100755
--- a/mbtk/mbtk_gnssd/gnss_main.c
+++ b/mbtk/mbtk_gnssd/gnss_main.c
@@ -20,6 +20,7 @@
#include "gnss_asr5311.h"
#include "gnss_n50db.h"
#include "gnss_log.h"
+#include "mbtk_utils.h"
#define GNSS_DEBUG 1
#define GNSS_UBUS_ENABLE 1
@@ -257,12 +258,12 @@
if(fd == nmea_log_fd) {
if(nmea_log_fd > 0) {
- write(nmea_log_fd, data, data_len);
+ mbtk_write(nmea_log_fd, data, data_len);
debug_fd_len += data_len;
}
} else if(fd == debug_fd) {
if(debug_fd > 0) {
- write(debug_fd, data, data_len);
+ mbtk_write(debug_fd, data, data_len);
debug_fd_len += data_len;
}
}
@@ -885,7 +886,7 @@
// Wait for read thread exit.
if(gnss_info.exit_fd[1] > 0) {
- write(gnss_info.exit_fd[1], "exit", 4);
+ mbtk_write(gnss_info.exit_fd[1], "exit", 4);
}
gnss_info.state = GNSS_STATE_CLOSING;
@@ -989,7 +990,7 @@
LOGE("gnss not ready");
return GNSS_ERR_UNKNOWN;
}
-
+
if(gnss_info.gnss_agnss_inject)
{
return gnss_info.gnss_agnss_inject(gnss_info.fd);
@@ -998,7 +999,7 @@
{
return GNSS_ERR_UNSUPPORT;
}
-
+
return GNSS_ERR_OK;
}
diff --git a/mbtk/mbtk_gnssd/gnss_utils.c b/mbtk/mbtk_gnssd/gnss_utils.c
index d114b4b..7fb9c3e 100755
--- a/mbtk/mbtk_gnssd/gnss_utils.c
+++ b/mbtk/mbtk_gnssd/gnss_utils.c
@@ -8,6 +8,7 @@
#include <stdarg.h>
#include <pty.h>
#include <libubox/uloop.h>
+#include <cutils/properties.h>
#include <time.h>
#include <sys/time.h>
@@ -15,6 +16,7 @@
#include "mbtk_log.h"
#include "gnss_log.h"
#include "mbtk_gnss.h"
+#include "mbtk_utils.h"
#define DATABITS CS8
#define STOPBITS 0
@@ -477,7 +479,7 @@
time_t _t = mktime(&tmp_time);//parse location tmp_time
-
+
return _t;
}
@@ -550,7 +552,7 @@
struct timeval tv;
tv.tv_sec = _t;
- tv.tv_sec += 28800; //cst
+ tv.tv_sec += 28800; //cst
tv.tv_usec = 0;
#endif
@@ -559,7 +561,7 @@
mbtk_gnss_time_set_flag = 0;
} else {
LOGD("%s: 1111, Set time success \n", __func__);
- system("hwclock -w rtc0");
+ mbtk_system("hwclock -w rtc0");
mbtk_gnss_time_set_flag = 1;
}
}
diff --git a/mbtk/mbtk_gnssd/hd8122_dl/fwup.c b/mbtk/mbtk_gnssd/hd8122_dl/fwup.c
index 9b667cf..b2662aa 100755
--- a/mbtk/mbtk_gnssd/hd8122_dl/fwup.c
+++ b/mbtk/mbtk_gnssd/hd8122_dl/fwup.c
@@ -316,7 +316,7 @@
int fw_update_boot(int uart_fd, uint8_t *data, uint32_t len)
{
int i = 1;
- uint8_t dataAck[10];
+// uint8_t dataAck[10];
//1st 1KB send at last
uint8_t *data1st1k = data;
uint8_t recvBuf[READ_LENGTH] = {0};
diff --git a/mbtk/mbtk_gnssd/hd8122_dl/port.c b/mbtk/mbtk_gnssd/hd8122_dl/port.c
index 89e1596..68c32f1 100755
--- a/mbtk/mbtk_gnssd/hd8122_dl/port.c
+++ b/mbtk/mbtk_gnssd/hd8122_dl/port.c
@@ -475,7 +475,7 @@
return 0;
}
-int OpenUart(char* UART_DEV)
+int OpenUart(const char* UART_DEV)
{
int fd=0;
diff --git a/mbtk/mbtk_gnssd/hd8122_dl/port.h b/mbtk/mbtk_gnssd/hd8122_dl/port.h
index 5e55db8..ace1d97 100755
--- a/mbtk/mbtk_gnssd/hd8122_dl/port.h
+++ b/mbtk/mbtk_gnssd/hd8122_dl/port.h
@@ -46,6 +46,6 @@
extern void clearBuffer(int fd, int selector);
extern int uart_open(unsigned char * GPS_DEVICE);
extern int uart_close(int fd);
-extern int OpenUart(char* UART_DEV);
+extern int OpenUart(const char* UART_DEV);
extern int set_baudrate(int fd, uint8_t baud);
#endif