This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

[Common BLE] Filter to connect ?

Hi. I have a central device call C_Board. It is scanning to find device has name is "123456" . This meaning is any device has name "123456" can connect to C_Board. Have any solution to choose device to connect? Thank for help.

  • i have a function for this :

    static bool is_valid_address(ble_gap_evt_adv_report_t const * p_adv_report)
    

    {

    if(p_adv_report->peer_addr.addr[0] == periph_addresses[0][0])
    {//matches first byte of address 0
        if((p_adv_report->peer_addr.addr[1] == periph_addresses[0][1]) &&
           (p_adv_report->peer_addr.addr[2] == periph_addresses[0][2]) &&
           (p_adv_report->peer_addr.addr[3] == periph_addresses[0][3]) &&
           (p_adv_report->peer_addr.addr[4] == periph_addresses[0][4]) &&
           (p_adv_report->peer_addr.addr[5] == periph_addresses[0][5]))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    else if (p_adv_report->peer_addr.addr[0] == periph_addresses[1][0])
    {//matches first byte of address 1
        if((p_adv_report->peer_addr.addr[1] == periph_addresses[1][1]) &&
           (p_adv_report->peer_addr.addr[2] == periph_addresses[1][2]) &&
           (p_adv_report->peer_addr.addr[3] == periph_addresses[1][3]) &&
           (p_adv_report->peer_addr.addr[4] == periph_addresses[1][4]) &&
           (p_adv_report->peer_addr.addr[5] == periph_addresses[1][5]))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    else
    {
        return false;
    }
    

    }

    And on the top , you declare your address board you want to connect :

    static uint8_t                  periph_addresses[2][6] = {{0x76,0x4a,0x55,0x10,0x40,0xe5},{0xb6,0x70,0x30,0xba,0xbb,0xdd}};
    
  • Thanks for your help! I am going to test your code immediately. ( Can you say Vietnamese ?)

  • and how can I get address of board which I want to connect?

  • cho em xin face với. em có chút việc muốn hỏi anh :)) tiếng anh em cùi quá

Related