From 3b252ca2bed6df8a900f8dabffef53440544df7c Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 13 Nov 2017 21:31:25 +0200 Subject: [PATCH] Bluetooth: Mesh: Rename configuration server code from cfg to cfg_srv Now that there's support for configuration client as well, rename cfg to cfg_srv to avoid any confusion. Signed-off-by: Johan Hedberg --- include/bluetooth/mesh/cfg_srv.h | 6 +-- samples/bluetooth/mesh/src/main.c | 2 +- samples/bluetooth/mesh_demo/src/main.c | 2 +- subsys/bluetooth/host/mesh/CMakeLists.txt | 2 +- subsys/bluetooth/host/mesh/access.c | 2 +- .../bluetooth/host/mesh/{cfg.c => cfg_srv.c} | 47 ++++++++++--------- subsys/bluetooth/host/mesh/foundation.h | 2 +- subsys/bluetooth/host/mesh/shell.c | 2 +- tests/bluetooth/mesh/src/main.c | 2 +- 9 files changed, 34 insertions(+), 33 deletions(-) rename subsys/bluetooth/host/mesh/{cfg.c => cfg_srv.c} (98%) diff --git a/include/bluetooth/mesh/cfg_srv.h b/include/bluetooth/mesh/cfg_srv.h index 9a03deae92b..387480f38b8 100644 --- a/include/bluetooth/mesh/cfg_srv.h +++ b/include/bluetooth/mesh/cfg_srv.h @@ -18,7 +18,7 @@ */ /** Mesh Configuration Server Model Context */ -struct bt_mesh_cfg { +struct bt_mesh_cfg_srv { struct bt_mesh_model *model; u8_t net_transmit; /* Network Transmit state */ @@ -56,11 +56,11 @@ struct bt_mesh_cfg { } hb_sub; }; -extern const struct bt_mesh_model_op bt_mesh_cfg_op[]; +extern const struct bt_mesh_model_op bt_mesh_cfg_srv_op[]; #define BT_MESH_MODEL_CFG_SRV(srv_data) \ BT_MESH_MODEL(BT_MESH_MODEL_ID_CFG_SRV, \ - bt_mesh_cfg_op, NULL, srv_data) + bt_mesh_cfg_srv_op, NULL, srv_data) /** * @} diff --git a/samples/bluetooth/mesh/src/main.c b/samples/bluetooth/mesh/src/main.c index 99873725ef2..1b12103d722 100644 --- a/samples/bluetooth/mesh/src/main.c +++ b/samples/bluetooth/mesh/src/main.c @@ -15,7 +15,7 @@ #define CID_INTEL 0x0002 -static struct bt_mesh_cfg cfg_srv = { +static struct bt_mesh_cfg_srv cfg_srv = { .relay = BT_MESH_RELAY_DISABLED, .beacon = BT_MESH_BEACON_ENABLED, #if defined(CONFIG_BT_MESH_FRIEND) diff --git a/samples/bluetooth/mesh_demo/src/main.c b/samples/bluetooth/mesh_demo/src/main.c index c7d75f7333e..896c1d96546 100644 --- a/samples/bluetooth/mesh_demo/src/main.c +++ b/samples/bluetooth/mesh_demo/src/main.c @@ -52,7 +52,7 @@ static void heartbeat(u8_t hops, u16_t feat) board_play("100H"); } -static struct bt_mesh_cfg cfg_srv = { +static struct bt_mesh_cfg_srv cfg_srv = { #if defined(CONFIG_BOARD_BBC_MICROBIT) .relay = BT_MESH_RELAY_ENABLED, .beacon = BT_MESH_BEACON_DISABLED, diff --git a/subsys/bluetooth/host/mesh/CMakeLists.txt b/subsys/bluetooth/host/mesh/CMakeLists.txt index 616edda98e5..d8db6ae474e 100644 --- a/subsys/bluetooth/host/mesh/CMakeLists.txt +++ b/subsys/bluetooth/host/mesh/CMakeLists.txt @@ -9,7 +9,7 @@ zephyr_library_sources_ifdef(CONFIG_BT_MESH transport.c crypto.c access.c - cfg.c + cfg_srv.c health.c ) diff --git a/subsys/bluetooth/host/mesh/access.c b/subsys/bluetooth/host/mesh/access.c index b63a622f644..146b1136efb 100644 --- a/subsys/bluetooth/host/mesh/access.c +++ b/subsys/bluetooth/host/mesh/access.c @@ -33,7 +33,7 @@ static const struct { const u16_t id; int (*const init)(struct bt_mesh_model *model, bool primary); } const model_init[] = { - { BT_MESH_MODEL_ID_CFG_SRV, bt_mesh_conf_init }, + { BT_MESH_MODEL_ID_CFG_SRV, bt_mesh_cfg_srv_init }, { BT_MESH_MODEL_ID_HEALTH_SRV, bt_mesh_health_init }, #if defined(CONFIG_BT_MESH_CFG_CLI) { BT_MESH_MODEL_ID_CFG_CLI, bt_mesh_cfg_cli_init }, diff --git a/subsys/bluetooth/host/mesh/cfg.c b/subsys/bluetooth/host/mesh/cfg_srv.c similarity index 98% rename from subsys/bluetooth/host/mesh/cfg.c rename to subsys/bluetooth/host/mesh/cfg_srv.c index 7e8136d980e..fb43ded2b63 100644 --- a/subsys/bluetooth/host/mesh/cfg.c +++ b/subsys/bluetooth/host/mesh/cfg_srv.c @@ -35,7 +35,7 @@ #define DEFAULT_TTL 7 -static struct bt_mesh_cfg *conf; +static struct bt_mesh_cfg_srv *conf; static struct label { u16_t addr; @@ -45,7 +45,7 @@ static struct label { static void hb_send(struct bt_mesh_model *model) { - struct bt_mesh_cfg *cfg = model->user_data; + struct bt_mesh_cfg_srv *cfg = model->user_data; u16_t feat = 0; struct __packed { u8_t init_ttl; @@ -652,7 +652,7 @@ static void beacon_set(struct bt_mesh_model *model, { /* Needed size: opcode (2 bytes) + msg + MIC */ struct net_buf_simple *msg = NET_BUF_SIMPLE(2 + 1 + 4); - struct bt_mesh_cfg *cfg = model->user_data; + struct bt_mesh_cfg_srv *cfg = model->user_data; 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, @@ -708,7 +708,7 @@ static void default_ttl_set(struct bt_mesh_model *model, { /* Needed size: opcode (2 bytes) + msg + MIC */ struct net_buf_simple *msg = NET_BUF_SIMPLE(2 + 1 + 4); - struct bt_mesh_cfg *cfg = model->user_data; + struct bt_mesh_cfg_srv *cfg = model->user_data; 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, @@ -760,7 +760,7 @@ static void gatt_proxy_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_cfg *cfg = model->user_data; + struct bt_mesh_cfg_srv *cfg = model->user_data; struct bt_mesh_subnet *sub; BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", @@ -824,7 +824,7 @@ static void net_transmit_set(struct bt_mesh_model *model, { /* Needed size: opcode (2 bytes) + msg + MIC */ struct net_buf_simple *msg = NET_BUF_SIMPLE(2 + 1 + 4); - struct bt_mesh_cfg *cfg = model->user_data; + struct bt_mesh_cfg_srv *cfg = model->user_data; 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, @@ -874,7 +874,7 @@ static void relay_set(struct bt_mesh_model *model, { /* Needed size: opcode (2 bytes) + msg + MIC */ struct net_buf_simple *msg = NET_BUF_SIMPLE(2 + 2 + 4); - struct bt_mesh_cfg *cfg = model->user_data; + struct bt_mesh_cfg_srv *cfg = model->user_data; 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, @@ -2001,7 +2001,7 @@ static void net_key_update(struct bt_mesh_model *model, send_net_key_status(model, ctx, idx, STATUS_SUCCESS); } -static void hb_pub_disable(struct bt_mesh_cfg *cfg) +static void hb_pub_disable(struct bt_mesh_cfg_srv *cfg) { BT_DBG(""); @@ -2017,7 +2017,7 @@ static void net_key_del(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_cfg *cfg = model->user_data; + struct bt_mesh_cfg_srv *cfg = model->user_data; struct bt_mesh_subnet *sub; u16_t del_idx, i; u8_t status; @@ -2374,7 +2374,7 @@ static void node_reset(struct bt_mesh_model *model, { /* Needed size: opcode (2 bytes) + msg + MIC */ struct net_buf_simple *msg = NET_BUF_SIMPLE(2 + 0 + 4); - struct bt_mesh_cfg *cfg = model->user_data; + struct bt_mesh_cfg_srv *cfg = model->user_data; int i; BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", @@ -2421,7 +2421,7 @@ static void send_friend_status(struct bt_mesh_model *model, { /* Needed size: opcode (2 bytes) + msg + MIC */ struct net_buf_simple *msg = NET_BUF_SIMPLE(2 + 1 + 4); - struct bt_mesh_cfg *cfg = model->user_data; + struct bt_mesh_cfg_srv *cfg = model->user_data; bt_mesh_model_msg_init(msg, OP_FRIEND_STATUS); net_buf_simple_add_u8(msg, cfg->frnd); @@ -2446,7 +2446,7 @@ static void friend_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_cfg *cfg = model->user_data; + struct bt_mesh_cfg_srv *cfg = model->user_data; struct bt_mesh_subnet *sub; BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", @@ -2674,7 +2674,7 @@ static void hb_pub_send_status(struct bt_mesh_model *model, { /* Needed size: opcode (1 byte) + msg + MIC */ struct net_buf_simple *msg = NET_BUF_SIMPLE(1 + 10 + 4); - struct bt_mesh_cfg *cfg = model->user_data; + struct bt_mesh_cfg_srv *cfg = model->user_data; BT_DBG("src 0x%04x status 0x%02x", ctx->addr, status); @@ -2713,7 +2713,7 @@ static void heartbeat_pub_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct hb_pub_param *param = (void *)buf->data; - struct bt_mesh_cfg *cfg = model->user_data; + struct bt_mesh_cfg_srv *cfg = model->user_data; u16_t dst, feat, idx; u8_t status; @@ -2792,7 +2792,7 @@ static void hb_sub_send_status(struct bt_mesh_model *model, { /* Needed size: opcode (2 bytes) + msg + MIC */ struct net_buf_simple *msg = NET_BUF_SIMPLE(2 + 9 + 4); - struct bt_mesh_cfg *cfg = model->user_data; + struct bt_mesh_cfg_srv *cfg = model->user_data; u16_t period; s64_t uptime; @@ -2838,7 +2838,7 @@ static void heartbeat_sub_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_cfg *cfg = model->user_data; + struct bt_mesh_cfg_srv *cfg = model->user_data; u16_t sub_src, sub_dst; u8_t sub_period; s32_t period_ms; @@ -2905,7 +2905,7 @@ static void heartbeat_sub_set(struct bt_mesh_model *model, hb_sub_send_status(model, ctx, STATUS_SUCCESS); } -const struct bt_mesh_model_op bt_mesh_cfg_op[] = { +const struct bt_mesh_model_op bt_mesh_cfg_srv_op[] = { { OP_DEV_COMP_DATA_GET, 1, dev_comp_data_get }, { OP_APP_KEY_ADD, 19, app_key_add }, { OP_APP_KEY_UPDATE, 19, app_key_update }, @@ -2958,8 +2958,9 @@ const struct bt_mesh_model_op bt_mesh_cfg_op[] = { static void hb_publish(struct k_work *work) { - struct bt_mesh_cfg *cfg = CONTAINER_OF(work, struct bt_mesh_cfg, - hb_pub.timer.work); + struct bt_mesh_cfg_srv *cfg = CONTAINER_OF(work, + struct bt_mesh_cfg_srv, + hb_pub.timer.work); struct bt_mesh_model *model = cfg->model; struct bt_mesh_subnet *sub; u16_t period_ms; @@ -2990,7 +2991,7 @@ static void hb_publish(struct k_work *work) } } -static bool conf_is_valid(struct bt_mesh_cfg *cfg) +static bool conf_is_valid(struct bt_mesh_cfg_srv *cfg) { if (cfg->relay > 0x02) { return false; @@ -3007,9 +3008,9 @@ static bool conf_is_valid(struct bt_mesh_cfg *cfg) return true; } -int bt_mesh_conf_init(struct bt_mesh_model *model, bool primary) +int bt_mesh_cfg_srv_init(struct bt_mesh_model *model, bool primary) { - struct bt_mesh_cfg *cfg = model->user_data; + struct bt_mesh_cfg_srv *cfg = model->user_data; if (!cfg) { BT_ERR("No Configuration Server context provided"); @@ -3048,7 +3049,7 @@ int bt_mesh_conf_init(struct bt_mesh_model *model, bool primary) void bt_mesh_heartbeat(u16_t src, u16_t dst, u8_t hops, u16_t feat) { - struct bt_mesh_cfg *cfg = conf; + struct bt_mesh_cfg_srv *cfg = conf; if (!cfg) { BT_WARN("No configuaration server context available"); diff --git a/subsys/bluetooth/host/mesh/foundation.h b/subsys/bluetooth/host/mesh/foundation.h index 4d3c0e9e0f8..c33b432a024 100644 --- a/subsys/bluetooth/host/mesh/foundation.h +++ b/subsys/bluetooth/host/mesh/foundation.h @@ -112,7 +112,7 @@ #define STATUS_UNSPECIFIED 0x10 #define STATUS_INVALID_BINDING 0x11 -int bt_mesh_conf_init(struct bt_mesh_model *model, bool primary); +int bt_mesh_cfg_srv_init(struct bt_mesh_model *model, bool primary); int bt_mesh_health_init(struct bt_mesh_model *model, bool primary); int bt_mesh_cfg_cli_init(struct bt_mesh_model *model, bool primary); diff --git a/subsys/bluetooth/host/mesh/shell.c b/subsys/bluetooth/host/mesh/shell.c index ea2b4100924..56bb8fbc8b0 100644 --- a/subsys/bluetooth/host/mesh/shell.c +++ b/subsys/bluetooth/host/mesh/shell.c @@ -21,7 +21,7 @@ static u16_t local = BT_MESH_ADDR_UNASSIGNED; static u16_t dst = BT_MESH_ADDR_UNASSIGNED; static u16_t net_idx; -static struct bt_mesh_cfg cfg_srv = { +static struct bt_mesh_cfg_srv cfg_srv = { .relay = BT_MESH_RELAY_DISABLED, .beacon = BT_MESH_BEACON_DISABLED, #if defined(CONFIG_BT_MESH_FRIEND) diff --git a/tests/bluetooth/mesh/src/main.c b/tests/bluetooth/mesh/src/main.c index 900f165f9cd..b7541240d2f 100644 --- a/tests/bluetooth/mesh/src/main.c +++ b/tests/bluetooth/mesh/src/main.c @@ -17,7 +17,7 @@ static bool has_reg_fault = true; -static struct bt_mesh_cfg cfg_srv = { +static struct bt_mesh_cfg_srv cfg_srv = { .relay = BT_MESH_RELAY_DISABLED, .beacon = BT_MESH_BEACON_DISABLED, #if defined(CONFIG_BT_MESH_FRIEND)