Mesh sensor cadence

Hi everyone,

I am planning to use the cadence/publish interval property within a mesh network. I can not find any examples on how to use it. I know I can set it in the nrf mesh app but I would like to set the cadence in my implementation (like by clicking a button on the nrf52840DK). The sensor observer should be able to call the set function to set the cadence on a sensor server. Also the sensor observer should get some information about the cadence from the sensor server. Can anyone share some code on how to do it?

Best,

Toni

  • Okay I might already have the answer as the sensor observer can not set the cadence on the sensor server, can it?

  • Hi Toni,

    The Sensor Observer sample uses the Sensor Client model, which, by spec, has to support Sensor Cadence Set. See Section 4.4.1.1 of the Bluetooth Mesh Models Specification v1.0.1. I also captured the relevant table below.

    As for code reference, have you looked at these functions?

    bt_mesh_sensor_cli_cadence_set()
    bt_mesh_sensor_cli_cadence_set_unack()

    Best,

    Hieu

  • Hi Hieu,

    thank you the quick reply! I read it already and tried to implement it, but without success.
    I implemented the bt_mesh_sensor_present_ambient_light_level type and would like to get/set the candence settings on the server.
    First I want to get the cadence on the client by pressing a button on the DK. Therefore I use the function

    err = bt_mesh_sensor_cli_cadence_get(&sensor_cli, NULL, &bt_mesh_sensor_present_amb_light_level, &rsp);

    And on the sensor server I configured it like this:

    static struct bt_mesh_sensor present_amb_light_level = {
    	.type = &bt_mesh_sensor_present_amb_light_level,
    	.get = amb_light_level_get,
    	.descriptor = &amb_light_level_desc,
    	.settings = {
    		.list = (const struct bt_mesh_sensor_setting *)&amb_light_level_setting,
    		.count = ARRAY_SIZE(amb_light_level_setting),
    	},
    	.state = {
    		.configured = true,
    		.fast_pub = true,
    		.pub_div = 1,
    		.min_int = 10,
    		.threshold = {
    			.range = {
    				.cadence = BT_MESH_SENSOR_CADENCE_NORMAL,
    				.low = {
    					.format = &bt_mesh_sensor_format_count_16,
    					.raw = {0x00, 0x00} // Replace with the actual raw value for low
    				},
    				.high = {
    					.format = &bt_mesh_sensor_format_count_16,
    					.raw = {0x0A, 0x00} // Replace with the actual raw value for high
    				},
    			},
    			.deltas = {
    				.up = {
    					.format = &bt_mesh_sensor_format_count_16,
    					.raw = {0x02, 0x00} // Replace with the actual raw value for up
    				},
    				.down = {
    					.format = &bt_mesh_sensor_format_count_16,
    					.raw = {0x00, 0x00} // Replace with the actual raw value for down
    				},
    			},
    		},
    	},
    };

    I always get the error -ETIMEDOUT

    Could you provide some example code?

    Best,

    Toni

  • Hi Toni,

    I am currently out of office, so this will have to wait until I return next week. My apology about this.

    Best,

    Hieu

Related