Squashed 'LYNQ_PUBLIC/' changes from b3e00b1a6..994e41a76
994e41a76 [Feature][ZK-91] support gps sync systime with ntpd
e06982dc9 Merge "[Bugfix][API-1547] Change RIL FWK broadcast addr to 127.255.255.255 --meta"
b39320b67 [Bugfix][API-1547] Change RIL FWK broadcast addr to 127.255.255.255 --meta
2ae66df88 Merge "[Feature][T8TSK-89][codec]Add get set_codec GPIO status"
496757d72 [Feature][T8TSK-89][codec]Add get set_codec GPIO status
a97b5ed7a [Feature][ZK-90] sync rtc with UTC zone using hwclock command
07536d0a2 Merge "[Bugfix][API-1547] Change RIL FWK broadcast addr to 127.255.255.255"
2974e4ad2 [Bugfix][API-1547] Change RIL FWK broadcast addr to 127.255.255.255
887dff00a [Bugfix][API-865]When using EPO, a new configuration file is required
34051454d [Feature][T8TSK-313]Print CN values to syslog every 10 seconds
git-subtree-dir: LYNQ_PUBLIC
git-subtree-split: 994e41a763e37b38441633e6f8d3a6b3fbea9717
Change-Id: I07f0ea437cacaae9e83d6aae54723c94a4bfc9e9
diff --git a/IC_meta/mtk/2735/liblynq-call/liblynq-call.bb b/IC_meta/mtk/2735/liblynq-call/liblynq-call.bb
index a985190..109490f 100755
--- a/IC_meta/mtk/2735/liblynq-call/liblynq-call.bb
+++ b/IC_meta/mtk/2735/liblynq-call/liblynq-call.bb
@@ -15,6 +15,8 @@
'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+EXTRA_OEMAKE += "'MOBILETEK_RIL_CFG = ${MOBILETEK_RIL_CFG}'"
+
FILES_${PN} = "${base_libdir}/*.so \
${base_bindir}\
${base_sbindir} \
diff --git a/IC_meta/mtk/2735/liblynq-gnss/liblynq-gnss.bb b/IC_meta/mtk/2735/liblynq-gnss/liblynq-gnss.bb
index d9c78b8..7a6ef90 100755
--- a/IC_meta/mtk/2735/liblynq-gnss/liblynq-gnss.bb
+++ b/IC_meta/mtk/2735/liblynq-gnss/liblynq-gnss.bb
@@ -23,6 +23,11 @@
MOBILETEK_GNSS_SYNC_TIME_CFG ?= "no"
EXTRA_OEMAKE += "'MOBILETEK_GNSS_SYNC_TIME_CFG = ${MOBILETEK_GNSS_SYNC_TIME_CFG}'"
+MOBILETEK_GNSS_CN_OUTPUT_SYSLOG ?= "no"
+EXTRA_OEMAKE += "'MOBILETEK_GNSS_CN_OUTPUT_SYSLOG = ${MOBILETEK_GNSS_CN_OUTPUT_SYSLOG}'"
+
+
+
FILES_${PN} = "${base_libdir}/*.so \
${base_bindir}\
${base_sbindir} \
diff --git a/IC_meta/mtk/2735/liblynq-network/liblynq-network.bb b/IC_meta/mtk/2735/liblynq-network/liblynq-network.bb
index 3edcdbe..a764c51 100755
--- a/IC_meta/mtk/2735/liblynq-network/liblynq-network.bb
+++ b/IC_meta/mtk/2735/liblynq-network/liblynq-network.bb
@@ -15,6 +15,8 @@
'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+EXTRA_OEMAKE += "'MOBILETEK_RIL_CFG = ${MOBILETEK_RIL_CFG}'"
+
FILES_${PN} = "${base_libdir}/*.so "
FILES_${PN} += "/data/ril/network"
diff --git a/IC_meta/mtk/2735/liblynq-sms/liblynq-sms.bb b/IC_meta/mtk/2735/liblynq-sms/liblynq-sms.bb
index 32bf553..2a90423 100755
--- a/IC_meta/mtk/2735/liblynq-sms/liblynq-sms.bb
+++ b/IC_meta/mtk/2735/liblynq-sms/liblynq-sms.bb
@@ -15,6 +15,8 @@
'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+EXTRA_OEMAKE += "'MOBILETEK_RIL_CFG = ${MOBILETEK_RIL_CFG}'"
+
FILES_${PN} = "${base_libdir}/*.so "
FILES_${PN}-dev = "/test \
diff --git a/IC_meta/mtk/2735/lynq-ril-service/lynq-ril-service.bb b/IC_meta/mtk/2735/lynq-ril-service/lynq-ril-service.bb
index ece6cd1..7ec9ecf 100755
--- a/IC_meta/mtk/2735/lynq-ril-service/lynq-ril-service.bb
+++ b/IC_meta/mtk/2735/lynq-ril-service/lynq-ril-service.bb
@@ -19,6 +19,8 @@
'TARGET_PLATFORM = ${TARGET_PLATFORM}'\
'MTK_LED_SUPPORT = ${MTK_LED_SUPPORT}'"
+EXTRA_OEMAKE += "'MOBILETEK_RIL_CFG = ${MOBILETEK_RIL_CFG}'"
+
#INHIBIT_PACKAGE_STRIP = "1"
do_compile () {
if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then
diff --git a/IC_meta/mtk/2735/suspend-service/files/autosuspend_wakeup_count.c b/IC_meta/mtk/2735/suspend-service/files/autosuspend_wakeup_count.c
index 76c9a86..4a7757c 100755
--- a/IC_meta/mtk/2735/suspend-service/files/autosuspend_wakeup_count.c
+++ b/IC_meta/mtk/2735/suspend-service/files/autosuspend_wakeup_count.c
@@ -257,7 +257,7 @@
if (systemtime_sync_flag == 0)
{
ALOGI("suspend_ctrl need sync time to rtc\n");
- if (system("timedatectl status | grep -E \"Universal time|RTC time\" | awk -F\": \" '{print \"date -d \\\"\"$2\"\\\" +%s\"}' | sh | tr '\n' ' ' | awk '{print \"[ \"$1\" -gt \"$2 \" ] && hwclock -w\"}' | sh") == 0)
+ if (system("timedatectl status | grep -E \"Universal time|RTC time\" | awk -F\": \" '{print \"date -d \\\"\"$2\"\\\" +%s\"}' | sh | tr '\n' ' ' | awk '{print \"[ $((\"$1\"- \"$2 \")) -gt 1 ] && hwclock -w --utc\"}' | sh") == 0)
{
ALOGI("suspend_ctrl sync time to rtc success\n");
systemtime_sync_flag = 1;
@@ -328,7 +328,7 @@
void wakeup_feedback(bool success)
{
char buf[80];
- system("hwclock -s");
+ system("hwclock -s --utc");
RLOGD("TIME: rtc to sys\n");
if (!success)
{
diff --git a/IC_src/mtk/lib/liblynq-codec/Makefile b/IC_src/mtk/lib/liblynq-codec/Makefile
index b24b4e8..876c030 100644
--- a/IC_src/mtk/lib/liblynq-codec/Makefile
+++ b/IC_src/mtk/lib/liblynq-codec/Makefile
@@ -14,7 +14,8 @@
SUBDIRS += liblynq-codec
-
+LOCAL_LIBS := \
+ -ldl \
$(warning ########## lynq-rilcmd SUBDIRS $(SUBDIRS) ##########)
diff --git a/IC_src/mtk/lib/liblynq-codec/liblynq-codec/lynq_codec.c b/IC_src/mtk/lib/liblynq-codec/liblynq-codec/lynq_codec.c
index f42ba33..e474b27 100755
--- a/IC_src/mtk/lib/liblynq-codec/liblynq-codec/lynq_codec.c
+++ b/IC_src/mtk/lib/liblynq-codec/liblynq-codec/lynq_codec.c
@@ -7,9 +7,92 @@
#include "lynq_codec.h"
#include <syslog.h>
#include <log/log.h>
+#include <dlfcn.h>
#define LOG_TAG "CODEC_API"
+void *handle = NULL;
+
+void openLibrary(const char *libraryPath)
+{
+ if (handle == NULL)
+ {
+ handle = dlopen(libraryPath, RTLD_LAZY);
+ if (!handle)
+ {
+ RLOGE(stderr, "Error opening library: %s\n", dlerror());
+ exit(EXIT_FAILURE);
+ }
+ }
+}
+
+void closeLibrary()
+{
+ if (handle)
+ {
+ dlclose(handle);
+ handle = NULL;
+ }
+}
+
+void setGpios(int *gpios, int numGpios, const char *state, int param)
+{
+ if (handle == NULL)
+ {
+ RLOGE(stderr, "Library is not opened.\n");
+ return;
+ }
+
+ int (*lynq_setGpio_values)(const char*, int, int) = dlsym(handle, "lynq_setGpio_values");
+ if (!lynq_setGpio_values)
+ {
+ RLOGE(stderr, "Error loading function lynq_setGpio_values: %s\n", dlerror());
+ return;
+ }
+
+ for (int i = 0; i < numGpios; ++i)
+ {
+ if (lynq_setGpio_values(state, gpios[i], param) == 0) {
+ RLOGD("GPIO %d Set value: state=%s, param=%d successfully.\n", gpios[i], state, param);
+ } else
+ {
+ RLOGD("Error setting GPIO %d\n", gpios[i]);
+ }
+ }
+}
+
+void ensureGpiosOutHigh(const char *libraryPath, int *gpios, int numGpios)
+{
+ if (handle == NULL)
+ {
+ openLibrary(libraryPath);
+ }
+
+ int (*lynq_getGpio_values)(int, char*, char*, char*, char*) = dlsym(handle, "lynq_getGpio_values");
+ if (!lynq_getGpio_values)
+ {
+ RLOGE(stderr, "Error loading function: %s\n", dlerror());
+ return;
+ }
+
+ for (int i = 0; i < numGpios; ++i)
+ {
+ char mode, dir, dout, drive;
+ if (lynq_getGpio_values(gpios[i], &mode, &dir, &dout, &drive) == 0)
+ {
+ RLOGD("GPIO %d Get value: mode=%c, dir=%c, dout=%c, drive=%c\n", gpios[i], mode, dir, dout, drive);
+ if (dout == '0')
+ {
+ RLOGD("GPIO %d is low, setting it high.\n", gpios[i]);
+ setGpios(gpios + i, 1, "out", 1);
+ }
+ } else
+ {
+ RLOGD("Error querying GPIO %d\n", gpios[i]);
+ }
+ }
+}
+
static void write_codec_reg(const char * val)
{
if (val == NULL)
@@ -50,7 +133,14 @@
system("echo out 113 1 >/sys/devices/platform/10005000.pinctrl/mt_gpio");
usleep(10);//just open need usleep 10us
system("echo out 29 1 >/sys/devices/platform/10005000.pinctrl/mt_gpio");
- write_codec_reg("0x00 0x00");
+ usleep(10);//just open need usleep 10us
+
+ int gpios[] = {201, 113, 29};
+ int numGpios = sizeof(gpios) / sizeof(gpios[0]);
+ ensureGpiosOutHigh("liblynq-driver.so", gpios, numGpios);
+ closeLibrary();
+
+ write_codec_reg("0x00 0x00");
write_codec_reg("0x01 0x00");
write_codec_reg("0x02 0x00");
write_codec_reg("0x03 0x80");
@@ -178,6 +268,11 @@
system("echo out 181 1 >/sys/devices/platform/10005000.pinctrl/mt_gpio");
usleep(10);//just open need usleep 10us
+ int gpios[] = {181};
+ int numGpios = sizeof(gpios) / sizeof(gpios[0]);
+ ensureGpiosOutHigh("liblynq-driver.so", gpios, numGpios);
+ closeLibrary();
+
write_codec_reg("0x00 0x00");
write_codec_reg("0x01 0x00");
write_codec_reg("0x02 0x00");
diff --git a/IC_src/mtk/lib/liblynq-gnss/gpsd/ntpshm.h b/IC_src/mtk/lib/liblynq-gnss/gpsd/ntpshm.h
new file mode 100755
index 0000000..e7b4b24
--- /dev/null
+++ b/IC_src/mtk/lib/liblynq-gnss/gpsd/ntpshm.h
@@ -0,0 +1,108 @@
+/*
+ * This file is Copyright 2015 by the GPSD project
+ * SPDX-License-Identifier: BSD-2-clause
+ */
+
+#ifndef GPSD_NTPSHM_H
+#define GPSD_NTPSHM_H
+
+#include <stdbool.h>
+#include <time.h>
+#include <sys/time.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+
+#define NTPD_BASE 0x4e545030 // "NTP0"
+
+/*
+ * How to read and write fields in an NTP shared segment.
+ * This definition of shmTime is from ntpd source ntpd/refclock_shm.c
+ *
+ * The fields aren't documented there. It appears the only use of
+ * nsamples is internal to the (obsolete and deprecated) EES M201
+ * receiver refclock. The precision field is nominally log(2) of the
+ * source's jitter in seconds:
+ * -1 is about 100mSec jitter
+ * -10 is about 1 mSec jitter (GR-601W or other USB with 1ms poll interval)
+ * -13 is about 100 uSec
+ * -20 is about 1 uSec (typical for serial PPS)
+ */
+
+struct shmTime
+{
+ int mode; /* 0 - if valid set
+ * use values,
+ * clear valid
+ * 1 - if valid set
+ * if count before and after read of values is equal,
+ * use values
+ * clear valid
+ */
+ volatile int count;
+#if defined(_TIME_BITS) && 64 == _TIME_BITS
+ /* libc default time_t is 32-bits, but we are using 64-bits.
+ * glibc 2.34 and later.
+ * Lower 31 bits, no sign bit, are here. */
+ unsigned clockTimeStampSec;
+#else
+ time_t clockTimeStampSec;
+#endif
+ int clockTimeStampUSec;
+#if defined(_TIME_BITS) && 64 == _TIME_BITS
+ /* libc default time_t is 32-bits, but we are using 64-bits.
+ * glibc 2.34 and later.
+ * Lower 31 bits, no sign bit, are here. */
+ unsigned receiveTimeStampSec;
+#else
+ time_t receiveTimeStampSec;
+#endif
+ int receiveTimeStampUSec;
+ int leap; // not leapsecond offset, a notification code
+ int precision; // log(2) of source jitter
+ int nsamples; // not used
+ volatile int valid;
+ unsigned clockTimeStampNSec; // Unsigned ns timestamps
+ unsigned receiveTimeStampNSec; // Unsigned ns timestamps
+ /* Change previous dummy[0,1] to hold top bits.
+ * Zero until 2038. */
+ unsigned top_clockTimeStampSec;
+ unsigned top_receiveTimeStampSec;
+ int dummy[6];
+};
+
+
+/*
+ * These types are internal to GPSD
+ */
+enum segstat_t {OK, NO_SEGMENT, NOT_READY, BAD_MODE, CLASH};
+
+struct shm_stat_t {
+ enum segstat_t status;
+ struct timespec tvc; // System time when SHM read, for debug only
+ struct timespec tvr; // System time at GPS time
+ struct timespec tvt; // GPS time
+ int precision;
+ int leap;
+};
+
+#ifndef TIMEDELTA_DEFINED
+
+struct timedelta_t {
+ struct timespec real;
+ struct timespec clock;
+};
+
+#define TIMEDELTA_DEFINED
+#endif // TIMEDELTA_DEFINED
+
+struct shmTime *shm_get(int, bool, bool);
+extern char *ntp_name(const int);
+enum segstat_t ntp_read(struct shmTime *, struct shm_stat_t *, const bool);
+void ntp_write(volatile struct shmTime *, struct timedelta_t *, int, int);
+void ntpshm_context_init(struct shmTime ** ppShmTime);
+void ntpshm_put(struct shmTime * pShmTime, int unit, int precision,
+ struct timedelta_t *td, int leap_notify);
+
+#endif // GPSD_NTPSHM_H
+
+// vim: set expandtab shiftwidth=4
diff --git a/IC_src/mtk/lib/liblynq-gnss/gpsd/ntpshmwrite.c b/IC_src/mtk/lib/liblynq-gnss/gpsd/ntpshmwrite.c
new file mode 100755
index 0000000..ba41264
--- /dev/null
+++ b/IC_src/mtk/lib/liblynq-gnss/gpsd/ntpshmwrite.c
@@ -0,0 +1,108 @@
+/*
+ * ntpshmwrite.c - put time information in SHM segment for ntpd
+ *
+ * This file is Copyright 2010 by the GPSD project
+ * SPDX-License-Identifier: BSD-2-clause
+ */
+
+#include <errno.h>
+#include <libgen.h>
+#include <math.h>
+#include <stdbool.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#include "ntpshm.h"
+#include "timespec.h"
+
+
+// prevent instruction reordering across any call to this function
+static inline void memory_barrier(void)
+{
+#ifdef __COVERITY__
+ // do nothing
+#elif defined(__cplusplus)
+ // we are C++
+ #if __cplusplus >= 201103L
+ // C++11 and later has atomics, earlier do not
+ std::atomic_thread_fence(std::memory_order_seq_cst);
+ #endif
+#elif defined HAVE_STDATOMIC_H
+ // we are C and atomics are in C98 and newer
+ atomic_thread_fence(memory_order_seq_cst);
+#elif defined(HAVE_OSATOMIC_H)
+ // do it the OS X way
+ OSMemoryBarrier();
+#elif defined(__GNUC__)
+ __asm__ __volatile__ ("" : : : "memory");
+#endif
+}
+
+#define LEAP_NOWARNING 0x0 // normal, no leap second warning
+
+// put a received fix time into shared memory for NTP
+void ntp_write(volatile struct shmTime *shmseg,
+ struct timedelta_t *td, int precision, int leap_notify)
+{
+ struct tm tm;
+
+ /*
+ * insist that leap seconds only happen in june and december
+ * GPS emits leap pending for 3 months prior to insertion
+ * NTP expects leap pending for only 1 month prior to insertion
+ * Per http://bugs.ntp.org/1090
+ *
+ * ITU-R TF.460-6, Section 2.1, says laep seconds can be primarily
+ * in Jun/Dec but may be in March or September
+ */
+ (void)gmtime_r(&(td->real.tv_sec), &tm);
+ if (5 != tm.tm_mon &&
+ 11 != tm.tm_mon ) {
+ // Not june, not December, no way
+ leap_notify = LEAP_NOWARNING;
+ }
+
+ /* we use the shmTime mode 1 protocol
+ *
+ * ntpd does this:
+ *
+ * reads valid.
+ * IFF valid is 1
+ * reads count
+ * reads values
+ * reads count
+ * IFF count unchanged
+ * use values
+ * clear valid
+ *
+ */
+
+ // should not be needed, but sometimes is...
+ TS_NORM(&td->real);
+ TS_NORM(&td->clock);
+
+ shmseg->valid = 0;
+ shmseg->count++;
+ /* We need a memory barrier here to prevent write reordering by
+ * the compiler or CPU cache */
+ memory_barrier();
+ shmseg->clockTimeStampSec = (time_t)td->real.tv_sec;
+ shmseg->clockTimeStampUSec = (int)(td->real.tv_nsec/1000);
+ shmseg->clockTimeStampNSec = (unsigned)td->real.tv_nsec;
+ shmseg->receiveTimeStampSec = (time_t)td->clock.tv_sec;
+ shmseg->receiveTimeStampUSec = (int)(td->clock.tv_nsec/1000);
+ shmseg->receiveTimeStampNSec = (unsigned)td->clock.tv_nsec;
+ shmseg->leap = leap_notify;
+ shmseg->precision = precision;
+ memory_barrier();
+ shmseg->count++;
+ // make sure that is flushed, then mark valid
+ memory_barrier();
+ shmseg->valid = 1;
+}
+
+// vim: set expandtab shiftwidth=4
diff --git a/IC_src/mtk/lib/liblynq-gnss/gpsd/strfuncs.h b/IC_src/mtk/lib/liblynq-gnss/gpsd/strfuncs.h
new file mode 100755
index 0000000..50b60f1
--- /dev/null
+++ b/IC_src/mtk/lib/liblynq-gnss/gpsd/strfuncs.h
@@ -0,0 +1,59 @@
+/*
+ * strfuncs.h - string functions
+ *
+ * This software is distributed under a BSD-style license. See the
+ * file "COPYING" in the toop-level directory of the distribution for details.
+ */
+#ifndef _GPSD_STRFUNCS_H_
+#define _GPSD_STRFUNCS_H_
+
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+
+
+static inline bool str_starts_with(const char *str, const char *prefix)
+{
+ return 0 == strncmp(str, prefix, strlen(prefix));
+}
+
+
+static inline void str_appendf(char *str, size_t alloc_size,
+ const char *format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+ (void)vsnprintf(str + strlen(str), alloc_size - strlen(str), format, ap);
+ va_end(ap);
+}
+
+
+static inline void str_vappendf(char *str, size_t alloc_size,
+ const char *format, va_list ap)
+{
+ (void) vsnprintf(str + strlen(str), alloc_size - strlen(str), format, ap);
+}
+
+
+static inline void str_rstrip_char(char *str, char ch)
+{
+ if (0 != strlen(str) &&
+ str[strlen(str) - 1] == ch) {
+ str[strlen(str) - 1] = '\0';
+ }
+}
+
+/* memset() for a volatile destination
+ * dest = destination
+ * c = fill character
+ * count = sizeof(dest)
+ */
+static inline void memset_volatile(volatile void *dest, char c, size_t count)
+{
+ volatile char *ptr = (volatile char*)dest;
+ while (count-- > 0) {
+ *ptr++ = c;
+ }
+}
+#endif /* _GPSD_STRFUNCS_H_ */
diff --git a/IC_src/mtk/lib/liblynq-gnss/gpsd/timehint.c b/IC_src/mtk/lib/liblynq-gnss/gpsd/timehint.c
new file mode 100755
index 0000000..ff248f7
--- /dev/null
+++ b/IC_src/mtk/lib/liblynq-gnss/gpsd/timehint.c
@@ -0,0 +1,199 @@
+/*
+ * timehint.c - put time information in SHM segment for ntpd, or to chrony
+ *
+ * Note that for easy debugging all logging from this file is prefixed
+ * with PPS or NTP.
+ *
+ * This file is Copyright 2010 by the GPSD project
+ * SPDX-License-Identifier: BSD-2-clause
+ */
+
+#include <errno.h>
+#include <libgen.h>
+#include <math.h>
+#include <stdbool.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <time.h> // for timespec
+#include <unistd.h>
+
+#include "ntpshm.h"
+#include "strfuncs.h" // for memset_volatile()
+#include "timespec.h"
+
+/* Note: you can start gpsd as non-root, and have it work with ntpd.
+ * However, it will then only use the ntpshm segments 2 3, and higher.
+ *
+ * Ntpd always runs as root (to be able to control the system clock).
+ * After that it often (depending on its host configuration) drops to run as
+ * user ntpd and group ntpd.
+ *
+ * As of February 2015 its rules for the creation of ntpshm segments are:
+ *
+ * Segments 0 and 1: permissions 0600, i.e. other programs can only
+ * read and write as root.
+ *
+ * Segments 2, 3, and higher:
+ * permissions 0666, i.e. other programs can read
+ * and write as any user. I.e.: if ntpd has been
+ * configured to use these segments, any
+ * unprivileged user is allowed to provide data
+ * for synchronisation.
+ *
+ * By default ntpd creates 0 segments (though the documentation is
+ * written in such a way as to suggest it creates 4). It can be
+ * configured to create up to 217. gpsd creates two segments for each
+ * device it can drive; by default this is 8 segments for 4
+ * devices,but can be higher if it was compiled with a larger value of
+ * MAX_DEVICES.
+ *
+ * Started as root, gpsd does as ntpd when attaching (creating) the
+ * segments. In contrast to ntpd, which only attaches (creates)
+ * configured segments, gpsd creates all segments. Thus a gpsd will
+ * by default create eight segments 0-7 that an ntpd with default
+ * configuration does not watch.
+ *
+ * Started as non-root, gpsd will only attach (create) segments 2 and
+ * above, with permissions 0666. As the permissions are for any user,
+ * the creator does not matter.
+ *
+ * For each GPS module gpsd controls, it will use the attached ntpshm
+ * segments in pairs (for coarse clock and pps source, respectively)
+ * starting from the first found segments. I.e. started as root, one
+ * GPS will deliver data on all segments including 0 and 1; started as
+ * non-root, gpsd will be deliver data only on segments 2 and higher.
+ *
+ * Segments are allocated to activated devices on a first-come-first-served
+ * basis. A device's segment is marked unused when the device is closed and
+ * may be re-used by devices connected later.
+ *
+ * To debug, try looking at the live segments this way:
+ *
+ * ipcs -m
+ *
+ * results should look like this:
+ * ------ Shared Memory Segments --------
+ * key shmid owner perms bytes nattch status
+ * 0x4e545030 0 root 700 96 2
+ * 0x4e545031 32769 root 700 96 2
+ * 0x4e545032 163842 root 666 96 1
+ * 0x4e545033 196611 root 666 96 1
+ * 0x4e545034 253555 root 666 96 1
+ * 0x4e545035 367311 root 666 96 1
+ *
+ * For a bit more data try this:
+ * cat /proc/sysvipc/shm
+ *
+ * If gpsd can not open the segments be sure you are not running SELinux
+ * or apparmor.
+ *
+ * if you see the shared segments (keys 1314148400 -- 1314148405), and
+ * no gpsd or ntpd is running, you can remove them like this:
+ *
+ * ipcrm -M 0x4e545030
+ * ipcrm -M 0x4e545031
+ * ipcrm -M 0x4e545032
+ * ipcrm -M 0x4e545033
+ * ipcrm -M 0x4e545034
+ * ipcrm -M 0x4e545035
+ *
+ * Removing these segments is usually not necessary, as the operating system
+ * garbage-collects them when they have no attached processes.
+ */
+
+static volatile struct shmTime *getShmTime(int unit)
+{
+ int shmid;
+ unsigned int perms;
+ volatile struct shmTime *p;
+
+ // set the SHM perms the way ntpd does
+ if (2 > unit) {
+ // we are root, be careful
+ perms = 0600;
+ } else {
+ // we are not root, try to work anyway
+ perms = 0666;
+ }
+
+ /*
+ * Note: this call requires root under BSD, and possibly on
+ * well-secured Linux systems. This is why ntpshm_context_init() has to be
+ * called before privilege-dropping.
+ */
+ shmid = shmget((key_t)(NTPD_BASE + unit),
+ sizeof(struct shmTime), (int)(IPC_CREAT | perms));
+ if (shmid == -1) {
+ printf("NTP:SHM: shmget(NTP%d, %zd, %o) fail: %s(%d)\n",
+ unit, sizeof(struct shmTime),
+ (int)perms, strerror(errno), errno);
+ return NULL;
+ }
+ p = (struct shmTime *)shmat(shmid, 0, 0);
+ if ((int)(long)p == -1) {
+ printf("NTP:SHM: shmat failed, unit %d: %s(%d)\n",
+ unit, strerror(errno), errno);
+ return NULL;
+ }
+ printf("NTP:SHM: shmat(%d,0,0) succeeded, unit %d\n",
+ shmid, unit);
+ return p;
+}
+
+// Attach all NTP SHM segments. Called once at startup, while still root.
+void ntpshm_context_init(struct shmTime ** ppShmTime)
+{
+ int unit;
+
+ // Only grab the first two when running as root.
+ // then grab all the rest
+ if (0 == getuid()) {
+ unit = 0;
+ } else {
+ unit = 2;
+ }
+ *ppShmTime = getShmTime(unit);
+ memset_volatile(*ppShmTime, 0, sizeof(struct shmTime));
+ (*ppShmTime)->mode = 0;
+ (*ppShmTime)->leap = 0;
+ //(*ppShmTime)->precision = -20; // initially 1 micro sec
+ (*ppShmTime)->precision = -1; // initially 1 micro sec
+ (*ppShmTime)->nsamples = 3; // stages of median filter
+}
+
+/* put a received fix time into shared memory for NTP
+ * unit is the SHM unit to use
+ * precision is the NTP precision
+ * Any NMEA will be about -1 or -2. Garmin GPS-18/USB can be -6 or -7
+ * PPS over USB, then precision = -10, 1 milli sec
+ * PPS over serial, precision = -20, 1 micro sec, maybe bettter
+ * td is the time delta to send
+ *
+ * Return: void
+ */
+void ntpshm_put(struct shmTime * pShmTime, int unit, int precision,
+ struct timedelta_t *td, int leap_notify)
+{
+ volatile struct shmTime *shmseg;
+ char real_str[TIMESPEC_LEN];
+ char clock_str[TIMESPEC_LEN];
+
+
+// if (!VALID_UNIT(unit)) {
+// printf("NTP:SHM: ntpshm_put(,%d,) invalid unit\n", unit);
+// return;
+// }
+
+ shmseg = pShmTime;
+ ntp_write(shmseg, td, precision, leap_notify);
+
+// printf("NTP:SHM: ntpshm_put(NTP%d, %d) %s @ %s\n",
+// unit, precision,
+// timespec_str(&td->real, real_str, sizeof(real_str)),
+// timespec_str(&td->clock, clock_str, sizeof(clock_str)));
+
+ return;
+}
diff --git a/IC_src/mtk/lib/liblynq-gnss/gpsd/timespec.h b/IC_src/mtk/lib/liblynq-gnss/gpsd/timespec.h
new file mode 100755
index 0000000..8e3efe5
--- /dev/null
+++ b/IC_src/mtk/lib/liblynq-gnss/gpsd/timespec.h
@@ -0,0 +1,171 @@
+/*
+ * This file is Copyright 2015 by the GPSD project
+ * SPDX-License-Identifier: BSD-2-clause
+ */
+
+#ifndef GPSD_TIMESPEC_H
+#define GPSD_TIMESPEC_H
+
+#include <math.h> // for modf()
+#include <stdbool.h> // for bool
+
+#define NS_IN_SEC 1000000000LL // nanoseconds in a second
+#define NS_IN_MS 1000000LL // nanoseconds in a millisecond
+#define US_IN_SEC 1000000LL // microseconds in a second
+#define MS_IN_SEC 1000LL // milliseconds in a second
+
+// convert a timespec_t to an int64_t of milliseconds
+#define TSTOMS(ts) ((int64_t)((ts)->tv_sec) * MS_IN_SEC + \
+ (int64_t)((ts)->tv_nsec / NS_IN_MS))
+
+/* normalize a timespec
+ *
+ * three cases to note
+ * if tv_sec is positive, then tv_nsec must be positive
+ * if tv_sec is negative, then tv_nsec must be negative
+ * if tv_sec is zero, then tv_nsec may be positive or negative.
+ *
+ * this only handles the case where two normalized timespecs
+ * are added or subtracted. (e.g. only a one needs to be borrowed/carried
+ *
+ * NOTE: this normalization is not the same as ntpd uses
+ */
+
+/* return the difference between timespecs in nanoseconds
+ * int may be too small, 32 bit long is too small, floats are too imprecise,
+ * doubles are not quite precise enough
+ * MUST be at least int64_t to maintain precision on 32 bit code */
+#define timespec_diff_ns(x, y) \
+ (int64_t)((((x).tv_sec-(y).tv_sec)*NS_IN_SEC)+(x).tv_nsec-(y).tv_nsec)
+
+static inline void TS_NORM( struct timespec *ts)
+{
+ if ((1 <= ts->tv_sec) ||
+ ((0 == ts->tv_sec) && (0 <= ts->tv_nsec))) {
+ // result is positive
+ if (NS_IN_SEC <= ts->tv_nsec) {
+ // borrow from tv_sec
+ ts->tv_nsec -= NS_IN_SEC;
+ ts->tv_sec++;
+ } else if (0 > (ts)->tv_nsec) {
+ // carry to tv_sec
+ ts->tv_nsec += NS_IN_SEC;
+ ts->tv_sec--;
+ }
+ } else {
+ // result is negative
+ if (-NS_IN_SEC >= ts->tv_nsec) {
+ /* carry to tv_sec */
+ ts->tv_nsec += NS_IN_SEC;
+ ts->tv_sec--;
+ } else if (0 < ts->tv_nsec) {
+ // borrow from tv_sec
+ ts->tv_nsec -= NS_IN_SEC;
+ ts->tv_sec++;
+ }
+ }
+}
+
+// normalize a timeval
+#define TV_NORM(tv) \
+ do { \
+ if (US_IN_SEC <= (tv)->tv_usec) { \
+ (tv)->tv_usec -= US_IN_SEC; \
+ (tv)->tv_sec++; \
+ } else if (0 > (tv)->tv_usec) { \
+ (tv)->tv_usec += US_IN_SEC; \
+ (tv)->tv_sec--; \
+ } \
+ } while (0)
+
+// convert timespec to timeval, with rounding
+#define TSTOTV(tv, ts) \
+ do { \
+ (tv)->tv_sec = (ts)->tv_sec; \
+ (tv)->tv_usec = ((ts)->tv_nsec + 500)/1000; \
+ TV_NORM(tv); \
+ } while (0)
+
+// convert timeval to timespec
+#define TVTOTS(ts, tv) \
+ do { \
+ (ts)->tv_sec = (tv)->tv_sec; \
+ (ts)->tv_nsec = (tv)->tv_usec*1000; \
+ TS_NORM(ts); \
+ } while (0)
+
+// subtract two timespec
+#define TS_SUB(r, ts1, ts2) \
+ do { \
+ (r)->tv_sec = (ts1)->tv_sec - (ts2)->tv_sec; \
+ (r)->tv_nsec = (ts1)->tv_nsec - (ts2)->tv_nsec; \
+ TS_NORM(r); \
+ } while (0)
+
+// subtract two timespec, return a double
+#define TS_SUB_D(ts1, ts2) \
+ ((double)((ts1)->tv_sec - (ts2)->tv_sec) + \
+ ((double)((ts1)->tv_nsec - (ts2)->tv_nsec) * 1e-9))
+
+// true if normalized timespec is non zero
+#define TS_NZ(ts) (0 != (ts)->tv_sec || 0 != (ts)->tv_nsec)
+
+// true if normalized timespec equal or greater than zero
+#define TS_GEZ(ts) (0 <= (ts)->tv_sec && 0 <= (ts)->tv_nsec)
+
+// true if normalized timespec greater than zero
+#define TS_GZ(ts) (0 < (ts)->tv_sec || 0 < (ts)->tv_nsec)
+
+// true if normalized timespec1 greater than timespec2
+#define TS_GT(ts1, ts2) ((ts1)->tv_sec > (ts2)->tv_sec || \
+ ((ts1)->tv_sec == (ts2)->tv_sec && \
+ (ts1)->tv_nsec > (ts2)->tv_nsec))
+
+// true if normalized timespec1 greater or equal to timespec2
+#define TS_GE(ts1, ts2) ((ts1)->tv_sec > (ts2)->tv_sec || \
+ ((ts1)->tv_sec == (ts2)->tv_sec && \
+ (ts1)->tv_nsec >= (ts2)->tv_nsec))
+
+// true if normalized timespec1 equal to timespec2
+#define TS_EQ(ts1, ts2) ((ts1)->tv_sec == (ts2)->tv_sec && \
+ (ts1)->tv_nsec == (ts2)->tv_nsec)
+
+/* convert a timespec to a double.
+ * if tv_sec > 2, then inevitable loss of precision in tv_nsec
+ * so best to NEVER use TSTONS()
+ * WARNING replacing 1e9 with NS_IN_SEC causes loss of precision */
+#define TSTONS(ts) ((double)((ts)->tv_sec + ((ts)->tv_nsec / 1e9)))
+
+/* convert a double to a timespec_t
+ * if D > 2, then inevitable loss of precision in nanoseconds
+ */
+#define DTOTS(ts, d) \
+ do { \
+ double int_part; \
+ (ts)->tv_nsec = (long)(modf(d, &int_part) * 1e9); \
+ (ts)->tv_sec = (time_t)int_part; \
+ } while (0)
+
+// convert integer (64 bit for full range) ms to a timespec_t
+#define MSTOTS(ts, ms) \
+ do { \
+ (ts)->tv_sec = (time_t)(ms / 1000); \
+ (ts)->tv_nsec = (long)((ms % 1000) * 1000000L); \
+ } while (0)
+
+// convert integer (64 bit for full range) us to a timespec_t
+#define USTOTS(ts, ms) \
+ do { \
+ (ts)->tv_sec = (time_t)(ms / 1000000); \
+ (ts)->tv_nsec = (long)((ms % 1000000) * 1000L); \
+ } while (0)
+
+#define TIMESPEC_LEN 42 // required length of a timespec buffer
+
+extern const char *timespec_str(const struct timespec *, char *, size_t);
+
+bool nanowait(int, struct timespec *);
+
+#endif // GPSD_TIMESPEC_H
+
+// vim: set expandtab shiftwidth=4
diff --git a/IC_src/mtk/lib/liblynq-gnss/makefile b/IC_src/mtk/lib/liblynq-gnss/makefile
index fcf6780..1d21aef 100755
--- a/IC_src/mtk/lib/liblynq-gnss/makefile
+++ b/IC_src/mtk/lib/liblynq-gnss/makefile
@@ -18,6 +18,7 @@
LOCAL_C_INCLUDES = \
-I$(LOCAL_PATH)/include \
+ -I$(LOCAL_PATH)/gpsd \
-I$(ROOT)$(includedir)/gps_hal \
-I$(ROOT)$(includedir)/gps_hal/inc \
-I$(ROOT)$(includedir)/gps_hal/hardware \
@@ -45,11 +46,21 @@
LOCAL_CFLAGS += -DGNSS_SYNC_TIME_CFG
endif
+ifeq ($(strip $(MOBILETEK_GNSS_CN_OUTPUT_SYSLOG)), yes)
+ LOCAL_CFLAGS += -DGNSS_CN_OUTPUT_SYSLOG
+endif
+
+
+
$(warning libs=$(LOCAL_LIBS))
CXXSRC=\
-SOURCES = $(wildcard *.c wildcard src/*.c)
+ifeq ($(strip $(MOBILETEK_GNSS_SYNC_TIME_CFG)), yes)
+ SOURCES = $(wildcard *.c wildcard src/*.c wildcard gpsd/*.c)
+else
+ SOURCES = $(wildcard *.c wildcard src/*.c)
+endif
EXECUTABLE = liblynq-gnss.so
diff --git a/IC_src/mtk/lib/liblynq-gnss/src/lynq_callback.c b/IC_src/mtk/lib/liblynq-gnss/src/lynq_callback.c
index 1c236be..51dd989 100755
--- a/IC_src/mtk/lib/liblynq-gnss/src/lynq_callback.c
+++ b/IC_src/mtk/lib/liblynq-gnss/src/lynq_callback.c
@@ -10,10 +10,14 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <time.h>
+#include <stdlib.h>
#include"lynq_gnsshal.h"
#include"mtk_lbs_utility.h"
#include"lynq_gnss.h"
+#ifdef GNSS_SYNC_TIME_CFG
+#include "ntpshm.h"
+#endif
#define NMEA_ACC "ACCURACY"
#define NMEA_GSA "GSA"
@@ -58,11 +62,19 @@
#ifdef GNSS_SYNC_TIME_CFG
extern int g_gnss_sync_enable_flag;
extern int g_gnss_sync_done;
+struct shmTime * g_pShmTime = NULL;
#endif
#ifdef GNSS_ELT_OUTPUT_CFG
extern int g_ttyGS_fd;
extern bool Open_ELT;
#endif
+#ifdef GNSS_CN_OUTPUT_SYSLOG
+char GSV_SNR[256] = {0};
+int arr[64] = {0};
+extern int frequency_turn;
+int count = 0;
+int nmea_count = 0;
+#endif
static inline int update_systime_time(GpsUtcTime gpstime)
{
@@ -87,23 +99,95 @@
return 0;
}
+#ifdef GNSS_CN_OUTPUT_SYSLOG
+void parse_gpgsv(const char* sentence)
+{
+ int comma_count = 0;
+ char* token;
+ char tmp[128] = {0};
+ char copy[128] = {0};
+ strcpy(copy,sentence);
+ for (int i = 0; copy[i] != '*'; i++) // NMEA statement ends with "*"
+ {
+ if (copy[i] == ',')
+ {
+ comma_count++;
+ /*in the GSV of NMEA,the value after the 7th, 11th, 15th, and 19th commas is the CN value */
+ if (comma_count == 7 || comma_count == 11 || comma_count == 15 || comma_count == 19)
+ {
+ if(copy[i+1] == ',')
+ {
+ i+=2;
+ comma_count++;
+ continue;
+ }
+ /*strtok will change the original sentence content, before strtok, copy and save the remaining sentences*/
+ strcpy(tmp,copy+i+1);
+ token = strtok(copy+i+1, ",");
+ if (strcmp(token,"")!=0)
+ {
+ count %= 64;
+ arr[count++] = atoi(token); // save CN_VALUE in arr[]
+ }
+ strcpy(copy+i+1,tmp); // restore the original sentence content
+ }
+ }
+ }
+}
+#endif
void lynq_gps_nmea_callback(GpsUtcTime timestamp, const char* nmea, int length)
{
+#ifdef GNSS_CN_OUTPUT_SYSLOG
+if (strncmp(nmea+3,NMEA_RMC,strlen(NMEA_RMC))==0)
+ nmea_count++;
+if (nmea_count/frequency_turn == 10 && strncmp(nmea+3,NMEA_GSV,strlen(NMEA_GSV))==0)
+{
+ parse_gpgsv(nmea);
+}
+if (nmea_count/frequency_turn == 11)
+{
+ for(int i=0; i < count; i++)
+ {
+ if(strlen(GSV_SNR)>0)
+ {
+ strcat(GSV_SNR,",");
+ }
+ sprintf(GSV_SNR,"%s%d",GSV_SNR,arr[i]);
+ }
+ RLOGE("CN_VALUE:%s\n",GSV_SNR);
+ memset(arr,0,sizeof(int)*64);
+ memset(GSV_SNR,0,strlen(GSV_SNR));
+ nmea_count = 0;
+ count = 0;
+}
+#endif
#ifdef GNSS_ELT_OUTPUT_CFG
int ret;
time_t reopen_end;
#endif
#ifdef GNSS_SYNC_TIME_CFG
- if (g_gnss_sync_enable_flag == 1 && g_gnss_sync_done == 0)
+ struct timedelta_t td;
+ if (g_gnss_sync_enable_flag == 1)
{
if( strncmp(nmea+3,NMEA_RMC,strlen(NMEA_RMC)) == 0 && nmea[18] == 'A')
{
- if (update_systime_time(timestamp) == 0)
+ if (g_gnss_sync_done == 0)
{
- system("hwclock -w");//jb.qi add for systime to dtr on 20240205
+ // if ntpd is not present set the time and sync rtc
+ if (system("ps -C ntpd") != 0 && update_systime_time(timestamp) == 0)
+ {
+ system("hwclock -w --utc");//jb.qi add for systime to dtr on 20240205
+ }
+ ntpshm_context_init(&g_pShmTime);
g_gnss_sync_done = 1;
+ RLOGD("ntpshm_context_init done\n");
}
+
+ (void)clock_gettime(CLOCK_REALTIME, &td.clock);
+ td.real.tv_sec = timestamp / 1000;
+ td.real.tv_nsec = (timestamp % 1000) * 1000;
+ ntpshm_put(g_pShmTime, 0, -1, &td, 0);
}
}
#endif
diff --git a/IC_src/mtk/lib/liblynq-gnss/src/lynq_gnss.c b/IC_src/mtk/lib/liblynq-gnss/src/lynq_gnss.c
index 0f9181f..053a2fd 100755
--- a/IC_src/mtk/lib/liblynq-gnss/src/lynq_gnss.c
+++ b/IC_src/mtk/lib/liblynq-gnss/src/lynq_gnss.c
@@ -51,7 +51,7 @@
int g_gnss_sync_enable_flag = 0;
int g_gnss_sync_done = 0;
#endif
-
+int frequency_turn = 1;
enum
{
Gnss_ok = 0,
@@ -373,9 +373,11 @@
{
case LYNQ_SWITCH_DISABLE:
mnld_write_cfg(LYNQ_EPO_STATUS,LYNQ_CONFIG_DISABLE);
+ system("echo EPO_ENABLE=0 > /etc/gnss/gps.conf");
break;
case LYNQ_SWITCH_ENABLE:
mnld_write_cfg(LYNQ_EPO_STATUS,LYNQ_CONFIG_ENABLE);
+ system("echo EPO_ENABLE=1 > /etc/gnss/gps.conf");
break;
default:
RLOGD("unknown op");
@@ -387,7 +389,7 @@
int lynq_gnss_output_frequency_set(int frequency)
{
- int frequency_turn = frequency;
+ frequency_turn = frequency;
int freq_num = 1000/frequency_turn;
char freq[LYNQ_MAX_FRREQUENCY];
diff --git a/common_src/framework/lynq-ril-service/src/common.cpp b/common_src/framework/lynq-ril-service/src/common.cpp
index 402aad1..b87b051 100755
--- a/common_src/framework/lynq-ril-service/src/common.cpp
+++ b/common_src/framework/lynq-ril-service/src/common.cpp
@@ -944,7 +944,7 @@
return ;
stime(&t);
- system("hwclock -w -f /dev/rtc0");
+ system("hwclock -w --utc -f /dev/rtc0");
return;
}
void notifyDataSignal() {
diff --git a/common_src/framework/lynq-ril-service/src/ril.cpp b/common_src/framework/lynq-ril-service/src/ril.cpp
index ef41d33..bf24c67 100755
--- a/common_src/framework/lynq-ril-service/src/ril.cpp
+++ b/common_src/framework/lynq-ril-service/src/ril.cpp
@@ -170,6 +170,12 @@
#define LYNQ_SERVICE_PORT 8088
#define LYNQ_AT_SERVICE_PORT 8087
#define LYNQ_BRODCAST_PORT 8086
+#ifdef GSW_RIL_CFG
+/*Interfaces lo net addr 127.0.0.1,mask 255.0.0.0,so lo broadcast addr is 127.255.255.255*/
+#define LYNQ_RIL_FWK_BROADCAST_IP "127.255.255.255" /*hong.liu change broadcast addr on 2024.2.18*/
+#else
+#define LYNQ_RIL_FWK_BROADCAST_IP "255.255.255.255"
+#endif
#define LYNQ_SOCKET_BUFFER (1024*8+sizeof(int)*3+10)
/*lei add*/
#define LYNQ_AT_SOCKET_BUFFER 1024
@@ -6052,8 +6058,6 @@
perror("creaet socket for udp fail");
return;
}
- /* 设置socket允许重复使用地址与端口,SO_REUSEADDR值为2 */
- //setsockopt(socket_fd,SOL_SOCKET,SO_REUSEADDR,&on,sizeof on);
/* 使能广播功能,SO_BROADCAST值为6 */
ret= setsockopt(lynq_urc_socket_fd,SOL_SOCKET,SO_BROADCAST,&on,sizeof(on));
if(ret<0)
@@ -6076,8 +6080,8 @@
urc_broadcast_addr.sin_family = AF_INET; //IPv4
urc_broadcast_addr.sin_port = htons(LYNQ_BRODCAST_PORT);
- urc_broadcast_addr.sin_addr.s_addr = inet_addr("255.255.255.255" );//255.255.255.255 broadcast addrress.
- printf("LYNQ_RIL_urcClientInit success!!!\n");
+ urc_broadcast_addr.sin_addr.s_addr = inet_addr(LYNQ_RIL_FWK_BROADCAST_IP);/*hong.liu change broadcast addr on 2024.2.18*/
+ RLOGE("LYNQ_RIL_urcClientInit success!!!");
return;
}
diff --git a/common_src/lib/liblynq-call/lynq_module_socket.cpp b/common_src/lib/liblynq-call/lynq_module_socket.cpp
index 1539a91..b33dd68 100755
--- a/common_src/lib/liblynq-call/lynq_module_socket.cpp
+++ b/common_src/lib/liblynq-call/lynq_module_socket.cpp
@@ -20,7 +20,11 @@
#define LYNQ_SERVICE_PORT 8088
#define LYNQ_ADDRESS "127.0.0.1"
#define LYNQ_URC_SERVICE_PORT 8086
+#ifdef GSW_RIL_CFG
+#define LYNQ_URC_ADDRESS "127.255.255.255" /*hong.liu change broadcast addr on 2024.2.18*/
+#else
#define LYNQ_URC_ADDRESS "0.0.0.0"
+#endif
#define LYNQ_REQUEST_PARAM_BUF 8192
#define LYNQ_REC_BUF 8192
diff --git a/common_src/lib/liblynq-call/makefile b/common_src/lib/liblynq-call/makefile
index 40415dc..6073694 100755
--- a/common_src/lib/liblynq-call/makefile
+++ b/common_src/lib/liblynq-call/makefile
@@ -13,6 +13,9 @@
-fpermissive \
+ifeq ($(strip $(MOBILETEK_RIL_CFG)), GSW)
+ LOCAL_CFLAGS += -DGSW_RIL_CFG
+endif
$(warning ################# lynq data demo ROOT: $(ROOT),includedir:$(includedir))
LOCAL_PATH = .
diff --git a/common_src/lib/liblynq-data/lynq_data_urc.cpp b/common_src/lib/liblynq-data/lynq_data_urc.cpp
index c3d95c6..45996e0 100755
--- a/common_src/lib/liblynq-data/lynq_data_urc.cpp
+++ b/common_src/lib/liblynq-data/lynq_data_urc.cpp
@@ -177,7 +177,7 @@
}
urc_local_addr.sin_family = AF_INET;
urc_local_addr.sin_port = htons(LYNQ_URC_SERVICE_PORT);
- urc_local_addr.sin_addr.s_addr = htons(INADDR_ANY);
+ urc_local_addr.sin_addr.s_addr = inet_addr(LYNQ_RIL_FWK_BROADCAST_IP);/*hong.liu change broadcast addr on 2024.2.18*/
/* Set socket to allow reuse of address and port, SO_REUSEADDR value is 2*/
rt = setsockopt(lynq_urc_sockfd,SOL_SOCKET,SO_REUSEADDR,&on,sizeof on);
if(rt<0)
diff --git a/common_src/lib/liblynq-data/lynq_data_urc.h b/common_src/lib/liblynq-data/lynq_data_urc.h
index 59f9f9d..11aeb08 100755
--- a/common_src/lib/liblynq-data/lynq_data_urc.h
+++ b/common_src/lib/liblynq-data/lynq_data_urc.h
@@ -4,6 +4,11 @@
using ::android::Parcel;
#define LYNQ_URC_SERVICE_PORT 8086
+#ifdef GSW_RIL_CFG
+#define LYNQ_RIL_FWK_BROADCAST_IP "127.255.255.255" /*hong.liu change broadcast addr on 2024.2.18*/
+#else
+#define LYNQ_RIL_FWK_BROADCAST_IP "0.0.0.0"
+#endif
/*the same with lynq_interface.h begin*/
#define LYNQ_REQUEST_VENDOR_BASE 8000
diff --git a/common_src/lib/liblynq-network/lynq_module_socket.cpp b/common_src/lib/liblynq-network/lynq_module_socket.cpp
index 8ab8f34..35dd9d6 100755
--- a/common_src/lib/liblynq-network/lynq_module_socket.cpp
+++ b/common_src/lib/liblynq-network/lynq_module_socket.cpp
@@ -20,7 +20,11 @@
#define LYNQ_SERVICE_PORT 8088
#define LYNQ_ADDRESS "127.0.0.1"
#define LYNQ_URC_SERVICE_PORT 8086
+#ifdef GSW_RIL_CFG
+#define LYNQ_URC_ADDRESS "127.255.255.255" /*hong.liu change broadcast addr on 2024.2.18*/
+#else
#define LYNQ_URC_ADDRESS "0.0.0.0"
+#endif
#define LYNQ_REQUEST_PARAM_BUF 8192
#define LYNQ_REC_BUF 8192
diff --git a/common_src/lib/liblynq-network/makefile b/common_src/lib/liblynq-network/makefile
index 0ae6805..044d7f5 100755
--- a/common_src/lib/liblynq-network/makefile
+++ b/common_src/lib/liblynq-network/makefile
@@ -10,7 +10,9 @@
-DKEEP_ALIVE \
-DECALL_SUPPORT
-
+ifeq ($(strip $(MOBILETEK_RIL_CFG)), GSW)
+ LOCAL_CFLAGS += -DGSW_RIL_CFG
+endif
$(warning ################# lynq network demo ROOT: $(ROOT),includedir:$(includedir))
LOCAL_PATH = .
diff --git a/common_src/lib/liblynq-sms/lynq_module_socket.cpp b/common_src/lib/liblynq-sms/lynq_module_socket.cpp
index d7c654e..dae9b5c 100755
--- a/common_src/lib/liblynq-sms/lynq_module_socket.cpp
+++ b/common_src/lib/liblynq-sms/lynq_module_socket.cpp
@@ -20,7 +20,11 @@
#define LYNQ_SERVICE_PORT 8088
#define LYNQ_ADDRESS "127.0.0.1"
#define LYNQ_URC_SERVICE_PORT 8086
+#ifdef GSW_RIL_CFG
+#define LYNQ_URC_ADDRESS "127.255.255.255" /*hong.liu change broadcast addr on 2024.2.18*/
+#else
#define LYNQ_URC_ADDRESS "0.0.0.0"
+#endif
#define LYNQ_REQUEST_PARAM_BUF 8192
#define LYNQ_REC_BUF 8192
diff --git a/common_src/lib/liblynq-sms/makefile b/common_src/lib/liblynq-sms/makefile
index e5dedab..e7abb27 100755
--- a/common_src/lib/liblynq-sms/makefile
+++ b/common_src/lib/liblynq-sms/makefile
@@ -12,7 +12,9 @@
-DECALL_SUPPORT \
-fpermissive \
-
+ifeq ($(strip $(MOBILETEK_RIL_CFG)), GSW)
+ LOCAL_CFLAGS += -DGSW_RIL_CFG
+endif
$(warning ################# lynq data demo ROOT: $(ROOT),includedir:$(includedir))
LOCAL_PATH = .
diff --git a/common_src/lib/liblynq-systime/src/lynq_systime.c b/common_src/lib/liblynq-systime/src/lynq_systime.c
index 46ec442..2ba6693 100755
--- a/common_src/lib/liblynq-systime/src/lynq_systime.c
+++ b/common_src/lib/liblynq-systime/src/lynq_systime.c
@@ -66,7 +66,7 @@
system(date);
system(time);
- system("hwclock -w -f /dev/rtc0");
+ system("hwclock -w --utc -f /dev/rtc0");
return 0;
}