4 Replies Latest reply on Jul 19, 2019 1:14 AM by PY_21

    Trying to use Cy_BLE_WriteCharacteristicValue() in an interrupt

    JoYa_4140271

      I am trying to call Cy_BLE_WriteCharacteristicValue() in an timer interrupt that periodically sends data to a Peripheral device. However, on the Peripheral end, I receive way much less bytes than I expected. Is it thread safe to call such non-blocking function in my interrupt?

        • 1. Re: Trying to use Cy_BLE_WriteCharacteristicValue() in an interrupt
          PY_21

          Hello,

           

          Please let me know how many bytes you are sending from central device and also how many bytes your getting at the peripheral side.

           

          Thanks,

          P Yugandhar.

          • 2. Re: Trying to use Cy_BLE_WriteCharacteristicValue() in an interrupt
            PY_21

            Hello,

             

            Could you please share your project ?

            Please check the MTU size of both central and peripheral. The amount of data that has to be transmitted is depends on the MTU size of client and peripheral. Client will send the MTU request to the peripheral. CYBLE_EVT_GATTS_XCNHG_MTU_REQ event will be generated at the Peripheral device. The client and server exchange the maximum size of a packet that can be received using the Exchange MTU Request and Response PDUs. Both devices then use the minimum of these exchanged values for all further communication.

             

            Thanks,

            P Yugandhar.

            • 3. Re: Trying to use Cy_BLE_WriteCharacteristicValue() in an interrupt
              JoYa_4140271

              Hi,

               

              I am not able to share my project at the moment.

              I am trying to send 64-byte GATT value in both direction (peripheral to central and central to peripheral; concurrently) with the timer triggering interrupts every 10ms. I let it run for a couple of minutes and while one side receives over 100,000 bytes in total, the other side receives much less.

               

              I have done the exchange MTU requests for both sides. Does the function of blocking or non-blocking affect the results in such a timing that is very close to BLE connection interval?

               

              Thanks!

              • 4. Re: Trying to use Cy_BLE_WriteCharacteristicValue() in an interrupt
                PY_21

                Hello,

                 

                Sending data from peripheral to central requires notify or indicate property. For notification it does not need any acknowledgement from the client device after sending data.

                For sending data from central to peripheral it requires write property. For every write request to peripheral a write response shall be sent by the server if the write of Characteristic Value succeeded or not. So write data is only sent when the server gets a write response from the client device that it has received the previous packet.

                Please increase your timer value to more than BLE connection interval because this will results in missing of some data calls which results in missing of packets.

                 

                Thanks,

                P Yugandhar.