Files
rockblock9704-zephyr/docs/TESTING.md
T
scottp a70e933b71 0.3.0: provisioning and messages to Cloudloop work, and P_EN is active low
The M5Stamp-C3 under open sky, driven over WiFi from its shell, found
the modem provisioned with topics 244 and 313 to 317 and sent two
messages on topic 244, 16 and 17 bytes. Each was with the network 6 to
10 s after the modem took it, and both arrived in Cloudloop whole.
docs/CLOUDLOOP.md, "What has run", records how Cloudloop shows one: the
same bytes in Base64 and in hex.

P_EN is the RockBLOCK's supercapacitor charge enable, header pin 6, and
it is active low. The sample's overlays had it GPIO_ACTIVE_HIGH, so every
begin switched the charger off: the modem ran down and went silent 2 to
5 minutes later, four times indoors and out. The overlays, the README
and the binding now say GPIO_ACTIVE_LOW. With P_EN wired again on the
new firmware the modem stayed up past every earlier drop and sent the
second message.

The control pins follow Ground Control's start-up and shutdown
sequence. I_EN starts and stops the modem and is what makes the pins
present (CONFIG_RB9704_POWER follows iridium-enable-gpios); P_EN and
I_BTD are optional beside it. Shutdown drives I_EN low and waits for
I_BTD to go low before anything else, as start-up waits for it to go
high, so I_EN never moves back before I_BTD has followed. P_EN is driven
only while the modem runs and released to an input while it is off.

docs/boards/stamp_c3.md has the header's pin numbers, V_IN+ against
V_BATT, and P_EN as the cause of the drops. The module, the sample and
the Python tools are 0.3.0.
2026-10-25 22:48:11 +11:00

7.6 KiB

Testing

One fake modem, three places to run the code against it, and a few free checks against a real modem.

Level What runs Against Needs
Python Ground Control's Python binding, the rb9704 command line, the fake itself the fake on a pty Python 3.10 to 3.14
Host Zephyr this module in the shell sample on native_sim the fake on a pty, or a real modem on USB a Zephyr workspace
Board the same sample on an ESP32-S3, STM32U5 or any board the fake on a USB-serial port wired to the board's modem pins a board and a wire

The native_sim and board runs are the same tests (python/tests/test_zephyr.py) through a different console, so a behaviour seen on one is checked on the other.

The fake modem

python/rb9704tools/fakemodem.py, rb9704-fake on the command line. It implements JSPR as JSPR.md describes it: the three exchanges rbBegin needs, the identity and signal getters, provisioning, MO in segments of any size with the CRC checked, MT in segments the library can take, and on command a refusal, a failed MO, a signal change or a change of provisioning. It writes every whole MO it receives as an event line, so a test checks the bytes that reached "the network".

What it cannot tell you is what a real modem does that the library's source does not show: unsolicited lines at odd moments, timing, MT segment sizes. That is what test_real.py and the hardware are for.

Running them

python/install.sh

# Python level: the fake, the command line, Ground Control's binding
python/.venv/bin/pytest -q python/tests

# Host Zephyr: build the sample for native_sim, then
west build -b native_sim/native/64 samples/shell -d build/native
python/.venv/bin/pytest -q python/tests --zephyr-exe build/native/zephyr/zephyr.exe

# Board: flash the sample with its modem UART wired to a USB-serial
# adapter (3.3 V), then the board's shell port and the adapter's port
python/.venv/bin/pytest -q python/tests/test_zephyr.py \
    --board-console /dev/ttyACM0 --board-modem /dev/ttyUSB0

# A real modem, free checks only (identity and signal, never a message)
python/.venv/bin/pytest -q python/tests/test_real.py --real-modem /dev/ttyUSB0 \
    [--zephyr-exe build/native/zephyr/zephyr.exe]

Every option has an environment variable as well: RB9704_ZEPHYR_EXE, RB9704_BOARD_CONSOLE, RB9704_BOARD_MODEM, RB9704_REAL_MODEM.

On native_sim the modem UART is a zephyr,native-tty-uart node (samples/shell/boards/native_sim.overlay); the tests give it the fake's pty with -modem_uart_port=. The same option takes a real modem's /dev/ttyUSB0, which is how host Zephyr talks to real hardware.

The rig: two boards, one wire

No USB-serial adapter to hand? Two boards with a UART wired between them will do: one runs the sample, the other runs tests/rig/bridge, which copies bytes between that UART and its own USB serial port, where the fake answers.

host --USB-- bridge board --UART-- board under test --USB-- host
             (tests/rig/bridge)    (samples/shell)
  fake modem on this port                       pytest drives this shell

The overlays in tests/rig/ are for a NUCLEO-U575ZI-Q (USART2 on PD5 and PD6) and a Seeed XIAO ESP32S3 (D8 and D9) wired to each other, either way round:

Under test Bridge --board-console --board-modem
XIAO ESP32S3, -DDTC_OVERLAY_FILE=tests/rig/xiao_esp32s3_rig.overlay Nucleo, tests/rig/bridge the XIAO's USB the Nucleo's ST-LINK port
Nucleo, -DDTC_OVERLAY_FILE=tests/rig/nucleo_u575zi_q_rig.overlay XIAO, tests/rig/bridge the Nucleo's ST-LINK port the XIAO's USB

The ESP32-S3 sits in its ROM loader after west flash until it is reset; toggle RTS on its USB port, or press reset, before the tests.

Out of doors: the shell over WiFi

A real modem needs the sky, and the sky is rarely where the USB cable reaches. samples/shell/overlay-wifi.conf puts the same shell on telnet, on any ESP32 board, so the board needs only power:

west build -b stamp_c3 samples/shell -- -DEXTRA_CONF_FILE=overlay-wifi.conf
west flash

Once, on the USB console, store the network; it is kept in flash:

wifi cred add -s "<SSID>" -k 1 -p "<password>"

At every boot after, the board joins it, logs address 192.168.1.50: telnet 192.168.1.50, and rejoins after a drop. A network added after boot is joined within 30 s. wifi cred list and wifi cred delete <SSID> look after the stored list; net iface shows the address again.

telnet 192.168.1.50
rb9704 begin
rb9704 spy on
rb9704 info

Telnet has no password and no encryption, and rb9704 send costs airtime: use it on a network you trust.

The Linux telnet client stays in line mode, where the up arrow and line editing do nothing: Ctrl-] then mode character fixes it, or connect with socat -,rawer,escape=0x1d TCP:<address>:23.

On the M5Stamp-C3 the board's RGB LED shows the modem's state and its button begins and ends it; boards/stamp_c3.md has the table, the pins and the WiFi commands.

Wiring

The board overlays for the M5Stamp-C3, ESP32-S3-DevKitC, ESP32 DevKitC and NUCLEO-U575ZI-Q wire all three control lines, so rb9704 begin starts the modem through I_EN and waits for I_BTD to say it has booted, and rb9704 power off waits for I_BTD to say it has shut down.

9704 header M5Stamp-C3 ESP32-S3-DevKitC ESP32 DevKitC NUCLEO-U575ZI-Q
14, RXD (board TX) GPIO4 GPIO17 GPIO17 PD8
13, TXD (board RX) GPIO5 GPIO18 GPIO16 PD9
3, I_EN GPIO6 GPIO4 GPIO25 PF14 (D4)
7, I_BTD GPIO7 GPIO5 GPIO26 PF13 (D7)
6, P̅_E̅N̅, active low, optional GPIO10 GPIO6 GPIO27 PF15 (D2)
1, 4 or 10, GND GND GND GND GND

The modem's supply goes to V_IN+ and V_IN- (pins 15 and 16), 4.0 to 5.3 V at up to 500 mA, not the board's 3.3 V regulator; V_BATT (pin 12) is for a lithium cell, never 5 V. P_EN is the supercapacitor charge enable and is active low: driven high it switches the charger off, and the modem runs down within minutes. Leaving it unconnected is fine.

A fake modem on a USB-serial adapter in place of the 9704 has no I_BTD: build with no-control-pins.overlay, below, or with the rig overlays, which have no control lines. Tying I_BTD to 3.3 V gets begin going, but power off then waits 30 s for it to fall and fails.

For a modem on TX and RX alone, samples/shell/no-control-pins.overlay takes the three lines out of any board's overlay at build time: -DEXTRA_DTC_OVERLAY_FILE=no-control-pins.overlay.

What has passed

On 2026-10-09, Zephyr v4.4.0, Ground Control's library v1.0.1, the binding 1.0.2:

Level Tests Result
Python: fake, command line, binding 16 all pass
native_sim/native/64 against the fake 12 all pass
XIAO ESP32S3 through the rig 12 all pass
NUCLEO-U575ZI-Q through the rig 12 all pass
a real 9704 (firmware v1.5.14), binding and native_sim, free checks 2 all pass

On 2026-10-25, the M5Stamp-C3 (ESP32-C3, RISC-V) with the shell over WiFi, and a real 9704 on its header pins, TX and RX only, powered from the Stamp's 5V: begin, info and signal all answer, nothing dropped (boards/stamp_c3.md).

Later the same day, under open sky with P_EN unconnected: provisioned with topics 244 and 313 to 317, and one message, 16 bytes on topic 244, sent from the Stamp's shell over telnet and received in Cloudloop. The first message through a real modem and satellite.

Then the reworked control pins outside, P_EN wired and active low: up over 6 minutes, past every earlier drop, and a second message, 17 bytes on topic 244, received in Cloudloop.

Not yet: an MT message down to the board.