SDK for TESAIoT Dev Kit
API reference & tutorials (ModusToolbox)
Loading...
Searching...
No Matches

Functions

uint32_t ai_engine_set_models (uint32_t set_index, uint8_t *idx, uint32_t max)
 Members of any set, in registry order; explicit membership wins outright.
const char * ai_engine_set_name (uint32_t set_index)
 Human name for a set; NULL for a non-set index.
uint32_t ai_engine_set_members (uint8_t *idx, uint32_t max)
 Registry indices of the ACTIVE set's members; test each member's sensor.
int ai_engine_set_define (uint32_t set_index, const uint8_t *members, uint32_t n)
 Give a set an explicit run-time membership; task context, all-or-nothing.
uint32_t ai_engine_set_members_defined (uint32_t set_index, uint8_t *out, uint32_t max)
 The explicit membership if defined, else 0 — the only ack for set_define.

Detailed Description

Five functions for sets — several models listening to the same sensor data. Constants, the legacy 13/14/15 translation and the two hard facts (ALL has no definable slot; ai_engine_snapshot() loses detections in a set) are in Set pseudo-indices and the legacy translation.

Variant
mtb-mpy and mtb-only

Function Documentation

◆ ai_engine_set_models()

uint32_t ai_engine_set_models ( uint32_t set_index,
uint8_t * idx,
uint32_t max )

Members of any set, in registry order; explicit membership wins outright.

Members of a set, in registry order. Returns how many were written.

Contract
Writes the members of any set, in registry order, and returns how many were written (0 for a non-set index). Precedence: an explicit membership from ai_engine_set_define() wins outright over the compiled name-match list (ai_engine.c:1146-1149). Resolution is rebuilt on every entry to the set, never cached, so a model whose init() failed once is not exiled for the boot. Inside a render, take ai_engine_active() once and pass that value here — the deepcraft task can start/stop from another task mid-render, and re-reading it would let the set used for the layout tag disagree with the set the rows were sized from.
Variant
mtb-mpy and mtb-only
Origin
Lifted from page_edge_ai.c:567-575 (read-once); deepcraft_task.c:259-269 (compiled into the prebuilt archive; not shipped as source).

◆ ai_engine_set_name()

const char * ai_engine_set_name ( uint32_t set_index)

Human name for a set; NULL for a non-set index.

Human name for a set, or NULL if that index is not one.

Contract
Human name for a set; NULL for a non-set index. The page requires nn >= 2 members and a non-NULL name before showing the dropdown row — a set that resolves to fewer than two members in this image is not offered.
Variant
mtb-mpy and mtb-only
Origin
Lifted from page_edge_ai.c:1036-1040 (compiled into the prebuilt archive; not shipped as source).

◆ ai_engine_set_members()

uint32_t ai_engine_set_members ( uint8_t * idx,
uint32_t max )

Registry indices of the ACTIVE set's members; test each member's sensor.

Registry indices of the ACTIVE SET's members, up to max, whatever sensor each one reads – not microphone models. Returns the count. Callers that iterate this must test desc->sensor before doing anything sensor-specific with an entry.

Contract
Registry indices of the ACTIVE set's members only, up to max; returns the count. Members may read any sensor — not only the microphone — so a caller that does anything sensor-specific must test desc->sensor on each ai_engine_model() entry first. This is the fan-out the MicroPython Q_RESULT path uses with ai_engine_snapshot_model() and ai_result_top_positive() to report the loudest positive member.
Variant
mtb-mpy and mtb-only
Origin
Lifted from deepcraft_task.c:451-467 (compiled into the prebuilt archive; not shipped as source).

◆ ai_engine_set_define()

int ai_engine_set_define ( uint32_t set_index,
const uint8_t * members,
uint32_t n )

Give a set an explicit run-time membership; task context, all-or-nothing.

Give a set an explicit membership at run time, replacing the compiled one. Task context. Undefined sets keep their compiled membership exactly.

Contract
Gives a set an explicit run-time membership, replacing the compiled one. Task context only — it takes taskENTER_CRITICAL() around the publish (ai_engine.c:1059-1075). 1..8 members. All-or-nothing: every index is validated and one bad index refuses the whole definition. AI_PARALLEL_ALL (252) has no slot — the call always returns -1 for it (set_slot(), ai_engine.c:1040-1048, maps only INTRUDER/ROOM/MIC). There is no ack event: the only acknowledgement is reading back ai_engine_set_members_defined(). The MicroPython edge_ai.set_define() drives this as a three-command build (SET_BEGIN, one SET_ADD per member paced at 5 ms, SET_COMMIT) applied whole on commit — a dropped ADD is caught only by the Q_SET read-back. Why it exists: compiled sets match by name, so a staged (uploaded) model can join a watch only through an explicit definition (ai_engine.c:1092-1127).
Variant
mtb-mpy and mtb-only
Origin
Lifted from deepcraft_task.c:731-749 (compiled into the prebuilt archive; not shipped as source).

◆ ai_engine_set_members_defined()

uint32_t ai_engine_set_members_defined ( uint32_t set_index,
uint8_t * out,
uint32_t max )

The explicit membership if defined, else 0 — the only ack for set_define.

Explicit membership if one was defined, else 0.

Contract
The explicit membership if one was defined, else 0 = no override — the caller then falls back to ai_engine_set_models() for the compiled membership. This read-back is the only ack for ai_engine_set_define(). Any CM55 context (plain read).
Variant
mtb-mpy and mtb-only
Origin
Lifted from deepcraft_task.c:334-353 (Q_SET) (compiled into the prebuilt archive; not shipped as source).