understanding of logic behind address used in Publish-Subscribe mechanism for Bluetooth Mesh


Vikrant More <vikrant8051@...>
 

static void gen_onoff_set(struct bt_mesh_model *model,
              struct bt_mesh_msg_ctx *ctx,
              struct net_buf_simple *buf)
{   
   
        static volatile unsigned char copy1=NULL;

        unsigned char elem_idx = model->elem->addr - bt_mesh_primary_addr();

        unsigned char boo = net_buf_simple_pull_u8(buf);

        if( boo != copy1)
        {   
       
         printk("Data(set)= %u \n\r",boo);
         printk("Data(set) unicast_addr = %u \n\r",model->elem->addr);
         printk("Data(set) pub_addr = %u \n\r",model->pub->addr);
         printk("Data(set) sub_addr = %u \n\r",model->groups[0]);
   
         switch(elem_idx)
         {
            case 0:   
                     if(boo!=0)
                        NRF_P0->OUT &= ~(1<<13);
                    
                     else
                        NRF_P0->OUTSET |= (1<<13);                             
                    
                     break;

             case 1:     
                  if(boo!=0)
                     NRF_P0->OUT &= ~(1<<14);
                  else
                     NRF_P0->OUTSET |= (1<<14);                             
                 
                 break;   
          }

          copy1=boo;

       }//end of if

}



I have edited gen_onoff_set function for onoff server as mentioned above.

I'm using Silicon Labs Bluetooth Mesh App to provision & configure my nrf52840_pca10056 Board.


After controlling LED using GUI from App, above function is executing normally.

And it prints ...

Data(set)= 0 or 1
Data(set) unicast_addr = 1
Data(set) pub_addr = 0xC000 <--------------------------What is significance of this address ??
Data(set) sub_addr = 0XC001

when I control Led individually , source address = 0x2001 & destination address = 0x0001

when I control Led using master control , source address = 0x2001 & destination address = 0xC001.

Then tell me what is roll or use of 0xC000 ?
Or how it will help us ?


   

 




Johan Hedberg
 

Hi Vikrant,

On Sat, Dec 02, 2017, Vikrant More wrote:
unsigned char elem_idx = model->elem->addr - bt_mesh_primary_addr();
What do you need this for? If you need to access the element it's right
there in model->elem.

Data(set)= *0 or 1*
Data(set) unicast_addr = *1*
Data(set) pub_addr = *0xC000 <--------------------------What is
significance of this address ??*
Data(set) sub_addr =

*0XC001 *

*when I control Led individually , source address = 0x2001 & destination
address = 0x0001*

*when I control Led using master control , source address = 0x2001 &
destination address = 0xC001.*

*Then tell me what is roll or use of 0xC000 ?*

*Or how it will help us ?*
That's just some group address the provisioner has apparently configured
this model to publish to.

Johan