Redis API Reference

All LibreScoot services communicate through Redis on the MDB. Below are the state hashes, command queues, and pub/sub channels.

Connection
Redis runs on the MDB at 192.168.7.1:6379. The DBC connects over USB Ethernet. From a connected machine:
redis-cli -h 192.168.7.1
# or via SSH tunnel:
ssh -L 6379:localhost:6379 root@<mdb-ip>
redis-ipc library
Go services use the redis-ipc library which wraps go-redis with helpers for hash publishing, queue processing, and pub/sub. Read its README for the patterns used across all services.

State Hashes

State is stored in Redis hashes. Services update fields with HSET and publish change notifications on channels of the same name.

vehicle

redis-cli -h 192.168.7.1 HGETALL vehicle
FieldValuesDescription
statestand-by / ready-to-drive / parked / booting / shutting-down / hibernating / updatingVehicle operating state
handlebar:positionon-place / off-placeHandlebar position sensor
handlebar:lock-sensorlocked / unlockedHandlebar lock state
seatbox:lockopen / closedSeatbox lock state
seatbox:buttonon / offSeat open button
kickstandup / downSide stand position
brake:left / brake:righton / offBrake lever states
blinker:switchleft / right / both / offBlinker switch position
blinker:stateon / offBlinker currently active
main-poweron / offMain power state
horn:buttonon / offHorn button

battery:0 / battery:1

redis-cli -h 192.168.7.1 HGETALL battery:0
FieldTypeDescription
presenttrue / falseBattery presence
statestringBattery state
chargeinteger (%)Charge level
voltageinteger (mV)Battery voltage
currentinteger (mA)Battery current
temperature:0temperature:3integer (°C)Temperature sensors
state-of-healthinteger (%)Battery health
cycle-countintegerCharge cycles
serial-numberstringBattery serial
fw-versionstringBMS firmware version

engine-ecu

redis-cli -h 192.168.7.1 HGETALL engine-ecu
FieldTypeDescription
speedinteger (km/h)Vehicle speed
rpmintegerMotor RPM
odometerinteger (m)Total distance
motor:voltageinteger (mV)Motor voltage
motor:currentinteger (mA)Motor current
temperatureinteger (°C)ECU temperature
throttleon / offThrottle active
kerson / offRegenerative braking active
kers-reason-offstringWhy KERS is off (none / cold / hot)
gearintegerGear position
fw-versionhex stringECU firmware version

internet

FieldDescription
statusConnection status (connected / disconnected)
access-techAccess technology (e.g. LTE)
signal-qualitySignal strength 0–100
ip-addressCurrent IP address
modem-stateModem power state

gps

FieldDescription
stateoff / searching / fix-established / error
latitude / longitudeCurrent position (6 decimal places)
altitudeAltitude in meters
speedGPS speed
courseHeading in degrees
timestampGPS timestamp (ISO format)

alarm

FieldValues
statusdisabled / disarmed / armed / level-1-triggered / level-2-triggered

settings

Persistent configuration managed by settings-service. All fields are readable/writable via lsc settings get/set. Notable keys:

KeyDescription
alarm.enabledtrue/false, alarm system on/off
alarm.honktrue/false, horn during alarm
alarm.durationAlarm duration in seconds
updates.mdb.channelOTA channel: testing / nightly / stable
updates.mdb.methodfull or delta
dashboard.valhalla-urlRouting engine endpoint
dashboard.map.typeonline / offline
scooter.auto-standby-secondsAuto-lock timeout (0 = disabled)
hibernation-timerHibernation timeout in seconds (0 = disabled)

ota

FieldDescription
status:mdb / status:dbcidle / downloading / installing / rebooting / error
download-progress:mdbDownload progress 0–100
update-version:mdbTarget version string
error-message:mdbError description if status is error

version:mdb / version:dbc

Written by version-service from /etc/os-release. Contains fields like version_id, build_id, id.

Command Queues

Services accept commands via Redis lists. Send with LPUSH; services consume with BRPOP.

QueueCommands
scooter:statelock, unlock, lock-hibernate
scooter:seatboxopen
scooter:powerrun, suspend, hibernate, hibernate-manual, reboot
scooter:blinkerleft, right, both, off
scooter:hornon, off
scooter:alarmenable, disable, start:<seconds>, stop
scooter:modemenable, disable, gps:enable, gps:disable
scooter:updatecheck-now
scooter:bluetoothadvertising-start-with-whitelisting, advertising-restart-no-whitelisting, advertising-stop, delete-all-bonds

Example:

redis-cli -h 192.168.7.1 LPUSH scooter:state unlock
redis-cli -h 192.168.7.1 LPUSH scooter:alarm start:30

Pub/Sub

When a service updates a hash field, it publishes the changed field name to a channel with the same name as the hash. Consumers subscribe and re-read only the changed field.

# Subscribe to vehicle state changes
redis-cli -h 192.168.7.1 SUBSCRIBE vehicle

# Subscribe to battery updates
redis-cli -h 192.168.7.1 SUBSCRIBE battery:0 battery:1

The published message payload is the field name that changed (e.g. "state", "charge"). Recipients call HGET <hash> <field> to get the new value.

This pattern is implemented in the redis-ipc library.

← Build Guide