Generic OnOff Client

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

API documentation

Header file: include/bluetooth/mesh/gen_onoff_cli.h
Source file: subsys/bluetooth/mesh/gen_onoff_cli.c
group bt_mesh_onoff_cli

API for the Generic OnOff Client model.

Defines

BT_MESH_ONOFF_CLI_INIT(_status_handler)

Initialization parameters for a Generic OnOff Client model instance.

Parameters
  • _status_handler[in] Optional status message handler.

BT_MESH_MODEL_ONOFF_CLI(_cli)

Generic OnOff Client model composition data entry.

Parameters

Functions

int bt_mesh_onoff_cli_get(struct bt_mesh_onoff_cli *cli, struct bt_mesh_msg_ctx *ctx, struct bt_mesh_onoff_status *rsp)

Get the status of the bound srv.

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_onoff_cli::status_handler callback.

Parameters
  • cli[in] Client model to send on.

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

  • rsp[out] Status response buffer, or NULL to keep from blocking.

Returns

  • 0 – Successfully sent the message and populated the rsp buffer.

  • -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_onoff_cli_set(struct bt_mesh_onoff_cli *cli, struct bt_mesh_msg_ctx *ctx, const struct bt_mesh_onoff_set *set, struct bt_mesh_onoff_status *rsp)

Set the OnOff state in the srv.

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_onoff_cli::status_handler callback.

Parameters
  • cli[in] Client model to send on.

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

  • set[in] New OnOff parameters to set. set::transition can either point to a transition structure, or be left to NULL to use the default transition parameters on the server.

  • rsp[out] Status response buffer, or NULL to keep from blocking.

Returns

  • 0 – Successfully sent the message and populated the rsp buffer.

  • -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_onoff_cli_set_unack(struct bt_mesh_onoff_cli *cli, struct bt_mesh_msg_ctx *ctx, const struct bt_mesh_onoff_set *set)

Set the OnOff state in the srv without requesting a response.

Parameters
  • cli[in] Client model to send on.

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

  • set[in] New OnOff parameters to set. set::transition can either point to a transition structure, or be left to NULL to use the default transition parameters on the server.

Returns

  • 0 – Successfully sent the message.

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

  • -EAGAIN – The device has not been provisioned.

struct bt_mesh_onoff_cli
#include <gen_onoff_cli.h>

Generic OnOff Client structure.

Should be initialized with the BT_MESH_ONOFF_CLI_INIT macro.

Public Members

void (*const status_handler)(struct bt_mesh_onoff_cli *cli, struct bt_mesh_msg_ctx *ctx, const struct bt_mesh_onoff_status *status)

OnOff status message handler.

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

  • ctx[in] Context of the incoming message.

  • status[in] OnOff Status of the Generic OnOff Server that published the message.

uint8_t tid

Current Transaction ID.

struct bt_mesh_msg_ack_ctx ack_ctx

Response context for tracking acknowledged messages.

struct bt_mesh_model_pub pub

Publish parameters.

struct bt_mesh_model *model

Access model pointer.