Crates.io | nrfxlib |
lib.rs | nrfxlib |
version | 0.6.1 |
source | src |
created_at | 2019-09-29 15:13:03.912332 |
updated_at | 2024-06-17 14:45:52.001697 |
description | Rust driver for the LTE stack on the Nordic nRF9160 |
homepage | |
repository | https://github.com/42-technology-ltd/nrfxlib |
max_upload_size | |
id | 168611 |
size | 107,756 |
Rust nrfxlib wrapper for the nRF9160
This crate is published by 42 Technology Ltd.
This crate provides a Socket API for embedded applications running on the Nordic nRF9160.
Access to the LTE baseband on the nRF9160 is currently only available using
Nordic's closed-source binary blob - a static library called libbsd.a
, which
lives in a public Nordic git repo called nrfxlib
along with a few other bits
and pieces (see https://github.com/NordicPlayground/nrfxlib).
That library provides a Berkeley-ish socket API, with some extensions to the usual socket types so that you can open an AT socket to talk AT commands to the baseband, and a GNSS socket so you can read GPS data.
We use a crate called nrfxlib-sys
to link to the library. This crate includes
Nordic's header files and static library as a git sub-module (from their Github
page) and runs bindgen
to
generate Rust 'headers' which correspond to the functions and constants in the
relevant header files. You no longer need to install bindgen
- it gets pulled
in as a crate - but you do need to use Rust 1.51 or higher.
The basic premise is that this crate calls out to Nordic's library to do all the work, and it just presents some simple types to the user (which hopefully reduce the likelihood of the user getting something seriously wrong).
For example, Nordic's library uses standard C integers for their socket file
descriptors. We have wrapped these up in a Socket
struct, ensuring that
nrf_socket_close
is called when the Socket
object is dropped. You can also
no longer pass arbitrary integers to the read
and write
functions, and
instead you call methods on the Socket
type.
We have further specialised the Socket
into TlsSocket
, AtSocket
,
GnssSocket
and TcpSocket
, each with their own factory functions and
special methods. Support for UDP datagrams and other sorts of sockets is TBD -
pull requests are welcome!
If you want to make a TLS connection, you need to first push the certificates
and keys into a special area of flash controlled by the Nordic library. You
can do this with the provision_certificates
function. Each certificate or
key is given a unique integer tag (by you), and you pass these tags when you
create the TlsSocket
so the stack knows which certificates you want to use.
You at least need to supply a root certificate to be used for verifying the
server-side certificate. You can optionally also supply a client-side
certificate and private key, for performing client authentication.
See nrf9160-demo for a demo application that uses this library.
nrf_modem_init
. The nrf_modem_init_params
pointer given to the init must
have a static lifetime. This has been a stack variable since forever.bsd_X
to nrf_modem_X
heapless::consts::Uxx
clone
for Error
.nrxflib-sys
crate.modem::start()
to modem::on()
and removed called to AT+COPS=0.nrf_poll
to pend on multiple sockets at once.GnssSocket::get_blocking_fix()
nrfxlib-sys
which has a cargo-5730 workaround.First release.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.