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.

  • @Antonio: Please call sd_ble_gap_address_set() to write the address. You can call this at any time after you enable the softdevice. To read the current address, you call sd_ble_gap_address_get(). Please have a look at function dfu_transport_update_start() in dfu_transport_ble.c file in the SDK \components\libraries\bootloader_dfu to see an example of using them.

  • ok i found it..

    this is the code..

    ble_gap_addr_t addr;
    
            err_code = sd_ble_gap_address_get(&addr);
            APP_ERROR_CHECK(err_code);
    
            // Increase the BLE address by one when advertising openly.
            addr.addr[0] += 1;
    
            err_code = sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_NONE, &addr);
            APP_ERROR_CHECK(err_code);
    

    instead of get the actual address with sd_ble_gap_address_get(&addr), i want to set my own address for example: {01:02:03:04:05:06} is it possible? and how?

    and why they increase the address by one?

  • @Antonio: You can set the address to anything you want, for testing purpose. For production, you should avoid using the public addresses domain that already claimed by other companies. Regarding the reason we change the address in the DFU example, please have a look at question D here.

  • @Hungbui: you mean that, when we will want to sell this product, we must pay for a own public address??

    I don`t want to implement DFU yet, so i don't need to increase the address by one, do i?

  • @Antonio: No, the DFU is just an example, you don't have to increase address.

    If you use random static address, you don't need to register and pay for your public address. You just need to generate it randomly, not 01:02:03:04:05:06 :) .

Related