Generic Property Servers¶
A Generic Property Server holds a list of Device Properties. The following property servers are supported:
Generic Manufacturer Property Server - Provides access to Manufacturer properties, which are read-only properties set by the device manufacturer.
Generic Admin Property Server - Provides access to Admin properties, which can be read and written to.
Generic User Property Server - Provides access to both Admin and Manufacturer properties on its element, but only if the Property owner allows it.
Generic Client Property Server - Provides a list of all properties supported by the Generic Property Client on the same element. The Client Property Server does not actually own any properties, and does not need the user to provide access to any property values.
When developing, take the following into account:
Only the administrator of the mesh network should have access to the Admin or Manufacturer servers.
All other mesh nodes should operate on the User server.
The Manufacturer and Admin servers:
May change the User property access rights for each individual Property they own at runtime.
Must provide a list of all Properties they own in the initialization of the model.
The User Property server does not own any properties, but relies on Admin and Manufacturer servers on the same element to provide access to their properties. An element with a User Property Server and no Admin or Manufacturer Server is useless.
The model keeps the user access field of each Admin and Manufacturer property in persistent storage. The property values themselves must be stored by the application.
Your application should provide access to the property values through the callbacks of server getter (
bt_mesh_prop_srv.get
) and setter (bt_mesh_prop_srv.set
).The set of Property IDs and their order cannot be changed.
States¶
The Generic Power OnOff Server model contains the following state:
- Device Properties:
bt_mesh_prop
A single server may own several Device Properties, which are accessed by the Property ID. Each Property holds a value and a user access parameter, which controls the Property’s availability to a Generic User Property Server on the same element.
The Device Properties have slightly different access restrictions depending on the type of server that owns them:
Manufacturer Property - The value can only be read.
Admin Property - The value can be read and written.
Client Property - Has no associated value, and is only a listing of the property IDs supported by the accompanying Generic Property Client.
Extended models¶
The Generic Admin Property Server and Generic Manufacturer Property Server should both extend the Generic User Property Server. This is not handled automatically by the model implementation. For this reason, to ensure compliance with the Bluetooth Mesh Model specification, a Generic User Property Server must be instantiated in the same element in the device composition data as the Generic Admin or Generic Manufacturer Property server.
Persistent storage¶
The Generic Manufacturer Property Server and Generic Admin Property Server models will store changes to the user access rights of their properties. Any permanent changes to the property values themselves should be stored manually by the application.
API documentation¶
include/bluetooth/mesh/gen_prop_srv.h
subsys/bluetooth/mesh/gen_prop_srv.c
-
group
bt_mesh_prop_srv
API for the Generic Property server models.
Defines
-
BT_MESH_PROP_SRV_INIT
(_properties, _property_count, _get, _set)¶ Initialization parameters for a Generic Property server models instance.
- See
- See
- Parameters
[in] _properties
: Array of properties supported by the server.[in] _property_count
: Number of properties supported by the server.[in] _get
: Getter handler for property values.
- Parameters
[in] _set
: Setter handler for property values.
-
BT_MESH_PROP_SRV_USER_INIT
()¶ Initialization parameters for a Generic Property server models acting as a Generic User Property Server.
-
BT_MESH_PROP_SRV_ADMIN_INIT
(_properties, _get, _set)¶ Initialization parameters for a Generic Property server models acting as a Generic Admin Property Server.
- Parameters
[in] _properties
: Array of properties exposed by the server.[in] _get
: Getter function for property values.[in] _set
: Setter function for property values.
-
BT_MESH_PROP_SRV_MFR_INIT
(_properties, _get)¶ Initialization parameters for a Generic Property server models acting as a Generic Manufacturer Property Server.
- Parameters
[in] _properties
: Array of properties exposed by the server.[in] _get
: Getter function for property values.
-
BT_MESH_PROP_SRV_CLIENT_INIT
(_properties)¶ Initialization parameters for a Generic Property server models acting as a Generic Client Property Server.
- Parameters
[in] _properties
: Array of properties exposed by the server. May be constant.
-
BT_MESH_MODEL_PROP_SRV_USER
(_srv)¶ Generic User Property Server model composition data entry.
-
BT_MESH_MODEL_PROP_SRV_ADMIN
(_srv)¶ Generic Admin Property Server model composition data entry.
- Parameters
[in] _srv
: Pointer to a Generic Property server models instance acting as an Admin Property Server.
-
BT_MESH_MODEL_PROP_SRV_MFR
(_srv)¶ Generic Manufacturer Property Server model data entry.
- Parameters
[in] _srv
: Pointer to a Generic Property server models instance acting as a Manufacturer Property Server.
-
BT_MESH_MODEL_PROP_SRV_CLIENT
(_srv)¶ Generic Client Property Server model data entry.
- Parameters
[in] _srv
: Pointer to a Generic Property server models instance acting as a Client Property Server.
Enums
Functions
-
int
bt_mesh_prop_srv_pub_list
(struct bt_mesh_prop_srv *srv, struct bt_mesh_msg_ctx *ctx)¶ Publish a list of all properties on the server.
- Parameters
[in] srv
: Server that owns the property.[in] ctx
: Message context to publish with, or NULL to publish on the configured publish parameters.
- Return Value
0
: Successfully publish a Generic Level Status message.-EMSGSIZE
: The given property size is not supported.-ENOTSUP
: A message context was not provided and publishing is not supported.-EADDRNOTAVAIL
: A message context was not provided and publishing is not configured.-EAGAIN
: The device has not been provisioned.
-
int
bt_mesh_prop_srv_pub
(struct bt_mesh_prop_srv *srv, struct bt_mesh_msg_ctx *ctx, const struct bt_mesh_prop_val *val)¶ Publish a property value.
- Parameters
[in] srv
: Server that owns the property.[in] ctx
: Message context to publish with, or NULL to publish on the configured publish parameters.[in] val
: Value of the property.
- Return Value
0
: Successfully publish a Generic Level Status message.-EINVAL
: The server is a Client Property server, which does not support publishing of property values.-EMSGSIZE
: The given property size is not supported.-ENOTSUP
: A message context was not provided and publishing is not supported.-EADDRNOTAVAIL
: A message context was not provided and publishing is not configured.-EAGAIN
: The device has not been provisioned.
-
struct
bt_mesh_prop_srv
¶ - #include <gen_prop_srv.h>
Generic Property Server instance. Should be initialized with the BT_MESH_PROP_SRV_INIT, BT_MESH_PROP_SRV_ADMIN_INIT, BT_MESH_PROP_SRV_MFR_INIT or BT_MESH_PROP_SRV_CLIENT_INIT macro.
Public Members
-
struct bt_mesh_model *
mod
¶ Pointer to the mesh model entry.
-
struct bt_mesh_model_pub
pub
¶ Model publication parameters.
-
uint16_t
pub_id
¶ Property ID currently being published.
-
enum bt_mesh_prop_srv_state
pub_state
¶ Which state is currently being published.
-
struct bt_mesh_prop *const
properties
¶ List of properties supported by the server.
-
const uint32_t
property_count
¶ Number of properties supported by the server.
-
void (*const
set
)(struct bt_mesh_prop_srv *srv, struct bt_mesh_msg_ctx *ctx, struct bt_mesh_prop_val *val)¶ Set a property value.
The handler may reject the value change with two levels of severity:
To indicate data format errors and permanently illegal values, change the
val::meta::id
field to BT_MESH_PROP_ID_PROHIBITED before returning. This will cancel the response message sending, indicating a protocol violation.To indicate that the new value is temporarily unable to change, but not in violation of the protocol, replace the contents of
buf
andsize
with the current property value and size. Note thatbuf
can only fit a value of sizeCONFIG_GEN_PROP_MAXSIZE
.- Note
This handler is mandatory if the server is acting as an Admin Property Server, and ignored if the server is acting as a Manufacturer Property Server.
- Parameters
[in] srv
: Property Server instance whose property to set.[in] ctx
: Message context for the message that triggered the change, or NULL if the change is not coming from a messge.[inout] val
: Property value to set. Any changes to the value will be reflected in the response message.
-
void (*const
get
)(struct bt_mesh_prop_srv *srv, struct bt_mesh_msg_ctx *ctx, struct bt_mesh_prop_val *val)¶ Get a property value.
Note that
buf
can only fit a value of sizeCONFIG_GEN_PROP_MAXSIZE
.- Note
This handler is mandatory.
- Parameters
[in] srv
: Property Server instance whose property to set.[in] ctx
: Message context for the message that triggered the change, or NULL if the change is not coming from a messge.[inout] val
: Property value to get. Any changes to the value will be reflected in the response message.
-
struct bt_mesh_model *
-