PebbleOS
Loading...
Searching...
No Matches
Functions
Session storage

Session data stored in a PFS file per session. More...

Functions

void dls_storage_invalidate_all (void)
 Delete the storage files of all sessions.
 
void dls_storage_delete_logging_storage (DataLoggingSession *session)
 Delete the storage file of a session.
 
int32_t dls_storage_read (DataLoggingSession *logging_session, uint8_t *buffer, int32_t num_bytes, uint32_t *new_read_offset)
 Read data from a session without consuming it.
 
int32_t dls_storage_consume (DataLoggingSession *logging_session, int32_t num_bytes)
 Consume data from a session without reading it.
 
bool dls_storage_write_session (DataLoggingSession *session)
 Move the data from a buffered session's RAM buffer to flash.
 
bool dls_storage_write_data (DataLoggingSession *session, const void *data, uint32_t num_bytes)
 Write data directly to a session's file.
 
void dls_storage_rebuild (void)
 Recreate the sessions stored in flash, called at boot from dls_init().
 

Detailed Description

Session data stored in a PFS file per session.

All functions must be called from KernelBG, except during dls_storage_rebuild() at boot. On a write error the session's file is deleted.

Function Documentation

◆ dls_storage_consume()

int32_t dls_storage_consume ( DataLoggingSession *  logging_session,
int32_t  num_bytes 
)

Consume data from a session without reading it.

Parameters
logging_sessionSession to consume from.
num_bytesNumber of bytes to consume. 0 only resynchronizes the read offset with the data already consumed, as done when rebuilding sessions at boot.
Returns
Number of bytes consumed, or -1 on error.

◆ dls_storage_delete_logging_storage()

void dls_storage_delete_logging_storage ( DataLoggingSession *  session)

Delete the storage file of a session.

The file must not be open.

Parameters
sessionSession.

◆ dls_storage_invalidate_all()

void dls_storage_invalidate_all ( void  )

Delete the storage files of all sessions.

◆ dls_storage_read()

int32_t dls_storage_read ( DataLoggingSession *  logging_session,
uint8_t *  buffer,
int32_t  num_bytes,
uint32_t *  new_read_offset 
)

Read data from a session without consuming it.

Only whole items are read, so fewer bytes than requested may be returned.

Parameters
logging_sessionSession to read from.
[out]bufferDestination, or NULL to only get the number of bytes available.
num_bytesMaximum number of bytes to read, ignored when buffer is NULL.
[out]new_read_offsetFile offset of the byte following the data read.
Returns
Number of bytes read (or available), or -1 on error.

◆ dls_storage_rebuild()

void dls_storage_rebuild ( void  )

Recreate the sessions stored in flash, called at boot from dls_init().

◆ dls_storage_write_data()

bool dls_storage_write_data ( DataLoggingSession *  session,
const void *  data,
uint32_t  num_bytes 
)

Write data directly to a session's file.

Used for unbuffered sessions; the session must be locked with dls_lock_session().

Parameters
sessionSession.
dataData to write.
num_bytesLength of data in bytes.
Returns
true on success.

◆ dls_storage_write_session()

bool dls_storage_write_session ( DataLoggingSession *  session)

Move the data from a buffered session's RAM buffer to flash.

Must be called with the list mutex held. Does nothing for inactive or unbuffered sessions.

Parameters
sessionSession.
Returns
true on success.