Generic Power OnOff Server¶
The Generic Power OnOff Server controls the power up behavior of other models on its element.
The Generic Power OnOff Server adds the following model instances in the composition data:
The Generic Power OnOff Server
The Generic Power OnOff Setup Server
These model instances share the states of the Generic Power OnOff Server, but accept different messages. This allows for a fine-grained control of the access rights for the Generic Power OnOff state, as the two model instances can be bound to different application keys:
The Generic Power OnOff Server only provides read access to the Generic On Power Up state.
The Generic Power OnOff Setup Server provides write access to the Generic On Power Up state, allowing configurator devices to change the power up behavior of the element.
Configuration¶
The following configuration parameters are associated with the Generic Power OnOff Server model:
CONFIG_BT_SETTINGS
- The server requires this option to be enabled to work properly. UnlessCONFIG_BT_SETTINGS
is explicitly disabled, including the Generic Power OnOff Server will enableCONFIG_BT_SETTINGS
.
States¶
The Generic Power OnOff Server model contains the following state:
- Generic On Power Up:
bt_mesh_on_power_up
The Generic On Power Up state controls the initial value of the extended Generic OnOff state when the device powers up. The state can have the following initial values:
BT_MESH_ON_POWER_UP_OFF
- The OnOff state is initialized to Off.BT_MESH_ON_POWER_UP_ON
- The OnOff state is initialized to On. If any other states are bound to the On Power Up state, they are initialized to their default values.BT_MESH_ON_POWER_UP_RESTORE
- The OnOff state is initialized to its last known value. If any other states are bound to the On Power Up state, they are initialized to their default values.
The memory for the Generic On Power Up state is contained in the model structure, and state changes can be observed with the
bt_mesh_ponoff_srv.update
callback.
Extended models¶
The Generic Power OnOff Server extends the following models:
The On Power Up state is bound to the Generic OnOff state of the extended Generic OnOff model through its power up behavior. No other state bindings are present, and the callbacks for both the Generic OnOff server and the Generic DTT server are forwarded to the application as they are.
Persistent storage¶
The Generic On Power Up state is stored persistently, along with the current Generic OnOff state of the extended Generic OnOff Server.
API documentation¶
include/bluetooth/mesh/gen_ponoff_srv.h
subsys/bluetooth/mesh/gen_ponoff_srv.c
-
group
bt_mesh_ponoff_srv
API for the Generic Power OnOff Server.
Defines
-
BT_MESH_PONOFF_SRV_INIT
(_onoff_handlers, _dtt_change_handler, _on_power_up_change_handler)¶ Initialization parameters for Generic Power OnOff Server model.
- Parameters
[in] _onoff_handlers
: Handlers for the underlying Generic OnOff Server.[in] _dtt_change_handler
: Handler function for changes to the Default Transition Time Server state.[in] _on_power_up_change_handler
: Handler function for changes to the OnPowerUp state.
-
BT_MESH_MODEL_PONOFF_SRV
(_srv)¶ Generic Power OnOff model entry.
- Parameters
[in] _srv
: Pointer to a Generic Power OnOff Server model instance.
Functions
-
void
bt_mesh_ponoff_srv_set
(struct bt_mesh_ponoff_srv *srv, enum bt_mesh_on_power_up on_power_up)¶ Set the OnPowerUp state of a Power OnOff server.
If an update handler is set, it’ll be called with the updated OnPowerUp value. If publication is configured, the change will cause the server to publish.
- Parameters
[in] srv
: Server to set the OnPowerUp state of.[in] on_power_up
: New OnPowerUp value.
-
int
bt_mesh_ponoff_srv_pub
(struct bt_mesh_ponoff_srv *srv, struct bt_mesh_msg_ctx *ctx)¶ Publish the current OnPowerUp state.
Publishes a Generic Power OnOff status message with the configured publish parameters, or using the given message context.
- Note
This API is only used publishing unprompted status messages. Response messages for get and set messages are handled internally.
- Return
0 Successfully published the current OnPowerUp state.
- Parameters
[in] srv
: Server instance to publish with.[in] ctx
: Message context, or NULL to publish with the configured parameters.
- Return Value
-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_ponoff_srv
¶ - #include <gen_ponoff_srv.h>
Generic Power OnOff Server instance.
Should be initialized with BT_MESH_PONOFF_SRV_INIT.
Public Members
-
struct bt_mesh_onoff_srv
onoff
¶ Generic OnOff Server instance.
-
struct bt_mesh_dtt_srv
dtt
¶ Generic Default Transition Time server instance.
-
struct bt_mesh_model *
ponoff_model
¶ Pointer to the model entry in the composition data.
-
struct bt_mesh_model_pub
pub
¶ Model publication parameters.
-
const struct bt_mesh_onoff_srv_handlers *const
onoff_handlers
¶ Handlers for the Generic OnOff Server.
-
void (*const
update
)(struct bt_mesh_ponoff_srv *srv, struct bt_mesh_msg_ctx *ctx, enum bt_mesh_on_power_up old_on_power_up, enum bt_mesh_on_power_up new_on_power_up)¶ Update handler.
Called every time there’s a change to the OnPowerUp state.
- Parameters
[in] srv
: Server instance that was updated[in] ctx
: Context of the set message that triggered the update, or NULL if it was not triggered by a message.[in] old_on_power_up
: The previous OnPowerUp value.[in] new_on_power_up
: The new OnPowerUp value.
-
enum bt_mesh_on_power_up
on_power_up
¶ Current OnPowerUp state.
-
struct bt_mesh_onoff_srv
-