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

Example for using S120 as peripheral?

Hello,

currently I am using the S110 Softdevice with the ble_template example as peripheral. This works fine.

For our final application, we need the central feature with up to 8 connected peripherals. Therfor I want to use the S120 softdevice. At the moment I use the ble_app_hrs_c_s120 example for learning how to use the S120 softdevice. But in this application, the device only acts a a central. Is there an example, how to configure the S120 softdevice as an peripheral?

Additional an example of how to do dynamic switching between central and peripheral would be helpful.

Thanks in advance!

Regards BTprogrammer

  • FormerMember
    0 FormerMember

    In order to dynamically switch roles when using S120, you have to do the following, see S120 2.0.0 migration notes:

    sd_softdevice_disable();
    sd_softdevice_enable(params);
    sd_ble_enable(new_role);
    

    Using the SDK, it will be something like this:

    uint32_t err_code;
    err_code = sd_softdevice_disable();
    APP_ERROR_CHECK(err_code);
    
    // Initialize the SoftDevice handler module.
    SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, NULL);
    
    // Enable BLE stack.
    ble_enable_params_t ble_enable_params;
    memset(&ble_enable_params, 0, sizeof(ble_enable_params));
    
    ble_enable_params.gatts_enable_params.service_changed = IS_SRVC_CHANGED_CHARACT_PRESENT;
    ble_enable_params.gap_enable_params.role              = BLE_GAP_ROLE_CENTRAL; // or BLE_GAP_ROLE_PERIPHERAL;
    
    err_code = sd_ble_enable(&ble_enable_params);
    APP_ERROR_CHECK(err_code);
    
  • Hello Kristine,

    thank you for your answer. I think the switching between central and peripheral is now a little bit more clear for me.

    Is there an example of how to use the S120 as peripheral (sending advertising packages, provide UUID`s)?

    As I mensioned, with the S110 this works very well for me. But with the S120 softdevice, Im not able to establish a connection between my smartphone (central) and the PCA10028 (peripheral). In my opinion, advertising doesnt start.

    Thanks!

    Regards!

  • I have modified ble_beacon example for S120 to be a simple connectable advertiser. you can use master control panel to connect to this app. you can find the zip file attached in my answer to this post. I have tested this with S120 softdevice that came with SDK8.x

  • Hello Aryan,

    I tried to compile and use your modified "beacon" example. If I try to compile your project directly, I get a few error messages: ......\main.c(25): error: #5: cannot open source input file "ble_advdata.h": No such file or directory "no source": Error: #5: cannot open source input file "..........\bsp\bsp.c": No such file or directory "no source": Error: #5: cannot open source input file "............\components\ble\common\ble_advdata.c": No such file or directory ... For me this looks like some missing/incorrect Paths. But I dont know how to set the right source Paths. I also tried to compile it in a comletly new project with the PACKS comming from the SDK. But there I only can select the S110 softdevice. With that configuration there is no gap_enable_params.role field in ble_enable_params. Do you have any additional recommendations?

Related