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

Custom characteristic isnt added to the custom service

I am using this tutorial to write a custom service and I got to a point to add custom characteristics and got a few questions:


- I don't seem to find any characteristic with UUID 1401 under Unknown Service that was just added with a UUID 1400.

- I am modifying ble_app_uart to add a new service and a characteristic. Even though I have ble_nus_init() commented out from services_init(), I still see UART TX/RX characteristic. Why would that be?

- where are read_perm and write_perm being initialized? I initially had issues compiling like that and the error was incorrect parameters. The properties and attribute metadata are supposed to align, yes? 

    attr_md.read_perm  = p_cus_init->custom_value_char_attr_md.read_perm;
    attr_md.write_perm = p_cus_init->custom_value_char_attr_md.write_perm;


After adding the following lines, I was able to compile

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm);

- What's up with changing the RAM size and start addresses to accommodate for the vendor-specific UUID to the BLE stack? Initially, I see the RAM_SIZE is set to 0x3dda0 which equals ~256KB (?) and in the tutorial, it's being set to 56800. Can you please clarify this modification?

Parents
  • Hi!

    - I don't seem to find any characteristic with UUID 1401 under Unknown Service that was just added with a UUID 1400.

    - I am modifying ble_app_uart to add a new service and a characteristic. Even though I have ble_nus_init() commented out from services_init(), I still see UART TX/RX characteristic. Why would that be?

    For these two questions, I'd want to use a BLE sniffer to sniff the packets the device is advertising. That might tell us more about what's happening. 

    - where are read_perm and write_perm being initialized? I initially had issues compiling like that and the error was incorrect parameters. The properties and attribute metadata are supposed to align, yes? 

    In custom_value_char_add in ble_cus.c:

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cus_init.custom_value_char_attr_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cus_init.custom_value_char_attr_md.write_perm);

    The BLE_GAP_CONN_SEC_MODE_SET_OPEN function takes a bl_gap_conn_sec_mode_t struct and sets sm = 1 and lv = 1, i.e security mode 1 level 1, which is an open link. 

    The permissions set in the attribute metadata should correspond with the properties set in the characteristic metadata struct char_md.

    - What's up with changing the RAM size and start addresses to accommodate for the vendor-specific UUID to the BLE stack? Initially, I see the RAM_SIZE is set to 0x3dda0 which equals ~256KB (?) and in the tutorial, it's being set to 56800. Can you please clarify this modification?

    When you add a vendor-specific UUID to the BLE stack, the SoftDevice requires more RAM, so you need to tell the Linker to allocate more RAM to the SoftDevice.. When you try to run the application without increasing the RAM allocations, you should see an output like this:

    <warning> nrf_sdh_ble: Insufficient RAM allocated for the SoftDevice.
    <warning> nrf_sdh_ble: Change the RAM start location from <OLD_RAM_START> to <NEW_RAM_START>.
    <warning> nrf_sdh_ble: Maximum RAM size for application is <RAM_SIZE>.

    where <NEW_RAM_START> and <RAM_SIZE> are the new values for RAM_START and RAM_SIZE. 

    Best regards,

    Heidi

Reply
  • Hi!

    - I don't seem to find any characteristic with UUID 1401 under Unknown Service that was just added with a UUID 1400.

    - I am modifying ble_app_uart to add a new service and a characteristic. Even though I have ble_nus_init() commented out from services_init(), I still see UART TX/RX characteristic. Why would that be?

    For these two questions, I'd want to use a BLE sniffer to sniff the packets the device is advertising. That might tell us more about what's happening. 

    - where are read_perm and write_perm being initialized? I initially had issues compiling like that and the error was incorrect parameters. The properties and attribute metadata are supposed to align, yes? 

    In custom_value_char_add in ble_cus.c:

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cus_init.custom_value_char_attr_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cus_init.custom_value_char_attr_md.write_perm);

    The BLE_GAP_CONN_SEC_MODE_SET_OPEN function takes a bl_gap_conn_sec_mode_t struct and sets sm = 1 and lv = 1, i.e security mode 1 level 1, which is an open link. 

    The permissions set in the attribute metadata should correspond with the properties set in the characteristic metadata struct char_md.

    - What's up with changing the RAM size and start addresses to accommodate for the vendor-specific UUID to the BLE stack? Initially, I see the RAM_SIZE is set to 0x3dda0 which equals ~256KB (?) and in the tutorial, it's being set to 56800. Can you please clarify this modification?

    When you add a vendor-specific UUID to the BLE stack, the SoftDevice requires more RAM, so you need to tell the Linker to allocate more RAM to the SoftDevice.. When you try to run the application without increasing the RAM allocations, you should see an output like this:

    <warning> nrf_sdh_ble: Insufficient RAM allocated for the SoftDevice.
    <warning> nrf_sdh_ble: Change the RAM start location from <OLD_RAM_START> to <NEW_RAM_START>.
    <warning> nrf_sdh_ble: Maximum RAM size for application is <RAM_SIZE>.

    where <NEW_RAM_START> and <RAM_SIZE> are the new values for RAM_START and RAM_SIZE. 

    Best regards,

    Heidi

Children
  • Hi Heidi, 

    Thanks for the response. For the BLE Sniffer, is the idea to run a python application while the BLE app is running that sets ups the service? I tried running the example.py inside BleSniffer/extcap and it outputs "No sniffers found!"

    The BLE_GAP_CONN_SEC_MODE_SET_OPEN function takes a bl_gap_conn_sec_mode_t struct and sets sm = 1 and lv = 1, i.e security mode 1 level 1, which is an open link. 

    what purposes does the following line serve then?

    attr_md.read_perm  = p_cus_init->custom_value_char_attr_md.read_perm;

    When you add a vendor-specific UUID to the BLE stack, the SoftDevice requires more RAM, so you need to tell the Linker to allocate more RAM to the SoftDevice.. When you try to run the application without increasing the RAM allocations, you should see an output like this:



    I didn't see any error when I ran this app. Could you also please explain the way nordic suggested to increase the RAM Size i.e setting to 0xDDE0 whereas currently RAM Size in my settings is to RAM_SIZE is set to 0x3dda0?

  • Hi! I will be on vacation until Monday so I will take a look at this case then.

  • Hi!

    morpho said:
    For the BLE Sniffer, is the idea to run a python application while the BLE app is running that sets ups the service?

    The BLE sniffer is an application that runs on a separate Nordic device and sniffs all nearby BLE packets, and you can use Wireshark to see them on your computer.

    See nRF Sniffer for Bluetooth LE for more information

    attr_md.read_perm  = p_cus_init->custom_value_char_attr_md.read_perm;

    The purpose of this line is the set the read permissions of the characteristic value declaration added to the Attribute Table to the same value as the read permission set here:


    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cus_init.custom_value_char_attr_md.read_perm);

     

    morpho said:
    I didn't see any error when I ran this app. Could you also please explain the way nordic suggested to increase the RAM Size i.e setting to 0xDDE0 whereas currently RAM Size in my settings is to RAM_SIZE is set to 0x3dda0?

    If you need to increase the RAM you should get an error from the SoftDevice when running the application. Try debugging the application in SES, then you should see this message in the SES terminal.

Related