这是最新(主)开发分支的文档。如果您正在查找以前版本的文档,使用左侧的下拉菜单选择所需的版本。

运行状况客户端

运行状况客户端模型与运行状况服务器模型交互,以读取诊断并控制节点的注意状态。

健康客户端 API 中的所有消息传递函数都将 cli 作为其第一个参数。这是指向要在此函数调用中使用的客户端模型实例的指针。 第二个参数是 ctx 或消息上下文。消息上下文包含目标节点使用的网络密钥索引、应用密钥索引和单播地址。

运行状况客户端模型是可选的,可以在任何元素上实例化。然而,如果在主元素以外的元素上实例化运行状况客户端模型,则主元素上也必须存在实例。

有关规范定义的故障值的列表,请参阅 运行状况故障

API 参考

group bt_mesh_health_cli

Health Client Model.

Defines

BT_MESH_MODEL_HEALTH_CLI(cli_data)

Generic Health Client model composition data entry.

参数:

Functions

int bt_mesh_health_cli_fault_get(struct bt_mesh_health_cli *cli, struct bt_mesh_msg_ctx *ctx, uint16_t cid, uint8_t *test_id, uint8_t *faults, size_t *fault_count)

Get the registered fault state for the given Company ID.

This method can be used asynchronously by setting test_id and ( faults or fault_count ) as NULL This way the method will not wait for response and will return immediately after sending the command.

To process the response arguments of an async method, register the fault_status callback in bt_mesh_health_cli struct.

参见

Health faults

参数:
  • cli – Client model to send on.

  • ctx – Message context, or NULL to use the configured publish parameters.

  • cid – Company ID to get the registered faults of.

  • test_id – Test ID response buffer.

  • faults – Fault array response buffer.

  • fault_count – Fault count response buffer.

返回:

0 on success, or (negative) error code on failure.

int bt_mesh_health_cli_fault_clear(struct bt_mesh_health_cli *cli, struct bt_mesh_msg_ctx *ctx, uint16_t cid, uint8_t *test_id, uint8_t *faults, size_t *fault_count)

Clear the registered faults for the given Company ID.

This method can be used asynchronously by setting test_id and ( faults or fault_count ) as NULL This way the method will not wait for response and will return immediately after sending the command.

To process the response arguments of an async method, register the fault_status callback in bt_mesh_health_cli struct.

参见

Health faults

参数:
  • cli – Client model to send on.

  • ctx – Message context, or NULL to use the configured publish parameters.

  • cid – Company ID to clear the registered faults for.

  • test_id – Test ID response buffer.

  • faults – Fault array response buffer.

  • fault_count – Fault count response buffer.

返回:

0 on success, or (negative) error code on failure.

int bt_mesh_health_cli_fault_clear_unack(struct bt_mesh_health_cli *cli, struct bt_mesh_msg_ctx *ctx, uint16_t cid)

Clear the registered faults for the given Company ID (unacked).

参见

Health faults

参数:
  • cli – Client model to send on.

  • ctx – Message context, or NULL to use the configured publish parameters.

  • cid – Company ID to clear the registered faults for.

返回:

0 on success, or (negative) error code on failure.

int bt_mesh_health_cli_fault_test(struct bt_mesh_health_cli *cli, struct bt_mesh_msg_ctx *ctx, uint16_t cid, uint8_t test_id, uint8_t *faults, size_t *fault_count)

Invoke a self-test procedure for the given Company ID.

This method can be used asynchronously by setting faults or fault_count as NULL This way the method will not wait for response and will return immediately after sending the command.

To process the response arguments of an async method, register the fault_status callback in bt_mesh_health_cli struct.

参数:
  • cli – Client model to send on.

  • ctx – Message context, or NULL to use the configured publish parameters.

  • cid – Company ID to invoke the test for.

  • test_id – Test ID response buffer.

  • faults – Fault array response buffer.

  • fault_count – Fault count response buffer.

返回:

0 on success, or (negative) error code on failure.

int bt_mesh_health_cli_fault_test_unack(struct bt_mesh_health_cli *cli, struct bt_mesh_msg_ctx *ctx, uint16_t cid, uint8_t test_id)

Invoke a self-test procedure for the given Company ID (unacked).

参数:
  • cli – Client model to send on.

  • ctx – Message context, or NULL to use the configured publish parameters.

  • cid – Company ID to invoke the test for.

  • test_id – Test ID response buffer.

返回:

0 on success, or (negative) error code on failure.

