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:

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.

If CONFIG_BT_SETTINGS is enabled, the Generic Power OnOff Server stores all its states persistently using a configurable storage delay to stagger storing. See CONFIG_BT_MESH_STORE_TIMEOUT.

API documentation

Header file: include/bluetooth/mesh/gen_ponoff_srv.h
Source file: 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:
  • _onoff_handlers[in] Handlers for the underlying Generic OnOff Server.

  • _dtt_change_handler[in] Handler function for changes to the Default Transition Time Server state.

  • _on_power_up_change_handler[in] Handler function for changes to the OnPowerUp state.

BT_MESH_MODEL_PONOFF_SRV(_srv)

Generic Power OnOff model entry.

Parameters:

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:
  • srv[in] Server to set the OnPowerUp state of.

  • on_power_up[in] 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 for publishing unprompted status messages. Response messages for get and set messages are handled internally.

Parameters:
  • srv[in] Server instance to publish with.

  • ctx[in] Message context, or NULL to publish with the configured parameters.

Return values:
  • -EADDRNOTAVAIL – A message context was not provided and publishing is not configured.

  • -EAGAIN – The device has not been provisioned.

Returns:

0 Successfully published the current OnPowerUp state.

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.

const struct bt_mesh_model *ponoff_model

Pointer to the model entry in the composition data.

const struct bt_mesh_model *ponoff_setup_model

Pointer to the model entry of the Setup Server.

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.

Param srv:

[in] Server instance that was updated

Param ctx:

[in] Context of the set message that triggered the update, or NULL if it was not triggered by a message.

Param old_on_power_up:

[in] The previous OnPowerUp value.

Param new_on_power_up:

[in] The new OnPowerUp value.

enum bt_mesh_on_power_up on_power_up

Current OnPowerUp state.