nRF Connect SDK API 2.8.99
Loading...
Searching...
No Matches

◆ bt_mesh_sensor_value_from_sensor_value()

int bt_mesh_sensor_value_from_sensor_value ( const struct bt_mesh_sensor_format * format,
const struct sensor_value * val,
struct bt_mesh_sensor_value * sensor_val )

#include <include/bluetooth/mesh/sensor.h>

Convert a sensor_value (include/zephyr/drivers/sensor.h) instance to a bt_mesh_sensor_value.

If val has a value that cannot be represented by the format, sensor_val will be set to the value clamped to the range supported by the format, and this function will return -ERANGE. This will clamp to "Greater than or equal to the maximum value" and "Less than or equal to the minimum value" if these are supported by the format.

If this function returns an error code other than -ERANGE, sensor_val is not modified.

Parameters
[in]formatFormat to use when encoding the sensor value.
[in]valThe sensor_value to convert.
[out]sensor_valThe resulting bt_mesh_sensor_value.
Returns
0 on success, (negative) error code otherwise.