Skip to content

Commit 57daf41

Browse files
KyraLengfeldnordicjm
authored andcommitted
Bluetooth: Mesh: add metadata to missing models
This commit adds metadata to the Sensor Server, and Time Server models in form of an optional parameter. Note: Metadata is only supported if the Large Composition Data Server model is supported. Signed-off-by: Kyra Lengfeld <[email protected]>
1 parent 497c6c7 commit 57daf41

File tree

5 files changed

+50
-14
lines changed

5 files changed

+50
-14
lines changed

include/bluetooth/mesh/light_hsl_srv.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ struct bt_mesh_light_hsl_srv;
6262
_srv), \
6363
&_bt_mesh_light_hsl_setup_srv_cb)
6464

65-
66-
#ifdef CONFIG_BT_MESH_LARGE_COMP_DATA_SRV
6765
/** Light HSL Hue Range Metadata ID. */
6866
#define BT_MESH_LIGHT_HSL_HUE_RANGE_METADATA_ID 0x0005
6967

@@ -89,7 +87,6 @@ struct bt_mesh_light_hsl_srv;
8987
#define BT_MESH_LIGHT_HSL_SAT_RANGE_METADATA(range_min, range_max) \
9088
BT_MESH_MODELS_METADATA_ENTRY(4, BT_MESH_LIGHT_HSL_SAT_RANGE_METADATA_ID, \
9189
((uint16_t[]){(range_min), (range_max)}))
92-
#endif
9390

9491
/**
9592
* Light HSL Server instance.

include/bluetooth/mesh/light_temp_srv.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ struct bt_mesh_light_temp_srv;
6161
BT_MESH_MODEL_USER_DATA(struct bt_mesh_light_temp_srv, _srv), \
6262
&_bt_mesh_light_temp_srv_cb, __VA_ARGS__)
6363

64-
#ifdef CONFIG_BT_MESH_LARGE_COMP_DATA_SRV
6564
/** Light CTL Temperature Range Metadata ID. */
6665
#define BT_MESH_LIGHT_CTL_TEMP_RANGE_METADATA_ID 0x0004
6766

@@ -74,7 +73,6 @@ struct bt_mesh_light_temp_srv;
7473
#define BT_MESH_LIGHT_CTL_TEMP_RANGE_METADATA(range_min, range_max) \
7574
BT_MESH_MODELS_METADATA_ENTRY(4, BT_MESH_LIGHT_CTL_TEMP_RANGE_METADATA_ID, \
7675
((uint16_t[]){(range_min), (range_max)}))
77-
#endif
7876

7977
/** Light CTL Temperature Server state access handlers. */
8078
struct bt_mesh_light_temp_srv_handlers {

include/bluetooth/mesh/lightness_srv.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ struct bt_mesh_lightness_srv;
6868
_srv), \
6969
&_bt_mesh_lightness_setup_srv_cb)
7070

71-
#ifdef CONFIG_BT_MESH_LARGE_COMP_DATA_SRV
7271
/** The Light Purpose Metadata ID. */
7372
#define BT_MESH_LIGHT_PURPOSE_METADATA_ID 0x0002
7473

@@ -93,7 +92,6 @@ struct bt_mesh_lightness_srv;
9392
#define BT_MESH_LIGHT_LIGHTNESS_RANGE_METADATA(range_min, range_max) \
9493
BT_MESH_MODELS_METADATA_ENTRY(4, BT_MESH_LIGHT_LIGHTNESS_RANGE_METADATA_ID, \
9594
((uint16_t[]){(range_min), (range_max)}))
96-
#endif
9795

