Generic OnOff Server¶
The Generic OnOff Server contains a single controllable On/Off state.
States¶
The Generic OnOff Server model contains the following state:
- Generic OnOff:
boolean
Generic boolean state representing an On/Off state. Your application is expected to hold the state memory and provide access to the state through the
bt_mesh_onoff_srv_handlers
handler structure.Changes to the Generic OnOff state may include transition parameters. When transitioning to a new OnOff state:
The state should be on during the entire transition, regardless of the target state. This ensures that any bound non-binary states can have non-zero values during the transition. Any request to read out the current OnOff state while in a transition should report the current OnOff value being on.
The
remaining_time
parameter should be reported in milliseconds (including an optional delay).
If the transition parameters include a delay, the state must remain unchanged until the delay expires.
Extended models¶
None.
Persistent storage¶
None.
API documentation¶
include/bluetooth/mesh/gen_onoff_srv.h
subsys/bluetooth/mesh/gen_onoff_srv.c
-
group
bt_mesh_onoff_srv
API for the Generic OnOff Server model.
Defines
-
BT_MESH_ONOFF_SRV_INIT
(_handlers)¶ Init parameters for a Generic OnOff Server model instance.
- Parameters
[in] _handlers
: State access handlers to use in the model instance.
-
BT_MESH_MODEL_ONOFF_SRV
(_srv)¶ Generic OnOff Server model composition data entry.
- Parameters
[in] _srv
: Pointer to a Generic OnOff Server model instance.
Functions
-
int32_t
bt_mesh_onoff_srv_pub
(struct bt_mesh_onoff_srv *srv, struct bt_mesh_msg_ctx *ctx, const struct bt_mesh_onoff_status *status)¶ Publish the Generic OnOff Server model status.
Asynchronously publishes a Generic OnOff status message with the configured publish parameters.
- Note
This API is only used for publishing unprompted status messages. Response messages for get and set messages are handled internally.
- Parameters
[in] srv
: Server instance to publish on.[in] ctx
: Message context to send with, or NULL to send with the default publish parameters.[in] status
: Current status.
- Return Value
0
: Successfully published a Generic OnOff Status message.-EADDRNOTAVAIL
: A message context was not provided and publishing is not configured.-EAGAIN
: The device has not been provisioned.
-
struct
bt_mesh_onoff_srv_handlers
¶ - #include <gen_onoff_srv.h>
Generic OnOff Server state access handlers.
Public Members
-
void (*const
set
)(struct bt_mesh_onoff_srv *srv, struct bt_mesh_msg_ctx *ctx, const struct bt_mesh_onoff_set *set, struct bt_mesh_onoff_status *rsp)¶ Set the OnOff state.
- Note
This handler is mandatory.
- Parameters
[in] srv
: Server instance to set the state of.[in] ctx
: Message context for the message that triggered the change, or NULL if the change is not coming from a message.[in] set
: Parameters of the state change.[out] rsp
: Response structure to be filled.
-
void (*const
get
)(struct bt_mesh_onoff_srv *srv, struct bt_mesh_msg_ctx *ctx, struct bt_mesh_onoff_status *rsp)¶ Get the OnOff state.
- Note
This handler is mandatory.
- Parameters
[in] srv
: Server instance to get the state of.[in] ctx
: Message context for the message that triggered the change, or NULL if the change is not coming from a message.[out] rsp
: Response structure to be filled.
-
void (*const
-
struct
bt_mesh_onoff_srv
¶ - #include <gen_onoff_srv.h>
Generic OnOff Server instance. Should primarily be initialized with the BT_MESH_ONOFF_SRV_INIT macro.
Public Members
-
struct bt_mesh_tid_ctx
prev_transaction
¶ Transaction ID tracker.
-
const struct bt_mesh_onoff_srv_handlers *
handlers
¶ Handler function structure.
-
struct bt_mesh_model *
model
¶ Access model pointer.
-
struct bt_mesh_model_pub
pub
¶ Publish parameters.
-
struct bt_mesh_tid_ctx
-