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

Ram Memory of Attribute Size question

Hi, 

I have some question below: note: the project_uuid belong uuid-16bit by my define uuid of product myself.

1. My project uses project_uuid and DFU_btn_less services. I figure out If my definition is wrong. I set "#define NRF_SDH_BLE_VS_UUID_COUNT 1", but my project still running OK. Is the setting right?

2. Receives writes, How many NRF_SDH_BLE_VS_UUID_COUNT if following I call how many time sd_ble_uuid_vs_add in services_init()?

3. My project includes many services(project_uuid, HID, TMP, and DFU), and then I addition ATT_MTU = 247 from 23. Now my service_init happen error message "NRF_ERROR_NO_MEM = sd_ble_gatts_characteristic_add", but execute nrf_sdh_ble_enable(&ram_start) is OK, what's the problem?

4. Receives writes, I try to fix NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE = 2048 from 1408, and then this "NRF_SUCCESS= sd_ble_gatts_characteristic_add". Really fix the problem in this way?

5. Could you explain "NRF_SDH_BLE_SERVICE_CHANGED"? I just follow some example to turn on, but I think to occupy Ram size when I turn on NRF_SDH_BLE_SERVICE_CHANGED.

  • Hi Ken

    1. If you have 1 vendor-specific UUID this should be correct.

    2. Sorry, but I'm struggling to see what you mean here. Can you try rephrasing your question?

    3. You're running out of memory in the SoftDevice itself. You can move your characteristics to userspace and if you are using a recent SoftDevice you can increase the size of the GATT table.

    4. Well, by decreasing the size of the GATTS Attribute table in the SoftDevice, there will be more room for other things, such as increased MTU.

    5. NRF_SDH_BLE_SERVICE_CHANGED must be enabled in order to include the "Service Changed" characteristic to the Attribute table, so yes, this takes up some space in the Attribute table within the SoftDevice.

    Due to the summer holidays in Norway, our support team is understaffed this week, and delayed replies must be expected. Sorry for the inconvenience!

    Best regards,

    Simon

  • Thank you, Simnr:

    Q1, Q2: I combined question1 with question2. How to calculate I need NRF_SDH_BLE_VS_UUID_COUNT ? I think to use sd_ble_uuid_vs_add(), if the function return p_uuid_type=2(BLE_UUID_TYPE_VENDOR_BEGIN) represent I need increase NRF_SDH_BLE_VS_UUID_COUNT. Is this idea right?

    Q3: I don't know what is userspace, and how to use userspace, could you provide examples or introduce document?

    Q4: I don't understand you say "decreasing the size of the GATTS Attribute table in the SoftDevice", because I set NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE is 1408 change to 2048, I think I do increase rather than decrease. So could you explain this concept?

    Q5: Thank your answer, but I don't know this service for application, why need this service in ble devices? Could you provide the document of NRF_SDH_BLE_SERVICE_CHANGED or recommend for me?

    Q6: Q3 and Q4 are solved for GATTS size of Ram problem. how is a different method between Q3 and Q4? In my problem, I need to add ATT_MTU induce  "NRF_ERROR_NO_MEM = sd_ble_gatts_characteristic_add", which are methods great solution for this?

  • Hi Ken

    Sorry, but I'm still having some trouble understanding some of your questions, I hope these answers will be helpful.

    Q1-2: Yes, you'll need to increase your NRF_SDH_BLE_VS_UUID_COUNT if you're using the sd_ble_uuid_vs_add() function.

    Q3: Sorry, for recent SoftDevices it's usually easier to just increase the size of your GATT table.

    Q4: I misunderstood your initial question, you're correct. Increasing the size of NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE will make more space for services in RAM and likely fix your problem.

    Q5: Hopefully this will help you understand, as we don't have any official documentation except what can be found on the Infocenter

    The NRF_SDH_BLE_SERVICE_CHANGED is used in nrf_sdh_ble.c, in the sd_ble_cfg_set(), inside the bl_cfg struct.

    As long as nrf_sdh_ble_default_cfg_set() returns NRF_SUCCESS, you should be fine.

    Remember to set the RAM settings according to when you have NRF_SDH_BLE_SERVICE_CHANGED = 1. This way, you will ensure that the SoftDevice has enough memory to work with the NRF_SDH_BLE_SERVICE_CHANGED when needed. It is not a problem that the SoftDevice has too much RAM.

    Note that it is not possible to delete services with the SoftDevice. Only add them. But of course, if you disable and enable the SoftDevice again, all the services have to be initialized again. If you skip one service after enabling it so that it isn't enabled, it will be "deleted" (not included).

    Q6: Do you have to increase the ATT_MTU size? The ATT_MTU Throughput Example shows you how to increase the ATT_MTU size.

    Best regards,

    Simon

  • Hi Simonr: Thank you for your answer.

    excuse me, I forgot to say I used SDK 15.2.0. 

    Follow your answer, we continue to discuss, thanks.

    Q1-Q2: This's done.

    Q3: Follow your answer 5 days ago, you told me "You can move your characteristics to userspace and if you are using a recent SoftDevice you can increase the size of the GATT table.", I don't know what is userspace, and how to use userspace, Is like to set NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE ?

    Q4: This's done.

    Q5: What kind the product need to add this service? (example: HID_mouse, heart rate sensor)  Because I consider if this service adds to our product. what do you recommend?

    Q6: I modify NRF_SDH_BLE_GAP_DATA_LENGTH and NRF_SDH_BLE_GATT_MAX_MTU_SIZE, I set NRF_SDH_BLE_GAP_DATA_LENGTH is 27 change to 251, and I set NRF_SDH_BLE_GATT_MAX_MTU_SIZE is 23 change to 247. Actually, I refer to the ATT_MTU Throughput Example already. But my project happen  "NRF_ERROR_NO_MEM = sd_ble_gatts_characteristic_add".

    Note: you told me that "I can move your characteristics to userspace" or "re-set NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE". what different in two methods? and which one can fix the Q6 problem?

    Thank you for your patience.

  • Hi Ken

    Q3: Yes, this was my mistake, the userspace solution was something used in older SoftDevices that had more limited storage, please use NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE in order to increase the size of the GATT table.

    Q5: To include the Service Changed characteristic in the Attribute Table set NRF_SDH_BLE_SERVICE_CHANGED in your sdk_config.h file. The ble_app_hrs example does this for example.

    Q6: Increasing the size of your GATT table should solve the NRF_ERROR_NO_MEM = sd_ble_gatts_characteristic_add error.

    Best regards,

    Simon

Related