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.

Extended models

None.

Persistent storage

None.

Shell commands

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

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

mesh models loc instance get-all

Print all instances of the Generic Location Client model on the device.

mesh models loc instance set <ElemIdx>

Select the Generic Location 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 loc global-get

Get the current global location value of the Generic Location state.

mesh models loc global-set <Lat> <Long> <Alt>

Set the global location value of the Generic Location state and wait for a response.

  • Lat - Global WGS84 North coordinate in degrees.

  • Long - Global WGS84 East coordinate in degrees.

  • Alt - Global altitude above the WGS84 datum in meters.

mesh models loc global-set-unack <Lat> <Long> <Alt>

Set the global location value of the Generic Location state without requesting a response.

  • Lat - Global WGS84 North coordinate in degrees.

  • Long - Global WGS84 East coordinate in degrees.

  • Alt - Global altitude above the WGS84 datum in meters.

mesh models loc local-get

Get the current local location value of the Generic Location state.

mesh models loc local-set <North> <East> <Alt> <Floor> [TimeDlt(ms) [Prec(mm) [IsMobile]]]

Set the local location value of the Generic Location state and wait for a response.

  • North - Local north position in decimeters.

  • East - Local east position in decimeters.

  • Alt - Local altitude in decimeters.

  • Floor - Floor number.

  • TimeDlt - If present, defines the time since the previous position update in milliseconds.

  • Prec - If present, defines the precision of the location in millimeters.

  • IsMobile - If present, defines whether the device is movable.

mesh models loc local-set-unack <North> <East> <Alt> <Floor> [TimeDlt(ms) [Prec(mm) [IsMobile]]]

Set the local location value of the Generic Location state without requesting a response.

  • North - Local north position in decimeters.

  • East - Local east position in decimeters.

  • Alt - Local altitude in decimeters.

  • Floor - Floor number.

  • TimeDlt - If present, defines the time since the previous position update in milliseconds.

  • Prec - If present, defines the precision of the location in millimeters.

  • IsMobile - If present, defines whether the device is movable.

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:
  • cli[in] Client model to send on.

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

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

Return values:
  • 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:
  • cli[in] Client model to send on.

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

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

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

Return values:
  • 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:
  • cli[in] Client model to send on.

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

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

Return values:
  • 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:
  • cli[in] Client model to send on.

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

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

Return values:
  • 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:
  • cli[in] Client model to send on.

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

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

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

Return values:
  • 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:
  • cli[in] Client model to send on.

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

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

Return values:
  • 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.

Param cli:

[in] Client that received the status message.

Param ctx:

[in] Context of the incoming message.

Param status:

[in] 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.

Param cli:

[in] Client that received the status message.

Param ctx:

[in] Context of the incoming message.

Param status:

[in] 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_msg_ack_ctx ack_ctx

Response context for tracking acknowledged messages.

struct bt_mesh_model_pub pub

Publish parameters.

const struct bt_mesh_model *model

Composition data model entry pointer.