nRF Example Code
Note: These are legacy C reference examples. For new development, use the Rust SDK examples with the Rust SDK instead.
C example code for using the Xylolabs API on Nordic Semiconductor nRF platforms.
The nRF9160 is the supported nRF target; for maintained firmware use the nrf9160-lte Rust example.
Design Principles
Zephyr RTOS
All examples use the nRF Connect SDK which is built on Zephyr RTOS. Zephyr provides portable abstractions for GPIO, I2C, SPI, BLE, and power management across nRF devices.
// Zephyr device tree binding (preferred over direct register access)
static const struct device *accel = DEVICE_DT_GET(DT_NODELABEL(lis2dh));
static const struct device *temp = DEVICE_DT_GET(DT_NODELABEL(hts221));
// Zephyr sensor API
sensor_sample_fetch(accel);
sensor_channel_get(accel, SENSOR_CHAN_ACCEL_XYZ, &accel_val);
Legacy C Build
These examples use the nRF Connect SDK
and the west build tool. Tested with nRF Connect SDK v2.x.
# Initialize nRF Connect SDK workspace (one-time)
west init -m https://github.com/nrfconnect/sdk-nrf --mr v2.6.0 nrf-workspace
cd nrf-workspace
west update
# Build for nRF9160 DK
west build -b nrf9160dk_nrf9160ns docs/examples/nrf/
# Flash
west flash
# Monitor serial output
screen /dev/ttyACM0 115200
API Documentation Reference
- API Reference -- XMBP protocol, ingest sessions, audio uploads, API key management, device management