Illustrated C/C++ source sheets, symbol index, API relationship graph, compiler console and debug trace

LIVE AI / FLEXIBLE SENSING / FLIGHT CONTEXT

Sensoraia API

Live AI and sensing, connected to the flight.
See, listen, inspect and return supported results while airborne.

Loading...
Searching...
No Matches
camera_control.h File Reference

Fixed-size camera-control wire codec and FC-side ticket state. More...

#include <stddef.h>
#include "usher_protocol.h"
Include dependency graph for camera_control.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  usher_control_request
 One addressed command request shared with the companion protocol. More...
struct  usher_control_result
 Result evidence for one camera selected by a request mask. More...
struct  usher_control_slot
 Fixed pending/result slot retained for one addressable camera. More...
struct  usher_control_client
 Handshake, capability cache, and eight-camera ticket state. More...

Macros

#define USHER_CONTROL_TIMEOUT_US   UINT32_C(70000000)
#define USHER_CONTROL_LEASE_US   UINT32_C(6000000)

Functions

bool usher_control_put_u32 (uint8_t *bytes, size_t size, size_t offset, uint32_t value)
 Encode a 32-bit value as four little-endian protocol bytes.
bool usher_control_get_u32 (const uint8_t *bytes, size_t size, size_t offset, uint32_t *value)
 Decode a bounded four-byte little-endian protocol value.
bool usher_control_encode_request (uint8_t *bytes, size_t size, const struct usher_control_request *request)
 Encode one command payload with the fixed wire size and field order.
bool usher_control_decode_request (const uint8_t *bytes, size_t size, struct usher_control_request *request)
 Validate and decode one fixed-size command payload.
bool usher_control_encode_result (uint8_t *bytes, size_t size, const struct usher_control_result *result)
 Encode one camera's correlated control result.
bool usher_control_decode_result (const uint8_t *bytes, size_t size, struct usher_control_result *result)
 Validate and decode one camera result payload.
bool usher_control_value_valid (uint8_t command, uint8_t value)
 Validate the command-specific legal value range.
void usher_control_client_reset (struct usher_control_client *client, uint32_t nonce)
 Reset session state and invalidate outstanding tickets without replay.
bool usher_control_client_hello (struct usher_control_client *client, const uint8_t *bytes, size_t size, uint32_t now_us)
 Accept only a HELLO matching the current nonce-bound negotiation.
bool usher_control_client_ready (const struct usher_control_client *client, uint32_t now_us)
 Check confirmed-session readiness and the bounded HELLO lease.
void usher_control_client_expire (struct usher_control_client *client, uint32_t now_us)
 Mark expired pending commands UNKNOWN; never resubmit them.
bool usher_control_client_prepare (struct usher_control_client *client, uint8_t mask, uint8_t command, uint8_t value, uint32_t now_us, struct usher_control_request *request)
 Prepare a request without consuming its ticket before UART admission.
void usher_control_client_commit (struct usher_control_client *client, const struct usher_control_request *request, uint32_t now_us)
 Commit a prepared request after full-frame UART admission.
bool usher_control_client_receive (struct usher_control_client *client, const uint8_t *bytes, size_t size, uint32_t now_us)
 Accept a result only when session, ticket, camera, and evidence correlate.
uint8_t usher_control_client_result (const struct usher_control_client *client, uint32_t ticket)
 Aggregate per-camera results for one group ticket.
uint8_t usher_control_client_camera_result (const struct usher_control_client *client, uint32_t ticket, uint8_t camera_id)
 Read one camera's status for a group request.

Detailed Description

Fixed-size camera-control wire codec and FC-side ticket state.

Control tickets are distinct from photo numbers and shot requests. Eight per-camera slots keep the flight-controller footprint bounded; a ticket is consumed only after its complete UART frame is admitted. Commands are not replayed after timeout because the camera may already have acted.

Definition in file camera_control.h.

Macro Definition Documentation

