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

Connecting to only one central. How to? detailed

Hi, i know this question has been ask before but, i was reading and readind and i could find a way to do it. I got the theory but when i'm going to implement it in my code i get confused.

Starting by symple, i have 2 devices, one of this as central and one of this as peripheral.

I need the peripheral only get connected to this specific central and avoide connection to another.

1-. How i can setup an static address to my central? which part of the code i do that?

2-.I know that it is possible to create a whitelist to save bond info about the connection that has been made but i think i don't need it because i only have 1 central and just want to connect to him. wich part of the code i have to writte to set the address of my central in order to only connect to him? What would be this address, the peer addres or another one?

3-. I have read about directed advertising, what i got was that, you use direct adv when you want to connect to a specific central, but again, where do you specify that?

4-. My peripheral could be scannable but i just want my central could connect not any other device.

Maybe these are newbie question, but how i wrote above, i have read and read and i don't find a good explanation to do that.

Sorry and thanks in advance.

  • okok.. look what i have done..

    Central: i set my own address to the device but as "random static address" .

    ble_gap_addr_t addr ={BLE_GAP_ADDR_TYPE_RANDOM_STATIC,{0xAD,0x16,0xBC,0xCA,0x30,0xE9}} ;
    err_code = sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_NONE, &addr);
    APP_ERROR_CHECK(err_code);
    

    Peripheral: i advertise with whitelist, and add an specific address to my whitelist.

    ble_gap_addr_t   * p_whitelist_addr[1];
    ble_gap_addr_t        whitelist_addr={BLE_GAP_ADDR_TYPE_RANDOM_STATIC,{0xAD,0x16,0xBC,0xCA,0x30,0xE9}} ;
    whitelist.pp_addrs   =  p_whitelist_addr;
    

    with this, the system works as i want to.. now, you mentioned "generated randomly", if i use an address's type: BLE_GAP_ADDR_TYPE_RANDOM_STATIC, and i set my own address, do i have to pay for that ?? i'm talking about production mode..

  • @Antonio: No, you don't have to pay if you use BLE_GAP_ADDR_TYPE_RANDOM_STATIC, but according to the spec, the address should be generated randomly. You can use any tool to generate the random number, for example this.

  • ok i got it.. what do you recommend to send data once a connection has established?

    For e.g: i need to send some bytes trough BLE once the devices are connect. NUS service??

  • @Antonio: Yes you can use NUS. If you have new question that's not related to the original question, please create a new case.

  • @HungBui: well, it's ok, thanks a lot for answer all my question, it was very usefull, i know some of them was repetitive. Congratulations to the nordic support team, your job is well done in this forum,

Related