Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

Commit

Permalink
POSSIBLY BREAKING change to cellular routing of GNSS stream. (#1069)
Browse files Browse the repository at this point in the history
When using a GNSS chip connected via or inside a cellular module it is necessary to tell the cellular module how to route the GNSS stream using the AT+UGPRF command; for instance, bit position 1 (i.e. 0x02) means to route the stream to the CMUX channel. The ubxlib code used to OR this bit into the pre-existing AT+UGPRF set, however the problem with this is that, on some module types, certain bit combinations are not supported (e.g. SARA-R4 doesn't support sending to both CMUX and the USB interface at the same time) and, on some module types, certain bits are set by default (e.g. SARA-R4 sets the USB bit (bit 0 or 0x01) by default); this can result in illegal combinations being requested.

To avoid this the AT+UGPRF setting is now assigned, rather than ORed (so to route via CMUX it will be set to 0x02).

The POSSIBLY BREAKING part of this is, if the application has set its own routing by using uCellCfgSetGnssProfile(), that will now be overridden.

Should this present a problem you may set the conditional compilation flag U_CELL_PWR_GNSS_PROFILE_BITS_EXTRA at build time (default 0) and those bits will also be ORed into the "<GNSS_IO_configuration>" value of AT+UGPRF. Setting U_CELL_PWR_GNSS_PROFILE_BITS_EXTRA to a negative value will prevent ubxlib fiddling with AT+UGPRF at all.
  • Loading branch information
RobMeades authored Jan 23, 2024
1 parent c315b4f commit b7dffb7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion cell/src/u_cell_pwr.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@
(((value) + 1) * 256 / 100) : \
(((value) + 1) * 128 / 100))

#ifndef U_CELL_PWR_GNSS_PROFILE_BITS_EXTRA
/** The extra bits to OR into the GNSS IO configuration (AT+UGPRF);
* set a negative value and this code will not set AT+UGPRF.
*/
# define U_CELL_PWR_GNSS_PROFILE_BITS_EXTRA 0
#endif

/* ----------------------------------------------------------------
* TYPES
* -------------------------------------------------------------- */
Expand Down Expand Up @@ -884,8 +891,10 @@ static int32_t moduleConfigure(uCellPrivateInstance_t *pInstance,
uAtClientStreamHandle_t stream = U_AT_CLIENT_STREAM_HANDLE_DEFAULTS;
uCellPwrPsvMode_t uartPowerSavingMode = U_CELL_PWR_PSV_MODE_DISABLED; // Assume no UART power saving
char buffer[20]; // Enough room for AT+UPSV=2,1300
#if U_CELL_PWR_GNSS_PROFILE_BITS_EXTRA >= 0
char *pServerNameGnss;
int32_t y;
#endif

// First send all the commands that everyone gets
for (size_t x = 0;
Expand Down Expand Up @@ -1067,6 +1076,7 @@ static int32_t moduleConfigure(uCellPrivateInstance_t *pInstance,
uAtClientResponseStop(atHandle);
uAtClientUnlock(atHandle);
}
#if U_CELL_PWR_GNSS_PROFILE_BITS_EXTRA >= 0
// The module may have a GNSS module inside it or
// connected via it, in which case, if we are to use
// that module via CMUX rather than via the clunky
Expand All @@ -1082,12 +1092,13 @@ static int32_t moduleConfigure(uCellPrivateInstance_t *pInstance,
y = uCellPrivateGetGnssProfile(pInstance, pServerNameGnss,
U_CELL_CFG_GNSS_SERVER_NAME_MAX_LEN_BYTES);
if ((y >= 0) && ((y & U_CELL_CFG_GNSS_PROFILE_MUX) == 0)) {
y |= U_CELL_CFG_GNSS_PROFILE_MUX;
y = U_CELL_CFG_GNSS_PROFILE_MUX | U_CELL_PWR_GNSS_PROFILE_BITS_EXTRA;
uCellPrivateSetGnssProfile(pInstance, y, pServerNameGnss);
}
// Free memory
uPortFree(pServerNameGnss);
}
#endif
if (andRadioOff) {
// Switch the radio off until commanded to connect
// Wait for flip time to expire
Expand Down

0 comments on commit b7dffb7

Please sign in to comment.