You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/04/30 09:27:40 UTC

[GitHub] michal-narajowski closed pull request #17: Mesh models fixes

michal-narajowski closed pull request #17: Mesh models fixes
URL: https://github.com/apache/mynewt-nimble/pull/17
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/nimble/host/mesh/include/mesh/cfg_srv.h b/nimble/host/mesh/include/mesh/cfg_srv.h
index 387480f3..ee652e2f 100644
--- a/nimble/host/mesh/include/mesh/cfg_srv.h
+++ b/nimble/host/mesh/include/mesh/cfg_srv.h
@@ -62,6 +62,7 @@ extern const struct bt_mesh_model_op bt_mesh_cfg_srv_op[];
 		BT_MESH_MODEL(BT_MESH_MODEL_ID_CFG_SRV,                      \
 			      bt_mesh_cfg_srv_op, NULL, srv_data)
 
+
 /**
  * @}
  */
diff --git a/nimble/host/mesh/src/model_cli.h b/nimble/host/mesh/include/mesh/model_cli.h
similarity index 100%
rename from nimble/host/mesh/src/model_cli.h
rename to nimble/host/mesh/include/mesh/model_cli.h
diff --git a/nimble/host/mesh/src/model_srv.h b/nimble/host/mesh/include/mesh/model_srv.h
similarity index 56%
rename from nimble/host/mesh/src/model_srv.h
rename to nimble/host/mesh/include/mesh/model_srv.h
index dc6dfdc9..1eff36ee 100644
--- a/nimble/host/mesh/src/model_srv.h
+++ b/nimble/host/mesh/include/mesh/model_srv.h
@@ -29,6 +29,20 @@ extern const struct bt_mesh_model_op gen_level_srv_op[];
 	BT_MESH_MODEL(BT_MESH_MODEL_ID_GEN_LEVEL_SRV,	\
 		      gen_level_srv_op, pub, srv)
 
-int pwm_init(void);
+struct bt_mesh_light_lightness_srv_cb {
+    int (*get)(struct bt_mesh_model *model, s16_t *level);
+    int (*set)(struct bt_mesh_model *model, s16_t level);
+};
+
+extern const struct bt_mesh_model_op light_lightness_srv_op[];
+
+#define BT_MESH_MODEL_LIGHT_LIGHTNESS_SRV(srv, pub)		\
+	BT_MESH_MODEL(BT_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV,	\
+		      light_lightness_srv_op, pub, srv)
+
+
+void bt_mesh_set_gen_onoff_srv_cb(struct bt_mesh_gen_onoff_srv_cb *gen_onoff_cb);
+void bt_mesh_set_gen_level_srv_cb(struct bt_mesh_gen_level_srv_cb *gen_level_cb);
+void bt_mesh_set_light_lightness_srv_cb(struct bt_mesh_light_lightness_srv_cb *light_lightness_cb);
 
 #endif
diff --git a/nimble/host/mesh/include/mesh/testing.h b/nimble/host/mesh/include/mesh/testing.h
index f8b9ab22..673c2cef 100644
--- a/nimble/host/mesh/include/mesh/testing.h
+++ b/nimble/host/mesh/include/mesh/testing.h
@@ -57,6 +57,13 @@ void bt_test_cb_register(struct bt_test_cb *cb);
  */
 void bt_test_cb_unregister(struct bt_test_cb *cb);
 
+u8_t mod_bind(struct bt_mesh_model *model, u16_t key_idx);
+u8_t mod_unbind(struct bt_mesh_model *model, u16_t key_idx);
+int cmd_init(int argc, char *argv[]);
+
+int bt_test_shell_init(void);
+int bt_test_bind_app_key_to_model(struct bt_mesh_model *model, u16_t key_idx, u16_t id);
+
 /**
  * @}
  */
diff --git a/nimble/host/mesh/src/access.c b/nimble/host/mesh/src/access.c
index 2fb3fec6..b79467ca 100644
--- a/nimble/host/mesh/src/access.c
+++ b/nimble/host/mesh/src/access.c
@@ -23,7 +23,7 @@
 #include "access.h"
 #include "foundation.h"
 #if MYNEWT_VAL(BLE_MESH_SHELL_MODELS)
-#include "model_cli.h"
+#include "mesh/model_cli.h"
 #endif
 
 static const struct bt_mesh_comp *dev_comp;
diff --git a/nimble/host/mesh/src/cfg_srv.c b/nimble/host/mesh/src/cfg_srv.c
index bda46a72..8645e03a 100644
--- a/nimble/host/mesh/src/cfg_srv.c
+++ b/nimble/host/mesh/src/cfg_srv.c
@@ -298,7 +298,7 @@ static u8_t _mod_pub_set(struct bt_mesh_model *model, u16_t pub_addr,
 	return STATUS_SUCCESS;
 }
 
