Ersa Wearable Platform
Embedded smartwatch firmware and application framework
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
ersa::events::Event Struct Reference

#include <event.h>

Collaboration diagram for ersa::events::Event:
Collaboration graph
[legend]

Public Member Functions

 Event ()
 
 Event (EventType t, uint32_t ts=0)
 

Static Public Member Functions

static Event createButton (EventType t, ButtonId btn, uint32_t ts=0)
 
static Event createMinuteTick (const TimePayload &tp, uint32_t ts=0)
 
static Event createTimeSync (uint32_t epoch, TimeSource source, uint32_t ts=0)
 
static Event createBatteryChanged (uint16_t mv, uint8_t pct, bool conn, bool chg, uint32_t ts=0)
 
static Event createCall (EventType t, const char *caller, const char *number, uint8_t state, uint32_t ts=0)
 
static Event createMedia (const char *title, const char *artist, bool playing, uint32_t ts=0)
 
static Event createNotification (const char *title, const char *message, const char *app="", uint32_t uid=0, uint32_t ts=0, bool canDismissRemotely=false)
 

Public Attributes

EventType type {EventType::None}
 
uint32_t timestampMs {0}
 
union { 
 
   ButtonPayload   button 
 
   TimePayload   time 
 
   BatteryPayload   battery 
 
   NetworkPayload   network 
 
   CallPayload   call 
 
   MediaPayload   media 
 
   NotificationPayload   notification 
 
   void *   customPayload 
 
};  
 

Detailed Description

Fixed-size event envelope with a tagged, type-specific payload union.

Creating and posting an Event copies all bounded text into the value. This lets asynchronous producers release callback-owned buffers immediately and avoids heap allocation; consumers must read only the union member associated with type because the payload storage is shared.

Constructor & Destructor Documentation

◆ Event() [1/2]

ersa::events::Event::Event ( )
inline

Construct an empty event whose button payload is initialized safely.

◆ Event() [2/2]

ersa::events::Event::Event ( EventType  t,
uint32_t  ts = 0 
)
inlineexplicit

Construct an event envelope for t at an optional monotonic timestamp.

Member Function Documentation

◆ createBatteryChanged()

static Event ersa::events::Event::createBatteryChanged ( uint16_t  mv,
uint8_t  pct,
bool  conn,
bool  chg,
uint32_t  ts = 0 
)
inlinestatic

Build a battery sample event, copying voltage, estimate, and status bits.

◆ createButton()

static Event ersa::events::Event::createButton ( EventType  t,
ButtonId  btn,
uint32_t  ts = 0 
)
inlinestatic

Build a button event with the requested subtype and logical button key.

◆ createCall()

static Event ersa::events::Event::createCall ( EventType  t,
const char *  caller,
const char *  number,
uint8_t  state,
uint32_t  ts = 0 
)
inlinestatic

Build a call transition with bounded copies of caller and number. Text is truncated to the inline payload capacity and null-terminated so later asynchronous consumers do not retain borrowed provider pointers.

◆ createMedia()

static Event ersa::events::Event::createMedia ( const char *  title,
const char *  artist,
bool  playing,
uint32_t  ts = 0 
)
inlinestatic

Build a media-track event with copied title, artist, and playback state.

◆ createMinuteTick()

static Event ersa::events::Event::createMinuteTick ( const TimePayload &  tp,
uint32_t  ts = 0 
)
inlinestatic

Build a minute-boundary event containing one RTC snapshot.

◆ createNotification()

static Event ersa::events::Event::createNotification ( const char *  title,
const char *  message,
const char *  app = "",
uint32_t  uid = 0,
uint32_t  ts = 0,
bool  canDismissRemotely = false 
)
inlinestatic

Build a notification event with bounded text copies and remote-dismiss metadata. Fixed buffers make queued events self-contained and predictable.

◆ createTimeSync()

static Event ersa::events::Event::createTimeSync ( uint32_t  epoch,
TimeSource  source,
uint32_t  ts = 0 
)
inlinestatic

Build a request to apply an external time value through TimeService.

Member Data Documentation

◆ [union]

union { ... } ersa::events::Event

◆ battery

BatteryPayload ersa::events::Event::battery

◆ button

ButtonPayload ersa::events::Event::button

◆ call

CallPayload ersa::events::Event::call

◆ customPayload

void* ersa::events::Event::customPayload

◆ media

MediaPayload ersa::events::Event::media

◆ network

NetworkPayload ersa::events::Event::network

◆ notification

NotificationPayload ersa::events::Event::notification

◆ time

TimePayload ersa::events::Event::time

◆ timestampMs

uint32_t ersa::events::Event::timestampMs {0}

Monotonic device uptime at event creation, in milliseconds.

◆ type

EventType ersa::events::Event::type {EventType::None}

Discriminator selecting the active payload member.


The documentation for this struct was generated from the following file: