summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/SystemStatus.cpp15
-rw-r--r--gnss/GnssAdapter.cpp4
-rw-r--r--utils/loc_nmea.h8
3 files changed, 17 insertions, 10 deletions
diff --git a/core/SystemStatus.cpp b/core/SystemStatus.cpp
index a7f282d..3310b8b 100644
--- a/core/SystemStatus.cpp
+++ b/core/SystemStatus.cpp
@@ -34,6 +34,7 @@
#include <sys/time.h>
#include <pthread.h>
#include <platform_lib_log_util.h>
+#include <loc_nmea.h>
#include <SystemStatus.h>
namespace loc_core
@@ -48,14 +49,10 @@ protected:
std::vector<std::string> mField;
timespec setUtcTime(std::string sutctime);
-public:
- static const uint32_t NMEA_MINSIZE = 6;
- static const uint32_t NMEA_MAXSIZE = 256;
-
SystemStatusNmeaBase(const char *str_in, uint32_t len_in)
{
// check size and talker
- if (len_in > NMEA_MAXSIZE || len_in < NMEA_MINSIZE || (str_in[0] != '$')) {
+ if (!loc_nmea_is_debug(str_in, len_in)) {
return;
}
@@ -83,6 +80,10 @@ public:
}
virtual ~SystemStatusNmeaBase() { }
+
+public:
+ static const uint32_t NMEA_MINSIZE = DEBUG_NMEA_MINSIZE;
+ static const uint32_t NMEA_MAXSIZE = DEBUG_NMEA_MAXSIZE;
};
timespec SystemStatusNmeaBase::setUtcTime(std::string sutctime)
@@ -1316,9 +1317,7 @@ static uint32_t cnt_s1 = 0;
bool SystemStatus::setNmeaString(const char *data, uint32_t len)
{
bool ret = false;
- if (NULL == data
- || (len < SystemStatusNmeaBase::NMEA_MINSIZE)
- || (len > SystemStatusNmeaBase::NMEA_MAXSIZE)) {
+ if (!loc_nmea_is_debug(data, len)) {
return false;
}
diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp
index 1c195c2..377a078 100644
--- a/gnss/GnssAdapter.cpp
+++ b/gnss/GnssAdapter.cpp
@@ -39,6 +39,7 @@
#include <GnssAdapter.h>
#include <string>
#include <loc_log.h>
+#include <loc_nmea.h>
#include <Agps.h>
#include <SystemStatus.h>
@@ -1987,9 +1988,8 @@ GnssAdapter::reportSv(GnssSvNotification& svNotify)
void
GnssAdapter::reportNmeaEvent(const char* nmea, size_t length, bool fromUlp)
{
-
// if this event is not called from ULP, then try to call into ULP and return if successfull
- if (!fromUlp) {
+ if (!fromUlp && !loc_nmea_is_debug(nmea, length)) {
if (mUlpProxy->reportNmea(nmea, length)) {
return;
}
diff --git a/utils/loc_nmea.h b/utils/loc_nmea.h
index 92f997e..d182e41 100644
--- a/utils/loc_nmea.h
+++ b/utils/loc_nmea.h
@@ -43,4 +43,12 @@ void loc_nmea_generate_pos(const UlpLocation &location,
unsigned char generate_nmea,
std::vector<std::string> &nmeaArraystr);
+#define DEBUG_NMEA_MINSIZE 6
+#define DEBUG_NMEA_MAXSIZE 256
+inline bool loc_nmea_is_debug(const char* nmea, int length) {
+ return ((nullptr != nmea) &&
+ (length >= DEBUG_NMEA_MINSIZE) && (length <= DEBUG_NMEA_MAXSIZE) &&
+ (nmea[0] == '$') && (nmea[1] == 'P') && (nmea[2] == 'Q') && (nmea[3] == 'W'));
+}
+
#endif // LOC_ENG_NMEA_H