Bluetooth: Mesh: Add support for receiving Health Current Status
Add a callback to the Health Client Model context, so that the application is able to receive Health Current Status messages that some Health Server Model publishes. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
b26231d770
commit
2eda34cf3f
3 changed files with 40 additions and 0 deletions
|
@ -21,6 +21,10 @@
|
|||
struct bt_mesh_health_cli {
|
||||
struct bt_mesh_model *model;
|
||||
|
||||
void (*current_status)(struct bt_mesh_health_cli *cli, u16_t addr,
|
||||
u8_t test_id, u16_t cid, u8_t *faults,
|
||||
size_t fault_count);
|
||||
|
||||
struct k_sem op_sync;
|
||||
u32_t op_pending;
|
||||
void *op_param;
|
||||
|
|
|
@ -74,8 +74,35 @@ static void health_fault_status(struct bt_mesh_model *model,
|
|||
k_sem_give(&health_cli->op_sync);
|
||||
}
|
||||
|
||||
static void health_current_status(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
struct bt_mesh_health_cli *cli = model->user_data;
|
||||
u8_t test_id;
|
||||
u16_t cid;
|
||||
|
||||
BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s",
|
||||
ctx->net_idx, ctx->app_idx, ctx->addr, buf->len,
|
||||
bt_hex(buf->data, buf->len));
|
||||
|
||||
test_id = net_buf_simple_pull_u8(buf);
|
||||
cid = net_buf_simple_pull_le16(buf);
|
||||
|
||||
BT_DBG("Test ID 0x%02x Company ID 0x%04x Fault Count %u",
|
||||
test_id, cid, buf->len);
|
||||
|
||||
if (!cli->current_status) {
|
||||
BT_WARN("No Current Status callback available");
|
||||
return;
|
||||
}
|
||||
|
||||
cli->current_status(cli, ctx->addr, test_id, cid, buf->data, buf->len);
|
||||
}
|
||||
|
||||
const struct bt_mesh_model_op bt_mesh_health_cli_op[] = {
|
||||
{ OP_HEALTH_FAULT_STATUS, 3, health_fault_status },
|
||||
{ OP_HEALTH_CURRENT_STATUS, 3, health_current_status },
|
||||
BT_MESH_MODEL_OP_END,
|
||||
};
|
||||
|
||||
|
|
|
@ -84,7 +84,16 @@ void show_faults(u8_t test_id, u16_t cid, u8_t *faults, size_t fault_count)
|
|||
}
|
||||
}
|
||||
|
||||
static void health_current_status(struct bt_mesh_health_cli *cli, u16_t addr,
|
||||
u8_t test_id, u16_t cid, u8_t *faults,
|
||||
size_t fault_count)
|
||||
{
|
||||
printk("Health Current Status from 0x%04x\n", addr);
|
||||
show_faults(test_id, cid, faults, fault_count);
|
||||
}
|
||||
|
||||
static struct bt_mesh_health_cli health_cli = {
|
||||
.current_status = health_current_status,
|
||||
};
|
||||
|
||||
static const u8_t dev_uuid[16] = { 0xdd, 0xdd };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue