This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Using the S130 alpha SD

I'm trying to test the throughput improvement of the S130 alpha softdevice vs S130 V1.

I notice a couple of changes in the API that I'm not sure how to handle:

First, ble_enable_params_t has changed and so has the number of arguments for sd_ble_enable. My old code looks like this:

ble_enable_params.gatts_enable_params.service_changed = false;
ble_enable_params.gap_enable_params.role              = BLE_GAP_ROLE_CENTRAL;
err_code = sd_ble_enable(&ble_enable_params);

There is no longer a "role" field and sd_ble_enable requires more arguments. Is there an example of how to call this?

Also, is there an existing define for the alpha release headers so I can protect the old code with an #ifndef S130_ALPHA or some such macro?

At this point I should also ask what other changes need to be made to the project in order to use the S130 alpha? All I've done so far is create a new folder for the new header files and changed the ble path in the project to point to that folder.

For example, is there anything I need to do to tell the SD to accept 3 packets per connection interval or is that automatic?

Parents
  • For an example of how to call sd_ble_enable, take a look at ble_stack_init() in the SDK examples. For your convenience, here it is:

    #if defined(S110) || defined(S130) || defined(S132)
        // Enable BLE stack.
        ble_enable_params_t ble_enable_params;
        memset(&ble_enable_params, 0, sizeof(ble_enable_params));
    #if (defined(S130) || defined(S132))
        ble_enable_params.gatts_enable_params.attr_tab_size   = BLE_GATTS_ATTR_TAB_SIZE_DEFAULT;
    #endif
        ble_enable_params.gatts_enable_params.service_changed = IS_SRVC_CHANGED_CHARACT_PRESENT;
        err_code = sd_ble_enable(&ble_enable_params);
        APP_ERROR_CHECK(err_code);
    #endif
    

    The macro S130 is defined in the preprocessor symbols, so you can add your old code inside an #ifdef S130_ALPHA and change the macro to S130_ALPHA to use old code.

    I don't have a complete overview of the changes, but they should be in the release notes located in the SoftDevice folder (zip file downloaded).

    As far as I know, you don't need to tell the SoftDevice to accept 3 packets per connection interval, this is automatic.

  • I got everything to build. It took a while because many header and c files were moved from SDK 9 to SDK 10. I also added a second NULL argument to sd_ble_enable and that fixed the build issue.

    Now I'm having trouble with notify_enable. Here's the code, which is the same in SDK 9 and SDK 10:

    static void notify_enable(void)
    {
        ble_gattc_write_params_t write_params;
        uint8_t                  buf[BLE_CCCD_VALUE_LEN];
    	
        buf[0] = BLE_GATT_HVX_NOTIFICATION;
        buf[1] = 0;
    
        write_params.write_op = BLE_GATT_OP_WRITE_REQ;
        write_params.handle   = RX_cccd_handle;
        write_params.offset   = 0;
        write_params.len      = sizeof(buf);
        write_params.p_value  = buf;
     write_params.flags    = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE;
    
        APP_ERROR_CHECK( sd_ble_gattc_write(conn_handle, &write_params) );
    }
    

    On SDK 9, this code works fine. With SDK 10, sd_ble_gattc_write() returns code 8, illegal state. Has there been a change in how this function is used?

Reply
  • I got everything to build. It took a while because many header and c files were moved from SDK 9 to SDK 10. I also added a second NULL argument to sd_ble_enable and that fixed the build issue.

    Now I'm having trouble with notify_enable. Here's the code, which is the same in SDK 9 and SDK 10:

    static void notify_enable(void)
    {
        ble_gattc_write_params_t write_params;
        uint8_t                  buf[BLE_CCCD_VALUE_LEN];
    	
        buf[0] = BLE_GATT_HVX_NOTIFICATION;
        buf[1] = 0;
    
        write_params.write_op = BLE_GATT_OP_WRITE_REQ;
        write_params.handle   = RX_cccd_handle;
        write_params.offset   = 0;
        write_params.len      = sizeof(buf);
        write_params.p_value  = buf;
     write_params.flags    = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE;
    
        APP_ERROR_CHECK( sd_ble_gattc_write(conn_handle, &write_params) );
    }
    

    On SDK 9, this code works fine. With SDK 10, sd_ble_gattc_write() returns code 8, illegal state. Has there been a change in how this function is used?

Children
No Data
Related