13#ifndef BT_MESH_SENSOR_SRV_H__
14#define BT_MESH_SENSOR_SRV_H__
35#define BT_MESH_SENSOR_SRV_INIT(_sensors, _count) \
37 .sensor_array = _sensors, \
39 MIN(CONFIG_BT_MESH_SENSOR_SRV_SENSORS_MAX, _count), \
51#define BT_MESH_MODEL_SENSOR_SRV(_srv, ...) \
52 BT_MESH_MODEL_METADATA_CB(BT_MESH_MODEL_ID_SENSOR_SRV, \
53 _bt_mesh_sensor_srv_op, &(_srv)->pub, \
54 BT_MESH_MODEL_USER_DATA(struct bt_mesh_sensor_srv, \
56 &_bt_mesh_sensor_srv_cb, __VA_ARGS__), \
57 BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_SENSOR_SETUP_SRV, \
58 _bt_mesh_sensor_setup_srv_op, \
60 BT_MESH_MODEL_USER_DATA(struct bt_mesh_sensor_srv, \
62 &_bt_mesh_sensor_setup_srv_cb)
65#define BT_MESH_SENSOR_PROP_METADATA_ID 0x0001
72#define BT_MESH_SENSOR_PROP_METADATA(...) \
73 BT_MESH_MODELS_METADATA_ENTRY(2 * ARRAY_SIZE(((uint16_t[]){__VA_ARGS__})), \
74 BT_MESH_SENSOR_PROP_METADATA_ID, \
75 ((uint16_t[]){__VA_ARGS__}))
89 struct bt_mesh_model_pub
pub;
94 BT_MESH_SENSOR_OP_STATUS,
95 (CONFIG_BT_MESH_SENSOR_SRV_SENSORS_MAX *
96 BT_MESH_SENSOR_STATUS_MAXLEN))];
103 BT_MESH_MODEL_BUF_LEN(
104 BT_MESH_SENSOR_OP_SETTING_STATUS,
105 BT_MESH_SENSOR_MSG_MAXLEN_SETTING_STATUS),
106 BT_MESH_MODEL_BUF_LEN(
107 BT_MESH_SENSOR_OP_CADENCE_STATUS,
108 BT_MESH_SENSOR_MSG_MAXLEN_CADENCE_STATUS))];
132 struct bt_mesh_msg_ctx *ctx,
159extern const struct bt_mesh_model_cb _bt_mesh_sensor_srv_cb;
160extern const struct bt_mesh_model_op _bt_mesh_sensor_srv_op[];
161extern const struct bt_mesh_model_cb _bt_mesh_sensor_setup_srv_cb;
162extern const struct bt_mesh_model_op _bt_mesh_sensor_setup_srv_op[];
int bt_mesh_sensor_srv_pub(struct bt_mesh_sensor_srv *srv, struct bt_mesh_msg_ctx *ctx, struct bt_mesh_sensor *sensor, const struct bt_mesh_sensor_value *value)
Publish a sensor value.
int bt_mesh_sensor_srv_sample(struct bt_mesh_sensor_srv *srv, struct bt_mesh_sensor *sensor)
Make the server to take a sample of the sensor, and publish if the value changed sufficiently.
struct net_buf_simple setup_pub_buf
Definition sensor_srv.h:100
struct bt_mesh_model_pub pub
Definition sensor_srv.h:89
uint8_t sensor_count
Definition sensor_srv.h:86
sys_slist_t sensors
Definition sensor_srv.h:82
const struct bt_mesh_model * model
Definition sensor_srv.h:110
struct bt_mesh_model_pub setup_pub
Definition sensor_srv.h:98
struct net_buf_simple pub_buf
Definition sensor_srv.h:91
struct bt_mesh_sensor *const * sensor_array
Definition sensor_srv.h:80
uint8_t setup_pub_data[MAX(BT_MESH_MODEL_BUF_LEN(BT_MESH_SENSOR_OP_SETTING_STATUS, BT_MESH_SENSOR_MSG_MAXLEN_SETTING_STATUS), BT_MESH_MODEL_BUF_LEN(BT_MESH_SENSOR_OP_CADENCE_STATUS, BT_MESH_SENSOR_MSG_MAXLEN_CADENCE_STATUS))]
Definition sensor_srv.h:108
uint16_t seq
Definition sensor_srv.h:84
uint8_t pub_data[BT_MESH_MODEL_BUF_LEN(BT_MESH_SENSOR_OP_STATUS,(CONFIG_BT_MESH_SENSOR_SRV_SENSORS_MAX *BT_MESH_SENSOR_STATUS_MAXLEN))]
Definition sensor_srv.h:96
Definition sensor_srv.h:78