aliro_reader.h
used by aliro_reader.c
API
Fint aliro_reader_start(void)
Bring up the Aliro reader (starts the BLE transport + session layer). Returns 0 on success, negative on failure.
Fconst void * aliro_reader_ble_prepare(void)
Prepare the reader for attach mode + return the Aliro GATT service def to register (cast to const struct ble_gatt_svc_def *). NULL on failure.
Fint aliro_reader_start_attached(void)
Start the reader on the shared host (L2CAP CoC + advertising + engine). Returns 0 on success, negative on failure.
Fvoid aliro_reader_refresh_adv(void)
Re-emit the BLE advertisement using the currently-provisioned GRK. Call after Matter provisioning (SetAliroReaderConfig) if the reader may already be advertising: it starts on kCommissioningComplete, before Apple sends the Aliro config, so its first advertisement has no GRK and the phone cannot resolve it. No-op if the reader has no GRK or is not yet advertising.
Fvoid aliro_reader_set_lock_state_listener(void (*cb)(bool unlocked))
Fvoid aliro_reader_rssi_sample(uint16_t conn_handle, int8_t rssi_dbm)
Fvoid aliro_reader_notify_unlock(bool unsecured)
Fvoid aliro_reader_status_tick(int64_t now_ms)
Fbool aliro_reader_session_active(void)
Fvoid aliro_reader_set_access_listener(void (*cb)(bool granted))
Fbool aliro_reader_authenticated_credential(uint8_t cred_pub[65])
Fuint32_t aliro_reader_presence_restart(void)
Fbool aliro_reader_presence_checkpoint(uint32_t request, uint32_t *auth_generation)
Fbool aliro_reader_presence_authenticated_after(uint32_t checkpoint, uint8_t cred_pub[65])
Fbool aliro_reader_presence_expected_credential(uint8_t cred_pub[65])
Fvoid aliro_reader_prov_print(void)
Print the reader identity (dev vs provisioned, reader_id), the trust store, and the most-recently-presented credential key.
Fint aliro_reader_trust_last(void)
Trust the most-recently-presented credential public key and persist it to NVS. Returns 0 (added + saved), 1 (nothing presented yet, or already trusted), negative on a store error.
Fint aliro_reader_trust_clear(void)
Empty the trust store and persist it, keeping the reader identity. Returns 0 (cleared + saved), 1 (already empty), negative on an NVS error. Needed because nothing evicts superseded credentials and a Matter factory reset leaves this store intact, so it otherwise fills up and rejects the current credential.
Fint aliro_reader_provision_identity(const uint8_t reader_id[32], const uint8_t sign_priv[32], const uint8_t grk[16])
Store the reader identity provisioned over Matter and persist it to NVS: reader_id = groupIdentifier(16) || groupSubIdentifier(16), sign_priv = signingKey(32), grk = groupResolvingKey(16) for the BLE-UWB advertising dynamic tag (pass all-zero if none); clears the dev flag. Existing trust anchors are preserved. Returns 0 on success, negative on an NVS error.
Fint aliro_reader_provision_add_trust(const uint8_t cred_pub[65])
Add a trusted credential public key (uncompressed P-256, 65 bytes) presented over Matter SetCredential and persist. Returns 0 (added), 1 (already present), negative (store full / not a P-256 point / NVS error).
Fint aliro_reader_provision_clear(void)
Revert to the dev identity + empty trust store (Matter ClearAliroReaderConfig) and persist. Returns 0 on success, negative on an NVS error.
Fint aliro_reader_export_blob(uint8_t *out, size_t cap, size_t *out_len)
Serialise the current identity + trust store into a portable blob (backs the aliro-export console command). Returns 0 and sets *out_len; -1 if cap is too small. The blob contains the reader private key.
Fint aliro_reader_import_blob(const uint8_t *buf, size_t len)
Adopt an identity + trust store from an exported blob, persist it, and use it live (backs aliro-import). 0 ok; -1 malformed blob; -2 NVS write failed.
Fvoid aliro_reader_stepup_arm(void)
Arm a one-shot Access-Document request: the next transaction is forced into the standard phase and requests + verifies a document. Never per-unlock; the verdict is logged only and never gates access.
Fvoid aliro_reader_stepup_status(void)
Print the armed state and the most recent verification verdict.