Topics

How to implement #BluetoothMesh Generic_Delta_Server_Unack opcode function ?? #bluetoothmesh


vikrant8051 <vikrant8051@...>
 

Hi,

Hi to all,

I am trying to  implement Generic_Delta_Server_Unack (Level Server) as follow ...

void gen_delta_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf)
{

   int  tmp32 = state_ptr->current + net_buf_simple_pull_le16(buf);
   int tid = net_buf_simple_pull_u8(buf);

    if(tmp32 < -32768)
    {
        tmp32 = -32768;
    }
    else if(tmp32 > 32767)
    {
        tmp32 = 32767;
    }
    state_ptr->current = (int16_t)tmp32;

    state_ptr->previous = state_ptr->current;

}

but it get executed 5 times if level client is configured as
--> pub-set 0100 c000 1 0 5 1003

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

If we use something like

       if(last_tid == tid)
       {
           return; 
       }

at start, then it could escape valid message too.

For eg. if Server & Client rebooted simultaneously in that case,
Server side variable last_tid  & Client side variable tid both get set to Zero.
So first message from client get ignore.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

How to solve this problem ?



vikrant8051 <vikrant8051@...>
 

Hi,

I forgot to mentioned about

struct server_state *state_ptr = model->user_data;

----------------------------------------------------------------------------------------

struct server_state
{
int current;
int previous;
int model_instance;
int last_tid;
};

----------------------------------------------------------------------------------------

Thank You!!

On Tue, Jun 5, 2018 at 11:47 PM, vikrant8051 <vikrant8051@...> wrote:
Hi,

Hi to all,

I am trying to  implement Generic_Delta_Server_Unack (Level Server) as follow ...

void gen_delta_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf)
{

   int  tmp32 = state_ptr->current + net_buf_simple_pull_le16(buf);
   int tid = net_buf_simple_pull_u8(buf);

    if(tmp32 < -32768)
    {
        tmp32 = -32768;
    }
    else if(tmp32 > 32767)
    {
        tmp32 = 32767;
    }
    state_ptr->current = (int16_t)tmp32;

    state_ptr->previous = state_ptr->current;

}

but it get executed 5 times if level client is configured as
--> pub-set 0100 c000 1 0 5 1003

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

If we use something like

       if(last_tid == tid)
       {
           return; 
       }

at start, then it could escape valid message too.

For eg. if Server & Client rebooted simultaneously in that case,
Server side variable last_tid  & Client side variable tid both get set to Zero.
So first message from client get ignore.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

How to solve this problem ?