Core

Core firmware: the fw class, device helpers and free functions.

Everything below is verbatim from the device firmware (firmware_core.py of Logger Pro and the findyIoT module). fw deliberately has no start()/measure() - those are plain functions in the user-editable last.py, attached with fw.start = start and fw.measure = measure.

Note

Methods reference the firmware module globals (modem, protocol, db, counter, buffer, wdt, led…) exactly as on the device.

findylab.core.Psda = 18

I2C pins of the external ADC (address 104).

findylab.core.Preed = 15

Reed-switch input (EXT0 deep-sleep wakeup).

findylab.core.Pinput4 = 4

Direct digital inputs (counted by the ULP as RTC GPIO 10/16).

class findylab.core.fw[source]

Main firmware class. Verbatim from firmware_core.py.

__init__() does the first-boot bootstrap (IMEI + database defaults). start() and measure() are not defined here - they live in the user-editable last.py and are attached with fw.start = start / fw.measure = measure.

__init__()[source]

First-boot bootstrap.

Reads the IMEI parameter (200); when empty, powers the modem (power-cycling it once via findylab.modem.eg915.reset() if it stays silent), reads the real IMEI, initializes the database defaults, re-opens the database and sends the defaults report. Reassigns the module-level db in that path.

seconds_to_next_wakeup(period_seconds)[source]

Computes the seconds until the next wakeup time.

Aligns wakeups to round boundaries of the RTC clock so reports arrive at predictable times.

Parameters:

period_seconds (int) – The period; one of 60, 300, 900, 1800, 3600 (anything else falls back to 900).

Returns:

Seconds until the next boundary.

Return type:

int

report(alarm=False, datalist=None)[source]

Sends a report to the HiGPS server.

Powers/registers the modem, refreshes the GSM info parameters, then sends samplingsAlarm or samplings; on a build error falls back to the minimal dataBat report. After a confirmed connection the alarm flag, ring-buffers and wakeup counter are reset, the database is stored and a just-committed OTA update is reported back to the server (53 = 0, 54 = 1) via _notifyUpdateResult().

Parameters:
  • alarm (bool) – Send the alarm variant of the report.

  • datalist (list) – Parameter IDs to send (defined by the user in last.py). None keeps the previously set list (protocol.datalist).

getGSMInfo()[source]

Copies the serving-cell info into parameters 230-238.

prepareSleep(t, trig)[source]

Releases the pins and enters deep sleep.

Turns the modem off, reconfigures all peripheral pins as inputs and arms the reed-switch EXT0 wakeup when trig is set, then calls goodNight().

Parameters:
  • t (int) – Sleep time in seconds.

  • trig (bool) – Arm the reed-switch wakeup.

Note

eg915 has no PSM support, so this is a plain machine.deepsleep() - no network PSM negotiation.

goodNight(timeS)[source]

Stores the database and enters deep sleep.

Parameters:

timeS (int) – Sleep time in milliseconds.

Note

Prints the exception and resets when db.store() fails.

adcMeasure(n)[source]

Performs one raw conversion on the external I2C ADC.

Channel selectors: b'' AIN1 (4-20 mA), b'°' AIN2 (4-20 mA), b'Ð' external power, b'ð' the 0-5 V input.

Parameters:

n (bytes) – Channel selector byte.

Returns:

Raw 16-bit conversion result.

Return type:

int

class findylab.core.device[source]

Device-level helpers. Never instantiated - the methods take no self and are called directly:

device.getTimestamp()

Verbatim class from firmware_core.py.

restart()[source]

Resets the device (machine.reset()).

factoryReset()[source]

Wipes the database to defaults and resets the device.

freeMemory()[source]

Returns the free heap in KB.

Returns:

Free RAM in kilobytes.

Return type:

int

serialNumber()[source]

Returns the unique chip ID.

Returns:

Hex-encoded machine.unique_id().

Return type:

str

memoryTotal()[source]

Returns the allocated heap in KB.

Returns:

Allocated RAM in kilobytes.

Return type:

int

getTimestamp()[source]

Returns the current Unix epoch (+946684800 legacy offset).

When the RTC looks invalid (before 2022) the time is fetched from the server via modem.getTimeF() and the RTC is set.

Returns:

Epoch seconds.

Return type:

int

setTimestamp()[source]

Sets the RTC from a given epoch or from the server.

Parameters:

timestamp (str) – 10-digit epoch string; when False the time is fetched from the server.

findylab.core.wdtAlert(p)[source]

Watchdog callback: stores the database, powers the modem off and resets the device.

Parameters:

p – Timer instance (unused).

findylab.core.beep()[source]

Audible signal: 5 kHz on the buzzer (GPIO27) for 0.5 s.

findylab.core.setError(error)[source]

Accumulates an error message for the next report.

Appends to the global errors (sent as the &er= request field) and clears errorsSent.

Parameters:

error (str) – Human-readable error text.