1 2 Previous Next 15 Replies Latest reply on Apr 22, 2020 4:07 AM by AnjanaM_61

    File transfer over CYW20719

    JiZh_4619191

      Hi,

      CYW20719 will transfer a 300KB file. I fill this 300KB file in 'uint8_t data[512] ' array for 600 times and send it.

       

      sendFile()

      {

       

           uint8_t data[512];

           uint16_t i;

      ...

           for(i=0; i<600; i++)

           {

                wiced_bt_gatt_send_notification(thermistor_conn_id,  HDLC_FILE,  sizeof(data), data);

           }

      ...

      }

       

      Unfortunately sendFile( ) sends only 10 notifications every time(note: i<600) !

      What's wrong?

       

      Thanks a lot

        • 1. Re: File transfer over CYW20719
          AnjanaM_61

          Hi JiZh_4619191 ,

           

          1. How did you confirmed its sending only 10 times?

          2. What is the peer device you are using ?

          3. Can you please check the API return status when you see a failure

          4. Could you please add a delay after the each send notification and see if issue still exists.

           

          Regards,
          Anjana

          • 2. Re: File transfer over CYW20719
            JiZh_4619191

            Hi,

             

            Thank you for your reply.

             

            Just as you suggested, I traced wiced_bt_gatt_send_notification() return status.

            From i=0 to i=8, the API returns WICED_BT_GATT_SUCCESS;

            When i=9, the API returns WICED_BT_GATT_CONGESTED;

            And from i=10 to i=599 the API returns WICED_BT_GATT_INTERNAL_ERROR;

             

            How to modify sendFile() function? Or do you have a better solution to send 300KB file?

             

            Thanks!

            • 3. Re: File transfer over CYW20719
              AnjanaM_61

              Hi JiZh_4619191 ,

               

              First of all please confirm if you are using latest SDK version WICED 6.4. If not please try with SDK 6.4 

              So for your i=9, the API returns WICED_BT_GATT_CONGESTED which means stack is running out of tx buffers.

              If you have registered call back function to receive GATT call back with API   wiced_bt_gatt_register( cb_handler ); , you will get GATT_CONGESTION_EVT on gatt congestion.

              {

                  uint16_t                                conn_id;            /**< ID of the connection */

                  wiced_bool_t                            congested;          /**< congestion state */

              } wiced_bt_gatt_congestion_event_t;

               

              The second parameter will tell whether the state is congestion or uncongestion . Whenever you receive a GATT_CONGESTION_EVT check congestion or uncongestion . If congestion , you should not send the next notification until GATT_CONGESTION_EVT  triggers again with state changed to uncongestion.

               

              Could you please try this logic and see if it helps?

               

              Regards,

              Anjana

              1 of 1 people found this helpful
              • 4. Re: File transfer over CYW20719
                JiZh_4619191

                Hi,

                As you suggested, whenever received 'congested' event, I stopped to send notification. Until  'uncongestion' event, I send notification again.

                The programm sends 300KB file correctly. But it cost 30 seconds!

                Do you recommend a better solution to transfer 300KB file as soon as possible?

                 

                Thanks!

                • 5. Re: File transfer over CYW20719
                  AnjanaM_61

                  Hi JiZh_4619191 ,

                   

                  I am unfortunately I don't see any other way to increase the speed...

                  However can you please let me know the below details:

                   

                  1. What is the peer device ? Is it CYW20719 or any phone or ? - Check whats the MTU size set by your peer Central device

                  2. Can you please confirm / Check if you have set the MTU size to maximum (Say 512 ) and the negotiated MTU using in the LE connection is max - Check if the negotiated MTU is maximum

                  3. What is the connection interval & latency using ? -  try varying the Connection interval and see if there is any change in the time

                  4. In the WICED SDK , in config file, can you check Large Buffer Pool value ?  - Try changing the buff_size and count of Large Buffer pool (according to https://www.cypress.com/file/462716/download ) and see if it helps

                   

                  const wiced_bt_cfg_buf_pool_t wiced_bt_cfg_buf_pools[WICED_BT_CFG_NUM_BUF_POOLS] =

                  {

                  /*  { buf_size, buf_count } */

                      { 64,       12  },      /* Small Buffer Pool */

                      { 360,      6   },      /* Medium Buffer Pool (used for HCI & RFCOMM control messages, min recommended size is 360) */

                      { **,     **   },      /* Large Buffer Pool  (used for HCI ACL messages) */

                      { 1056,     0   },      /* Extra Large Buffer Pool - Used for avdt media packets and miscellaneous (if not needed, set buf_count to 0) */

                  };

                   

                  These are the options which I can suggest you . If still the time is not improving , then there may not be other way.

                   

                  Thanks & Regards,

                  Anjana

                  • 6. Re: File transfer over CYW20719
                    JiZh_4619191

                    Hi,

                    Thank you so much for your patience!

                    The peer device is IPhone7 CySmart. I don't know how to check its MTU size.

                    In wiced_app_cfg.c:

                    ...

                    /* Connection configuration */

                    .conn_min_interval               = 112,                                                       // Minimum connection interval, 112 * 1.25 = 140ms.

                    .conn_max_interval               = 128,                                                       // Maximum connection interval, 128 * 1.25 = 160ms.

                    .conn_latency                    = WICED_BT_CFG_DEFAULT_CONN_LATENCY,                         // Connection latency, ~1sec

                    .conn_supervision_timeout        = WICED_BT_CFG_DEFAULT_CONN_SUPERVISION_TIMEOUT              // Connection link supervsion timeout

                    ...

                    I didn't find Large Buffer Pool value in my current wiced_app_cfg.c.

                     

                    According to your estimate, What is the shortest time for 300KB file transmission?

                     

                    Thanks

                    • 7. Re: File transfer over CYW20719
                      AnjanaM_61

                      Hi JiZh_4619191 ,

                       

                      I am sorry I don't have any test results as such.

                       

                      In case of iphone Cysmart , mostly it will be using a default MTU size and connection interval settings.

                       

                      If in your end application , you want to test you can make use of below points :

                       

                      - In general LE Central device will set the connection parameters.  To modify the connection parameters like connection interval, from peripheral ,your device should send connection parameter update request using API wiced_bt_l2cap_update_ble_conn_params

                      - If you want to set and modify buffer pools - Refer implementation wiced_bt_cfg_buf_pool_t in hello_sensor or any LE demo project available in WICED

                       

                      Thanks,

                      Anjana

                      • 8. Re: File transfer over CYW20719
                        JiZh_4619191

                        Hi,

                        I modified wiced_app_cfg_buf_pools, and the time consuming has reduced to 17 seconds!

                        What is the maxium MTU size of Bluetooth 5.0 ?

                         

                         

                        Thanks

                        • 9. Re: File transfer over CYW20719
                          AnjanaM_61

                          Hi JiZh_4619191 ,

                           

                          That's great.

                           

                          Maximum MTU size as per spec is 512 bytes.

                           

                          Regards,

                          Anjana

                          • 10. Re: File transfer over CYW20719
                            JiZh_4619191

                            Hi,

                            Can I modify MTU size of IPhone?

                             

                            Thanks

                            • 11. Re: File transfer over CYW20719
                              AnjanaM_61

                              Hi JiZh_4619191 ,

                               

                              Iphone I am not sure. Because there used to be some limit for IOS MTU size.

                              You may check this on IoS LE app development page.

                              In General , default MTU size will be 23 bytes. Central can decide whether to use a different value for MTU size and initiate a MTU exchange request.

                              You may also try to request from peripheral side , for 20719 I think wiced_bt_gatt_configure_mtu is the API. However the decision will be upon Central side configuration / support.

                               

                              Regards,
                              Anjana

                              1 of 1 people found this helpful
                              • 12. Re: File transfer over CYW20719
                                JiZh_4619191

                                Hi Anjana,

                                 

                                I'm not familiar with wiced_bt_l2cap_update_ble_conn_params().

                                I found this function in Cypress WICED Studio API Reference Guide.

                                Would you please to tell me how to get the first parameter of 'wiced_bt_device_address_t rem_bdRa'?

                                 

                                Thank you!

                                Jian

                                • 13. Re: File transfer over CYW20719
                                  AnjanaM_61

                                  Hi Jian,

                                   

                                  wiced_bt_l2cap_update_ble_conn_params  ( Check wiced_bt_l2c.h file )

                                   

                                  First parameter is remote device BD address to which the device is connected. You will get this once the device is in connected state.

                                   

                                  Example with respect to hello_sensor demo:

                                      uint16_t min_int = 400; /* Minimum connection interval - 400 x 1.25 = 500 ms */

                                      uint16_t max_int = 400; /* Maximum connection interval - 400 x 1.25 = 500 ms */

                                      uint16_t latency = 0;   /* Slave latency */

                                      uint16_t timeout = 500; /* Supervision timeout - 500 x 10 = 5000 ms */

                                  result = wiced_bt_l2cap_update_ble_conn_params (hello_sensor_state.remote_addr,  min_int,  max_int,  latency,  timeout);

                                   

                                  Please note iOS won't accept any random connection parameters. It should be as per ios spec . Refer Making a BLE Device Discoverable on iOS Devices - KBA223312

                                  Also its depend on the app development whether to accept new connection interval or not.

                                   

                                  These may also help:

                                  Re: Code Example - Update connection parameter base on Wiced Studio

                                   

                                  Thanks,

                                  Anjana

                                  1 of 1 people found this helpful
                                  • 14. Re: File transfer over CYW20719
                                    JiZh_4619191

                                    Hi Anjana,

                                    Before parameters update, Iphone can reveive 16KB per second.

                                    After parameters update,:

                                    ...

                                    wiced_bt_l2cap_update_ble_conn_params(p_conn_status->bd_addr, 20, 20, 0, 100);

                                    ...

                                    Iphone can  reveive 10KB per second.

                                    According to my understanding,  shorter connection interval will result faster data transfer rate.

                                    Am I wrong?

                                     

                                    Thanks

                                    1 2 Previous Next