◆ USHER_CONTROL_LEASE_US

#define USHER_CONTROL_LEASE_US   UINT32_C(6000000)

Definition at line 33 of file camera_control.h.

◆ USHER_CONTROL_TIMEOUT_US

#define USHER_CONTROL_TIMEOUT_US   UINT32_C(70000000)

Definition at line 32 of file camera_control.h.

Function Documentation

◆ usher_control_client_camera_result()

uint8_t usher_control_client_camera_result ( const struct usher_control_client * client,
uint32_t ticket,
uint8_t camera_id )

Read one camera's status for a group request.

Parameters
[in]clientClient result slots.
[in]ticketRequest ID; zero means NOT_SENT.
[in]camera_idOne-based camera slot from 1 through 8.
Returns
Matching result status, UNKNOWN for absent/replaced tickets, or NOT_SENT.

Definition at line 196 of file camera_control.c.

◆ usher_control_client_commit()

void usher_control_client_commit ( struct usher_control_client * client,
const struct usher_control_request * request,
uint32_t now_us )

Commit a prepared request after full-frame UART admission.

Parameters
[in,out]clientClient state whose ticket and selected slots are updated.
[in]requestRequest previously returned by usher_control_client_prepare.
[in]now_usMonotonic send time in microseconds.

Definition at line 160 of file camera_control.c.

◆ usher_control_client_expire()

void usher_control_client_expire ( struct usher_control_client * client,
uint32_t now_us )

Mark expired pending commands UNKNOWN; never resubmit them.

Parameters
[in,out]clientClient state to update.
[in]now_usCurrent monotonic time in microseconds.

Definition at line 138 of file camera_control.c.

◆ usher_control_client_hello()

bool usher_control_client_hello ( struct usher_control_client * client,
const uint8_t * bytes,
size_t size,
uint32_t now_us )

Accept only a HELLO matching the current nonce-bound negotiation.

Parameters
[in,out]clientHandshake and capability state.
[in]bytesHELLO payload.
[in]sizePayload size; must equal USHER_CONTROL_HELLO_SIZE.
[in]now_usCurrent monotonic time in microseconds.
Returns
True if the reply is structurally valid and belongs to this negotiation.

Definition at line 115 of file camera_control.c.

◆ usher_control_client_prepare()

bool usher_control_client_prepare ( struct usher_control_client * client,
uint8_t mask,
uint8_t command,
uint8_t value,
uint32_t now_us,
struct usher_control_request * request )

Prepare a request without consuming its ticket before UART admission.

Parameters
[in,out]clientSession state and pending slots.
[in]maskEight-bit camera selection mask.
[in]commandCommand identifier.
[in]valueCommand-specific value.
[in]now_usCurrent monotonic time in microseconds.
[out]requestReceives the tentative request on success.
Returns
True only if the session is ready, values are legal, and selected slots are free.
Note
Call usher_control_client_commit only after the complete frame is admitted.

Definition at line 147 of file camera_control.c.

◆ usher_control_client_ready()

bool usher_control_client_ready ( const struct usher_control_client * client,
uint32_t now_us )

Check confirmed-session readiness and the bounded HELLO lease.

Parameters
[in]clientClient state.
[in]now_usCurrent monotonic time in microseconds.
Returns
True only while the negotiated session is fresh and confirmed.

Definition at line 133 of file camera_control.c.

◆ usher_control_client_receive()

bool usher_control_client_receive ( struct usher_control_client * client,
const uint8_t * bytes,
size_t size,
uint32_t now_us )

Accept a result only when session, ticket, camera, and evidence correlate.

Parameters
[in,out]clientClient state containing pending requests.
[in]bytesReceived result payload.
[in]sizePayload length.
[in]now_usCurrent monotonic time in microseconds.
Returns
True when the result belongs to a pending request and its evidence is valid.

Definition at line 173 of file camera_control.c.

◆ usher_control_client_reset()

