|
Contiki 3.x
|
Convenience layer for storing readings and the config. More...
#include "contiki.h"#include <stdint.h>#include <stdbool.h>#include "settings.pb.h"#include "readings.pb.h"Go to the source code of this file.
Functions | |
| void | store_init (void) |
| Initialize the data store. More... | |
| uint16_t | store_save_sample (Sample *sample) |
| Store a sample in the flash. More... | |
| bool | store_get_sample (uint16_t id, Sample *sample) |
| Get a given sample from the flash,. More... | |
| uint8_t | store_get_raw_sample (uint16_t id, uint8_t buffer[Sample_size]) |
| Get a given sample from the flash, in the form of an encoded protocol buffer. More... | |
| bool | store_get_latest_sample (Sample *sample) |
| Get the most recent sample from the flash. More... | |
| uint8_t | store_get_latest_raw_sample (uint8_t buffer[Sample_size]) |
| Get the most recent sample from the flash, in the form of an encoded protocol buffer. More... | |
| uint16_t | store_get_latest_sample_id (void) |
| Get the identifer of the most recent sample stored. More... | |
| bool | store_delete_sample (uint16_t id) |
| Delete a given sample from the flash. More... | |
| bool | store_save_config (SensorConfig *config) |
| Save the configuration to flash. More... | |
| bool | store_get_config (SensorConfig *config) |
| Get the configuration from the flash. More... | |
| uint8_t | store_get_raw_config (uint8_t buffer[SensorConfig_size]) |
| Get the configuration from the flash. More... | |
Convenience layer for storing readings and the config.
Implements locking, and SPI sharing with the CC1120 driver.
Every sample is assigned a unique id for it's lifetime on flash. The id of a sample may be reused once it has been deleted. The store allows deleting any given sample, by gracefully dealing with files that do not exist.
Callers are always responsible for allocating the required memory.
Definition in file store.h.
| bool store_delete_sample | ( | uint16_t | id | ) |
Delete a given sample from the flash.
| id | The id of the sample to delete. |
true on success, false otherwise. Definition at line 174 of file store.c.
Referenced by res_delete_handler().
| bool store_get_config | ( | SensorConfig * | config | ) |
| uint8_t store_get_latest_raw_sample | ( | uint8_t | buffer[Sample_size] | ) |
Get the most recent sample from the flash, in the form of an encoded protocol buffer.
| buffer | An allocated buffer at last Sample_size big to which the sample protocol buffer will be written. |
false otherwise. Definition at line 135 of file store.c.
Referenced by res_get_handler().
| bool store_get_latest_sample | ( | Sample * | sample | ) |
| uint16_t store_get_latest_sample_id | ( | void | ) |
| uint8_t store_get_raw_config | ( | uint8_t | buffer[SensorConfig_size] | ) |
Get the configuration from the flash.
| An | allocated buffer at least SensorConfig_size big to which the config protocol buffer will be written. |
false otherwise. Definition at line 262 of file store.c.
Referenced by store_get_config().
| uint8_t store_get_raw_sample | ( | uint16_t | id, |
| uint8_t | buffer[Sample_size] | ||
| ) |
Get a given sample from the flash, in the form of an encoded protocol buffer.
| id | The id of the sample. |
| buffer | An allocated buffer at least Samle_size big to which the sample protocol buffer will be written. |
false otherwise. Definition at line 155 of file store.c.
Referenced by res_get_handler(), store_get_latest_raw_sample(), and store_get_sample().
| bool store_get_sample | ( | uint16_t | id, |
| Sample * | sample | ||
| ) |
Get a given sample from the flash,.
| id | The id of the sample. |
| *sample | The Sample to write the sample to. |
true on success, false otherwise. Definition at line 139 of file store.c.
Referenced by store_get_latest_sample().
| void store_init | ( | void | ) |
| bool store_save_config | ( | SensorConfig * | config | ) |
1.8.6