• Stars
    star
    299
  • Rank 139,269 (Top 3 %)
  • Language
    C
  • License
    Apache License 2.0
  • Created almost 4 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Portable C libraries which provide APIs to build applications with u-blox products and services. Delivered as add-on to existing microcontroller and RTOS SDKs.

important message

Introduction to ubxlib

This repository contains an add-on to microcontroller and RTOS SDKs for building embedded applications with u-blox products and services. It provides portable C libraries which expose APIs with examples. ubxlib supports u-blox modules with cellular (2G/3G/4G), short-range (Bluetooth and Wi-Fi) and positioning (GNSS) functionality. The ubxlib libraries present high level C APIs for use in customer applications (e.g. connect to a network, open a TCP socket, establish location, etc.) and implements these APIs on selected popular MCUs, also available inside u-blox modules.

The goal of ubxlib is to deliver a single tested solution, with examples, which provides uniform easy-to-use APIs across several u-blox products. Releases of ubxlib are tested automatically for all configurations on multiple boards in a test farm.

ubxlib high level overview

The easiest way to quickly explore ubxlib is to start with a board listed in the test farm. u-blox EVKs (evaluation kits) or application boards can be found here or at major electronics distributors and code examples which run on the u-blox XPLR-IOT-1 platform can be found here. If you've heard enough and want to get started with the XPLR-IOT-1 platform, or maybe with PlatformIO, jump straight to How To Use This Repo below.

ubxlib runs on a host microcontroller and has a peripheral attached. This setup is very common in embedded applications. An example of such a host-peripheral configuration with EVK-NINA-B301 (Bluetooth 5.0) and EVK-R4 (SARA-R4 with 2G/3G/4G) in which the ubxlib host sets up a TCP connection is shown in the following figure. Many other combinations can be achieved, with the supported hosts and peripherals in the tables in the next section.

EVK setup

APIs

The key APIs provided by this repo, and their relationships with each other, are shown in the picture below.

APIs

  • If you wish to bring up a device/network and don't care about the details, use the common device and network APIs, which can bring up cellular, BLE/Wi-Fi or GNSS network(s) at your choosing.
  • If you wish to use a socket over that network, use the common sock API.
  • If you wish to use security, use the common security API.
  • If you wish to contact an MQTT broker over that network, use the common mqtt_client API.
  • If you wish to use HTTP, use the common http_client API.
  • If you wish to get a location fix use the common location API.
  • If you wish to take finer control of cellular, ble, wifi or gnss, use the respective control API directly.
  • GNSS may be used via the gnss API.
  • The BLE and Wi-Fi APIs are internally common within u-blox and so they both use the common short_range API.
  • The at_client API is used by the cellular and short range APIs to talk to AT-based u-blox modules.
  • The ubx_protocol API implements the necessary encoding/decoding to talk to u-blox GNSS modules.
  • The port API permits all of the above to run on different hosts; this API is not really intended for customer use - you can use it if you wish but it is quite restricted and is intended only to provide what ubxlib needs in the form that ubxlib needs it.

All APIs are documented with Doxygen compatible comments: simply download the latest Doxygen and either run it from the ubxlib directory at a command prompt or open Doxyfile in the Doxygen GUI and run it to obtain the output.

Supported ubxlib host platforms and APIs

Hosts run ubxlib and interact with an attached periperal. A host platform contains an MCU, toolchain and RTOS/SDK as listed in the table below. Hosts are typically u-blox open CPU (standalone) modules or other MCUs. To use a host you need a development board or an EVK. Currently ubxlib supports and tests the following purchasable boards out-of-the box.

If your MCU is on the list but your board is not:

  • just set the HW pins in the source file of the example to match how your MCU is wired to the u-blox peripheral.

If your MCU is not on the list:

  • if you are using PlatformIO and Zephyr then any MCU that Zephyr supports should work with ubxlib, just follow the instructions here to bring ubxlib into your existing PlatformIO environment,
  • otherwise, to port ubxlib to a new host platform follow the DIY instructions for the port API.
