Files
infix/src/statd
Joachim Wiberg 7b7baa0730 modem: expose location and last-change in operational state
Cellular modem location data (GPS coordinates, 3GPP cell info) was
previously CLI-only — 'show modem modem0' shelled out to modem-info
which queried mmcli on demand and rendered straight to terminal.
NETCONF/RESTCONF clients had no view into modem location, and there
was no way to tell how stale any modem-state field was.

This commit moves both into the YANG operational tree so they are
accessible through every northbound interface, not just the CLI.  It
is Phase 1 of the modem GPS / location integration plan; Phase 2 will
route the modem's NMEA TTY into the existing gpsd → chronyd pipeline
so cellular modems can also serve as an NTP fallback time source.

YANG (infix-hardware.yang, revision 2026-05-10):
  - modem-state/last-change (yang:date-and-time): freshness indicator
    for the modem-state subtree, bumped on each modemd poll cycle
  - modem-state/location-state container: source (gps|3gpp|...),
    latitude/longitude/altitude (decimal64 6/6/1 fraction-digits),
    cell-id/lac/tac/mcc/mnc, and its own last-change

Runtime path:
  - modemd's check_location() now writes
    /run/modemd/modemN/location/data.json with the full location data
    plus an RFC3339 last-change.  Atomic via tmp+rename.  Walks the
    mmcli output once instead of twice.
  - check() touches /run/modemd/modemN/state.json with a fresh
    last-change after each successful state poll.
  - yanger/infix_modem.py reads both files via HOST.read_json and
    folds them into the modem-state operational subtree.
  - cli_pretty show_modem_detail rewritten to consume the operational
    tree (same path as 'show modem' overview), with new 'Last Update'
    lines for both top-level state and location.
  - bin/show/modem() consolidated: both 'show modem' and
    'show modem REF' use get_json('/ietf-hardware:hardware') — no
    more direct modem-info subprocess call.

Cleanup along the way:
  - Removed the legacy /run/modemd/modemN/location/{up,down,disabled,
    failed} marker file writes — they had no readers anywhere in the
    tree.  In-memory self.location['state'] is kept purely as the
    edge-trigger for the 'Retrieved GPS location' log line.
  - Aligned now_rfc3339() output with yanger.common.YangDate (+00:00
    form, not Z) so consumers see one consistent yang:date-and-time
    format regardless of producer.
  - Fixed multi-modem SIM scoping in show_modem_detail: now derives
    sim<N> from modem<N> instead of picking the first SIM globally.

The bearer / hardware-revision / phone-number / supported-carrier
sections of 'show modem REF' are deliberately omitted for now —
those fields are not yet in the YANG tree.  Bearer details in
particular likely belong on the wwan interface
(ietf-interfaces:interfaces-state) rather than on the modem hardware
component, and can be addressed in a follow-up.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2026-06-07 20:51:02 +02:00
..
2026-03-22 20:23:44 +01:00
2026-03-22 20:23:44 +01:00
2024-02-29 08:44:08 +01:00
2024-04-16 12:47:16 +02:00

Introduction

Statd is designed to be integrated into Infix and supply the operational database with data. To do this it uses companion binaries written in python, these are located in the python directory.

Run outside Infix

Prerequisites

There are some requirements set on your computer to run statd locally.

  • An Ubuntu based system
  • lldpd
  • python3
  • libite
  • libsrx
  • python-poetry
  • sysrepo (At least the same version as Infix)
  • libyang (At least the same version as Infix)

Install YANG modules in local sysrepo

This requires that you first build Infix, since netopeer2 and sysrepo are responsible for installing their own YANG files.

user@host ~/infix$ export TARGET_DIR="output/target/"
user@host ~/infix$ export NETOPEER2_SEARCHPATH=$TARGET_DIR/usr/share/yang/modules/netopeer2/
user@host ~/infix$ export SYSREPO_SEARCHPATH=$TARGET_DIR/usr/share/yang/modules/sysrepo/
user@host ~/infix$ export LIBNETCONF2_SEARCHPATH=$TARGET_DIR/usr/share/yang/modules/libnetconf2/
user@host ~/infix$ export CONFD_SEARCHPATH=$TARGET_DIR/usr/share/yang/modules/confd/
user@host ~/infix$ export TEST_MODE_SEARCHPATH=$TARGET_DIR/usr/share/yang/modules/test-mode/
user@host ~/infix$ export ROUSETTE_SEARCHPATH=$TARGET_DIR/usr/share/yang/modules/rousette/
user@host ~/infix$ export SEARCH_PATH="$NETOPEER2_SEARCHPATH $SYSREPO_SEARCHPATH $LIBNETCONF2_SEARCHPATH $CONFD_SEARCHPATH $TEST_MODE_SEARCHPATH $ROUSETTE_SEARCHPATH"

user@host ~/infix$ ./utils/srload src/confd/yang/sysrepo.inc
user@host ~/infix$ ./utils/srload src/confd/yang/libnetconf2.inc
user@host ~/infix$ ./utils/srload src/confd/yang/netopeer2.inc
user@host ~/infix$ ./utils/srload src/confd/yang/confd.inc
user@host ~/infix$ ./utils/srload src/confd/yang/rousette.inc
user@host ~/infix$ ./utils/srload src/confd/yang/test-mode.inc

Build and install python companion binaries

user@host ~/infix/src/statd/python$ ./local_install.sh

This will install the binaries in ~/.local/bin

Build and install statd

user@host ~/infix/src/statd$ ./configure --with-yanger-dir=$HOME/.local/bin
user@host ~/infix/src/statd$ make
user@host ~/infix/src/statd$ sudo make install

Running statd

Since the yanger binary, for example, reads the shadow database, you can expect different results if running statd as root or not.

user@host ~/infix/src/statd$ statd