PebbleOS
Loading...
Searching...
No Matches
Typedefs | Functions
Session list

In-memory list of data logging sessions, sorted by session ID. More...

Typedefs

typedef bool(* DlsListCallback) (DataLoggingSession *, void *)
 Callback for dls_list_for_each_session().
 

Functions

DataLoggingSession * dls_list_find_by_session_id (uint8_t session_id)
 Find a session by ID.
 
DataLoggingSession * dls_list_find_active_session (uint32_t tag, const Uuid *app_uuid)
 Find the active session with a given tag and owner.
 
void dls_list_remove_session (DataLoggingSession *logging_session)
 Remove a session from the list and free it.
 
void dls_list_remove_all (void)
 Free all sessions in memory without touching flash.
 
uint8_t dls_list_add_new_session (DataLoggingSession *logging_session)
 Assign a new random unique ID to a session and add it to the list.
 
void dls_list_insert_session (DataLoggingSession *logging_session)
 Add a session that already has an ID.
 
DataLoggingSession * dls_list_create_session (uint32_t tag, DataLoggingItemType type, uint16_t size, const Uuid *app_uuid, time_t timestamp, DataLoggingStatus status)
 Allocate a session.
 
DataLoggingSession * dls_list_get_next (DataLoggingSession *cur)
 Iterate over the session list.
 
bool dls_list_for_each_session (DlsListCallback cb, void *data)
 Call a callback for each session, with the list mutex held.
 
void dls_list_init (void)
 Initialize the session list.
 
bool dls_list_is_session_valid (DataLoggingSession *logging_session)
 Check whether a pointer refers to a session in the list.
 
bool dls_lock_session (DataLoggingSession *session)
 Lock an active session.
 
void dls_unlock_session (DataLoggingSession *session, bool inactivate)
 Unlock a session locked with dls_lock_session().
 
DataLoggingStatus dls_get_session_status (DataLoggingSession *session)
 Get the status of a session.
 
void dls_assert_own_list_mutex (void)
 Assert that the current task owns the list mutex.
 
void dls_list_lock (void)
 Lock the list mutex (recursive).
 
void dls_list_unlock (void)
 Unlock the list mutex (recursive).
 

Detailed Description

In-memory list of data logging sessions, sorted by session ID.

The list is protected by a recursive mutex. Each active session also has its own mutex, taken with dls_lock_session().

Typedef Documentation

◆ DlsListCallback

typedef bool(* DlsListCallback) (DataLoggingSession *, void *)

Callback for dls_list_for_each_session().

Called with the list mutex held, with the session and the user data. Returns false to stop iterating.

Function Documentation

◆ dls_assert_own_list_mutex()

void dls_assert_own_list_mutex ( void  )

Assert that the current task owns the list mutex.

◆ dls_get_session_status()

DataLoggingStatus dls_get_session_status ( DataLoggingSession *  session)

Get the status of a session.

Parameters
sessionSession.
Returns
Session status.

◆ dls_list_add_new_session()

uint8_t dls_list_add_new_session ( DataLoggingSession *  logging_session)

Assign a new random unique ID to a session and add it to the list.

Parameters
logging_sessionSession to add.
Returns
Assigned session ID.

◆ dls_list_create_session()

DataLoggingSession * dls_list_create_session ( uint32_t  tag,
DataLoggingItemType  type,
uint16_t  size,
const Uuid *  app_uuid,
time_t  timestamp,
DataLoggingStatus  status 
)

Allocate a session.

Only the given fields are set; DataLoggingSession::storage and DataLoggingSession::comm must be initialized separately, and the session added with dls_list_add_new_session() or dls_list_insert_session(). Active sessions also get their DataLoggingActiveState.

Parameters
tagSession tag.
typeItem type.
sizeItem size in bytes.
app_uuidOwner UUID.
timestampCreation time.
statusInitial status.
Returns
Session, or NULL if there are already DLS_MAX_NUM_SESSIONS sessions.

◆ dls_list_find_active_session()

DataLoggingSession * dls_list_find_active_session ( uint32_t  tag,
const Uuid *  app_uuid 
)

Find the active session with a given tag and owner.

Parameters
tagSession tag.
app_uuidOwner UUID.
Returns
Session, or NULL if not found.

◆ dls_list_find_by_session_id()

DataLoggingSession * dls_list_find_by_session_id ( uint8_t  session_id)

Find a session by ID.

Parameters
session_idSession ID.
Returns
Session, or NULL if not found.

◆ dls_list_for_each_session()

bool dls_list_for_each_session ( DlsListCallback  cb,
void *  data 
)

Call a callback for each session, with the list mutex held.

Parameters
cbCallback.
dataUser data passed to cb.
Returns
false if cb stopped the iteration, true otherwise.

◆ dls_list_get_next()

DataLoggingSession * dls_list_get_next ( DataLoggingSession *  cur)

Iterate over the session list.

Parameters
curCurrent session, or NULL to get the first one.
Returns
Next session, or NULL at the end of the list.

◆ dls_list_init()

void dls_list_init ( void  )

Initialize the session list.

◆ dls_list_insert_session()

void dls_list_insert_session ( DataLoggingSession *  logging_session)

Add a session that already has an ID.

Used at boot when restoring sessions from flash.

Parameters
logging_sessionSession to add.

◆ dls_list_is_session_valid()

bool dls_list_is_session_valid ( DataLoggingSession *  logging_session)

Check whether a pointer refers to a session in the list.

Safe to call with arbitrary pointers: only compares against the known sessions.

Parameters
logging_sessionPointer to check.
Returns
true if logging_session is in the list.

◆ dls_list_lock()

void dls_list_lock ( void  )

Lock the list mutex (recursive).

◆ dls_list_remove_all()

void dls_list_remove_all ( void  )

Free all sessions in memory without touching flash.

◆ dls_list_remove_session()

void dls_list_remove_session ( DataLoggingSession *  logging_session)

Remove a session from the list and free it.

Parameters
logging_sessionSession to remove.

◆ dls_list_unlock()

void dls_list_unlock ( void  )

Unlock the list mutex (recursive).

◆ dls_lock_session()

bool dls_lock_session ( DataLoggingSession *  session)

Lock an active session.

Must not be called with the list mutex held.

Parameters
sessionSession to lock.
Returns
true if the session was active and is now locked, false if it is inactive.

◆ dls_unlock_session()

void dls_unlock_session ( DataLoggingSession *  session,
bool  inactivate 
)

Unlock a session locked with dls_lock_session().

Parameters
sessionSession to unlock.
inactivateInactivate the session, and free its active state, once its last lock is released.