ubxlib hosts NINA-W10 NINA-B40 series
NINA-B30 series
NINA-B1 series
ANNA-B1 series
NORA-B1 series C030 board PC* PC*
MCU Espressif ESP32 Nordic nRF52 Nordic nRF53 ST-Micro STM32F4 x86 (win32) x86 (32-bit Linux)
Toolchain ESP-IDF
Arduino-ESP32
GCC
nRF Connect
nRF Connect Cube MSVC Zephyr
RTOS/SDK FreeRTOS FreeRTOS
Zephyr
Zephyr FreeRTOS Windows Zephyr
APIs provided by host with peripheral attached** wifi
ble
device
network
sock
ble
device
network
ble
device
network
cell
device
network
sock
location***
TLSย security
N/A N/A

* For development/test purposes only.
** Only SPS API provided for native (on-chip) BLE interface, other APIs for native (on-chip) access, e.g. WiFi support, are a work in progress.

Supported modules as ubxlib peripherals and APIs

Peripherals are u-blox modules which accept commands (e.g. AT-commands) over a serial interface and have no open MCU environment. To run the APIs they need to be attached to a host which runs ubxlib. For example in the test farm combinations of hosts and peripherals are listed.

ubxlib peripherals NINA-B41 series
NINA-B31 series
NINA-B1 series
ANNA-B1
NINA-W13 NINA-W15 SARA-U2 series SARA-R4 series
SARA-R5 series
LARA-R6 series
SARA-R510M8S
SARA-R422M8S
M8/M9/M10 series
APIs provided by host with peripheral attached ble
device
network
wifi
device
network
sock
TLSย security
mqtt_client
wifi
ble
device
network
sock
TLSย security
mqtt_client
cell
device
network
sock
location*
TLSย security
http_client
cell
device
network
sock
location***
security
mqtt_client
http_client
All APIs of
SARA-R4,
SARA-R5 seriesย +
gnss
location
gnss
location

*** Through the u-blox CellLocate mobile network-based location service.

Structure of ubxlib

The APIs for each type of u-blox module can be found in the relevant directory (e.g. cell for cellular modules and ble/wifi for BLE/Wi-Fi modules). The common directory contains APIs and 'helper' modules that are shared by u-blox modules, most importantly the device API, the network API and the sockets API. All APIs are documented in the API header files.

Examples demonstrating the use of the APIs can be found in the example directory. If you are using Zephyr or the u-blox XPLR-IOT-1 platform you will find examples that are very simple to install and use in https://github.com/u-blox/ubxlib_examples_xplr_iot.

Each API includes a test sub-directory containing the tests for that API which you may compile and run if you wish.

Build information for each platform can be found in the platform sub-directory of port; more on this below.

In order for u-blox to support multiple platforms with this code there is also a port API. This is not intended to be a generic porting API, it is simply sufficient to support the APIs we require. If you have not chosen a supported platform you may still be able to use the high level APIs here unchanged by implementing the port API for your platform.

+---example                    <-- examples that introduce the main features 
+---cfg                        <-- global configuration header files
+---common                     <-- APIs that are common across u-blox modules
ยฆ   +---device                 <-- the simple device API for opening cell, short-range (i.e. BLE or Wi-Fi) and GNSS modules
ยฆ   ยฆ   +---api                <-- all folders, in general, have an API directory
ยฆ   ยฆ   +---src                    containing public headers, a source directory with
ยฆ   ยฆ   +---test                   the implementation and a test directory with the tests
ยฆ   +---network                <-- the simple network API for BLE, cell, Wi-Fi and GNSS
ยฆ   +---sock                   <-- the sockets API for cell, Wi-Fi (and in the future BLE)
ยฆ   +---security               <-- common API for u-blox security and TLS security/credential storage
ยฆ   +---mqtt_client            <-- common MQTT client API
ยฆ   +---http_client            <-- common HTTP client API
ยฆ   +---location               <-- common location API, can use GNSS, Cell Locate, Cloud Locate and in the future Wi-Fi/BLE stations, etc.
ยฆ   +---short_range            <-- internal API used by the BLE and Wi-Fi APIs (see below)
ยฆ   +---at_client              <-- internal API used by the BLE, cell and Wi-Fi APIs
ยฆ   +---ubx_protocol           <-- internal API used by the GNSS API
ยฆ   +---spartn                 <-- message validation utilities for SPARTN
ยฆ   +---error                  <-- u_error_common.h: error codes common across APIs
ยฆ   +---assert                 <-- assert hook
ยฆ   +---utils                  <-- contains common utilities
ยฆ   ...
+---cell                       <-- API for cellular (if you need more than network provides)
+---wifi                       <-- API for Wi-Fi (if you need more than network provides)
+---ble                        <-- API for BLE
+---gnss                       <-- API for GNSS
+---port                       <-- port API: maps to SDKs and MCU platforms, includes build metadata
    +---api
    +---test
    +---clib
    +---platform               <-- look here for the supported SDKs and MCU platforms
        +---<platform>         <-- e.g. esp-idf
        ยฆ   +---app            <-- main() for this platform: runs all examples and tests
        ยฆ   +---src            <-- implementation of the port API for this platform
        ยฆ   +---mcu            <-- configuration and build metadata for the MCUs supported on this platform
        ยฆ       +---<mcu>      <-- e.g. esp32
        ยฆ           +---cfg    <-- platform specific config (pins, OS things, MCU HW blocks)
        ยฆ           +---runner <-- a build which compiles and links all examples and tests
        +---static_size        <-- a build that measures RAM/flash usage
        +---common             <-- things common to all platforms, most notably...
            +---automation     <-- the internal Python automation scripts that test everything
            ...

How to use this Repo

There are a few possible approaches to adopting ubxlib. If you do not have a fixed environment (MCU, toolchain, RTOS, etc.) then the first two options offer an easy start; if you are constrained in how you must work (i.e. you must use a particular MCU or toolchain or RTOS), or you are happy to dive into the detail from the outset, then the third way is for you.

The Easy Way 1: XPLR IoT

If you would like to explore cellular, positioning, Wifi and BLE, along with a suite of sensors, all at once, you might consider purchasing a u-blox XPLR-IOT-1 platform and using the associated ubxlib examples repo, which allows you to install, build and run Zephyr-based applications.

The Easy Way 2: PlatformIO

ubxlib is supported as a PlatformIO library; if you have a board that either (a) runs Zephyr or (b) contains an ESP32 chip (running ESP-IDF or Arduino), then just follow the instructions here to load ubxlib directly into the PlatformIO Visual Studio Code-based IDE.

The Hard Way: Down in the Detail

This repo uses Git submodules: make sure that once it has been cloned you do something like:

git submodule update --init --recursive

...to obtain the submodules.

The native SDKs for each supported platform are used directly, unchanged, by this code. To use this repo you must first choose your MCU and associated platform. For instance, you might choose an STM32F4 MCU, which is supported via ST's STM32Cube IDE. Instructions for how to install and use each platform can be found in your chosen MCU sub-directory; for an STM32F4 MCU this would be port/platform/stm32cube/mcu/stm32f4.

Having chosen your MCU and installed the platform tools, navigate to the directories below your chosen MCU directory to find the required build information. For instance, you may find a runner directory, which is a generic build that compiles any or all of the examples and tests that can run on a given platform. In that directory you will find detailed information on how to perform the build.

Configuration information for the examples and the tests can be found in the cfg directory of your chosen MCU. Depending on how you have connected your MCU to a u-blox module you may need to override this configuration, e.g. to change which MCU pin is connected to which pin of the u-blox module. The README.md in the runner directory of your chosen MCU will tell you how to override conditional compilation flags in order to do this.

Examples

A number of examples are provided with this repo:

