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

Adding a service to existing SDK example code

Hello, I am trying to add an extra service like "experimental_ble_app_blinky" into "ble_app_hids_keyboard" example code. "ble_app_hids_keyboard" example code has 3 servcies HID, Device info and battery info services, I would like to add the 4th service, like a custom service in this "experimental_ble_app_blinky" example, I tried and did not work!! Is this possible to do with Nordic Software?

  • Yes it's perfectly possibly to add multiple services. Since you have given no details at all about what "didn't work" it's rather hard to suggest what your problem is.

  • As I mentioned, I added this service into exiting code:

    static void services_init(void) { dis_init(); bas_init(); hids_init(); lbs_init(); }

    last line is the led button service, which comes right from example experimental_led blinky: static void lbs_init(void) { uint32_t err_code; ble_lbs_init_t init;

    init.led_write_handler = led_write_handler;
    
    err_code = ble_lbs_init(&m_lbs, &init);
    APP_ERROR_CHECK(err_code);
    

    }

    Of course I added all relevant code for building and compile with no error. What I was expecting to see 1 more service which is a custom service in addition to device manager service and battery service, in my iphone which I am running some BLE scnner apps, but all I saw was device manger service and batter service only, no custom service!!. Am I missing something here? Also in hid keyboard example, during advertisement, in example code there is only one UUID number and type, like this:

    static ble_uuid_t m_adv_uuids[] = {{BLE_UUID_HUMAN_INTERFACE_DEVICE_SERVICE, BLE_UUID_TYPE_BLE}};

    I don't see any UUID for DI Service, and battery service, although it shows up as services in my iphone BLE scan app, which I don't understand. Now do I need to add the UUID of my custom service into advertisement init? I have seen some example they are adding all services in there, like HRS example: static ble_uuid_t m_adv_uuids[] = /**< Universally unique service identifiers. */ { {BLE_UUID_HEART_RATE_SERVICE, BLE_UUID_TYPE_BLE}, {BLE_UUID_BATTERY_SERVICE, BLE_UUID_TYPE_BLE}, {BLE_UUID_DEVICE_INFORMATION_SERVICE, BLE_UUID_TYPE_BLE} }; I am thinking may be its optional! I also added scan response part of lbs service into advertising _init(), the hid keyboard code was like this: err_code = ble_advertising_init(&advdata, NULL, &options, on_adv_evt, ble_advertising_error_handler); as you can see the second parameter is NULL, so I changed it to this: rr_code = ble_advertising_init(&advdata, &scanrsp, &options, on_adv_evt, ble_advertising_error_handler); Again it just like the example LED_BLINKY custom service, which scan response is pass into this code:

    err_code = ble_advdata_set(&advdata, &scanrsp);

    Please let me know if you need more information? Thanks

  • so now I suggest you put all this information into a new question, format it properly and ask it. Since all the information is now in a comment, it's likely nobody is going to read it and, since it's in a comment, it's a mess to read.

Related