Topic

FAQ
Login Register
TX function questions for "ble_mesh_sdk"
Feb 22, 2023 05:40

/

A

/A

I looked at the tx function of "ble_mesh_sdk" and I have a question.
- What is the difference between light_notify() and light_slave_tx_command() functions?
- The result of my test is that I had to use the "light_notify()" function when sending data to my smartphone.
- The function "light_slave_tx_command()" had to be used when sending data to other nodes.
- Is it right to use the "light_slave_tx_command()" function to transfer data between nodes?


intlight_slave_tx_command_ll(u8 *p_cmd, intpara, u8sub_addr)
{
    staticu8dbg_tx = 0;
    dbg_tx++;

    if(is_bridge_task_busy()){
        return0;   // user should retry tx command to handle this case.
    }
   
    u8cmd_op_para[16] = {0};
    staticintcmd_sno = 0;
    cmd_sno = clock_time() + device_address;
    memset(cmd_op_para, 0, 16);
    memcpy(cmd_op_para, p_cmd, 13);
    cmd_op_para[0] = p_cmd[0] | 0xc0;
    cmd_op_para[1] = VENDOR_ID & 0xFF;
    cmd_op_para[2] = VENDOR_ID >> 8;
    #if0   // for test
    static u8 a_oppara[16];
    memcpy(a_oppara, p_cmd, 16);
    #endif

    u16dst = (u16)para;
    #ifSUB_ADDR_EN
    if(sub_addr){
        mesh_push_user_command_sub_addr(cmd_sno++, sub_addr, dst, cmd_op_para, 13);
    }else
    #endif
    {
        mesh_push_user_command(cmd_sno++, dst, cmd_op_para, 13);
    }

    return1;
}

intlight_slave_tx_command(u8 *p_cmd, intpara)
{
    returnlight_slave_tx_command_ll(p_cmd, para, 0);
}




intlight_notify(u8 *p, u8len, u8* p_src){
    interr = -1;
    if(slave_link_connected && pair_login_ok){
        if(len > 10){   //max length of par is 10
            return -1;
        }
       
        pkt_light_notify.value[3] = p_src[0];
        pkt_light_notify.value[4] = p_src[1];
       
        u8 *p_par = &(pkt_light_notify.value[10]);
        memset(p_par, 0, 10);
        memcpy(p_par, p, len);
        u8r = irq_disable();
        if (is_add_packet_buf_ready()){
            if(0 != rf_link_add_tx_packet ((u32)(&pkt_light_notify))){
                err = 0;
            }
        }
        irq_restore(r);
    }

    returnerr;
}


1 replies
TL_Soyo Feb 22, 2023 13:50
0
/A

Hi,

  you are right ,light_slave_tx_command can send data to other nodes.