9896
/** Collection of handler callbacks for the Light Lightness Server. */
9997
struct bt_mesh_lightness_srv_handlers {

include/bluetooth/mesh/sensor_srv.h

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,36 @@ struct bt_mesh_sensor_srv;
4444
* @brief Sensor Server model composition data entry.
4545
*
4646
* @param[in] _srv Pointer to a @ref bt_mesh_sensor_srv instance.
47+
* @param ... Optional Light Lightness Server metadata if application is
48+
* compiled with Large Composition Data Server support,
49+
* otherwise this parameter is ignored.
4750
*/
48-
#define BT_MESH_MODEL_SENSOR_SRV(_srv) \
49-
BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_SENSOR_SRV, _bt_mesh_sensor_srv_op, \
50-
&(_srv)->pub, \
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, \
5154
BT_MESH_MODEL_USER_DATA(struct bt_mesh_sensor_srv, \
5255
_srv), \
53-
&_bt_mesh_sensor_srv_cb), \
56+
&_bt_mesh_sensor_srv_cb, __VA_ARGS__), \
5457
BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_SENSOR_SETUP_SRV, \
5558
_bt_mesh_sensor_setup_srv_op, \
5659
&(_srv)->setup_pub, \
5760
BT_MESH_MODEL_USER_DATA(struct bt_mesh_sensor_srv, \
5861
_srv), \
5962
&_bt_mesh_sensor_setup_srv_cb)
6063

64+
/** Sensor Properties Metadata ID. */
65+
#define BT_MESH_SENSOR_PROP_METADATA_ID 0x0001
66+
67+
/**
68+
* Sensor Properties Metadata entry.
69+
*
70+
* @param[in] ... list of 16-bit sensor property IDs split by comma.
71+
*/
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__}))
76+
6177
/** Sensor server instance. */
6278
struct bt_mesh_sensor_srv {
6379
/** Sensors owned by this server. */

include/bluetooth/mesh/time_srv.h

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,46 @@ struct tm;
4646
* @brief Time Server model composition data entry.
4747
*
4848
* @param[in] _srv Pointer to a @ref bt_mesh_time_srv instance.
49+
* @param ... Optional Time Server metadata if application is
50+
* compiled with Large Composition Data Server support,
51+
* otherwise this parameter is ignored.
4952
*/
50-
#define BT_MESH_MODEL_TIME_SRV(_srv) \
51-
BT_MESH_MODEL_CB( \
53+
#define BT_MESH_MODEL_TIME_SRV(_srv, ...) \
54+
BT_MESH_MODEL_METADATA_CB( \
5255
BT_MESH_MODEL_ID_TIME_SRV, _bt_mesh_time_srv_op, &(_srv)->pub, \
5356
BT_MESH_MODEL_USER_DATA(struct bt_mesh_time_srv, _srv), \
54-
&_bt_mesh_time_srv_cb), \
57+
&_bt_mesh_time_srv_cb, __VA_ARGS__), \
5558
BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_TIME_SETUP_SRV, \
5659
_bt_mesh_time_setup_srv_op, \
5760
&(_srv)->setup_pub, \
5861
BT_MESH_MODEL_USER_DATA( \
5962
struct bt_mesh_time_srv, _srv), \
6063
&_bt_mesh_time_setup_srv_cb)
6164

65+
/** Clock Accuracy Metadata ID. */
66+
#define BT_MESH_CLOCK_ACCURACY_METADATA_ID 0x0007
67+
68+
/** Timekeeping Reserve Metadata ID. */
69+
#define BT_MESH_TIMEKEEPING_RESERVE_METADATA_ID 0x0008
70+
71+
/**
72+
* Clock Accuracy Metadata entry.
73+
*
74+
* @param clock_accuracy 24-bit clock accuracy value.
75+
*/
76+
#define BT_MESH_CLOCK_ACCURACY_METADATA(clock_accuracy) \
77+
BT_MESH_MODELS_METADATA_ENTRY(3, BT_MESH_CLOCK_ACCURACY_METADATA_ID, \
78+
((uint8_t[]){BT_BYTES_LIST_LE24(clock_accuracy)}))
79+
80+
/**
81+
* Timekeeping Reserve Metadata entry.
82+
*
83+
* @param timekeeping_reserve 24-bit timekeeping reserve value.
84+
*/
85+
#define BT_MESH_TIMEKEEPING_RESERVE_METADATA(timekeeping_reserve) \
86+
BT_MESH_MODELS_METADATA_ENTRY(3, BT_MESH_TIMEKEEPING_RESERVE_METADATA_ID, \
87+
((uint8_t[]){BT_BYTES_LIST_LE24(timekeeping_reserve)}))
88+
6289
/** Time srv update types */
6390
enum bt_mesh_time_update_types {
6491
/** Status update */

0 commit comments

Comments
 (0)