Batch read helper

Asset Tracker Template

tags
Asset Tracker Template

The Storage module provides a convenience function for reading batch data:

int storage_batch_read(struct storage_data_item *out_item, k_timeout_t timeout);

The function reads stored data through the batch interface, handling the header parsing and the data extraction automatically. All other operations go through zbus messages, including requesting batch access and session management.

The function returns 0 on a successful read, -ENODATA when it reaches the end-of-batch marker and the session has consumed all items, -EAGAIN if no data becomes available within timeout, or another negative errno on error.

Note

Call this function only after receiving a STORAGE_BATCH_AVAILABLE message in response to a STORAGE_BATCH_REQUEST. When you have consumed all items, send STORAGE_BATCH_CLOSE with the same session_id.