-static u8_t mod_bind(struct bt_mesh_model *model, u16_t key_idx)
+u8_t mod_bind(struct bt_mesh_model *model, u16_t key_idx)
 {
 	int i;
 
@@ -325,7 +325,7 @@ static u8_t mod_bind(struct bt_mesh_model *model, u16_t key_idx)
 	return STATUS_INSUFF_RESOURCES;
 }
 
-static u8_t mod_unbind(struct bt_mesh_model *model, u16_t key_idx)
+u8_t mod_unbind(struct bt_mesh_model *model, u16_t key_idx)
 {
 	int i;
 
diff --git a/nimble/host/mesh/src/light_model.c b/nimble/host/mesh/src/light_model.c
index 0fd4d767..b6d83818 100644
--- a/nimble/host/mesh/src/light_model.c
+++ b/nimble/host/mesh/src/light_model.c
@@ -1,54 +1,17 @@
 
 #include "syscfg/syscfg.h"
 
-#if MYNEWT_VAL(BLE_MESH_SHELL_MODELS)
-
 #include "mesh/mesh.h"
-#include "bsp.h"
-#include "pwm/pwm.h"
+#include "console/console.h"
 #include "light_model.h"
 
-struct pwm_dev *pwm0;
-struct pwm_dev *pwm1;
-struct pwm_dev *pwm2;
-struct pwm_dev *pwm3;
-static uint16_t top_val;
 
 static u8_t gen_onoff_state;
 static s16_t gen_level_state;
 
-static void light_set_lightness(u8_t percentage)
-{
-	int rc;
-
-	uint16_t pwm_val = (uint16_t) (percentage * top_val / 100);
-
-	rc = pwm_enable_duty_cycle(pwm0, 0, pwm_val);
-	assert(rc == 0);
-	rc = pwm_enable_duty_cycle(pwm1, 0, pwm_val);
-	assert(rc == 0);
-	rc = pwm_enable_duty_cycle(pwm2, 0, pwm_val);
-	assert(rc == 0);
-	rc = pwm_enable_duty_cycle(pwm3, 0, pwm_val);
-	assert(rc == 0);
-}
-
 static void update_light_state(void)
 {
-	int level = gen_level_state;
-
-	if (level > 100) {
-		level = 100;
-	}
-	if (level < 0) {
-		level = 0;
-	}
-
-	if (gen_onoff_state == 0) {
-		level = 0;
-	}
-
-	light_set_lightness((uint8_t) level);
+	console_printf("Light state: onoff=%d lvl=0x%04x\n", gen_onoff_state, (u16_t)gen_level_state);
 }
 
 int light_model_gen_onoff_get(struct bt_mesh_model *model, u8_t *state)
@@ -73,102 +36,23 @@ int light_model_gen_level_get(struct bt_mesh_model *model, s16_t *level)
 int light_model_gen_level_set(struct bt_mesh_model *model, s16_t level)
 {
 	gen_level_state = level;
-	if (gen_level_state > 0) {
+	if ((u16_t)gen_level_state > 0x0000) {
 		gen_onoff_state = 1;
 	}
-	if (gen_level_state <= 0) {
+	if ((u16_t)gen_level_state == 0x0000) {
 		gen_onoff_state = 0;
 	}
 	update_light_state();
 	return 0;
 }
 
-static struct pwm_dev_interrupt_cfg led1_conf = {
-	.cfg = {
-		.pin = LED_1,
-		.inverted = true,
-		.n_cycles = 0,
-		.interrupts_cfg = true,
-	},
-	.int_prio = 3,
-};
-
-static struct pwm_dev_interrupt_cfg led2_conf = {
-	.cfg = {
-		.pin = LED_2,
-		.inverted = true,
-		.n_cycles = 0,
-		.interrupts_cfg = true,
-	},
-	.int_prio = 3,
-};
-
-static struct pwm_dev_interrupt_cfg led3_conf = {
-	.cfg = {
-		.pin = LED_3,
-		.inverted = true,
-		.n_cycles = 0,
-		.interrupts_cfg = true,
-	},
-	.int_prio = 3,
-};
-
-static struct pwm_dev_interrupt_cfg led4_conf = {
-	.cfg = {
-		.pin = LED_4,
-		.inverted = true,
-		.n_cycles = 0,
-		.interrupts_cfg = true,
-	},
-	.int_prio = 3,
-};
-
-int pwm_init(void)
+int light_model_light_lightness_get(struct bt_mesh_model *model, s16_t *lightness)
 {
-	int rc;
-
-	led1_conf.seq_end_data = &led1_conf;
-	led2_conf.seq_end_data = &led2_conf;
-	led3_conf.seq_end_data = &led3_conf;
-	led4_conf.seq_end_data = &led4_conf;
-
-	pwm0 = (struct pwm_dev *) os_dev_open("pwm0", 0, NULL);
-	assert(pwm0);
-	pwm1 = (struct pwm_dev *) os_dev_open("pwm1", 0, NULL);
-	assert(pwm1);
-	pwm2 = (struct pwm_dev *) os_dev_open("pwm2", 0, NULL);
-	assert(pwm2);
-	pwm3 = (struct pwm_dev *) os_dev_open("pwm3", 0, NULL);
-	assert(pwm3);
-
-	/* set the PWM frequency */
-	pwm_set_frequency(pwm0, 1000);
-	pwm_set_frequency(pwm1, 1000);
-	pwm_set_frequency(pwm2, 1000);
-	pwm_set_frequency(pwm3, 1000);
-	top_val = (uint16_t) pwm_get_top_value(pwm0);
-
-	rc = pwm_chan_config(pwm0, 0, (struct pwm_chan_cfg*) &led1_conf);
-	assert(rc == 0);
-	rc = pwm_chan_config(pwm1, 0, (struct pwm_chan_cfg*) &led2_conf);
-	assert(rc == 0);
-	rc = pwm_chan_config(pwm2, 0, (struct pwm_chan_cfg*) &led3_conf);
-	assert(rc == 0);
-	rc = pwm_chan_config(pwm3, 0, (struct pwm_chan_cfg*) &led4_conf);
-	assert(rc == 0);
-
-	update_light_state();
-
-	return rc;
+	return light_model_gen_level_get(model, lightness);
 }
-#endif
 
-int light_model_init(void)
+int light_model_light_lightness_set(struct bt_mesh_model *model, s16_t lightness)
 {
-#if MYNEWT_VAL(BLE_MESH_SHELL_MODELS)
-	return pwm_init();
-#else
-	return 0;
-#endif
+	return light_model_gen_level_set(model, lightness);
 }
 
diff --git a/nimble/host/mesh/src/light_model.h b/nimble/host/mesh/src/light_model.h
index 732e45bd..95fcdb78 100644
--- a/nimble/host/mesh/src/light_model.h
+++ b/nimble/host/mesh/src/light_model.h
@@ -9,18 +9,11 @@
 #include "syscfg/syscfg.h"
 #include "mesh/mesh.h"
 
-#if MYNEWT_VAL(BLE_MESH_SHELL_MODELS)
 int light_model_gen_onoff_get(struct bt_mesh_model *model, u8_t *state);
 int light_model_gen_onoff_set(struct bt_mesh_model *model, u8_t state);
 int light_model_gen_level_get(struct bt_mesh_model *model, s16_t *level);
 int light_model_gen_level_set(struct bt_mesh_model *model, s16_t level);
-int light_model_init(void);
-#else
-static inline int light_model_gen_onoff_get(struct bt_mesh_model *model, u8_t *state) { return 0; }
-static inline int light_model_gen_onoff_set(struct bt_mesh_model *model, u8_t state) { return 0; }
-static inline int light_model_gen_level_get(struct bt_mesh_model *model, s16_t *level) { return 0; }
-static inline int light_model_gen_level_set(struct bt_mesh_model *model, s16_t level) { return 0; }
-static inline int light_model_init(void) { return 0; }
-#endif
+int light_model_light_lightness_get(struct bt_mesh_model *model, s16_t *lightness);
+int light_model_light_lightness_set(struct bt_mesh_model *model, s16_t lightness);
 
 #endif
diff --git a/nimble/host/mesh/src/mesh_priv.h b/nimble/host/mesh/src/mesh_priv.h
index 044444c5..ab664f3a 100644
--- a/nimble/host/mesh/src/mesh_priv.h
+++ b/nimble/host/mesh/src/mesh_priv.h
@@ -26,8 +26,11 @@
 #define OP_GEN_LEVEL_STATUS		BT_MESH_MODEL_OP_2(0x82, 0x08)
 #define OP_GEN_DELTA_SET		BT_MESH_MODEL_OP_2(0x82, 0x09)
 #define OP_GEN_DELTA_SET_UNACK		BT_MESH_MODEL_OP_2(0x82, 0x0a)
-#define OP_GEN_MOVE_SET		BT_MESH_MODEL_OP_2(0x82, 0x0b)
+#define OP_GEN_MOVE_SET			BT_MESH_MODEL_OP_2(0x82, 0x0b)
 #define OP_GEN_MOVE_SET_UNACK		BT_MESH_MODEL_OP_2(0x82, 0x0c)
+#define OP_LIGHT_LIGHTNESS_GET		BT_MESH_MODEL_OP_2(0x82, 0x4b)
+#define OP_LIGHT_LIGHTNESS_SET		BT_MESH_MODEL_OP_2(0x82, 0x4c)
+#define OP_LIGHT_LIGHTNESS_SET_UNACK	BT_MESH_MODEL_OP_2(0x82, 0x4d)
 
 bool bt_mesh_is_provisioned(void);
 
diff --git a/nimble/host/mesh/src/model_cli.c b/nimble/host/mesh/src/model_cli.c
index 3df5c695..68d40167 100644
--- a/nimble/host/mesh/src/model_cli.c
+++ b/nimble/host/mesh/src/model_cli.c
@@ -7,7 +7,7 @@
 #include <mesh/mesh.h>
 
 #define BT_DBG_ENABLED (MYNEWT_VAL(BLE_MESH_DEBUG_MODEL))
-#include "model_cli.h"
+#include "mesh/model_cli.h"
 #include "mesh_priv.h"
 
 static s32_t msg_timeout = K_SECONDS(5);
diff --git a/nimble/host/mesh/src/model_srv.c b/nimble/host/mesh/src/model_srv.c
index be727ce3..1420b1cc 100644
--- a/nimble/host/mesh/src/model_srv.c
+++ b/nimble/host/mesh/src/model_srv.c
@@ -8,7 +8,7 @@
 
 #define BT_DBG_ENABLED (MYNEWT_VAL(BLE_MESH_DEBUG_MODEL))
 
-#include "model_srv.h"
+#include "mesh/model_srv.h"
 #include "mesh_priv.h"
 
 static void gen_onoff_status(struct bt_mesh_model *model,
@@ -24,7 +24,7 @@ static void gen_onoff_status(struct bt_mesh_model *model,
 		cb->get(model, state);
 	}
 
-	BT_DBG("state: %d", state);
+	BT_DBG("state: %d", *state);
 
 	if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) {
 		BT_ERR("Send status failed");
@@ -81,7 +81,7 @@ static void gen_level_status(struct bt_mesh_model *model,
 		cb->get(model, level);
 	}
 
-	BT_DBG("level: %d", level);
+	BT_DBG("level: %d", *level);
 
 	if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) {
 		BT_ERR("Send status failed");
@@ -121,6 +121,59 @@ static void gen_level_set(struct bt_mesh_model *model,
 	gen_level_status(model, ctx);
 }
 
+static void light_lightness_status(struct bt_mesh_model *model,
+			     struct bt_mesh_msg_ctx *ctx)
+{
+	struct bt_mesh_light_lightness_srv_cb *cb = model->user_data;
+	struct os_mbuf *msg = NET_BUF_SIMPLE(4);
+	s16_t *lightness;
+
+	bt_mesh_model_msg_init(msg, OP_GEN_LEVEL_STATUS);
+	lightness = net_buf_simple_add(msg, 2);
+	if (cb && cb->get) {
+		cb->get(model, lightness);
+	}
+
+	BT_DBG("lightness: %d", *lightness);
+
+	if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) {
+		BT_ERR("Send status failed");
+	}
+
+	os_mbuf_free_chain(msg);
+}
+
+static void light_lightness_get(struct bt_mesh_model *model,
+			  struct bt_mesh_msg_ctx *ctx,
+			  struct os_mbuf *buf)
+{
+	BT_DBG("");
+
+	light_lightness_status(model, ctx);
+}
+
+static void light_lightness_set_unack(struct bt_mesh_model *model,
+				struct bt_mesh_msg_ctx *ctx,
+				struct os_mbuf *buf) {
+	struct bt_mesh_light_lightness_srv_cb *cb = model->user_data;
+	s16_t lightness;
+
+	lightness = (s16_t) net_buf_simple_pull_le16(buf);
+	BT_DBG("lightness: %d", lightness);
+
+	if (cb && cb->set) {
+		cb->set(model, lightness);
+	}
+}
+
+static void light_lightness_set(struct bt_mesh_model *model,
+			  struct bt_mesh_msg_ctx *ctx,
+			  struct os_mbuf *buf)
+{
+	light_lightness_set_unack(model, ctx, buf);
+	light_lightness_status(model, ctx);
+}
+
 const struct bt_mesh_model_op gen_onoff_srv_op[] = {
 	{ OP_GEN_ONOFF_GET, 		0, gen_onoff_get },
 	{ OP_GEN_ONOFF_SET, 		2, gen_onoff_set },
@@ -134,3 +187,10 @@ const struct bt_mesh_model_op gen_level_srv_op[] = {
 	{ OP_GEN_LEVEL_SET_UNACK, 	3, gen_level_set_unack },
 	BT_MESH_MODEL_OP_END,
 };
+
+const struct bt_mesh_model_op light_lightness_srv_op[] = {
+	{ OP_LIGHT_LIGHTNESS_GET, 		0, light_lightness_get },
+	{ OP_LIGHT_LIGHTNESS_SET, 		3, light_lightness_set },
+	{ OP_LIGHT_LIGHTNESS_SET_UNACK, 	3, light_lightness_set_unack },
+	BT_MESH_MODEL_OP_END,
+};
diff --git a/nimble/host/mesh/src/shell.c b/nimble/host/mesh/src/shell.c
index 44b4f5f7..379115fc 100644
--- a/nimble/host/mesh/src/shell.c
+++ b/nimble/host/mesh/src/shell.c
@@ -28,15 +28,14 @@
 #include "access.h"
 #include "mesh_priv.h"
 #if MYNEWT_VAL(BLE_MESH_SHELL_MODELS)
-#include "model_srv.h"
-#include "model_cli.h"
+#include "mesh/model_srv.h"
+#include "mesh/model_cli.h"
 #include "light_model.h"
 #endif
 #include "lpn.h"
 #include "transport.h"
 #include "foundation.h"
 #include "testing.h"
-#include "model_cli.h"
 
 /* This should be higher priority (lower value) than main task priority */
 #define BLE_MESH_SHELL_TASK_PRIO 126
@@ -180,10 +179,14 @@ health_pub_init(void)
 {
 	health_pub.msg  = BT_MESH_HEALTH_FAULT_MSG(CUR_FAULTS_MAX);
 }
+#if MYNEWT_VAL(BLE_MESH_CFG_CLI)
 
 static struct bt_mesh_cfg_cli cfg_cli = {
 };
 
+#endif /* MYNEWT_VAL(BLE_MESH_CFG_CLI) */
+
+#if MYNEWT_VAL(BLE_MESH_HEALTH_CLI)
 void show_faults(u8_t test_id, u16_t cid, u8_t *faults, size_t fault_count)
 {
 	size_t i;
@@ -214,9 +217,12 @@ static struct bt_mesh_health_cli health_cli = {
 	.current_status = health_current_status,
 };
 
+#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 light_lightness_pub;
 static struct bt_mesh_gen_onoff_srv_cb gen_onoff_srv_cb = {
 	.get = light_model_gen_onoff_get,
 	.set = light_model_gen_onoff_set,
@@ -225,18 +231,43 @@ static struct bt_mesh_gen_level_srv_cb gen_level_srv_cb = {
 	.get = light_model_gen_level_get,
 	.set = light_model_gen_level_set,
 };
+static struct bt_mesh_light_lightness_srv_cb light_lightness_srv_cb = {
+	.get = light_model_light_lightness_get,
+	.set = light_model_light_lightness_set,
+};
+
+void bt_mesh_set_gen_onoff_srv_cb(struct bt_mesh_gen_onoff_srv_cb *gen_onoff_cb)
+{
+	gen_onoff_srv_cb = *gen_onoff_cb;
+}
+
+void bt_mesh_set_gen_level_srv_cb(struct bt_mesh_gen_level_srv_cb *gen_level_cb)
+{
+	gen_level_srv_cb = *gen_level_cb;
+}
+
+void bt_mesh_set_light_lightness_srv_cb(struct bt_mesh_light_lightness_srv_cb *light_lightness_cb)
+{
+	light_lightness_srv_cb = *light_lightness_cb;
+}
+
 #endif
 
 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),
+#if MYNEWT_VAL(BLE_MESH_CFG_CLI)
+	BT_MESH_MODEL_CFG_CLI(&cfg_cli),
+#endif
+#if MYNEWT_VAL(BLE_MESH_HEALTH_CLI)
 	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_LIGHT_LIGHTNESS_SRV(&light_lightness_srv_cb, &light_lightness_pub),
 #endif
 };
 
@@ -437,12 +468,12 @@ static struct bt_mesh_prov prov = {
 	.reset = prov_reset,
 	.static_val = NULL,
 	.static_val_len = 0,
-	.output_size = 4,
-	.output_actions = (BT_MESH_BLINK | BT_MESH_BEEP | BT_MESH_DISPLAY_NUMBER | BT_MESH_DISPLAY_STRING),
+	.output_size = MYNEWT_VAL(BLE_MESH_OOB_OUTPUT_SIZE),
+	.output_actions = MYNEWT_VAL(BLE_MESH_OOB_OUTPUT_ACTIONS),
 	.output_number = output_number,
 	.output_string = output_string,
-	.input_size = 4,
-	.input_actions = (BT_MESH_ENTER_NUMBER | BT_MESH_ENTER_STRING),
+	.input_size = MYNEWT_VAL(BLE_MESH_OOB_INPUT_SIZE),
+	.input_actions = MYNEWT_VAL(BLE_MESH_OOB_INPUT_ACTIONS),
 	.input = input,
 };
 
@@ -602,7 +633,7 @@ static int check_pub_addr_unassigned(void)
 #endif
 }
 
-static int cmd_init(int argc, char *argv[])
+int cmd_init(int argc, char *argv[])
 {
 	int err;
 	ble_addr_t addr;
@@ -648,85 +679,6 @@ static int cmd_ident(int argc, char *argv[])
 }
 #endif /* MESH_GATT_PROXY */
 
-static int cmd_get_comp(int argc, char *argv[])
-{
-	struct os_mbuf*comp = NET_BUF_SIMPLE(32);
-	u8_t status, page = 0x00;
-	int err;
-
-	if (argc > 1) {
-		page = strtol(argv[1], NULL, 0);
-	}
-
-	net_buf_simple_init(comp, 0);
-	err = bt_mesh_cfg_comp_data_get(net.net_idx, net.dst, page,
-					&status, comp);
-	if (err) {
-		printk("Getting composition failed (err %d)\n", err);
-		return 0;
-	}
-
-	if (status != 0x00) {
-		printk("Got non-success status 0x%02x\n", status);
-		return 0;
-	}
-
-	printk("Got Composition Data for 0x%04x:\n", net.dst);
-	printk("\tCID      0x%04x\n", net_buf_simple_pull_le16(comp));
-	printk("\tPID      0x%04x\n", net_buf_simple_pull_le16(comp));
-	printk("\tVID      0x%04x\n", net_buf_simple_pull_le16(comp));
-	printk("\tCRPL     0x%04x\n", net_buf_simple_pull_le16(comp));
-	printk("\tFeatures 0x%04x\n", net_buf_simple_pull_le16(comp));
-
-	while (comp->om_len > 4) {
-		u8_t sig, vnd;
-		u16_t loc;
-		int i;
-
-		loc = net_buf_simple_pull_le16(comp);
-		sig = net_buf_simple_pull_u8(comp);
-		vnd = net_buf_simple_pull_u8(comp);
-
-		printk("\n\tElement @ 0x%04x:\n", loc);
-
-		if (comp->om_len < ((sig * 2) + (vnd * 4))) {
-			printk("\t\t...truncated data!\n");
-			break;
-		}
-
-		if (sig) {
-			printk("\t\tSIG Models:\n");
-		} else {
-			printk("\t\tNo SIG Models\n");
-		}
-
-		for (i = 0; i < sig; i++) {
-			u16_t mod_id = net_buf_simple_pull_le16(comp);
-
-			printk("\t\t\t0x%04x\n", mod_id);
-		}
-
-		if (vnd) {
-			printk("\t\tVendor Models:\n");
-		} else {
-			printk("\t\tNo Vendor Models\n");
-		}
-
-		for (i = 0; i < vnd; i++) {
-			u16_t cid = net_buf_simple_pull_le16(comp);
-			u16_t mod_id = net_buf_simple_pull_le16(comp);
-
-			printk("\t\t\tCompany 0x%04x: 0x%04x\n", cid, mod_id);
-		}
-	}
-
-	return 0;
-}
-
-struct shell_cmd_help cmd_get_comp_help = {
-	NULL, "[page]", NULL
-};
-
 static int cmd_dst(int argc, char *argv[])
 {
 	if (argc < 2) {
@@ -914,6 +866,126 @@ struct shell_cmd_help cmd_iv_update_test_help = {
 	NULL, "<value: off, on>", NULL
 };
 
+#if MYNEWT_VAL(BLE_MESH_CFG_CLI)
+
+int cmd_timeout(int argc, char *argv[])
+{
+	s32_t timeout;
+
+	if (argc < 2) {
+		timeout = bt_mesh_cfg_cli_timeout_get();
+		if (timeout == K_FOREVER) {
+			printk("Message timeout: forever\n");
+		} else {
+			printk("Message timeout: %lu seconds\n",
+			       timeout / 1000);
+		}
+
+		return 0;
+	}
+
+	timeout = strtol(argv[1], NULL, 0);
+	if (timeout < 0 || timeout > (INT32_MAX / 1000)) {
+		timeout = K_FOREVER;
+	} else {
+		timeout = timeout * 1000;
+	}
+
+	bt_mesh_cfg_cli_timeout_set(timeout);
+	if (timeout == K_FOREVER) {
+		printk("Message timeout: forever\n");
+	} else {
+		printk("Message timeout: %lu seconds\n",
+		       timeout / 1000);
+	}
+
+	return 0;
+}
+
+struct shell_cmd_help cmd_timeout_help = {
+	NULL, "[timeout in seconds]", NULL
+};
+
+
+static int cmd_get_comp(int argc, char *argv[])
+{
+	struct os_mbuf*comp = NET_BUF_SIMPLE(32);
+	u8_t status, page = 0x00;
+	int err;
+
+	if (argc > 1) {
+		page = strtol(argv[1], NULL, 0);
+	}
+
+	net_buf_simple_init(comp, 0);
+	err = bt_mesh_cfg_comp_data_get(net.net_idx, net.dst, page,
+					&status, comp);
+	if (err) {
+		printk("Getting composition failed (err %d)\n", err);
+		return 0;
+	}
+
+	if (status != 0x00) {
+		printk("Got non-success status 0x%02x\n", status);
+		return 0;
+	}
+
+	printk("Got Composition Data for 0x%04x:\n", net.dst);
+	printk("\tCID      0x%04x\n", net_buf_simple_pull_le16(comp));
+	printk("\tPID      0x%04x\n", net_buf_simple_pull_le16(comp));
+	printk("\tVID      0x%04x\n", net_buf_simple_pull_le16(comp));
+	printk("\tCRPL     0x%04x\n", net_buf_simple_pull_le16(comp));
+	printk("\tFeatures 0x%04x\n", net_buf_simple_pull_le16(comp));
+
+	while (comp->om_len > 4) {
+		u8_t sig, vnd;
+		u16_t loc;
+		int i;
+
+		loc = net_buf_simple_pull_le16(comp);
+		sig = net_buf_simple_pull_u8(comp);
+		vnd = net_buf_simple_pull_u8(comp);
+
+		printk("\n\tElement @ 0x%04x:\n", loc);
+
+		if (comp->om_len < ((sig * 2) + (vnd * 4))) {
+			printk("\t\t...truncated data!\n");
+			break;
+		}
+
+		if (sig) {
+			printk("\t\tSIG Models:\n");
+		} else {
+			printk("\t\tNo SIG Models\n");
+		}
+
+		for (i = 0; i < sig; i++) {
+			u16_t mod_id = net_buf_simple_pull_le16(comp);
+
+			printk("\t\t\t0x%04x\n", mod_id);
+		}
+
+		if (vnd) {
+			printk("\t\tVendor Models:\n");
+		} else {
+			printk("\t\tNo Vendor Models\n");
+		}
+
+		for (i = 0; i < vnd; i++) {
+			u16_t cid = net_buf_simple_pull_le16(comp);
+			u16_t mod_id = net_buf_simple_pull_le16(comp);
+
+			printk("\t\t\tCompany 0x%04x: 0x%04x\n", cid, mod_id);
+		}
+	}
+
+	return 0;
+}
+
+struct shell_cmd_help cmd_get_comp_help = {
+	NULL, "[page]", NULL
+};
+
 static int cmd_beacon(int argc, char *argv[])
 {
 	u8_t status;
@@ -1669,6 +1741,8 @@ struct shell_cmd_help cmd_hb_pub_help = {
 	NULL, "<dst> <count> <period> <ttl> <features> <NetKeyIndex>" , NULL
 };
 
+#endif /* MYNEWT_VAL(BLE_MESH_CFG_CLI) */
+
 #if MYNEWT_VAL(BLE_MESH_PROV)
 static int cmd_pb(bt_mesh_prov_bearer_t bearer, int argc, char *argv[])
 {
@@ -1752,43 +1826,7 @@ struct shell_cmd_help cmd_provision_help = {
 	NULL, "<NetKeyIndex> <addr> [IVIndex]" , NULL
 };
 
-int cmd_timeout(int argc, char *argv[])
-{
-	s32_t timeout;
-
-	if (argc < 2) {
-		timeout = bt_mesh_cfg_cli_timeout_get();
-		if (timeout == K_FOREVER) {
-			printk("Message timeout: forever\n");
-		} else {
-			printk("Message timeout: %lu seconds\n",
-			       timeout / 1000);
-		}
-
-		return 0;
-	}
-
-	timeout = strtol(argv[1], NULL, 0);
-	if (timeout < 0 || timeout > (INT32_MAX / 1000)) {
-		timeout = K_FOREVER;
-	} else {
-		timeout = timeout * 1000;
-	}
-
-	bt_mesh_cfg_cli_timeout_set(timeout);
-	if (timeout == K_FOREVER) {
-		printk("Message timeout: forever\n");
-	} else {
-		printk("Message timeout: %lu seconds\n",
-		       timeout / 1000);
-	}
-
-	return 0;
-}
-
-struct shell_cmd_help cmd_timeout_help = {
-	NULL, "[timeout in seconds]", NULL
-};
+#if MYNEWT_VAL(BLE_MESH_HEALTH_CLI)
 
 static int cmd_fault_get(int argc, char *argv[])
 {
@@ -2065,6 +2103,8 @@ struct shell_cmd_help cmd_attention_set_unack_help = {
 	NULL, "<timer>", NULL
 };
 
+#endif /* MYNEWT_VAL(BLE_MESH_HEALTH_CLI) */
+
 static int cmd_add_fault(int argc, char *argv[])
 {
 	u8_t fault_id;
@@ -2335,7 +2375,6 @@ static int cmd_print_composition_data(int argc, char *argv[])
 
 static const struct shell_cmd mesh_commands[] = {
 	{ "init", cmd_init, NULL },
-	{ "timeout", cmd_timeout, &cmd_timeout_help },
 #if MYNEWT_VAL(BLE_MESH_PB_ADV)
 	{ "pb-adv", cmd_pb_adv, &cmd_pb_help },
 #endif
@@ -2371,7 +2410,10 @@ static const struct shell_cmd mesh_commands[] = {
 	{ "print-credentials", cmd_print_credentials, NULL },
 	{ "print-composition-data", cmd_print_composition_data, NULL },
 
+
+#if MYNEWT_VAL(BLE_MESH_CFG_CLI)
 	/* Configuration Client Model operations */
+	{ "timeout", cmd_timeout, &cmd_timeout_help },
 	{ "get-comp", cmd_get_comp, &cmd_get_comp_help },
 	{ "beacon", cmd_beacon, &cmd_beacon_help },
 	{ "ttl", cmd_ttl, &cmd_ttl_help},
@@ -2388,7 +2430,9 @@ static const struct shell_cmd mesh_commands[] = {
 	{ "mod-sub-del-va", cmd_mod_sub_del_va, &cmd_mod_sub_del_va_help },
 	{ "hb-sub", cmd_hb_sub, &cmd_hb_sub_help },
 	{ "hb-pub", cmd_hb_pub, &cmd_hb_pub_help },
+#endif
 
+#if MYNEWT_VAL(BLE_MESH_HEALTH_CLI)
 	/* Health Client Model Operations */
 	{ "fault-get", cmd_fault_get, &cmd_fault_get_help },
 	{ "fault-clear", cmd_fault_clear, &cmd_fault_clear_help },
@@ -2401,6 +2445,7 @@ static const struct shell_cmd mesh_commands[] = {
 	{ "attention-get", cmd_attention_get, NULL },
 	{ "attention-set", cmd_attention_set, &cmd_attention_set_help },
 	{ "attention-set-unack", cmd_attention_set_unack, &cmd_attention_set_unack_help },
+#endif
 
 	/* Health Server Model Operations */
 	{ "add-fault", cmd_add_fault, &cmd_add_fault_help },
@@ -2449,9 +2494,5 @@ void ble_mesh_shell_init(void)
 	shell_evq_set(&mesh_shell_queue);
 	shell_register("mesh", mesh_commands);
 
-#if MYNEWT_VAL(BLE_MESH_SHELL_MODELS)
-	light_model_init();
-#endif
-
 #endif
 }
diff --git a/nimble/host/mesh/src/testing.c b/nimble/host/mesh/src/testing.c
index bb35cff3..8db62f7a 100644
--- a/nimble/host/mesh/src/testing.c
+++ b/nimble/host/mesh/src/testing.c
@@ -14,6 +14,8 @@
 
 #include "net.h"
 #include "testing.h"
+#include "access.h"
+#include "foundation.h"
 
 static sys_slist_t cb_slist;
 
@@ -152,3 +154,20 @@ void bt_test_print_credentials(void)
 			       bt_hex(priv, 16));
 	}
 }
+
+int bt_test_shell_init(void)
+{
+	return cmd_init(0, NULL);
+}
+
+int bt_test_bind_app_key_to_model(struct bt_mesh_model *model, u16_t key_idx, u16_t id)
+{
+	struct bt_mesh_model *found_model;
+
+	found_model = bt_mesh_model_find(model->elem, id);
+	if (!found_model) {
+		return STATUS_INVALID_MODEL;
+	}
+
+	return mod_bind(found_model, key_idx);
+}
diff --git a/nimble/host/mesh/syscfg.yml b/nimble/host/mesh/syscfg.yml
index 0184a652..ef83c661 100644
--- a/nimble/host/mesh/syscfg.yml
+++ b/nimble/host/mesh/syscfg.yml
@@ -385,9 +385,40 @@ syscfg.defs:
     BLE_MESH_SHELL_MODELS:
         description: >
             Include implementation of some demo models.
-            This requires pwm0, pwm1, pwm2 and pwm3 devices.
         value: 0
 
+    BLE_MESH_OOB_OUTPUT_ACTIONS:
+        description: >
+            Supported Output OOB Actions
+            BT_MESH_NO_OUTPUT       = 0,
+            BT_MESH_BLINK           = BIT(0)
+            BT_MESH_BEEP            = BIT(1)
+            BT_MESH_VIBRATE         = BIT(2)
+            BT_MESH_DISPLAY_NUMBER  = BIT(3)
+            BT_MESH_DISPLAY_STRING  = BIT(4)
+        value: ((BT_MESH_DISPLAY_NUMBER))
+
+    BLE_MESH_OOB_OUTPUT_SIZE:
+        description: >
+            Output OOB size
+        value: 4
+
+    BLE_MESH_OOB_INPUT_ACTIONS:
+        description: >
+            Supported Input OOB Actions
+            BT_MESH_NO_INPUT      = 0,
+            BT_MESH_PUSH          = BIT(0)
+            BT_MESH_TWIST         = BIT(1)
+            BT_MESH_ENTER_NUMBER  = BIT(2)
+            BT_MESH_ENTER_STRING  = BIT(3)
+        value: ((BT_MESH_NO_INPUT))
+
+    BLE_MESH_OOB_INPUT_SIZE:
+        description: >
+            Input OOB size
+        value: 4
+
+
 syscfg.vals.BLE_MESH_SHELL:
     BLE_MESH_CFG_CLI: 1
     BLE_MESH_HEALTH_CLI: 1


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services