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

  • Hello,

    I understand, but I am missing quite a few steps of understanding. What happens between you pressing the button on the thingy and you end up in the sensor_cli_data_cb()? Can you please try to set a breakpoint there to check the callstack? Where is the sensor->id being set? 

    Are you using the sample as it is descibred in the sample description? You have one node acting as a server and one as a client? The sensor_cli_data_cb() is triggered on the client, right? 

    I needed to try the sample that you are talking about, and I want to clear up a few things:

    The thingy is programmed with the sensor_server sample, not the sensor_client sample, right?

    Edvin said:
    Is it the same thingy that is running the application that produced the logs that you sent? Or does the Thingy send some message over Mesh to the device that printed the logs?
    SaSu said:
    It is the same thingy that sending the logs(eg: 4 seconds since presence detected when i pressed button on thingy)

    And the logs are coming from a separate device in the same network? So the callback is not a button handler. It is a callback handler from the sensor. 

    I need to leave the office now. I will be back on Monday. But you need to look into the implementation. Where in the sensor server is it triggering the message that triggers the callback in the sensor_client that prints the "presence detected" message. Because by default, it is not set up to send the temperature data. Alternatively, you can figure out how it prints the.

    65.000000 second(s) since last presence detected
    Relative runtime in 0 to 20 degrees: 0.000000 percent
    Relative runtime in 20 to 25 degrees: 0.000000 percent
    Relative runtime in 25 to 30 degrees: 100.000000 percent
    Relative runtime in 30 to 100 degrees: 0.000000 percent
    71.000000 second(s) since last presence detected
    

    Where it gathers the temperature data from. You should be able to find that. 

    Best regards,

    Edvin

  • pressing the button on the thingy and you end up in the sensor_cli_data_cb()?

    Yes it goes to  

    else if (sensor->id ==
    		   bt_mesh_sensor_time_since_presence_detected.id) {
    		if (value->val1) {
    			printk("%s second(s) since last presence detected\n",
    			       bt_mesh_sensor_ch_str(value));
    		} else {
    			printk("No presence detected, or under 1 second since presence detected\n");
    		}

    Already "No Presence detecte, or.....") will be printing and when i press "%s second(s) since last presence detected" will print as follows

    Can you please try to set a breakpoint there to check the callstack?

    Could not understand this, I could set break point as far as i know it really doesn't do anything just building process will stop till there(FYI: I doesn't get any errors in building process) and what is call stack and how can i check it? if you mean something different than what i understood.

    Where is the sensor->id being set?

    Its sending to sensor_cli_data_cb() but bt_mesh_sensor_present_dev_op_temp.id and bt_mesh_sensor_presence_detected.id id's are getting different don't know why. and sensor->id ==bt_mesh_sensor_time_since_presence_detected.id these id's are same that's why when we press or don' press that part is being printed.

    Are you using the sample as it is descibred in the sample description? You have one node acting as a server and one as a client? The sensor_cli_data_cb() is triggered on the client, right? 

    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.

    The thingy is programmed with the sensor_server sample, not the sensor_client sample, right?

    Yes, it is programmed in sensor_server not in sensor_client thats why i get some output right otherwise i will get some issues or errors.

    and FYI: everything is perfect with the sample program except

     this part is not triggering because bt_mesh_sensor_present_dev_op_temp.id and bt_mesh_sensor_presence_detected.id id's are different.

    And the logs are coming from a separate device in the same network? So the callback is not a button handler. It is a callback handler from the sensor. 

    Logs are coming from sensor_client with me its COM10 which i can see on PuTTY and those are being sent from sensor_server as it is a mesh sample example.

    Where in the sensor server is it triggering the message that triggers the callback in the sensor_client that prints the "presence detected" message. Because by default, it is not set up to send the temperature data. Alternatively, you can figure out how it prints the.

    I know from where it is sending the messages.

    from sensor_server from below part it is sending

    and from sensor_client

     here it receives. as you can see we use sensor types and as far as i figured that is main function to send and receive messages .

    (FYI: You please check the sample program and run by yourself and update me whether you get the "chip temperature" output or not. Because i checked with 3 mobiles and its same problem and you check it once, if its working please tell me what different you have done and if it is not please check it what is the problem because you are expert than me as i am student, i am really not able to figure out what is the problem as the id's are auto generated and its not user given values. I am literally trying since 2 months as i couldn't figure out i updated a forum question a month ago. I am really waiting for answer. Hope you understand).

    Thank You

    Best 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

Reply Children
  • 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

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

    Yes it is the error i am talking about and not any function i am getting and yes later i realised == is not making any sence

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

    I did still shows nothing

    Regards

  • Hello,

    Did you change anything else in the project? Does it work like before if you revert the button handler back to default? Try the attached application in an unmodified (!) NCS v2.1.2:

    3343.sensor_server.zip

    BR,

    Edvin

  • Hi

    Have done as you told with NCS v2.1.2 with the server file you attached , still no output looks like its same and no difference ..  

    Does it work for you? No idea what have you done different

    Regards

Related