Bluetooth: Mesh: Add skeleton for Health Client model
Add a skeleton for the Health Client model. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
2a6010f1b3
commit
7ef5e53e28
9 changed files with 143 additions and 0 deletions
|
@ -23,6 +23,10 @@
|
|||
#include <bluetooth/mesh/cfg_cli.h>
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_MESH_HEALTH_CLI)
|
||||
#include <bluetooth/mesh/health_cli.h>
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_MESH_GATT_PROXY)
|
||||
#include <bluetooth/mesh/proxy.h>
|
||||
#endif
|
||||
|
|
44
include/bluetooth/mesh/health_cli.h
Normal file
44
include/bluetooth/mesh/health_cli.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/** @file
|
||||
* @brief Bluetooth Mesh Health Client Model APIs.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2017 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef __BT_MESH_HEALTH_CLI_H
|
||||
#define __BT_MESH_HEALTH_CLI_H
|
||||
|
||||
/**
|
||||
* @brief Bluetooth Mesh
|
||||
* @defgroup bt_mesh_health_cli Bluetooth Mesh Health Client Model
|
||||
* @ingroup bt_mesh
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** Mesh Health Client Model Context */
|
||||
struct bt_mesh_health_cli {
|
||||
struct bt_mesh_model *model;
|
||||
|
||||
struct k_sem op_sync;
|
||||
u32_t op_pending;
|
||||
void *op_param;
|
||||
};
|
||||
|
||||
extern const struct bt_mesh_model_op bt_mesh_health_cli_op[];
|
||||
|
||||
#define BT_MESH_MODEL_HEALTH_CLI(cli_data) \
|
||||
BT_MESH_MODEL(BT_MESH_MODEL_ID_HEALTH_CLI, \
|
||||
bt_mesh_health_cli_op, NULL, cli_data)
|
||||
|
||||
int bt_mesh_health_cli_set(struct bt_mesh_model *model);
|
||||
|
||||
s32_t bt_mesh_health_cli_timeout_get(void);
|
||||
void bt_mesh_health_cli_timeout_set(s32_t timeout);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* __BT_MESH_HEALTH_CLI_H */
|
|
@ -23,6 +23,8 @@ zephyr_library_sources_ifdef(CONFIG_BT_MESH_PROXY proxy.c)
|
|||
|
||||
zephyr_library_sources_ifdef(CONFIG_BT_MESH_CFG_CLI cfg_cli.c)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_BT_MESH_HEALTH_CLI health_cli.c)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_BT_MESH_SELF_TEST test.c)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_BT_MESH_SHELL shell.c)
|
||||
|
|
|
@ -341,10 +341,16 @@ config BT_MESH_CFG_CLI
|
|||
help
|
||||
Enable support for the configuration client model.
|
||||
|
||||
config BT_MESH_HEALTH_CLI
|
||||
bool "Support for Health Client Model"
|
||||
help
|
||||
Enable support for the health client model.
|
||||
|
||||
config BT_MESH_SHELL
|
||||
bool "Enable Bluetooth Mesh shell"
|
||||
select CONSOLE_SHELL
|
||||
depends on BT_MESH_CFG_CLI
|
||||
depends on BT_MESH_HEALTH_CLI
|
||||
help
|
||||
Activate shell module that provides Bluetooth Mesh commands to
|
||||
the console.
|
||||
|
|
|
@ -38,6 +38,9 @@ static const struct {
|
|||
#if defined(CONFIG_BT_MESH_CFG_CLI)
|
||||
{ BT_MESH_MODEL_ID_CFG_CLI, bt_mesh_cfg_cli_init },
|
||||
#endif
|
||||
#if defined(CONFIG_BT_MESH_HEALTH_CLI)
|
||||
{ BT_MESH_MODEL_ID_HEALTH_CLI, bt_mesh_health_cli_init },
|
||||
#endif
|
||||
};
|
||||
|
||||
void bt_mesh_model_foreach(void (*func)(struct bt_mesh_model *mod,
|
||||
|
|
|
@ -116,6 +116,7 @@ int bt_mesh_cfg_srv_init(struct bt_mesh_model *model, bool primary);
|
|||
int bt_mesh_health_srv_init(struct bt_mesh_model *model, bool primary);
|
||||
|
||||
int bt_mesh_cfg_cli_init(struct bt_mesh_model *model, bool primary);
|
||||
int bt_mesh_health_cli_init(struct bt_mesh_model *model, bool primary);
|
||||
|
||||
void bt_mesh_cfg_reset(void);
|
||||
|
||||
|
|
78
subsys/bluetooth/host/mesh/health_cli.c
Normal file
78
subsys/bluetooth/host/mesh/health_cli.c
Normal file
|
@ -0,0 +1,78 @@
|
|||
/* Bluetooth Mesh */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2017 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
#include <zephyr/types.h>
|
||||
#include <misc/util.h>
|
||||
#include <misc/byteorder.h>
|
||||
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include <bluetooth/conn.h>
|
||||
#include <bluetooth/mesh.h>
|
||||
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_MODEL)
|
||||
#include "common/log.h"
|
||||
|
||||
#include "foundation.h"
|
||||
|
||||
static s32_t msg_timeout = K_SECONDS(2);
|
||||
|
||||
static struct bt_mesh_health_cli *health_cli;
|
||||
|
||||
const struct bt_mesh_model_op bt_mesh_health_cli_op[] = {
|
||||
BT_MESH_MODEL_OP_END,
|
||||
};
|
||||
|
||||
s32_t bt_mesh_health_cli_timeout_get(void)
|
||||
{
|
||||
return msg_timeout;
|
||||
}
|
||||
|
||||
void bt_mesh_health_cli_timeout_set(s32_t timeout)
|
||||
{
|
||||
msg_timeout = timeout;
|
||||
}
|
||||
|
||||
int bt_mesh_health_cli_set(struct bt_mesh_model *model)
|
||||
{
|
||||
if (!model->user_data) {
|
||||
BT_ERR("No Health Client context for given model");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
health_cli = model->user_data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_health_cli_init(struct bt_mesh_model *model, bool primary)
|
||||
{
|
||||
struct bt_mesh_health_cli *cli = model->user_data;
|
||||
|
||||
BT_DBG("primary %u", primary);
|
||||
|
||||
if (!cli) {
|
||||
BT_ERR("No Health Client context provided");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
cli = model->user_data;
|
||||
cli->model = model;
|
||||
|
||||
k_sem_init(&cli->op_sync, 0, 1);
|
||||
|
||||
/* Set the default health client pointer */
|
||||
if (!health_cli) {
|
||||
health_cli = cli;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -66,12 +66,16 @@ static struct bt_mesh_model_pub health_pub = {
|
|||
static struct bt_mesh_cfg_cli cfg_cli = {
|
||||
};
|
||||
|
||||
static struct bt_mesh_health_cli health_cli = {
|
||||
};
|
||||
|
||||
static const u8_t dev_uuid[16] = { 0xdd, 0xdd };
|
||||
|
||||
static struct bt_mesh_model root_models[] = {
|
||||
BT_MESH_MODEL_CFG_SRV(&cfg_srv),
|
||||
BT_MESH_MODEL_CFG_CLI(&cfg_cli),
|
||||
BT_MESH_MODEL_HEALTH_SRV(&health_srv, &health_pub),
|
||||
BT_MESH_MODEL_HEALTH_CLI(&health_cli),
|
||||
};
|
||||
|
||||
static struct bt_mesh_elem elements[] = {
|
||||
|
|
|
@ -36,6 +36,7 @@ CONFIG_BT_MESH_FRIEND=y
|
|||
CONFIG_BT_MESH_FRIEND_QUEUE_SIZE=16
|
||||
CONFIG_BT_MESH_ADV_BUF_COUNT=20
|
||||
CONFIG_BT_MESH_CFG_CLI=y
|
||||
CONFIG_BT_MESH_HEALTH_CLI=y
|
||||
CONFIG_BT_MESH_TX_SEG_MSG_COUNT=2
|
||||
CONFIG_BT_MESH_RX_SEG_MSG_COUNT=2
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue