Bluetooth mesh sensor client example gives different outputs in different mobile devices

Hello

I tried bluetooth mesh sensor server and client example, everything is good including provisioning process in mobile but the output is different with different mobiles. i have 2 mobiles where i tested in both mobiles i get output of this part as shown in picture-1

picture-1

and

picture-2

and from the picture-2 of code except chip temperature i can see other printk functions in output.

I tried this in my colleague mobile in that i can see picture-2 outputs but not picture-1 output.

I am really confused, why this happens? Can anyone help me as soon as possible please...

Regards

SaSu

Parents
  • Hi,

    1. Which devices did you use for the sensor server and client samples?
    2. Could you add the output you see on your mobiles as well? 
    3. Are there any differences between the mobiles? Different OS'?

    Kind regards,
    Andreas

  • Hello

    Sorry for late response. 1. For sensor_server thingy:53 with nRF5340DK and for sensor_client nRF52840DK

    2. From my colleague mobile i dont have screenshot also he is not available now its android and output comes from picture-2 i.e "chip temperature is .. ", "presence detected" and so on. I have two mobiles one is android and other is IOS so in both i could not see "chip temperature" output line its directly jumping to picture-1 i.e "Relative runtime in 0 to 30 degrees : 0.0000 percent" and also i can see presence detected lines when i press button on thingy-53.

    3. Already answered in point 2

    Regards

  • SaSu said:
    Yes, i am using the sample described in the sample description. Yes one node is server(i am using thing 53 with nRF5320_DK as server) and one node is client(i am using nRF42840_DK as client). Yes sensor_cli_data_cb() is triggering but only one if else part i.e as explained in above line.

    That was not something I understood until now. You said it was the same device that pushed the button and printed the text.

    I understand how you want the sample to work, but that is not the way it works by default. The server has (at least two) "sensors". One presence sensor, where changes are triggered by pushing the sensor. Then it has one temperature sensor, which is being sent regularly. What you want is perfectly possible, but it is not what the sample does. This is why I suggested you try to figure out what happens in the application on the Thingy when you press the button, to see how you can repurpose that to send the temperature value instead of triggering the presence detection.

    But sure, let us walk through it.

    So something happens when you press a button on the sensor_server application. I want to look for a button handler. In the model_handler.c file in the sensor_server application there is a function that is being called inside model_handler_init():

    dk_button_handler_add(), which initializes a button handler struct called "button_handler". It has one member, called button_handler_cb(). Inside there you can see that it publishes something if the button is pressed:

    		err = bt_mesh_sensor_srv_pub(&sensor_srv, NULL,
    					     &presence_sensor, &val);

    It looks like it publishes something about a presence_sensor. Have you tried changing this to the chip_temp sensor instead?

    Please note that the &val consists of two parameters. One before the decimal point and one representing the value after the decimal point. From it's declaration:

    /**
     * @brief Representation of a sensor readout value.
     *
     * The value is represented as having an integer and a fractional part,
     * and can be obtained using the formula val1 + val2 * 10^(-6). Negative
     * values also adhere to the above formula, but may need special attention.
     * Here are some examples of the value representation:
     *
     *      0.5: val1 =  0, val2 =  500000
     *     -0.5: val1 =  0, val2 = -500000
     *     -1.0: val1 = -1, val2 =  0
     *     -1.5: val1 = -1, val2 = -500000
     */
    struct sensor_value {
    	/** Integer part of the value. */
    	int32_t val1;
    	/** Fractional part of the value (in one-millionth parts). */
    	int32_t val2;
    };

    I suggest that you first try by setting it to a dummy value, to see whether it triggers the correct sensor->id. Then you can try to actually read the actual temperature later.

    Best regards,

    Edvin

  • Hello

    I set it to 10 it shows error . Could give me instructions how exactly to do that by any example code attached. It would be great so that i would get exact idea how to do that.

    For val1 to 0 and val2 to 1 it doesn't work as we expected.

    Edit:

    I also changed "presence_sensor" in button_handler_cb to "chip_temp" as below

    Still its printing "presence_sensor". No idea what is going on. Looks like so much struggle to get "Chip Temperature" which is already integrated in the sample program

    Thank You

    Best Regards

  • SaSu said:
    I set it to 10 it shows error

    What do you set to 10, and what error does it give?

    SaSu said:
    Could give me instructions how exactly to do that by any example code attached. It would be great so that i would get exact idea how to do that.

    Can you please upload what you already did?

    BR,

    Edvin

  • I did like below and it doesn't work

    With the error thing i did like below, I know its wrong

    int32_t val1==10;

    Please tell me what do you mean with example code and please tell me the working code which you already tested it and works as i already told you its important to me and since a month that this forum question is running.

    Regards

  • Well, we do not develop applications for customers here on DevZone, and to be fair, I have tried as best I can to get information.

    I can ask again:

    SaSu said:
    I set it to 10 it shows error . Could give me instructions how exactly to do that by any example code attached. It would be great so that i would get exact idea how to do that.

    What do you set to 10? How do you do it? is it the int32_t val1==10 from your snippet above? That is not setting anything. When you are using two "=", it is a comparison. That line doesn't make sense. It basically says:

    int32_t 1;

    or 

    int32_t 0;

    depending on whether val1 equals 10 or not.

    Is that the error you were talking about? Or is it some sort of function that returns an error?

    Why don't you try to change your button_handler_cb() in your sensor_server application to do this:

    static void button_handler_cb(uint32_t pressed, uint32_t changed)
    {
    	if ((pressed & BIT(0))) {
    		int err;
    
    		/* This sensor value must be boolean -
    		 * .val1 can only be '0' or '1'
    		 */
    		// struct sensor_value val = {
    		// 	.val1 = 1,
    		// };
            struct sensor_value val = {
    			.val1 = 1,
                .val2 = 500000,
    		};
    
    		// err = bt_mesh_sensor_srv_pub(&sensor_srv, NULL,
    		// 			     &presence_sensor, &val);
            err = bt_mesh_sensor_srv_pub(&sensor_srv, NULL,
    					     &chip_temp, &val);
    
    		if (err) {
    			printk("Error publishing presence (%d)\n", err);
    		}
    
    		prev_pres = k_uptime_get_32();
    
    		k_work_reschedule(&end_of_presence_work, K_MSEC(2000));
    	}
    }

    Then it should print something like this:

    Best regards,

    Edvin

