From f1a9137e76097b35525ea66e9febd5420e4ee2a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Narajowski?= Date: Tue, 5 Nov 2019 15:35:40 +0100 Subject: [PATCH] nimble/mesh: Fix Client model publishing Shell did not have publish structures for Client models so Configuration Client could not configure them to publish messages. This patch adds those structures and fixes model definition macros to accept publish structures. --- nimble/host/mesh/include/mesh/model_cli.h | 6 +++--- nimble/host/mesh/src/shell.c | 14 ++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/nimble/host/mesh/include/mesh/model_cli.h b/nimble/host/mesh/include/mesh/model_cli.h index 33fbd6e9d..bd80a1ca2 100644 --- a/nimble/host/mesh/include/mesh/model_cli.h +++ b/nimble/host/mesh/include/mesh/model_cli.h @@ -22,16 +22,16 @@ struct bt_mesh_gen_model_cli { extern struct bt_mesh_gen_model_cli gen_onoff_cli; extern const struct bt_mesh_model_op gen_onoff_cli_op[]; -#define BT_MESH_MODEL_GEN_ONOFF_CLI() \ +#define BT_MESH_MODEL_GEN_ONOFF_CLI(pub) \ BT_MESH_MODEL(BT_MESH_MODEL_ID_GEN_ONOFF_CLI, \ - gen_onoff_cli_op, NULL, &gen_onoff_cli) + gen_onoff_cli_op, pub, &gen_onoff_cli) extern struct bt_mesh_gen_model_cli gen_level_cli; extern const struct bt_mesh_model_op gen_level_cli_op[]; #define BT_MESH_MODEL_GEN_LEVEL_CLI(pub) \ BT_MESH_MODEL(BT_MESH_MODEL_ID_GEN_LEVEL_CLI, \ - gen_level_cli_op, NULL, &gen_level_cli) + gen_level_cli_op, pub, &gen_level_cli) int bt_mesh_gen_onoff_get(u16_t net_idx, u16_t addr, u16_t app_idx, diff --git a/nimble/host/mesh/src/shell.c b/nimble/host/mesh/src/shell.c index 94a7b58be..06ec1c825 100644 --- a/nimble/host/mesh/src/shell.c +++ b/nimble/host/mesh/src/shell.c @@ -222,8 +222,10 @@ static struct bt_mesh_health_cli health_cli = { #endif /* MYNEWT_VAL(BLE_MESH_HEALTH_CLI) */ #if MYNEWT_VAL(BLE_MESH_SHELL_MODELS) -static struct bt_mesh_model_pub gen_onoff_pub; -static struct bt_mesh_model_pub gen_level_pub; +static struct bt_mesh_model_pub gen_onoff_cli_pub; +static struct bt_mesh_model_pub gen_onoff_srv_pub; +static struct bt_mesh_model_pub gen_level_cli_pub; +static struct bt_mesh_model_pub gen_level_srv_pub; static struct bt_mesh_model_pub light_lightness_pub; static struct bt_mesh_gen_onoff_srv_cb gen_onoff_srv_cb = { .get = light_model_gen_onoff_get, @@ -265,10 +267,10 @@ static struct bt_mesh_model root_models[] = { BT_MESH_MODEL_HEALTH_CLI(&health_cli), #endif #if MYNEWT_VAL(BLE_MESH_SHELL_MODELS) - BT_MESH_MODEL_GEN_ONOFF_SRV(&gen_onoff_srv_cb, &gen_onoff_pub), - BT_MESH_MODEL_GEN_ONOFF_CLI(), - BT_MESH_MODEL_GEN_LEVEL_SRV(&gen_level_srv_cb, &gen_level_pub), - BT_MESH_MODEL_GEN_LEVEL_CLI(), + BT_MESH_MODEL_GEN_ONOFF_SRV(&gen_onoff_srv_cb, &gen_onoff_srv_pub), + BT_MESH_MODEL_GEN_ONOFF_CLI(&gen_onoff_cli_pub), + BT_MESH_MODEL_GEN_LEVEL_SRV(&gen_level_srv_cb, &gen_level_srv_pub), + BT_MESH_MODEL_GEN_LEVEL_CLI(&gen_level_cli_pub), BT_MESH_MODEL_LIGHT_LIGHTNESS_SRV(&light_lightness_srv_cb, &light_lightness_pub), #endif };