Skip to content

Commit 7d93128

Browse files
authored
Merge pull request #9124 from iNavFlight/mmosca-gps-glonass
Add configuration of Beidou and Glonass to M8, M9 and M10 gps modules
2 parents c334579 + 4923888 commit 7d93128

File tree

13 files changed

+1051
-321
lines changed

13 files changed

+1051
-321
lines changed

docs/Settings.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,6 +1432,16 @@ Navigation update rate for UBLOX7 receivers. Some receivers may limit the maximu
14321432

14331433
---
14341434

1435+
### gps_ublox_use_beidou
1436+
1437+
Enable use of Beidou satellites. This is at the expense of other regional constellations, so benefit may also be regional. Requires gps hardware support [OFF/ON].
1438+
1439+
| Default | Min | Max |
1440+
| --- | --- | --- |
1441+
| OFF | OFF | ON |
1442+
1443+
---
1444+
14351445
### gps_ublox_use_galileo
14361446

14371447
Enable use of Galileo satellites. This is at the expense of other regional constellations, so benefit may also be regional. Requires M8N and Ublox firmware 3.x (or later) [OFF/ON].
@@ -1442,6 +1452,16 @@ Enable use of Galileo satellites. This is at the expense of other regional const
14421452

14431453
---
14441454

1455+
### gps_ublox_use_glonass
1456+
1457+
Enable use of Glonass satellites. This is at the expense of other regional constellations, so benefit may also be regional. Requires gps haardware support [OFF/ON].
1458+
1459+
| Default | Min | Max |
1460+
| --- | --- | --- |
1461+
| OFF | OFF | ON |
1462+
1463+
---
1464+
14451465
### ground_test_mode
14461466

14471467
For developer ground test use. Disables motors, sets heading status = Trusted on FW.

