Skip to content

Commit 2feb439

Browse files
DzikuVxrmaia3d
authored andcommitted
Merge pull request iNavFlight#9124 from iNavFlight/mmosca-gps-glonass
Add configuration of Beidou and Glonass to M8, M9 and M10 gps modules
1 parent 6a668c9 commit 2feb439

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
@@ -1502,6 +1502,16 @@ Navigation update rate for UBLOX7 receivers. Some receivers may limit the maximu
15021502

15031503
---
15041504

1505+
### gps_ublox_use_beidou
1506+
1507+
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].
1508+
1509+
| Default | Min | Max |
1510+
| --- | --- | --- |
1511+
| OFF | OFF | ON |
1512+
1513+
---
1514+
15051515
### gps_ublox_use_galileo
15061516

15071517
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].
@@ -1512,6 +1522,16 @@ Enable use of Galileo satellites. This is at the expense of other regional const
15121522

15131523
---
15141524

1525+
### gps_ublox_use_glonass
1526+
1527+
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].
1528+
1529+
| Default | Min | Max |
1530+
| --- | --- | --- |
1531+
| OFF | OFF | ON |
1532+
1533+
---
1534+
15151535
### ground_test_mode
15161536

15171537
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"
@@ -3469,6 +3470,23 @@ static void cliStatus(char *cmdline)
34693470
cliPrintLinefeed();
34703471
#endif
34713472

3473+
if (featureConfigured(FEATURE_GPS) && (gpsConfig()->provider == GPS_UBLOX || gpsConfig()->provider == GPS_UBLOX7PLUS)) {
3474+
cliPrint("GPS: ");
3475+
cliPrintf("HW Version: %s Proto: %d.%02d Baud: %d", getGpsHwVersion(), getGpsProtoMajorVersion(), getGpsProtoMinorVersion(), getGpsBaudrate());
3476+
cliPrintLinefeed();
3477+
//cliPrintLinef(" GNSS Capabilities: %d", gpsUbloxCapLastUpdate());
3478+
cliPrintLinef(" GNSS Capabilities:");
3479+
cliPrintLine(" GNSS Provider active/default");
3480+
cliPrintLine(" GPS 1/1");
3481+
if(gpsUbloxHasGalileo())
3482+
cliPrintLinef(" Galileo %d/%d", gpsUbloxGalileoEnabled(), gpsUbloxGalileoDefault());
3483+
if(gpsUbloxHasBeidou())
3484+
cliPrintLinef(" BeiDou %d/%d", gpsUbloxBeidouEnabled(), gpsUbloxBeidouDefault());
3485+
if(gpsUbloxHasGlonass())
3486+
cliPrintLinef(" Glonass %d/%d", gpsUbloxGlonassEnabled(), gpsUbloxGlonassDefault());
3487+
cliPrintLinef(" Max concurrent: %d", gpsUbloxMaxGnss());
3488+
}
3489+
34723490
// If we are blocked by PWM init - provide more information
34733491
if (getPwmInitError() != PWM_INIT_ERROR_NONE) {
34743492
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
@@ -1545,6 +1545,16 @@ groups:
15451545
default_value: OFF
15461546
field: ubloxUseGalileo
15471547
type: bool
1548+
- name: gps_ublox_use_beidou
1549+
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]."
1550+
default_value: OFF
1551+
field: ubloxUseBeidou
1552+
type: bool
1553+
- name: gps_ublox_use_glonass
1554+
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]."
1555+
default_value: OFF
1556+
field: ubloxUseGlonass
1557+
type: bool
15481558
- name: gps_min_sats
15491559
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."
15501560
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)