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.

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
  • [in] _power_onoff_status_handler: 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
  • [in] cli: Power OnOff client to send the message on.

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

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

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

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

  • -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.

  • -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
  • [in] cli: Power OnOff client to send the message on.

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

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

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

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

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

  • -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.

  • -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
  • [in] cli: Power OnOff client to send the message on.

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

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

Return Value
  • 0: Successfully sent a set message.

  • -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_cli
#include <gen_ponoff_cli.h>

Generic Power OnOff client instance.

Should be initialized with BT_MESH_PONOFF_CLI_INIT.

Public Members

struct bt_mesh_model *model

Model entry pointer.

struct bt_mesh_model_pub pub

Publish parameters.

struct bt_mesh_model_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.

Parameters
  • [in] cli: Client that received the status message.

  • [in] ctx: Message context the message was received with.

  • [in] on_power_up: The OnPowerUp state presented in the message.