int bt_mesh_health_cli_period_get(struct bt_mesh_health_cli *cli, struct bt_mesh_msg_ctx *ctx, uint8_t *divisor)

Get the target node’s Health fast period divisor.

The health period divisor is used to increase the publish rate when a fault is registered. Normally, the Health server will publish with the period in the configured publish parameters. When a fault is registered, the publish period is divided by (1 << divisor). For example, if the target node’s Health server is configured to publish with a period of 16 seconds, and the Health fast period divisor is 5, the Health server will publish with an interval of 500 ms when a fault is registered.

This method can be used asynchronously by setting divisor as NULL. This way the method will not wait for response and will return immediately after sending the command.

To process the response arguments of an async method, register the period_status callback in bt_mesh_health_cli struct.

参数:
  • cli – Client model to send on.

  • ctx – Message context, or NULL to use the configured publish parameters.

  • divisor – Health period divisor response buffer.

返回:

0 on success, or (negative) error code on failure.

int bt_mesh_health_cli_period_set(struct bt_mesh_health_cli *cli, struct bt_mesh_msg_ctx *ctx, uint8_t divisor, uint8_t *updated_divisor)

Set the target node’s Health fast period divisor.

The health period divisor is used to increase the publish rate when a fault is registered. Normally, the Health server will publish with the period in the configured publish parameters. When a fault is registered, the publish period is divided by (1 << divisor). For example, if the target node’s Health server is configured to publish with a period of 16 seconds, and the Health fast period divisor is 5, the Health server will publish with an interval of 500 ms when a fault is registered.

This method can be used asynchronously by setting updated_divisor as NULL. This way the method will not wait for response and will return immediately after sending the command.

To process the response arguments of an async method, register the period_status callback in bt_mesh_health_cli struct.

参数:
  • cli – Client model to send on.

  • ctx – Message context, or NULL to use the configured publish parameters.

  • divisor – New Health period divisor.

  • updated_divisor – Health period divisor response buffer.

返回:

0 on success, or (negative) error code on failure.

int bt_mesh_health_cli_period_set_unack(struct bt_mesh_health_cli *cli, struct bt_mesh_msg_ctx *ctx, uint8_t divisor)

Set the target node’s Health fast period divisor (unacknowledged).

This is an unacknowledged version of this API.

参数:
  • cli – Client model to send on.

  • ctx – Message context, or NULL to use the configured publish parameters.

  • divisor – New Health period divisor.

返回:

0 on success, or (negative) error code on failure.

int bt_mesh_health_cli_attention_get(struct bt_mesh_health_cli *cli, struct bt_mesh_msg_ctx *ctx, uint8_t *attention)

Get the current attention timer value.

This method can be used asynchronously by setting attention as NULL. This way the method will not wait for response and will return immediately after sending the command.

To process the response arguments of an async method, register the attention_status callback in bt_mesh_health_cli struct.

参数:
  • cli – Client model to send on.

  • ctx – Message context, or NULL to use the configured publish parameters.

  • attention – Attention timer response buffer, measured in seconds.

返回:

0 on success, or (negative) error code on failure.

int bt_mesh_health_cli_attention_set(struct bt_mesh_health_cli *cli, struct bt_mesh_msg_ctx *ctx, uint8_t attention, uint8_t *updated_attention)

Set the attention timer.

This method can be used asynchronously by setting updated_attention as NULL. This way the method will not wait for response and will return immediately after sending the command.

To process the response arguments of an async method, register the attention_status callback in bt_mesh_health_cli struct.

参数:
  • cli – Client model to send on.

  • ctx – Message context, or NULL to use the configured publish parameters.

  • attention – New attention timer time, in seconds.

  • updated_attention – Attention timer response buffer, measured in seconds.

返回:

0 on success, or (negative) error code on failure.

int bt_mesh_health_cli_attention_set_unack(struct bt_mesh_health_cli *cli, struct bt_mesh_msg_ctx *ctx, uint8_t attention)

Set the attention timer (unacknowledged).

参数:
  • cli – Client model to send on.

  • ctx – Message context, or NULL to use the configured publish parameters.

  • attention – New attention timer time, in seconds.

返回:

0 on success, or (negative) error code on failure.

int32_t bt_mesh_health_cli_timeout_get(void)

Get the current transmission timeout value.

返回:

The configured transmission timeout in milliseconds.

void bt_mesh_health_cli_timeout_set(int32_t timeout)

Set the transmission timeout value.

参数:

timeout – The new transmission timeout.

struct bt_mesh_health_cli

Health Client Model Context