Skip to content

API Documentation

Dan edited this page Nov 30, 2025 · 4 revisions

Control Interface

class

osmoctrl.CtrlInterface(server: str, port: int, timeout=10)

This class represents the Osmocom Control Interface connection, and is used to GET and SET vars.

Parameters:

  • server (str) - The IP address of the Osmocom Control Interface host.
  • port (int) - The port of the Osmocom Control Interface.
  • timeout (int | 10) - The maximum time to wait for a response to a message. Defaults to 10 seconds.

Properties:

  • TRAPS (list) - A list of TRAP messages received over the lifetime of the CtrlInterface() object.

Note: Retrieval of TRAP messages is handled by popping all messages out of the TRAPS list. This means that the list is functionally a queue, and is emptied when called.

Usage Example:

ctrl = CtrlInterface('127.0.0.1', 4729)

method

get(var: str, parse_val = PARSE_VAL_DEFAULT)

Get a variable via the Osmocom Control Interface.

Parameters:

  • var (str) - The variable to retrieve.
  • parse_val (bool | True) - Should the returned value be parsed? Defaults to True.

Usage Example:

ctrl = CtrlInterface('127.0.0.1', 4729)

ctrl.get('subscriber.by-id-1.info-all')

method

set(var: str, val: str, parse_val = PARSE_VAL_DEFAULT)

Set a variable via the Osmocom Control Interface.

Parameters:

  • var (str) - The variable to set.
  • val (str) - The new value of the variable.
  • parse_val (bool | True) - Should the returned value be parsed? Defaults to True.

Usage Example:

ctrl = CtrlInterface('127.0.0.1', 4729)

ctrl.set('subscriber.by-id-1.msisdn', '123')

Exceptions

exception

osmoctrl.CtrlError(Exception)

Raised when the control interface returns an error.

Clone this wiki locally