MCCI has released version 6.1.0 of the MCCI LoRaWAN LMIC library for Arduino, the open-source LoRaWAN stack for the Semtech SX127x and SX126x radios.
A battery-powered device can now keep its LoRaWAN session through deep sleep or a reset. LMIC_saveSessionState() copies the session state into a buffer, which the application stores with the session keys in flash, FRAM or RTC memory. After a wake-up, LMIC_restoreSessionState() puts the state back, and the device sends its next uplink without joining again. The saved state holds the frame counters, the settings and channels that the network sent, and the duty-cycle waits. Until now, applications did this by copying the library’s internal structure, which broke whenever the structure changed.
The library also tells the application when it can sleep. os_queryNextJobTicks() reports how long it is until the LMIC next needs the processor, and os_runloop_once_ex() runs any pending work and returns the same figure. A new example, ttn-otaa-session-sleep, shows both features together.
Other changes in 6.1.0:
- FSK transmit and receive now work on the SX127x and SX126x radios.
- Join-Requests stay within the airtime limits of LoRaWAN 1.0.4, and the DevNonce counts up from a value the application can save.
- Accessor functions, named as in the LoRaWAN specification, read the fields that applications used to take from the
LMICstructure. - An application can request a link check, query the channel list, and set the ADR_ACK limits at run time.
LMIC_getRSSI()returns the RSSI of the last received frame in dBm, so a sketch no longer needs to correctLMIC.rssiitself.
The SX126x driver, used with the SX1261 and SX1262, has a series of fixes. Class C receive keeps running after an uplink. The driver allows time for the radio’s cold-start setup and opens each receive window at the right time. The DIO2 RF switch check works, and RSSI and SNR of received frames are valid. Boards can set the crystal trim.
The release adds pin maps for the MCCI Catena 5220 and 5230 and the MCCI Model 4916, 4917, 4931 and 4933.
One change can stop an existing sketch from compiling. The Class B code (beacon tracking and ping slots) is untested, so the library no longer compiles it by default. A sketch that uses Class B must set LMIC_ENABLE_class_b to 1 in its project configuration. Other builds get about 2 KB smaller.
Thanks to Pontus Oldberg, who made ABP work with the secure element and added crystal trim settings for SX126x boards; to @gerontec, who found and fixed an encryption error in frames of 128 bytes or more; and to Stephen Horvath, who added support for the SX127x chip version used in the S76G.
We developed and tested 6.1.0 on a hardware-in-the-loop bench. A RedwoodComm RWC5020B tester acts as the LoRaWAN gateway and network server: an MCCI Catena 4612, connected to it by RF cable, joins it, takes downlinks from it, and keeps its frame counters against it. An ST-LINK/V2 programs and resets the board. It connects through an MCCI Model 2101 Connection Exerciser, so a script can disconnect the probe. Another script logs the board’s USB console with timestamps. MCCI’s open-source Python libraries control the RWC5020B (rwc-python-api) and the Connection Exercisers (cricketlib), and a Nordic Power Profiler Kit II can power a board and measure its sleep current. With this bench, Claude Code, working under our direction, could reproduce a bug, try a fix and confirm it on a real radio. The session example ran in all seven band plans, EU868, US915, AU915, AS923, AS923 Japan, KR920 and IN866: join, downlink, restart from the saved session, and more uplinks with the frame counter continuing, with the script switching the tester between regions. A later post will describe the bench.
APIs added in v6.1 describes the new functions and what to check when upgrading from 6.0. The release notes list every change. The Arduino Library Manager lists the library as “MCCI LoRaWAN LMIC library”.