void usher_control_client_reset ( struct usher_control_client * client,
uint32_t nonce )

Reset session state and invalidate outstanding tickets without replay.

Parameters
[in,out]clientClient state to reset.
[in]nonceNew handshake nonce; zero is normalized to one.

Definition at line 101 of file camera_control.c.

◆ usher_control_client_result()

uint8_t usher_control_client_result ( const struct usher_control_client * client,
uint32_t ticket )

Aggregate per-camera results for one group ticket.

Parameters
[in]clientClient result slots.
[in]ticketRequest ID; zero means NOT_SENT.
Returns
UNKNOWN if evidence is missing, PENDING if any selected camera is pending, PARTIAL for mixed terminal outcomes, or the common terminal status.

Definition at line 203 of file camera_control.c.

◆ usher_control_decode_request()

bool usher_control_decode_request ( const uint8_t * bytes,
size_t size,
struct usher_control_request * request )

Validate and decode one fixed-size command payload.

Parameters
[in]bytesReceived payload.
[in]sizePayload size; must equal USHER_CONTROL_COMMAND_SIZE.
[out]requestReceives decoded fields on success.
Returns
True only when version, mask, command, session, and ticket are valid.

Definition at line 61 of file camera_control.c.

◆ usher_control_decode_result()

bool usher_control_decode_result ( const uint8_t * bytes,
size_t size,
struct usher_control_result * result )

Validate and decode one camera result payload.

Parameters
[in]bytesReceived payload.
[in]sizePayload size; must equal USHER_CONTROL_RESULT_SIZE.
[out]resultReceives decoded fields on success.
Returns
True only when version, identity, status, and evidence are valid.

Definition at line 88 of file camera_control.c.

◆ usher_control_encode_request()

bool usher_control_encode_request ( uint8_t * bytes,
size_t size,
const struct usher_control_request * request )

Encode one command payload with the fixed wire size and field order.

Parameters
[out]bytesDestination payload buffer.
[in]sizePayload size; must equal USHER_CONTROL_COMMAND_SIZE.
[in]requestSession, ticket, camera mask, command, and value.
Returns
True only for valid required fields and exact payload size.

Definition at line 48 of file camera_control.c.

◆ usher_control_encode_result()

bool usher_control_encode_result ( uint8_t * bytes,
size_t size,
const struct usher_control_result * result )

Encode one camera's correlated control result.

Parameters
[out]bytesDestination payload buffer.
[in]sizePayload size; must equal USHER_CONTROL_RESULT_SIZE.
[in]resultResult status and evidence for one camera.
Returns
True only when camera, request, status, and evidence fields are valid.

Definition at line 71 of file camera_control.c.

◆ usher_control_get_u32()

bool usher_control_get_u32 ( const uint8_t * bytes,
size_t size,
size_t offset,
uint32_t * value )

Decode a bounded four-byte little-endian protocol value.

Parameters
[in]bytesSource payload buffer.
[in]sizeTotal buffer size.
[in]offsetByte offset for the field.
[out]valueReceives the decoded value.
Returns
True if the field fits and both pointers are valid.

Definition at line 34 of file camera_control.c.

◆ usher_control_put_u32()

bool usher_control_put_u32 ( uint8_t * bytes,
size_t size,
size_t offset,
uint32_t value )

Encode a 32-bit value as four little-endian protocol bytes.

Parameters
[out]bytesDestination payload buffer.
[in]sizeTotal buffer size.
[in]offsetByte offset for the field.
[in]valueValue to encode.
Returns
True if the field fits and the buffer is non-null.

Definition at line 27 of file camera_control.c.

◆ usher_control_value_valid()

bool usher_control_value_valid ( uint8_t command,
uint8_t value )

Validate the command-specific legal value range.

Parameters
[in]commandControl command ID.
[in]valueCommand value.
Returns
True for a supported value, false before any ticket is reserved otherwise.

Definition at line 42 of file camera_control.c.