-
Notifications
You must be signed in to change notification settings - Fork 3
DeviceManagerRESTAPI
The API for DeviceManager is included in the Raft API List
This endpoint operates in two modes:
-
Type lookup — supply a
typeparameter (device type name or device type index) to retrieve the static device type record from the firmware's device type database. -
Per-device lookup — supply a
deviceid(orbus+addr) to retrieve the type record for the device actually instantiated/detected at that address, along with optional sidecar fields (name,role) that have been assigned to that specific instance.
Per-device lookup is preferred when the caller wants instance-specific metadata (e.g. the friendly name or role tag) in addition to the type description.
| GET Parameter | Type | Required | Description |
|---|---|---|---|
type |
string | Type-lookup mode | The type name (e.g. LSM6DS) or numeric device type index. |
deviceid |
string | Per-device mode | Canonical device identifier <busNum>_<hexAddr> (e.g. 1_6a). For a static device the bus number is 0. |
bus |
string | Per-device mode | Bus name (e.g. I2CA) or bus number — used together with addr. |
addr |
string | Per-device mode | Device address as plain hex without 0x prefix (e.g. 6a). |
Note: A request with only
bus(noaddr) is treated as legacy type-name lookup mode (e.g.?bus=I2CA&type=LSM6DS) for backward compatibility.
# Type lookup by name
/devman/typeinfo?type=LSM6DS
# Type lookup by type index
/devman/typeinfo?type=5
# Per-device lookup (canonical id)
/devman/typeinfo?deviceid=1_6a
# Per-device lookup (bus + addr)
/devman/typeinfo?bus=I2CA&addr=6a
{
"req": "/devman/typeinfo?type=LSM6DS",
"devinfo": {
"name": "LSM6DS",
"desc": "6-Axis IMU",
"manu": "ST",
"type": "LSM6DS",
"resp": {
"b": 12,
"a": [
{
"n": "gx",
"t": "<h",
"u": "dps",
"r": [
-2000,
2000
],
"d": 16.384,
"f": ".2f",
"o": "float"
},
{
"n": "gy",
"t": "<h",
"u": "dps",
"r": [
-2000,
2000
],
"d": 16.384,
"f": ".2f",
"o": "float"
},
{
"n": "gz",
"t": "<h",
"u": "dps",
"r": [
-2000,
2000
],
"d": 16.384,
"f": ".2f",
"o": "float"
},
{
"n": "ax",
"t": "<h",
"u": "g",
"r": [
-4,
4
],
"d": 8192,
"f": ".2f",
"o": "float"
},
{
"n": "ay",
"t": "<h",
"u": "g",
"r": [
-4,
4
],
"d": 8192,
"f": ".2f",
"o": "float"
},
{
"n": "az",
"t": "<h",
"u": "g",
"r": [
-4,
4
],
"d": 8192,
"f": ".2f",
"o": "float"
}
]
}
},
"rslt": "ok"
}{
"req": "/devman/typeinfo?type=UnknownDevice",
"rslt": "error",
"error": "failTypeNotFound"
}Other failure reasons:
-
failTypeMissing: Missingtypeparameter (in type-lookup mode). -
failTypeNotFound: The specified type was not found. -
failInvalidDeviceId:deviceidwas supplied but is malformed. -
failBusNotFound: The supplied bus name/number could not be resolved. -
failDeviceNotFound: Per-device lookup could not find an installed/detected device at the supplied address.
When deviceid (or bus+addr) is supplied, the response also contains the canonical fields below. The name field is omitted entirely when no friendly name is mapped, and role is omitted when the role is the default (normal).
{
"req": "/devman/typeinfo?deviceid=1_6a",
"rslt": "ok",
"devinfo": { "name": "LSM6DS", "desc": "6-Axis IMU", ... },
"dtIdx": 5,
"name": "IMU1",
"role": "system"
}If the device has no type record (e.g. some statically-instantiated devices), devinfo is omitted but dtIdx, name, and role are still returned.
Description:
Sends a raw command to a device on a specified bus. Can write bytes and/or read bytes back. The device can be identified either by a canonical deviceid string or by separate bus and addr parameters — both options are supported.
Method: GET
| Parameter | Type | Required | Description |
|---|---|---|---|
deviceid |
string | One of deviceid or bus+addr
|
Canonical device identifier in the form <busNumber>_<hexAddr> (e.g., 1_6a). Takes precedence if present. |
bus |
string | One of deviceid or bus+addr
|
Bus name (e.g., I2CA) or bus number. |
addr |
string | One of deviceid or bus+addr
|
Device address as plain hex without 0x prefix (e.g., 6a for I2C address 0x6A). |
hexWr |
string | No | Hex-encoded bytes to write to the device. |
numToRd |
int | No | Number of bytes to read back from the device. |
msgKey |
string | No | Optional key for response correlation. |
# Option 1: canonical deviceid
/devman/cmdraw?deviceid=1_6a&hexWr=0F&numToRd=1
# Option 2: bus name and address
/devman/cmdraw?bus=I2CA&addr=6a&hexWr=0F&numToRd=1
{
"req": "/devman/cmdraw?bus=I2CA&addr=6a&hexWr=0F&numToRd=1",
"rslt": "ok"
}-
failBusMissing: Neitherdeviceidnorbusparameter provided. -
failMissingAddr: Neitherdeviceidnoraddrparameter provided. -
failBusNotFound: The specified bus was not found.
Description:
Routes a JSON command to a specific device. The JSON body must include a device field that matches the configured device name or device ID string. The response only indicates whether the command was successfully dispatched; any result from command execution should be obtained via device data updates or separate API calls.
Method: GET
| Parameter | Type | Required | Description |
|---|---|---|---|
body |
string | Yes | JSON command string; must include a device field. |
/devman/cmdjson?body={"device":"I2CA_20","cmd":"reset"}
-
failMissingBody: Missingbodyparameter. -
failDeviceNotFound: The specified device was not found. -
failNoDeviceSpecified: The JSON body did not include adevicefield. -
failCmdFailed: The command failed in the device handler.
Description:
This endpoint retrieves the bus name from a bus number. Bus numbers start from 1 and match the numbering used in device data JSON/binary messages. Only buses with valid device interfaces are numbered.
Method: GET
| Parameter | Type | Required | Description |
|---|---|---|---|
busnum |
int | Yes | The bus number to retrieve the name for. |
/devman/busname?busnum=1
{
"req": "devman/busname?busnum=1",
"rslt": "ok",
"busName": "I2CA"
}-
failInvalidBusNum: Missing or invalidbusnumparameter. -
failBusNotFound: The specified bus number was not found.
Description:
Configure polling parameters for a bus device at runtime. Supports setting the polling interval, the number of buffered samples, and the I2C bus speed override for polls. The device can be identified either by a canonical deviceid string or by separate bus and addr parameters — both options are supported. The response always includes the current values of pollIntervalUs, numSamples, busHz, and busHzSlots for the device, regardless of which parameters were changed.
Method: GET
| Parameter | Type | Required | Description |
|---|---|---|---|
deviceid |
string | One of deviceid or bus+addr
|
Canonical device identifier in the form <busNumber>_<hexAddr> (e.g., 1_25). Takes precedence if present. |
bus |
string or int | One of deviceid or bus+addr
|
Bus name (e.g., I2CA) or bus number. |
addr |
string | One of deviceid or bus+addr
|
Device address as plain hex without 0x prefix (e.g., 25 for I2C address 0x25). |
intervalUs |
int | No | Polling interval in microseconds. Must be > 0. |
numSamples |
int | No | Number of poll result samples the device buffers. Must be > 0. Changing this clears any previously buffered samples. |
busHz |
int | No | I2C bus speed in Hz for this device's polls. Set to 0 to revert to the default bus speed. Common values: 100000 (100 kHz), 400000 (400 kHz). |
busHzSlots |
string | No | Comma-separated list of slot numbers (0–63) to which busHz applies. Omit to keep the current slot mask. Set to empty or 0 to apply to all slots. Example: 4,5,6. |
At least one configuration parameter (intervalUs, numSamples, busHz, or busHzSlots) should be provided, though the endpoint can also be used to read current values without changing them.
Set polling interval only:
/devman/devconfig?deviceid=1_25&intervalUs=50000
Set number of buffered samples only:
/devman/devconfig?deviceid=1_25&numSamples=10
Set both at once:
/devman/devconfig?bus=I2CA&addr=25&intervalUs=50000&numSamples=5
Set bus speed override for all slots:
/devman/devconfig?deviceid=1_6a&busHz=400000
Set bus speed override for specific slots only:
/devman/devconfig?deviceid=1_6a&busHz=400000&busHzSlots=4,5,6
Revert to default bus speed:
/devman/devconfig?deviceid=1_6a&busHz=0
Read current configuration:
/devman/devconfig?bus=I2CA&addr=25
{
"req": "devman/devconfig?bus=I2CA&addr=25&intervalUs=50000&numSamples=5",
"rslt": "ok",
"deviceID": "1_25",
"pollIntervalUs": 50000,
"numSamples": 5,
"busHz": 400000,
"busHzSlots": [4, 5, 6]
}Notes on busHz and busHzSlots in the response:
-
busHzis0when no bus speed override is set (default bus speed is used) -
busHzSlotsis an empty array[]when the override applies to all slots
| Error | Cause |
|---|---|
failAddrMissing |
No deviceid or addr parameter provided |
failBusMissing |
Using addr style but no bus parameter provided |
failBusNotFound |
Bus name or number does not exist |
failInvalidDeviceID |
Device ID could not be parsed |
failInvalidInterval |
intervalUs is 0 |
failInvalidNumSamples |
numSamples is 0 |
failUnsupportedBus |
The bus does not support the requested operation, or the device was not found on the bus |
-
numSamplescorresponds to the"s"field in the device'spollInfoconfiguration. Changing it at runtime overrides the value from theDeviceTypeRecord. - Changing
numSamplesclears all previously buffered poll data for the device. -
busHzcorresponds to the"h"field in the device'spollInfoconfiguration. When set, the I2C bus speed is changed to this value before each poll of the device and restored to the default afterwards. -
busHzSlotscorresponds to the"hSlots"field. It limits which multiplexer slots the bus speed override applies to. This is useful when different slots have different electrical characteristics (e.g. cable length, capacitance). - All parameters are backward-compatible additions; existing clients that omit them are unaffected.
Description:
Sets the sample rate for a specific slot. An optional addr filter restricts the update to a device with the given address on that slot.
Method: GET
/slotcontrol/setrate/<slotNumber>/<rateHz>
| Path Segment | Type | Description |
|---|---|---|
slotNumber |
int | The slot index to configure. |
rateHz |
int | The desired sample rate in Hz. |
| Parameter | Type | Required | Description |
|---|---|---|---|
addr |
string | No | Filter to a specific device address. Plain hex without 0x prefix (e.g., 25 for address 0x25). A 0x prefix is also tolerated. |
# Set rate for all devices in slot 2
/slotcontrol/setrate/2/10
# Set rate for the device at address 0x25 only
/slotcontrol/setrate/2/10?addr=25
Description:
Starts a demo device instance (if enabled) with a configurable sample rate, duration, and offline behavior. Useful for testing pipelines without real hardware.
Method: GET
| Parameter | Type | Required | Description |
|---|---|---|---|
type |
string | No | Device type name; default ACCDEMO. |
rate |
int | No | Sample rate in ms (min 10, max 60000). |
duration |
int | No | Duration in ms (0 for continuous). |
offlineIntvS |
int | No | Offline interval seconds. |
offlineDurS |
int | No | Offline duration seconds (min 1). |
/devman/demo?type=ACCDEMO&rate=100&duration=10000
-
failDemoDeviceExists: The demo device already exists.
Description:
Assign a friendly name to a device. The mapping is held in DeviceManager's in-memory name map and applies to both statically-instantiated devices and bus-detected devices. Names assigned via this endpoint are not persisted across restarts — to persist them, add a name field on the corresponding Devices entry (or a top-level DeviceNames map) in the SysType configuration.
Method: GET
| Parameter | Type | Required | Description |
|---|---|---|---|
deviceid |
string | Yes | Canonical device identifier <busNum>_<hexAddr> (use 0_<hexAddr> for statically-instantiated devices). |
name |
string | Yes | Friendly name to assign. Must be non-empty. |
/devman/setname?deviceid=1_6a&name=IMU1
/devman/setname?deviceid=0_0&name=MotorControl
-
failDeviceIdMissing: Nodeviceidparameter supplied. -
failNameMissing: Nonameparameter supplied (or empty). -
failInvalidDeviceId: The supplieddeviceidcould not be parsed.
Description:
Assign a role string to a device. Roles allow callers to distinguish between standard published measurement devices (default role normal) and devices that should be treated as system infrastructure (role system, e.g. a fuel gauge, charger, or RTC). The role is reflected in the per-device /devman/typeinfo response and can be used as a filter for /devman/listdevs.
The mapping is held in-memory; pass role=normal or an empty role to clear it. To assign a role persistently, set the role field on the corresponding entry in the SysType Devices array (see DeviceManager Settings).
Method: GET
| Parameter | Type | Required | Description |
|---|---|---|---|
deviceid |
string | Yes | Canonical device identifier <busNum>_<hexAddr>. |
role |
string | Yes (may be empty) | Role string; common values are normal (default) and system. Empty or normal clears the mapping. |
/devman/setrole?deviceid=1_36&role=system
/devman/setrole?deviceid=1_36&role=normal # clears the role
-
failDeviceIdMissing: Nodeviceidparameter supplied. -
failInvalidDeviceId: The supplieddeviceidcould not be parsed.
Description: Enumerate currently-known devices. The list contains:
- All statically-instantiated devices (those configured via the
Devicesarray with aclassfield). - All bus-detected devices that the bus has successfully identified.
Undetected bus addresses are intentionally not reported. An optional role filter restricts the result to devices with the supplied role string.
Each entry contains the canonical deviceid and, when set/non-default, optional name and role sidecar fields plus the dtIdx (device type index) when known.
Method: GET
| Parameter | Type | Required | Description |
|---|---|---|---|
role |
string | No | Filter the result to devices whose role exactly matches (case-insensitive). E.g. role=system returns only system-tagged devices. |
/devman/listdevs
/devman/listdevs?role=system
/devman/listdevs?role=normal
{
"req": "devman/listdevs",
"rslt": "ok",
"devices": [
{ "deviceid": "0_0", "name": "MotorControl", "dtIdx": 12 },
{ "deviceid": "1_36", "role": "system", "dtIdx": 7 },
{ "deviceid": "1_6a", "name": "IMU1", "dtIdx": 5 }
]
}-
nameis only present in entries that have a friendly name mapped. -
roleis omitted when the role is the default (normal). -
dtIdxis omitted when the device type has not been identified.
Getting Started
- Quick Start
- Architecture at a Glance
- Writing Your First SysMod
- Adding a Comms Channel
- Adding an I2C Device Type
- PlatformIO / Arduino
Scaffolding & Building
- Raft CLI
- SysTypes
- Top-Level SysType
- Build Process
- WebUI Build Pipeline
- File System
- Partitions & Flash
- Local Dev Libraries
- Library Developer Guide
Architecture
Built-in SysMods
- NetworkManager
- BLEManager
- WebServer
- MQTTManager
- SerialConsole
- CommandSerial
- CommandSocket
- CommandFile
- FileManager
- LogManager
- ESPOTAUpdate
- StatePublisher
- Remote Logging
- Data Source Registration
Comms & Protocols
- Stack Overview
- Comms Channels
- ProtocolExchange
- RICREST Protocol
- Real-Time Streams
- Adding REST Endpoints
- Built-in REST Endpoints
- File Download (OKTO)
- OTA Update Flow
Devices & Buses
- DeviceManager
- Device Manager REST API
- Device Factory & Classes
- Device Type Records
- Adding an I2C Device Type
- Device Data Publishing
- Data Logger
- I2C Bus
- I2C Device Scanning
- I2C ID & Polling
- MotorControl Overview
- MotorControl Config
- MotorControl Commands
Helpers
Reference