Zephyr API Documentation  3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Sensing Subsystem API

Sensing Subsystem API. More...

Data Structures

struct  sensing_sensor_version
 Sensor Version. More...
 
struct  sensing_sensor_info
 Sensor basic constant information. More...
 
struct  sensing_callback_list
 Sensing subsystem event callback list. More...
 
struct  sensing_sensor_config
 Sensing subsystem sensor configure, including interval, sensitivity, latency. More...
 

Macros

#define SENSING_SENSOR_VERSION(_major, _minor, _hotfix, _build)
 Macro to create a sensor version value.
 
#define SENSING_SENSOR_FLAG_REPORT_ON_EVENT   BIT(0)
 Sensor flag indicating if this sensor is on event reporting data.
 
#define SENSING_SENSOR_FLAG_REPORT_ON_CHANGE   BIT(1)
 Sensor flag indicating if this sensor is on change reporting data.
 
#define SENSING_SENSITIVITY_INDEX_ALL   -1
 SENSING_SENSITIVITY_INDEX_ALL indicating sensitivity of each data field should be set.
 

Typedefs

typedef void * sensing_sensor_handle_t
 Define Sensing subsystem sensor handle.
 
typedef void(* sensing_data_event_t) (sensing_sensor_handle_t handle, const void *buf, void *context)
 Sensor data event receive callback.
 

Enumerations

enum  sensing_sensor_state { SENSING_SENSOR_STATE_READY = 0 , SENSING_SENSOR_STATE_OFFLINE = 1 }
 Sensing subsystem sensor state. More...
 
enum  sensing_sensor_attribute { SENSING_SENSOR_ATTRIBUTE_INTERVAL = 0 , SENSING_SENSOR_ATTRIBUTE_SENSITIVITY = 1 , SENSING_SENSOR_ATTRIBUTE_LATENCY = 2 , SENSING_SENSOR_ATTRIBUTE_MAX }
 Sensing subsystem sensor config attribute. More...
 

Functions

int sensing_get_sensors (int *num_sensors, const struct sensing_sensor_info **info)
 Get all supported sensor instances' information.
 
int sensing_open_sensor (const struct sensing_sensor_info *info, struct sensing_callback_list *cb_list, sensing_sensor_handle_t *handle)
 Open sensor instance by sensing sensor info.
 
int sensing_open_sensor_by_dt (const struct device *dev, struct sensing_callback_list *cb_list, sensing_sensor_handle_t *handle)
 Open sensor instance by device.
 
int sensing_close_sensor (sensing_sensor_handle_t *handle)
 Close sensor instance.
 
int sensing_set_config (sensing_sensor_handle_t handle, struct sensing_sensor_config *configs, int count)
 Set current config items to Sensing subsystem.
 
int sensing_get_config (sensing_sensor_handle_t handle, struct sensing_sensor_config *configs, int count)
 Get current config items from Sensing subsystem.
 
const struct sensing_sensor_infosensing_get_sensor_info (sensing_sensor_handle_t handle)
 Get sensor information from sensor instance handle.
 

Detailed Description

Sensing Subsystem API.

Macro Definition Documentation

◆ SENSING_SENSITIVITY_INDEX_ALL

#define SENSING_SENSITIVITY_INDEX_ALL   -1

#include <zephyr/sensing/sensing.h>

SENSING_SENSITIVITY_INDEX_ALL indicating sensitivity of each data field should be set.

◆ SENSING_SENSOR_FLAG_REPORT_ON_CHANGE

#define SENSING_SENSOR_FLAG_REPORT_ON_CHANGE   BIT(1)

#include <zephyr/sensing/sensing.h>

Sensor flag indicating if this sensor is on change reporting data.

Reporting sensor data when the sensor data changes.

Exclusive with SENSING_SENSOR_FLAG_REPORT_ON_EVENT

◆ SENSING_SENSOR_FLAG_REPORT_ON_EVENT

#define SENSING_SENSOR_FLAG_REPORT_ON_EVENT   BIT(0)

#include <zephyr/sensing/sensing.h>

Sensor flag indicating if this sensor is on event reporting data.

Reporting sensor data when the sensor event occurs, such as a motion detect sensor reporting a motion or motionless detected event.

◆ SENSING_SENSOR_VERSION

#define SENSING_SENSOR_VERSION (   _major,
  _minor,
  _hotfix,
  _build 
)

#include <zephyr/sensing/sensing.h>

Value:
(FIELD_PREP(GENMASK(31, 24), _major) | \
FIELD_PREP(GENMASK(23, 16), _minor) | \
FIELD_PREP(GENMASK(15, 8), _hotfix) | \
FIELD_PREP(GENMASK(7, 0), _build))
#define GENMASK(h, l)
Create a contiguous bitmask starting at bit position l and ending at position h.
Definition: util.h:70
#define FIELD_PREP(mask, value)
Prepare a bitfield element using value with mask representing its field position and width.
Definition: util.h:94

