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

How to modify the BPS format to insert custom data in nrf52

I am currently working on sending some custom data using BLE nrf52.

I find the BPS format best suited for my application but I want to modify the systolic and diastolic keys with something else.

How do I make that happen? I have searched the documentation and the header files but I am unable to find anything for that.

Could you please let me know on how it is done?

Parents
  • Hi,

    How do I make that happen? I have searched the documentation and the header files but I am unable to find anything for that.

    You can take the ble_bps.c and ble_bps.h files, rename them and adapt them to your needs in any way you like. Just remember that you should use a different UUID, as this is a registered/official 16 bit service UUID. You can refer to for instance the NUS service implementation (ble_nus.c) to see an example of a custom 128 bit service.

    Other than that, what to change and how depends on what you want to do?

  • Hello,

    I have added the 128 bit as follows:

    #define BLE_UUID_WB                  0x03beb05229f8435fb5912f57a464106f /**< Used vendor specific UUID. */
    
    
    static ble_uuid_t m_adv_uuids[] =                                       /**< Universally unique service identifiers. */
    {
        {BLE_UUID_WB,BLE_UUID_TYPE_BLE},
        {BLE_UUID_BATTERY_SERVICE,            BLE_UUID_TYPE_BLE},
        {BLE_UUID_DEVICE_INFORMATION_SERVICE, BLE_UUID_TYPE_BLE}
    };
    

    However it shows "integer constant is too large for its type" alert after building.

    I am trying to replace the bps with this thing. However the bps UUID still is being read.

  • Hi,

    This is not how you use a vendor specific UUID. You need to register the UUID base using sd_ble_uuid_vs_add(). The second parameter to that call is an output, and that is the type you should use when referring to this UUID. BLE_UUID_TYPE_BLE (0) is only used for 16 bit UUIDs. I recommend you refer to ble_nus_init() in ble_nus.c to see how this can be done. If you only have a single custom UUID, this will have 

    After that, to add it to your list of advertisied UUIDs you should do refer to the type for the UUID you have added instead of BLE_UUID_TYPE_BLE. If you only have a single type then that will get the ID BLE_UUID_TYPE_VENDOR_BEGIN, so you can refer to that directly like the SDK examples do (see of examples\ble_peripheral\ble_app_uart\main.c for an example).

  • hi.

    I am following this 

    https://devzone.nordicsemi.com/nordic/short-range-guides/b/bluetooth-low-energy/posts/ble-services-a-beginners-tutorial

    I did step 1 and step 2 

    ble_os_t m_our_service;

    our_service_init (&m_our_service);

    For step 3 and 4 : It fails at this point when I debug it.

    void our_service_init(ble_os_t * p_our_service)
    {
    
        // STEP 3: Declare 16 bit service and 128 bit base UUIDs and add them to BLE stack table  
           
           uint32_t   err_code;
            ble_uuid_t        service_uuid;
            ble_uuid128_t     base_uuid = BLE_UUID_OUR_BASE_UUID;
            service_uuid.uuid = BLE_UUID_OUR_SERVICE;
            err_code = sd_ble_uuid_vs_add(&base_uuid, &service_uuid.type);
            APP_ERROR_CHECK(err_code);
    
            //Done with step 3
        
    	// STEP 4: Add our service
    
            err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
                                        &service_uuid,
                                        &p_our_service->service_handle);
            APP_ERROR_CHECK(err_code);
    
            //Done with step 4
    }

    May I know what is the mistake?

Reply Children
Related