Database
Parameter database and ring buffers.
Both classes below are verbatim from the device firmware
(firmware_core.py of Logger Pro and the findyIoT module). The parameter registry itself
(databaseParams, aka db.params) lives in the user-editable
last.py and is passed into the database constructor - see
System IDs for the entry format and the full ID table.
Note
Methods reference the firmware module globals (modem, db,
device, setError…) exactly as on the device.
- class findylab.database.database(params)[source]
Persistent key/value storage on top of btree (the “mydb” file).
Verbatim class from
firmware_core.py. Keys are HiGPS parameter IDs registered in the dict passed to the constructor - on a device that dict isdatabaseParamsfrom the user-editablelast.py:db = database(databaseParams)
Values are stored as bytes;
read()also returns the encoded default for a registered-but-missing key.- __init__(params)[source]
Loads the existing “mydb” btree file into RAM.
- Parameters:
params (dict) – The parameter registry (
databaseParamsfromlast.py); stored as the class-leveldatabase.params.
- getParameterData(uri)[source]
Returns the registry row for a parameter ID.
- Parameters:
uri (str) – Parameter ID, e.g.
'421'.- Returns:
The registry entry, or False for unknown IDs.
- Return type:
list
- getParameterByHiGPS(higpsId)[source]
Returns the registry row for a HiGPS parameter ID.
- Parameters:
higpsId (str) – Parameter ID.
- Returns:
The registry entry, or False for unknown IDs.
- Return type:
list
- initDefaults()[source]
Factory-initializes the database.
Deletes an existing “mydb” (and resets so the next boot starts clean), reads the IMEI from the modem, then writes every storage-type-0 parameter’s default value.
- read(property, echo=True)[source]
Reads a parameter value.
- Parameters:
property (str or bytes) – Parameter ID.
echo (bool) – Print the value while reading (debug aid).
- Returns:
The stored value; the encoded default when the key is missing but registered; False for unknown IDs.
- Return type:
bytes
- class findylab.database.buffer[source]
Ring buffers over
database(slots"540"+n).Verbatim class from
firmware_core.py. Never instantiated - the methods take noselfand are called directly:buffer.create('540')
Used to keep pulse-count series between successful reports; the current slot index lives in parameters 538/539.
- create()[source]
Opens a fresh buffer slot.
Finds a free slot (0..99), writes the header (log period + timestamp + base counter value) and records the slot index in parameter 538/539.
- Parameters:
bufferName (str) –
'540'or'541'.- Returns:
The slot index used.
- Return type:
int
- get()[source]
Returns the first full buffer slot.
- Parameters:
bufferName (str) –
'540'or'541'.- Returns:
(period, timestamp, base_value, data)or False when no slot holds data.- Return type:
tuple