Use of scenes in BLE mesh with nrf52840

Hi,

I have autoprovisioned and autoconfigured my nrf52840 board (provisioning and configuring are made inside the software and not through external app/provisioner).

In particular, I have configured three couples of switch/led as client/server.

Now I'd like to set some scenes, for example:

  • two leds on and one off.
  • one led on and two off
  • all led on

My goal is to be able to recall one of these scenes 

How can I implement these scenes in the software? Which is the way to memorize them?

And then how can I recall each of them?

Here is my elements definition:

/* ELEMENTS */
static struct bt_mesh_elem elements[] = {
	BT_MESH_ELEM(1,
				 BT_MESH_MODEL_LIST(
					 BT_MESH_MODEL_CFG_SRV,
					 BT_MESH_MODEL_CFG_CLI(&cli_data),
					 BT_MESH_MODEL_HEALTH_SRV(&health_srv, &health_pub),
					 BT_MESH_MODEL_DFD_SRV(&dfd_srv),
					 BT_MESH_MODEL_ONOFF_CLI(&buttons[BUTTON_IDX].client),
					 BT_MESH_MODEL_ONOFF_SRV(&led_ctx[LED_IDX].srv)),
				 BT_MESH_MODEL_LIST(
					 BT_MESH_MODEL_CHAT_CLI(&chat))),
	BT_MESH_ELEM(2,
				 BT_MESH_MODEL_LIST(
					 BT_MESH_MODEL_DFU_SRV(&dfu_srv)),
				 BT_MESH_MODEL_NONE),
	BT_MESH_ELEM(3,
				 BT_MESH_MODEL_LIST(
					 BT_MESH_MODEL_ONOFF_CLI(&buttons[BUTTON_IDX2].client),
					 BT_MESH_MODEL_ONOFF_SRV(&led_ctx[LED_IDX2].srv)),
				 BT_MESH_MODEL_NONE),
	BT_MESH_ELEM(4,
				 BT_MESH_MODEL_LIST(
					 BT_MESH_MODEL_ONOFF_CLI(&buttons[BUTTON_IDX3].client),
					 BT_MESH_MODEL_ONOFF_SRV(&led_ctx[LED_IDX3].srv)),
				 BT_MESH_MODEL_NONE),
};

I hope in your help as always

Best regards

Parents
  • Hi Stefano and thanks for your patience,

    First of all, doing things in regards to provisioning etc in Mesh programmatically is always a bit frowned upon, as having a dedicated provisioner is considered the safer choice. Though I assume you've already been told about this in the past, so I'll leave it at that. 

    In order to use scenes you'll have to use scene server models, and eg. using bt_mesh_scene_cli_store() and bt_mesh_scene_cli_recall(). Have a look here.

    The best way to learn how this can be done is probably using and testing out the Light dimmer and scene selector sample.

    Regards,

    Elfving

  • Hi,

    Thank you for your information.

    I have examined your firmware related to light_ctrl sample and I tried to import in my firmware all the instructions related to scenes. Here is what I did:

    • I added CONFIG_BT_MESH_SCENE_SRV=y in my prj.conf
    • I added:
      • static struct bt_mesh_scene_srv scene_srv in my model_handler.c
      • BT_MESH_MODEL_SCENE_SRV(&scene_srv), in element list in my model_handler.c

    Well, I manage to build correctly my program (0 errors), but after programming the result is that the program does not start (the red led should light on but nothing happens)

    Then I verified that if I comment:

     BT_MESH_MODEL_SCENE_SRV(&scene_srv)

    the program starts correctly (the red led lights on etc.)

    Why this happens?

    What have I missed?

    I wait for your help

    Best regards

Reply
  • Hi,

    Thank you for your information.

    I have examined your firmware related to light_ctrl sample and I tried to import in my firmware all the instructions related to scenes. Here is what I did:

    • I added CONFIG_BT_MESH_SCENE_SRV=y in my prj.conf
    • I added:
      • static struct bt_mesh_scene_srv scene_srv in my model_handler.c
      • BT_MESH_MODEL_SCENE_SRV(&scene_srv), in element list in my model_handler.c

    Well, I manage to build correctly my program (0 errors), but after programming the result is that the program does not start (the red led should light on but nothing happens)

    Then I verified that if I comment:

     BT_MESH_MODEL_SCENE_SRV(&scene_srv)

    the program starts correctly (the red led lights on etc.)

    Why this happens?

    What have I missed?

    I wait for your help

    Best regards

Children
No Data
Related