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

Parents
  • 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);
    
Reply
  • 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);
    
Children
No Data
Related