Topics

[ #BluetoothMesh ] possible Bug .. without assigning subscription address to Model, it is reacting to subscription address assign to other Model #bluetoothmesh


Vikrant More <vikrant8051@...>
 

Hello World !!

This is observation based on following configuration done by #meshctl.
Two nRF52840-PDK boards has been used for it.

For Board 1. after provisioning, I used following commands to configure it
**************************************************************************************

appkey-add 1

bind 0 1 1000
bind 0 1 1001
bind 0 1 1002
bind 0 1 1003

sub-add 0100 c000 1000
pub-set 0100 c000 1 0 5 1001

sub-add 0100 c000 1002
pub-set 0100 c000 1 0 5 1003


For Board 2. after provisioning, I used following commands to configure it
**************************************************************************************

appkey-add 1

bind 0 1 1000
bind 0 1 1001
bind 0 1 1002
bind 0 1 1003

sub-add 0101 c000 1000
pub-set 0101 c000 1 0 5 1001

In case of Board 2, I didn't assign pub & sub addresses to Models 1002 & 1003

**************************************************************************************

Button 1 & 2 are related to GEN_ONOFF_CLIENT
Button 3 & 4 are related to GEN_LEVEL_CLIENT

As per my implementation,
1. if Button 1 is pressed, then LED1 on all Boards turns ON.

2. if Button 2 is pressed, then LED1 on all Boards turns OFF.

3.if Button 3 is pressed, then it publishes value for eg. 2000.
   On subscriber side, it checks that value (since it is less than 10000 it turns ON LED3 & turns OFF LED4 )

4. if Button 4 is pressed, then it publishes value for eg. 15000.
   On subscriber side, it checks that value (since it is greater than 10000 it turns OFF LED 3 & turns ON LED4)

******************************************************************************************

Ideally, as per #meshctl configuration,

if I pressed Button1 on any board, then LED1 on all boards should turn ON & if pressed
pressed Button2 then LED1 should OFF.

And if I pressed Button3 or Button4 on Board1, it should affect LED3&4 only on Board1(self).

And if I pressed Button3 or Button4 on Board2, it should not affect LEDs on any Board.

********************************************************************************************

But here, I found strange behavior in case of Board2. Here without assigning subscription
addresses to Model 1002, LED 3 & LED 4 on Board2 are reacting as soon as I pressed
Button 3&4 on Board 1.


Is it Bug ?

Thank You !!


Kai Ren
 

Hi vikrant8051,
Could you please share the following definitions?
             static struct bt_mesh_model root_models[] = {};
             static struct bt_mesh_elem elements[] = { };

Thanks!

Kai


vikrant8051 <vikrant8051@...>
 

Hi,
It was bug from my side & I've resolved it.
Now everything is working as expected.

Excuse me for that !!

On Wed, May 2, 2018 at 2:31 PM, Vikrant More <vikrant8051@...> wrote:
Hi,

I gone through my code once again & found that it was small bug from my side.
I had forgotten to add "break" in my customized version of $zephyr/samples/bluetooth/mesh .

Extremely sorry for that.

//------------------------------------------------------------------------doer.c----------------------------------------------------------------------------------------------------------------------

#include "common.h"

int8_t  gen_onoff_srv_state, last_gen_onoff_srv_state;
int16_t gen_level_srv_state, last_gen_level_srv_state;

void doer(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, uint16_t opcode)
{
    int err=0;

    int8_t tmp8;
   
    int16_t tmp16;

    struct net_buf_simple *msg;

    switch(opcode)
    {

        case 0x8201:    //GEN_ONOFF_SRV_GET

            msg = NET_BUF_SIMPLE(2 + 1 + 4);

            bt_mesh_model_msg_init(msg, BT_MESH_MODEL_OP_2(0x82, 0x04));

            net_buf_simple_add_u8(msg, gen_onoff_srv_state);

            if (bt_mesh_model_send(model, ctx, msg, NULL, NULL))
            {
                printk("Unable to send GEN_ONOFF_SRV Status response\n\r");
            }
       
           break;


        case 0x8203:    //GEN_ONOFF_SRV_UNACK

            msg = model->pub->msg;

            gen_onoff_srv_state = (unsigned char)global_state;

            if(last_gen_onoff_srv_state != gen_onoff_srv_state )
            {
                last_gen_onoff_srv_state = gen_onoff_srv_state;

                if(gen_onoff_srv_state != 0)
                {
                    NRF_P0->OUT &= ~(1<<13);    //LED ON
                }
                else
                {
                    NRF_P0->OUT |=  (1<<13);    //LED OFF   
                }

                if(model->pub->addr != BT_MESH_ADDR_UNASSIGNED)
                {

                    bt_mesh_model_msg_init(msg, BT_MESH_MODEL_OP_2(0x82, 0x04));
                    net_buf_simple_add_u8(msg, gen_onoff_srv_state);

                    err = bt_mesh_model_publish(model);

                    if(err)
                    {
                        printk("bt_mesh_model_publish err %d", err);
                    }

                }
            }

            break;

        case 0x8204:    //GEN_ONOFF_SRV_STATUS

            tmp8 = net_buf_simple_pull_u8(buf);

            NRF_P0->OUT ^= (1<<16);

            printk("Acknownledgement from GEN_ONOFF_SRV = %u\n\r",tmp8);

            break;

        case 0x8205:    //GEN_LEVEL_SRV_GET
           
            msg = NET_BUF_SIMPLE(10);

            bt_mesh_model_msg_init(msg, BT_MESH_MODEL_OP_2(0x82, 0x08));

            net_buf_simple_add_le16(msg, gen_level_srv_state);

            if(bt_mesh_model_send(model, ctx, msg, NULL, NULL))
            {
                printk("Unable to send GEN_LEVEL_SRV Status response\n\r");
            }

            break;

        case 0x8207:    //GEN_LEVEL_SRV_UNACK

            msg = model->pub->msg;

            gen_level_srv_state = (int16_t)global_state;

            if(last_gen_level_srv_state != gen_level_srv_state )
            {
                last_gen_level_srv_state = gen_level_srv_state;

                printk("gen_level_srv_state = %d \n\r" , gen_level_srv_state );
               
                if(gen_level_srv_state > 10000)
                {   
                    CLRB(NRF_P0->OUT,15);
                    SETB(NRF_P0->OUT,16);
                }
                else
                {   
                    CLRB(NRF_P0->OUT,16);
                    SETB(NRF_P0->OUT,15);
                }
                               
                if(model->pub->addr != BT_MESH_ADDR_UNASSIGNED)
                {

                    bt_mesh_model_msg_init(msg,BT_MESH_MODEL_OP_2(0x82, 0x08));

                    net_buf_simple_add_le16(msg,gen_level_srv_state);

                    err = bt_mesh_model_publish(model);

                    if (err)
                    {
                        printk("bt_mesh_model_publish err %d", err);
                    }

                }
            }       
   
            break;

        case 0x8208:    //GEN_LEVEL_SRV_STATUS

            tmp16 = net_buf_simple_pull_le16(buf);
            printk("Acknownledgement from GEN_LEVEL_SRV = %d\n\r",tmp16);

            break;

        case 0x820A:    //GEN_DELTA_SRV_UNACK
           
            break;

        case 0x820C:    //GEN_MOVE_SRV_UNACK
           
            break;

        default:

           break;
    }
}



On Wed, Apr 25, 2018 at 9:28 PM, Vikrant More <vikrant8051@...> wrote:
Hi Kai,

Please see attached mesh.zip file for what you had asked. (Refer DEVICE_composition.c for 
static struct bt_mesh_model root_models[] = {};
             static struct bt_mesh_elem elements[] = { }; )

I have break provided #ZephyrBluetoothMesh sample code into multiple files for simplicity.

Have you faced same issue ?

Please let me Know, if there is bug from my side & keep me in loop if you are going to ask further queries based on it.

Thank You !!

On Wed, Apr 25, 2018, 8:39 PM Vikrant More <vikrant8051@...> wrote:
Hi Kai,
Sorry, today I was busy & didn't get time to access my email. Right now I am on the way to my Home. Tomorrow I will definitely share what you have asked.

Thanks !!

On Wed, Apr 25, 2018, 9:21 AM Kai Ren <kren@...> wrote:
Hi vikrant8051,
Could you please share the following definitions?
             static struct bt_mesh_model root_models[] = {};
             static struct bt_mesh_elem elements[] = { };

Thanks!

Kai