Generic Power OnOff Client

The Generic Power OnOff Client model remotely controls the state of a Generic Power OnOff Server model.

Unlike the Generic Power OnOff Server, the Generic Power OnOff Client only adds one model instance to the composition data. The Generic Power OnOff Client may send messages to both the Generic Power OnOff Server and the Generic Power OnOff Setup Server, as long as it has the right application keys.

Extended models

None.

Persistent storage

None.

Shell commands

The Bluetooth Mesh shell subsystem provides a set of commands to interact with the Generic Power OnOff Client model instantiated on a device.

To make these commands available, enable the following Kconfig options:

mesh models ponoff instance get-all

Print all instances of the Generic Power OnOff Client model on the device.

mesh models ponoff instance set <ElemIdx>

Select the Generic Power OnOff Client model instantiated on the specified element ID. This instance will be used in message sending. If no model instance is selected, the first model instance found on the device will be used by default.

  • ElemIdx - Element index where the model instance is found.

mesh models ponoff get

Get the OnPowerUp state of the server.

mesh models ponoff set <PowUpState>

Set the OnPowerUp state of the server and wait for a response.

  • PowUpState - OnPowerUp state value to set. Allowed values:
    • 0 - On power-up, sets the state to off.

    • 1 - On power-up, sets the state to on.

    • 2 - On power-up, restores the previous state value.

mesh models ponoff set-unack <PowUpState>

Set the Generic Power OnOff state value without requesting a response.

  • PowUpState - OnPowerUp state value to set. Allowed values:
    • 0 - On power-up, sets the state to off.

    • 1 - On power-up, sets the state to on.

    • 2 - On power-up, restores the previous state value.

API documentation

Header file: include/bluetooth/mesh/gen_ponoff_cli.h
Source file: subsys/bluetooth/mesh/gen_ponoff_cli.c
group bt_mesh_ponoff_cli

API for the Generic Power OnOff Client.

Defines

BT_MESH_PONOFF_CLI_INIT(_power_onoff_status_handler)

Initialization parameters for Generic Power OnOff Client.

Parameters:
  • _power_onoff_status_handler[in] OnPowerUp status handler.

BT_MESH_MODEL_PONOFF_CLI(_cli)

Generic Power OnOff Client model composition data entry.

Parameters:

Functions

int bt_mesh_ponoff_cli_on_power_up_get(struct bt_mesh_ponoff_cli *cli, struct bt_mesh_msg_ctx *ctx, enum bt_mesh_on_power_up *rsp)

Get the OnPowerUp state of a server.

This call is blocking if the rsp buffer is non-NULL. Otherwise, this function will return, and the response will be passed to the bt_mesh_ponoff_cli::status_handler callback.

Parameters:
  • cli[in] Power OnOff client to send the message on.

  • ctx[in] Context of the message, or NULL to send on the configured publish parameters.

  • rsp[out] Response buffer to put the received response in, or NULL to process the response in the status handler callback.

Return values:
  • 0 – Successfully sent a get message. If a response buffer is provided, it has been populated.

  • -EALREADY – A blocking request is already in progress.

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

  • -EAGAIN – The device has not been provisioned.

  • -ETIMEDOUT – The request timed out without a response.

int bt_mesh_ponoff_cli_on_power_up_set(struct bt_mesh_ponoff_cli *cli, struct bt_mesh_msg_ctx *ctx, enum bt_mesh_on_power_up on_power_up, enum bt_mesh_on_power_up *rsp)

Set the OnPowerUp state of a server.

This call is blocking if the rsp buffer is non-NULL. Otherwise, this function will return, and the response will be passed to the bt_mesh_ponoff_cli::status_handler callback.

Parameters:
  • cli[in] Power OnOff client to send the message on.

  • ctx[in] Context of the message, or NULL to send with the configured publish parameters.

  • on_power_up[in] New OnPowerUp state of the server.

  • rsp[out] Response buffer to put the received response in, or NULL to keep from blocking.

Return values:
  • 0 – Successfully sent a set message. If a response buffer is provided, it has been populated.

  • -EALREADY – A blocking request is already in progress.

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

  • -EAGAIN – The device has not been provisioned.

  • -ETIMEDOUT – The request timed out without a response.

int bt_mesh_ponoff_cli_on_power_up_set_unack(struct bt_mesh_ponoff_cli *cli, struct bt_mesh_msg_ctx *ctx, enum bt_mesh_on_power_up on_power_up)

Set the OnPowerUp state of a server without requesting a response.

Parameters:
  • cli[in] Power OnOff client to send the message on.

  • ctx[in] Context of the message, or NULL to send with the configured publish parameters.

  • on_power_up[in] New OnPowerUp state of the server.

Return values:
  • 0 – Successfully sent a set message.

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

  • -EAGAIN – The device has not been provisioned.

struct bt_mesh_ponoff_cli
#include <gen_ponoff_cli.h>

Generic Power OnOff client instance.

Should be initialized with BT_MESH_PONOFF_CLI_INIT.

Public Members

const struct bt_mesh_model *model

Model entry pointer.

struct bt_mesh_model_pub pub

Publish parameters.

struct bt_mesh_msg_ack_ctx ack_ctx

Response context for tracking acknowledged messages.

void (*const status_handler)(struct bt_mesh_ponoff_cli *cli, struct bt_mesh_msg_ctx *ctx, enum bt_mesh_on_power_up on_power_up)

OnPowerUp status message handler.

Param cli:

[in] Client that received the status message.

Param ctx:

[in] Message context the message was received with.

Param on_power_up:

[in] The OnPowerUp state presented in the message.