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

CoAP server, send max amount of data

Hi!

Goal: I want to send as much data as possible using CoAP.

I have connected a nRF52 (IoT-DK) to a Raspberry Pi using BLE and 6LoWPAN. The nRF52 is running the CoAP Observable server example, and I am able to observe the state of LED3 from the Pi.

In my project it would be preferable to send as much data as possible. To make it simple, I just changed *str in the method led_value_get, to for instance "Current data: 210, 220, 205". This works great, but the board crashes at runtime (all four LEDs flashing) if the *str is bigger than about 200 bytes.

Is there a simple way that I can change the memory allocated of the *str field, so that it can hold and send a bigger char array in this example project?

Thanks a lot!

Regards, Sindre Schei, M.Sc Student, Department of Telematics, NTNU

Parents
  • Hi Sindre,

    I recommend you to take a look at the define in sdk_config.h defining the maximum CoAP Payload size, COAP_MESSAGE_DATA_MAX_SIZE 256. Also, you could enabling memory manager statistics to see whether you are starving any the memory.

    By default, the configurations are:

    MEMORY_MANAGER_SMALL_BLOCK_COUNT      8
    MEMORY_MANAGER_SMALL_BLOCK_SIZE       128
    MEMORY_MANAGER_MEDIUM_BLOCK_COUNT     4
    MEMORY_MANAGER_MEDIUM_BLOCK_SIZE      256
    MEMORY_MANAGER_LARGE_BLOCK_COUNT      1
    MEMORY_MANAGER_LARGE_BLOCK_SIZE       1024
    

    Normally, you would if you sent small packets (< 128) use the SMALL buffers. As you describe you are using > 128 bytes payloads, which could indicate that you would need to increase the number of medium buffers.

    To get a statistic in your code which you can use to debug the memory, you can enable this by adding these two defines to your sdk_config.h:

    #define MEM_MANAGER_ENABLE_DIAGNOSTICS 1
    #define MEM_MANAGER_DIAGNOSTICS_LOGS_ONLY 1
    

    You can now call the nrf_mem_diagnose() whenever you like to see the state of the memory usage.

    Please let me know if you get any results.

    Cheers, Glenn

Reply
  • Hi Sindre,

    I recommend you to take a look at the define in sdk_config.h defining the maximum CoAP Payload size, COAP_MESSAGE_DATA_MAX_SIZE 256. Also, you could enabling memory manager statistics to see whether you are starving any the memory.

    By default, the configurations are:

    MEMORY_MANAGER_SMALL_BLOCK_COUNT      8
    MEMORY_MANAGER_SMALL_BLOCK_SIZE       128
    MEMORY_MANAGER_MEDIUM_BLOCK_COUNT     4
    MEMORY_MANAGER_MEDIUM_BLOCK_SIZE      256
    MEMORY_MANAGER_LARGE_BLOCK_COUNT      1
    MEMORY_MANAGER_LARGE_BLOCK_SIZE       1024
    

    Normally, you would if you sent small packets (< 128) use the SMALL buffers. As you describe you are using > 128 bytes payloads, which could indicate that you would need to increase the number of medium buffers.

    To get a statistic in your code which you can use to debug the memory, you can enable this by adding these two defines to your sdk_config.h:

    #define MEM_MANAGER_ENABLE_DIAGNOSTICS 1
    #define MEM_MANAGER_DIAGNOSTICS_LOGS_ONLY 1
    

    You can now call the nrf_mem_diagnose() whenever you like to see the state of the memory usage.

    Please let me know if you get any results.

    Cheers, Glenn

Children
Related