Macro to create a sensor version value.

Typedef Documentation

◆ sensing_data_event_t

typedef void(* sensing_data_event_t) (sensing_sensor_handle_t handle, const void *buf, void *context)

#include <zephyr/sensing/sensing.h>

Sensor data event receive callback.

Parameters
handleThe sensor instance handle.
bufThe data buffer with sensor data.
contextUser provided context pointer.

◆ sensing_sensor_handle_t

typedef void* sensing_sensor_handle_t

#include <zephyr/sensing/sensing.h>

Define Sensing subsystem sensor handle.

Enumeration Type Documentation

◆ sensing_sensor_attribute

#include <zephyr/sensing/sensing.h>

Sensing subsystem sensor config attribute.

Enumerator
SENSING_SENSOR_ATTRIBUTE_INTERVAL 

The interval attribute of a sensor configuration.

SENSING_SENSOR_ATTRIBUTE_SENSITIVITY 

The sensitivity attribute of a sensor configuration.

SENSING_SENSOR_ATTRIBUTE_LATENCY 

The latency attribute of a sensor configuration.

SENSING_SENSOR_ATTRIBUTE_MAX 

The maximum number of attributes that a sensor configuration can have.

◆ sensing_sensor_state

#include <zephyr/sensing/sensing.h>

Sensing subsystem sensor state.

Enumerator
SENSING_SENSOR_STATE_READY 

The sensor is ready.

SENSING_SENSOR_STATE_OFFLINE 

The sensor is offline.

Function Documentation

◆ sensing_close_sensor()

int sensing_close_sensor ( sensing_sensor_handle_t handle)

#include <zephyr/sensing/sensing.h>

Close sensor instance.

Parameters
handleThe sensor instance handle need to close.
Returns
0 on success or negative error value on failure.

◆ sensing_get_config()

int sensing_get_config ( sensing_sensor_handle_t  handle,
struct sensing_sensor_config configs,
int  count 
)

#include <zephyr/sensing/sensing.h>

Get current config items from Sensing subsystem.

Parameters
handleThe sensor instance handle.
configsThe configs to be get according to config attribute.
countcount of configs.
Returns
0 on success or negative error value on failure, not support etc.

◆ sensing_get_sensor_info()

const struct sensing_sensor_info * sensing_get_sensor_info ( sensing_sensor_handle_t  handle)

#include <zephyr/sensing/sensing.h>

Get sensor information from sensor instance handle.

Parameters
handleThe sensor instance handle.
Returns
a const pointer to sensing_sensor_info on success or NULL on failure.

◆ sensing_get_sensors()

int sensing_get_sensors ( int *  num_sensors,
const struct sensing_sensor_info **  info 
)

#include <zephyr/sensing/sensing.h>

Get all supported sensor instances' information.

This API just returns read only information of sensor instances, pointer info will directly point to internal buffer, no need for caller to allocate buffer, no side effect to sensor instances.

Parameters
num_sensorsGet number of sensor instances.
infoFor receiving sensor instances' information array pointer.
Returns
0 on success or negative error value on failure.

◆ sensing_open_sensor()

int sensing_open_sensor ( const struct sensing_sensor_info info,
struct sensing_callback_list cb_list,
sensing_sensor_handle_t handle 
)

#include <zephyr/sensing/sensing.h>

Open sensor instance by sensing sensor info.

Application clients use it to open a sensor instance and get its handle. Support multiple Application clients for open same sensor instance, in this case, the returned handle will different for different clients. meanwhile, also register sensing callback list

Parameters
infoThe sensor info got from sensing_get_sensors
cb_listcallback list to be registered to sensing, must have a static lifetime.
handleThe opened instance handle, if failed will be set to NULL.
Returns
0 on success or negative error value on failure.

◆ sensing_open_sensor_by_dt()

int sensing_open_sensor_by_dt ( const struct device dev,
struct sensing_callback_list cb_list,
sensing_sensor_handle_t handle 
)

#include <zephyr/sensing/sensing.h>

Open sensor instance by device.

Application clients use it to open a sensor instance and get its handle. Support multiple Application clients for open same sensor instance, in this case, the returned handle will different for different clients. meanwhile, also register sensing callback list.

Parameters
devpointer device get from device tree.
cb_listcallback list to be registered to sensing, must have a static lifetime.
handleThe opened instance handle, if failed will be set to NULL.
Returns
0 on success or negative error value on failure.

◆ sensing_set_config()

int sensing_set_config ( sensing_sensor_handle_t  handle,
struct sensing_sensor_config configs,
int  count 
)

#include <zephyr/sensing/sensing.h>

Set current config items to Sensing subsystem.

Parameters
handleThe sensor instance handle.
configsThe configs to be set according to config attribute.
countcount of configs.
Returns
0 on success or negative error value on failure, not support etc.