Generic Location Client

The Generic Location Client model can get and set the state of a Generic Location Server model remotely.

Unlike the Generic Location Server model, the Generic Location Client only creates a single model instance in the mesh composition data. The Generic Location Client may send messages to both the Generic Location Server and the Generic Location Setup Server, as long as it has the right application keys.

API documentation

Header file: include/bluetooth/mesh/gen_loc_cli.h
Source file: subsys/bluetooth/mesh/gen_loc_cli.c
group bt_mesh_loc_cli

API for the Generic Location Client model.

Defines

BT_MESH_LOC_CLI_INIT(_handlers)

Initialization parameters for a Generic Location Client model instance.

Parameters

BT_MESH_MODEL_LOC_CLI(_cli)

Generic Location Client model composition data entry.

Parameters

Functions

int bt_mesh_loc_cli_global_get(struct bt_mesh_loc_cli *cli, struct bt_mesh_msg_ctx *ctx, struct bt_mesh_loc_global *rsp)

Get the global location 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_loc_cli_handlers::global_status callback.

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

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

  • [out] rsp: Global Location response buffer, or NULL to keep from blocking.

Return Value
  • 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_loc_cli_global_set(struct bt_mesh_loc_cli *cli, struct bt_mesh_msg_ctx *ctx, const struct bt_mesh_loc_global *loc, struct bt_mesh_loc_global *rsp)

Set the Global Location in the 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_loc_cli_handlers::global_status callback.

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

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

  • [in] loc: New Global Location value to set.

  • [out] rsp: Response status buffer, or NULL to keep from blocking.

Return Value
  • 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_loc_cli_global_set_unack(struct bt_mesh_loc_cli *cli, struct bt_mesh_msg_ctx *ctx, const struct bt_mesh_loc_global *loc)

Set the Global Location in the server without requesting a response.

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

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

  • [in] loc: New Global Location value to set.

Return Value
  • 0: Successfully sent the message.

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

  • -EAGAIN: The device has not been provisioned.

int bt_mesh_loc_cli_local_get(struct bt_mesh_loc_cli *cli, struct bt_mesh_msg_ctx *ctx, struct bt_mesh_loc_local *rsp)

Get the local location 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_loc_cli_handlers::local_status callback.

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

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

  • [out] rsp: Local Location response buffer, or NULL to keep from blocking.

Return Value
  • 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_loc_cli_local_set(struct bt_mesh_loc_cli *cli, struct bt_mesh_msg_ctx *ctx, const struct bt_mesh_loc_local *loc, struct bt_mesh_loc_local *rsp)

Set the Local Location in the 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_loc_cli_handlers::local_status callback.

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

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

  • [in] loc: New Local Location value to set.

  • [out] rsp: Response status buffer, or NULL to keep from blocking.

Return Value
  • 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_loc_cli_local_set_unack(struct bt_mesh_loc_cli *cli, struct bt_mesh_msg_ctx *ctx, const struct bt_mesh_loc_local *loc)

Set the Local Location in the server without requesting a response.

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

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

  • [in] loc: New Local Location value to set.

Return Value
  • 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_loc_cli_handlers
#include <gen_loc_cli.h>

Location handler functions

Public Members

void (*const global_status)(struct bt_mesh_loc_cli *cli, struct bt_mesh_msg_ctx *ctx, const struct bt_mesh_loc_global *status)

Global Location status message handler.

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

  • [in] ctx: Context of the incoming message.

  • [in] status: Global Location parameters of the Generic Location Server that published the message.

void (*const local_status)(struct bt_mesh_loc_cli *cli, struct bt_mesh_msg_ctx *ctx, const struct bt_mesh_loc_local *status)

Local Location status message handler.

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

  • [in] ctx: Context of the incoming message.

  • [in] status: Local Location parameters of the Generic Location Server that published the message.

struct bt_mesh_loc_cli
#include <gen_loc_cli.h>

Generic Location Client structure.

Should be initialized with the BT_MESH_LOC_CLI_INIT macro.

Public Members

const struct bt_mesh_loc_cli_handlers *const handlers

Handler function structure

struct bt_mesh_model_ack_ctx ack_ctx

Response context for tracking acknowledged messages.

struct bt_mesh_model_pub pub

Publish parameters.

struct bt_mesh_model *model

Composition data model entry pointer.