Technology Example
Cellular The sockets example brings up a TCP/UDP socket by using the device, network and sock APIs.
Cellular The end-to-end security example using the security API.
Cellular The PSK generation example using the security API.
Cellular The chip-to-chip security example using the security API.
Cellular A TLS-secured version of the sockets example.
Cellular An MQTT/MQTT-SN client using the MQTT/MQTT-SN client API.
Cellular An HTTP client using the HTTP client API.
Cellular CellLocate example.
Bluetooth See the BLE examples in the XPLR-IOT-1 ubxlib examples repo.
Wi-Fi The sockets example brings up a TCP/UDP socket by using the device, network and sock APIs.
GNSS location example using a GNSS chip connected directly or via a cellular module.
GNSS cfg_val example configuring an M9 or later GNSS chip with CFGVALXXX messages.
GNSS message example communicating directly with a GNSS chip, messages of your choice.
GNSS position example obtaining streamed position directly from a GNSS chip.

You may use the code from any of these examples as a basis for your work as follows:

  • Copy the source files for the example that is closest to your intended application to your project directory.
  • Remove all definitions and include files that are related purely to the ubxlib test system; for example you only need to include the ubxlib.h file and you will want the entry point to be something like int main() rather than U_PORT_TEST_FUNCTION(...).
  • Adapt the definitions needed for your example, see the include file u_cfg_app_platform_specific.h for your platform; some examples of definitions that need to be set are:
    • UART/I2C/SPI number and UART/I2C/SPI pins (i.e. for whichever transport is being used) connecting the MCU to the target module,
    • network credentials (e.g. Wi-Fi SSID and password).
  • Copy the make or cmake files from the runner directory of the port (port/platform/) of your chosen MCU and adapt them to your application:
    • point out the ubxlib directory by setting the UBXLIB_BASE variable,
    • remove any definitions related to the ubxlib test environment as you wish,
    • if needed, add the source file(s) of your application to the make/cmake files.
  • Build and flash your adapted example using your IDE of choice or command-line make/cmake.

General information about how to integrate ubxlib into a build system is available in the port directory and platform specific information is available in the platform specific port directory for your chosen MCU.

Feature Request and Roadmap

New features can be requested and up-voted here. The comments of this issue also contains an outlook about features of upcoming releases. Also it is the right place to discuss features and their priority.

License

The software in this repository is Apache 2.0 licensed and copyright u-blox with the following exceptions:

In all cases copyright, and our thanks, remain with the original authors.

Disclaimer

  • The software in this repository assumes the module is in a state equal to a factory reset.
  • If you modify the AT command sequences employed by ubxlib please take the time to debug/test those changes as we can't easily support you.

More Repositories

1

Altium-Designer-Library

Symbols and Footprints for Altium Designer
71
star
2

ublox-C099_F9P-uCS

58
star
3

3D-Step-Models-Library

Mechanical 3D Models in Step AP214 File Format
45
star
4

com2tcp

The com2tcp utility that comes with com0com updated to compile under MS Visual Studio C++ 2017.
C++
44
star
5

ubx-v2x

Simulation model of a baseband 802.11p transceiver
MATLAB
41
star
6

Android-u-blox-BLE

Android app for stand-alone Bluetooth low energy modules from u-blox.
Java
35
star
7

c209-aoa-tag

Bluetooth Direction Finding Tag sample application. Works with u-connectLocate.
C
31
star
8

CadSoft-Eagle-Library

Symbols and Footprints for CadSoft Eagle
29
star
9

cellular

Cellular API, compatible with LWIP, in C for embedded platforms.
C
22
star
10

iOS-u-blox-BLE

iOS app for stand-alone Bluetooth low energy modules from u-blox.
Swift
19
star
11

u-blox-sho-OpenCPU

Repository with sample code and examples for u-blox Open CPU modules.
C
19
star
12

Cadence-AllegroPCBDesigner-Library

Symbols and Footprints for Cadence Allegro PCB Designer
13
star
13

XPLR-HPG-software

C
13
star
14

m-center

Collection of AT scripts that can be incorporated and used on the u-blox m-center tool.
13
star
15

linux

u-blox Linux Kernel repository
C
12
star
16

blueprint-B200-NINA-B1

Schematics, layout and firmware for a small battery powered solution with the NINA-B1 Bluetooth Low Energy module
C
11
star
17

u-connectXpress-host-library

Host library for short range u-connectXpress modules with AT command and EDM support
HTML
10
star
18

XPLR-HPG-hardware

9
star
19

XPLR-IOT-1-hardware

ANTLR
8
star
20