src/main/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ main_sources(COMMON_SRC
499499
io/gps.c
500500
io/gps.h
501501
io/gps_ublox.c
502+
io/gps_ublox_utils.c
502503
io/gps_nmea.c
503504
io/gps_msp.c
504505
io/gps_fake.c

src/main/fc/cli.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ bool cliMode = false;
8989
#include "io/beeper.h"
9090
#include "io/flashfs.h"
9191
#include "io/gps.h"
92+
#include "io/gps_ublox.h"
9293
#include "io/ledstrip.h"
9394
#include "io/osd.h"
9495
#include "io/serial.h"
@@ -3468,6 +3469,23 @@ static void cliStatus(char *cmdline)
34683469
cliPrintLinefeed();
34693470
#endif
34703471

3472+
if (featureConfigured(FEATURE_GPS) && (gpsConfig()->provider == GPS_UBLOX || gpsConfig()->provider == GPS_UBLOX7PLUS)) {
3473+
cliPrint("GPS: ");
3474+
cliPrintf("HW Version: %s Proto: %d.%02d Baud: %d", getGpsHwVersion(), getGpsProtoMajorVersion(), getGpsProtoMinorVersion(), getGpsBaudrate());
3475+
cliPrintLinefeed();
3476+
//cliPrintLinef(" GNSS Capabilities: %d", gpsUbloxCapLastUpdate());
3477+
cliPrintLinef(" GNSS Capabilities:");
3478+
cliPrintLine(" GNSS Provider active/default");
3479+
cliPrintLine(" GPS 1/1");
3480+
if(gpsUbloxHasGalileo())
3481+
cliPrintLinef(" Galileo %d/%d", gpsUbloxGalileoEnabled(), gpsUbloxGalileoDefault());
3482+
if(gpsUbloxHasBeidou())
3483+
cliPrintLinef(" BeiDou %d/%d", gpsUbloxBeidouEnabled(), gpsUbloxBeidouDefault());
3484+
if(gpsUbloxHasGlonass())
3485+
cliPrintLinef(" Glonass %d/%d", gpsUbloxGlonassEnabled(), gpsUbloxGlonassDefault());
3486+
cliPrintLinef(" Max concurrent: %d", gpsUbloxMaxGnss());
3487+
}
3488+
34713489
// If we are blocked by PWM init - provide more information
34723490
if (getPwmInitError() != PWM_INIT_ERROR_NONE) {
34733491
cliPrintLinef("PWM output init error: %s", getPwmInitErrorMessage());

src/main/fc/settings.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,6 +1537,16 @@ groups:
15371537
default_value: OFF
15381538
field: ubloxUseGalileo
15391539
type: bool
1540+
- name: gps_ublox_use_beidou
1541+
description: "Enable use of Beidou satellites. This is at the expense of other regional constellations, so benefit may also be regional. Requires gps hardware support [OFF/ON]."
1542+
default_value: OFF
1543+
field: ubloxUseBeidou
1544+
type: bool
1545+
- name: gps_ublox_use_glonass
1546+
description: "Enable use of Glonass satellites. This is at the expense of other regional constellations, so benefit may also be regional. Requires gps haardware support [OFF/ON]."
1547+
default_value: OFF
1548+
field: ubloxUseGlonass
1549+
type: bool
15401550
- name: gps_min_sats
15411551
description: "Minimum number of GPS satellites in view to acquire GPS_FIX and consider GPS position valid. Some GPS receivers appeared to be very inaccurate with low satellite count."
15421552
default_value: 6

src/main/io/gps.c

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include "io/serial.h"
5252
#include "io/gps.h"
5353
#include "io/gps_private.h"
54+
#include "io/gps_ublox.h"
5455

5556
#include "navigation/navigation.h"
5657

@@ -122,9 +123,64 @@ PG_RESET_TEMPLATE(gpsConfig_t, gpsConfig,
122123
.dynModel = SETTING_GPS_DYN_MODEL_DEFAULT,
123124
.gpsMinSats = SETTING_GPS_MIN_SATS_DEFAULT,
124125
.ubloxUseGalileo = SETTING_GPS_UBLOX_USE_GALILEO_DEFAULT,
126+
.ubloxUseBeidou = SETTING_GPS_UBLOX_USE_BEIDOU_DEFAULT,
127+
.ubloxUseGlonass = SETTING_GPS_UBLOX_USE_GLONASS_DEFAULT,
125128
.ubloxNavHz = SETTING_GPS_UBLOX_NAV_HZ_DEFAULT
126129
);
127130

131+
132+
int getGpsBaudrate(void)
133+
{
134+
switch(gpsState.baudrateIndex)
135+
{
136+
case GPS_BAUDRATE_115200:
137+
return 115200;
138+
case GPS_BAUDRATE_57600:
139+
return 57600;
140+
case GPS_BAUDRATE_38400:
141+
return 38400;
142+
case GPS_BAUDRATE_19200:
143+
return 19200;
144+
case GPS_BAUDRATE_9600:
145+
return 9600;
146+
case GPS_BAUDRATE_230400:
147+
return 230400;
148+
default:
149+
return 0;
150+
}
151+
}
152+
153+
const char *getGpsHwVersion(void)
154+
{
155+
switch(gpsState.hwVersion)
156+
{
157+
case UBX_HW_VERSION_UBLOX5:
158+
return "UBLOX5";
159+
case UBX_HW_VERSION_UBLOX6:
160+
return "UBLOX6";
161+
case UBX_HW_VERSION_UBLOX7:
162+
return "UBLOX7";
163+
case UBX_HW_VERSION_UBLOX8:
164+
return "UBLOX8";
165+
case UBX_HW_VERSION_UBLOX9:
166+
return "UBLOX9";
167+
case UBX_HW_VERSION_UBLOX10:
168+
return "UBLOX10";
169+
default:
170+
return "Unknown";
171+
}
172+
}
173+
174+
uint8_t getGpsProtoMajorVersion(void)
175+
{
176+
return gpsState.swVersionMajor;
177+
}
178+
179+
uint8_t getGpsProtoMinorVersion(void)
180+
{
181+
return gpsState.swVersionMinor;
182+
}
183+
128184
void gpsSetState(gpsState_e state)
129185
{
130186
gpsState.state = state;

src/main/io/gps.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ typedef struct gpsConfig_s {
9393
gpsAutoBaud_e autoBaud;
9494
gpsDynModel_e dynModel;
9595
bool ubloxUseGalileo;
96+
bool ubloxUseBeidou;
97+
bool ubloxUseGlonass;
9698
uint8_t gpsMinSats;
9799
uint8_t ubloxNavHz;
98100
} gpsConfig_t;
@@ -166,6 +168,12 @@ struct serialPort_s;
166168
void gpsEnablePassthrough(struct serialPort_s *gpsPassthroughPort);
167169
void mspGPSReceiveNewData(const uint8_t * bufferPtr);
168170

171+
const char *getGpsHwVersion(void);
172+
uint8_t getGpsProtoMajorVersion(void);
173+
uint8_t getGpsProtoMinorVersion(void);
174+
175+
int getGpsBaudrate(void);
176+
169177
#if defined(USE_GPS_FAKE)
170178
void gpsFakeSet(
171179
gpsFixType_e fixType,

src/main/io/gps_private.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ typedef struct {
4343
serialPort_t * gpsPort; // Serial GPS only
4444

4545
uint32_t hwVersion;
46+
uint8_t swVersionMajor;
47+
uint8_t swVersionMinor;
4648

4749
gpsState_e state;
4850
gpsBaudRate_e baudrateIndex;
@@ -54,6 +56,8 @@ typedef struct {
5456
timeMs_t lastMessageMs;
5557
timeMs_t timeoutMs;
5658
timeMs_t baseTimeoutMs;
59+
timeMs_t lastCapaPoolMs;
60+
timeMs_t lastCapaUpdMs;
5761
} gpsReceiverData_t;
5862

5963
extern gpsReceiverData_t gpsState;

0 commit comments

Comments
 (0)