Reply
  • Well, we do not develop applications for customers here on DevZone, and to be fair, I have tried as best I can to get information.

    I can ask again:

    SaSu said:
    I set it to 10 it shows error . Could give me instructions how exactly to do that by any example code attached. It would be great so that i would get exact idea how to do that.

    What do you set to 10? How do you do it? is it the int32_t val1==10 from your snippet above? That is not setting anything. When you are using two "=", it is a comparison. That line doesn't make sense. It basically says:

    int32_t 1;

    or 

    int32_t 0;

    depending on whether val1 equals 10 or not.

    Is that the error you were talking about? Or is it some sort of function that returns an error?

    Why don't you try to change your button_handler_cb() in your sensor_server application to do this:

    static void button_handler_cb(uint32_t pressed, uint32_t changed)
    {
    	if ((pressed & BIT(0))) {
    		int err;
    
    		/* This sensor value must be boolean -
    		 * .val1 can only be '0' or '1'
    		 */
    		// struct sensor_value val = {
    		// 	.val1 = 1,
    		// };
            struct sensor_value val = {
    			.val1 = 1,
                .val2 = 500000,
    		};
    
    		// err = bt_mesh_sensor_srv_pub(&sensor_srv, NULL,
    		// 			     &presence_sensor, &val);
            err = bt_mesh_sensor_srv_pub(&sensor_srv, NULL,
    					     &chip_temp, &val);
    
    		if (err) {
    			printk("Error publishing presence (%d)\n", err);
    		}
    
    		prev_pres = k_uptime_get_32();
    
    		k_work_reschedule(&end_of_presence_work, K_MSEC(2000));
    	}
    }

    Then it should print something like this:

    Best regards,

    Edvin

Children
Related