ublox-odin-w2-drivers-binary-mbed-3

C
6
star
21

XPLR-IOT-1-software

C
6
star
22

blueprint-B201-NINA-B1-EVA-M8

Schematics, layout and source for a small solar powered solution with the NINA-B1 Bluetooth Low Energy module that also integrates EVA-M8 GNSS module
C
6
star
23

ubxlib_examples_xplr_iot

Examples of how to set up and run ubxlib on the XPLR IOT (Zephyr) platform.
Python
6
star
24

ublox-C099_F9P-mbed-3

6
star
25

nrg-nina-b1

Nina B1 software for energy harvesting experiment
C++
5
star
26

mbedOSLua

A very simple port of the Lua interpreter to mbedOS
C
5
star
27

mbed-examples-odin-w2-mbed-3

Example applications on how to use the u-blox ODIN-W2 drivers on mbed 3
C++
5
star
28

ublox-odin-w2-drivers-docs-mbed-5

Documentation for u-blox ODIN-W2 drivers for mbed 5
5
star
29

log-client

A simple embedded logging client for use with Mbed applications.
C++
4
star
30

evb-ant-1

C
4
star
31

battery-shield-factory-test

Factory test program for the primary battery shield, originally designed for the C030 board and carrying a BQ35100 battery monitoring chip
C++
4
star
32

meta-ublox

u-blox BSP meta layer for Yocto
BitBake
4
star
33

XPLR-IOT-1-Node-RED-dashboard

3
star
34

m2m-object-helper

Class to help with making LWM2M objects for Mbed Client/Mbed Cloud Client.
C++
3
star
35

tracker

A tracker
C++
3
star
36

XPLR-IOT-1-location-example

C
2
star
37

u-locateEngine

2
star
38

example_nbiot_pre_standard

C++
2
star
39

c030-tracker

Tracker example code for the C030 board: a port of the earlier Particle-based tracker code.
C++
2
star
40

ucxclient

AT client for 2nd gen uConnectXpress
C
2
star
41

arrayify

Utility to convert a text file into a const char array that can be included in C source code.
C++
2
star
42

open-source-licenses-cellular

2
star
43

blueprint-B204-NINA-B1

Schematics and layout for a small USB dongle solution with the NINA-B1 Bluetooth Low Energy module
2
star
44

C94-application-board-radio-firmware

C94 radio firmware for all country variants with flashing tool
2
star
45

u-blox-nina-b3-javascript

Repository with JavaScript libraries and examples for u-blox BLE module NINA-B3
2
star
46

extended-data-mode-example-application-py

Extended data mode example appliction for use with short range radio stand-alone modules
Python
2
star
47

ioc-server

Server for the Internet of Chuffs
Go
1
star
48

mbed-os-ublox-app

A basic executable that uses the u-blox port of mbedOS.
C++
1
star
49

c030-dev

Development area for C030 drivers etc.
C++
1
star
50

legacy-bmd-programmers

1
star
51

stdio-to-socket

Run a named application, redirecting its stdio to a socket.
C++
1
star
52

ioc-client

Internet of Chuffs client
C++
1
star
53

ltc2943

mbed driver for the Linear Technology LTC2943 Coulomb counter chip
C++
1
star
54

nina-w10-power-test

A test of low power modes of the NINA-W10 module on an EVK board.
C
1
star
55

infinite-iot

Embedded SW for the Technology Group (cellular)'s Infinite IoT energy harvesting board
C++
1
star
56

blueprint-B203-JODY-W1

1
star
57

accelerometer-adxl345

Driver for the ADXL345 3-axis accelerometer chip.
C++
1
star
58

XPLR-IOT-1-Air-Quality-Monitor-Example

C
1
star
59

blueprints_sho_altium

Design files and source code for blueprints/reference designs
Shell
1
star
60

XPLR-IOT-1

1
star
61

http-data-logger

Starts a web server listening on a given port and appends the body of any HTTP request received to a given file.
Go
1
star
62

ubxlib_evk_applications

Example applications which run on the EVK on Windows & Raspberry PI using the u-blox cellular EVK.
C
1
star