During testing and code inspection, there were various anti-patterns on this (and U-Blox driver) codebase(s), including obfuscation, and lack of data validation. This made it increasingly difficult to introduce further variants of u-blox GNSS modems. With this patch, both the UBX modem and the M8 driver have been refactored to ease the reliability and maintainability of these codebases. Here are some highlights: WRT UBX modem: - Helper macros to easily create UBX frames, (including checksum calculation), at compile time; thus, making it easier to extend UBX commands. - Logic validation by the inclusion of the modem_ubx testsuite, used to refactor the code through TDD. - Ability to receive unsolicited messages, in order to enable U-Blox drivers to rely on modem_ubx to transceive all commands, and avoid hopping between modem_ubx and modem_chat. WRT M8 driver: - Remove GNSS specific protocol header files. Instead, unify them under modem/ubx/protocol.h. Background: After a survey and looking at ubxlib SDK I conclude the UBX protocol is by definition a GNSS protocol (there are non-GNSS u-blox modems, but they're not interfaced through UBX protocol). - Establish pattern to create and send/receive commands using new foundations on modem ubx. - Remove dependency of Modem chat, and instead use UBX unsolicited messages to get Navigation and Satellites data. - Switch from the auto-baudrate detection pattern to a pattern of transitioning between an initial known baudrate to a desired baudrate, in order to improve initialization time. - Add dts property to configure default fix-rate. Signed-off-by: Luis Ubieda <luisf@croxel.com> |
||
|---|---|---|
| .. | ||
| boards | ||
| src | ||
| CMakeLists.txt | ||
| prj.conf | ||
| README.rst | ||
| sample.yaml | ||
.. zephyr:code-sample:: gnss
:name: GNSS
:relevant-api: gnss_interface navigation
Connect to a GNSS device to obtain time, navigation data, and satellite information.
Overview
********
This sample demonstrates how to use a GNSS device implementing the
GNSS device driver API.
Requirements
************
This sample requires a board with a GNSS device present and enabled
in the devicetree.
Sample Output
*************
.. code-block:: console
gnss: gnss_info: {satellites_cnt: 14, hdop: 0.850, fix_status: GNSS_FIX, fix_quality: GNSS_SPS}
gnss: navigation_data: {latitude: 57.162331699, longitude : 9.961104199, bearing 12.530, speed 0.25, altitude: 42.372}
gnss: gnss_time: {hour: 16, minute: 17, millisecond 36000, month_day 3, month: 10, century_year: 23}
gnss has fix!
gnss: gnss_satellite: {prn: 1, snr: 30, elevation 71, azimuth 276, system: GLONASS, is_tracked: 1}
gnss: gnss_satellite: {prn: 11, snr: 31, elevation 62, azimuth 221, system: GLONASS, is_tracked: 1}
gnss reported 2 satellites!