11 #ifndef TASK_SENSOR_LOG_LEVEL
12 #define TASK_SENSOR_LOG_LEVEL RI_LOG_LEVEL_DEBUG
15 static inline void LOG (
const char *
const msg)
17 ri_log (TASK_SENSOR_LOG_LEVEL, msg);
20 static inline void LOGD (
const char *
const msg)
25 static inline void LOGHEX (
const uint8_t *
const msg,
const size_t len)
50 if ( (NULL == sensor) || (NULL == sensor->
init))
149 LOG (
"\r\nAttempting to configure ");
156 LOG (
"Actual configuration:\r\n");
183 const size_t count,
const char *
const name)
187 for (
size_t ii = 0; (count > ii) && (NULL == p_sensor); ii++)
189 if (0 == strcmp (sensor_list[ii].sensor.name, name))
191 p_sensor = & (sensor_list[ii]);
213 for (
size_t ii = 0; (count > ii) && (NULL == p_sensor); ii++)
215 if ( (values.
bitfield & sensor_list[ii].sensor.provides.bitfield) == values.
bitfield)
217 p_sensor = & (sensor_list[ii]);
#define RD_ERROR_NULL
Null Pointer.
uint32_t rd_status_t
bitfield for representing errors
#define RD_SUCCESS
Internal Error.
#define RD_ERROR_NOT_FOUND
Not found.
#define RD_ERROR_INVALID_STATE
Invalid state, operation disallowed in this state.
#define RD_ERROR_BUSY
Busy.
void ri_log_hex(const ri_log_severity_t severity, const uint8_t *const bytes, size_t byte_length)
Queues bytes to be logged out as a hex string.
void ri_log(const ri_log_severity_t severity, const char *const message)
Queues messages into log.
void ri_log_sensor_configuration(const ri_log_severity_t level, const rd_sensor_configuration_t *const configuration, const char *unit)
bool rd_sensor_is_init(const rd_sensor_t *const sensor)
Check if given sensor structure is already initialized.
#define RD_HANDLE_UNUSED
Mark sensor as unused with this handle.
bool rt_flash_busy(void)
Check if flash is running an operation.
rd_status_t rt_flash_load(const uint16_t page_id, const uint16_t record_id, void *const message, const size_t message_length)
Load data from flash.
rd_status_t rt_flash_store(const uint16_t file_id, const uint16_t record_id, const void *const message, const size_t message_length)
Store data to flash.
Header to enable and disable module compilation.
Ruuvi error codes and error check function.
Ruuvi sensor interface Lifecycle: Beta
rt_sensor_ctx_t * rt_sensor_find_backend(rt_sensor_ctx_t *const sensor_list, const size_t count, const char *const name)
Search for requested sensor backend in given list of sensors.
rd_status_t rt_sensor_store(rt_sensor_ctx_t *const sensor)
Store the sensor state to NVM.
rd_status_t rt_sensor_configure(rt_sensor_ctx_t *const sensor)
Configure a sensor with given settings.
rd_status_t rt_sensor_load(rt_sensor_ctx_t *const sensor)
Load the sensor state from NVM.
rd_status_t rt_sensor_initialize(rt_sensor_ctx_t *const sensor)
Initialize sensor CTX.
rt_sensor_ctx_t * rt_sensor_find_provider(rt_sensor_ctx_t *const sensor_list, const size_t count, rd_sensor_data_fields_t values)
Search for a sensor which can provide requested values.
rd_configuration_fp configuration_set
rd_configuration_fp
const char * name
Sensor human-readable name. Should be at most 8 bytes long.
rd_sensor_t sensor
Control structure for sensor.
uint8_t handle
Handle of sensor.
uint16_t nvm_file
NVM file of configuration.
uint16_t nvm_record
NVM record of configuration.
rd_sensor_configuration_t configuration
Sensor configuration.
rd_sensor_init_fp init
Initialization function.
rd_bus_t bus
Bus of sensor.
Union to access sensor data.
uint32_t bitfield
Bitfield used to access sensor data.