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

image_transfer_service questions

 

Hello,

 

We have an application based on NRF52832 which runs Nordic UART service and DFU service SDK15.2 SD132V6.0. Now, we need to add “high speed data pipe” and we are thinking of using “image_transfer_demo” example. Therefore we have few questions with regards to this idea

 

  1. Can NUS, DFU services coexist on same device and run in parallel? Ie NUS and video service
  2. We are trying to understand: what makes image_transfer_demo faster compare to  ble_app_uart example? We compared both examples and find few differences:

 

  1. Nrf_uart_example uses characteristic_add(…) and image_tranffer_example uses sd_ble_gatts_characteristic_add(…) . Can you please advise what is difference between those two functions?
  2. It is not clear to us why on BLE Event (function  ble_nus_on_ble_evt) event type BLE_GATTS_EVT_HVN_TX_COMPLETE ble_app_uart example calling on_hvx_tx_complete function and image transfer example pretty much does nithing .

 

Can you please advise at your earliest convenience.

 

Regards,

 

 

andrew

  • Hi Andrew

    1. Yes, you can combine several services if you like, only limited by memory on the device. The service used in the image transfer demo is essentially just a modified version of the NUS service with a different UUID and some additional characteristics. 

    An important thing to keep in mind is that if you want to have multiple proprietary services (like the NUS, DFU and image transfer services) is that you need to increase the NRF_SDH_BLE_VS_UUID_COUNT define in sdk_config.h equal to the number of unique 128-bit UUID bases you use. 

    2.1. characteristic_add(..) is just a wrapper around sd_ble_gatts_characteristic_add(..), and takes care of some of the boilerplate configuration code needed to set up characteristics. I don't remember exactly why I didn't use this function in the image transfer demo, possibly this function was added after I made the first version (the image transfer demo was made for an older SDK originally). 

    All the functionality of characteristic_add(..)is available in the various ...char_add(..) function in ble_image_transfer_service.c

    2.2. Which event handler are you looking at?
    The BLE_GATTS_EVT_HVN_TX_COMPLETE event is handled by the event handler in ble_image_transfer_service.c, where it calls the push_data_packets() function. 

    If you look at the implementation of push_data_packets() you will see that it calls ble_its_string_send(..) in a loop until the return code is not NRF_SUCCESS, which typically means the internal buffers are full. Once that happens the push_data_packets() function will exit, until the next time the BLE_GATTS_EVT_HVN_TX_COMPLETE event occurs and the procedure continues. 

    Eventually it will end for good when file_pos variable is equal to the file_size variable, which means the entire image is transferred successfully. 

    Best regards
    Torbjørn

  • Hi Torbjorn,

    Thank you for detailed explanations.

    in the ble_app_uart application function on_hvx_tx_compliete (...) purpose of this function is pretty much to send notification to the application.

    whereas in video example rather then sending notification we simply keep pushing the data without sending notifications .

    Therefore we are getting significant data rate transfer improvements? Or there are other speed improving contributors?

    Can you please comment on those two questions...

    Thank you for your support....

    Regards,

    Andrew

  • Hi Andrew

    That is essentially it, yes. 

    The image transfer demo makes sure to send as large packets as possible, and will push more packets as soon as the BLE_GATTS_EVT_HVN_TX_COMPLETE event occurs. 

    The ble_app_uart example will just forward this event to the application, and by default there is no handling of this event in the application to check if there is more data to send. 

    In the image transfer demo I also changed the NRF_SDH_BLE_GAP_EVENT_LENGTH to 12, to ensure that more packets can be sent on each connection interval. 

    Best regards
    Torbjørn

  • Hi Torbjorn,

    Sorry for the late response and keeping ticket open, I finally manage get back to this project.

    I was able to compile the code and while trying the example  I got few problems what I would like to get your expert advise.

    running example under follow development tools:

    SDK15.2 SD132 V6.1

    Once I try to connect with with  "NRF Connect":

    1. I am getting message (on NRF connect)Failed to call gattsExchangeMtuReply (NRF_ERROR_INVALID_PARAM)

    on Nordic side I am getting message "BLE event not handled by app: 36" 36 is event number and I think event is "BLE_GAP_EVT_DATA_LENGTH_UPDATE"

    2. I am able to connect to the Nordic with NRF connect and I am getting length set at 20 bytes which I think is too small

    3. after 30 second disconnect happens I am not sure who is initiating disconnect ie Nordic or NRF Connect

    I think something is totally wrong here and I am not sure what it is, can you please advise at your earliest convenience 

    Thank you,

    Andrew

  • Hi Torbjorn,

    After further investigations: we root caused problem to: gatt_init(...) function, specifically:

    err_code = nrf_ble_gatt_att_mtu_periph_set(&m_gatt, NRF_SDH_BLE_GATT_MAX_MTU_SIZE); 

    when change parameters function to:

    err_code = nrf_ble_gatt_att_mtu_periph_set(&m_gatt, 247); 

    connection part works fine and we are not getting any error message from NRF-connect, nor device disconnects from NRF connect.

    any number above "247" are bringing problem back.

    Can you please comment on our observation, is it issue specifically related to the Nordic BLE stack or it is something to do with  NRF Connect app running on Windows machine, or anything else?

    Thank you,

    Andrew.

Related