5 Replies Latest reply on Mar 10, 2020 2:32 AM by ShipingW_81

    Read Values from BLE Device

    MuNa_4652896

      Hello Cypress Community.

      I am new to using PSoC 6 so please bear with me. I have been learning the PSoC 6 and I want to achieve a specific role.

      The PSoC is running a GATT Server / GAP Peripheral, while there is an App running on Android as GATT Client / GAP Central.

       

      The Client tries to connect to the PSoC, after connecting, it reads a Service called "STATUS" which is updated according the activities of the PSoC amd can be read only by the client. If the STATUS Characteristic is set to "StandBy", the client is able to enter different values in the application and  Click on a button to send these values.

       

      These values are configuration parameters (3 numeric values). which are required for the task that the PSoC does. According to the videos (which I learnt from), all the values that are controlled from the client are in the specified in the GATT Database as Services with available Characteristics and their values are updates (LED, Capsense). Now the question is, I want to receive these parameters, from the client app and parse them to do the required task. How do I receive values from the client after they click on the button on the app? Any available Code Snippets or Examples will be helpful.

       

      Thank you

        • 1. Re: Read Values from BLE Device
          ShipingW_81

          MuNa_4652896

           

          From your description, my understanding is you want to receive the parameters from the Client app on ther GATT Server (PSoC) end.

          Actually, it largely depends on the method adopted on Client app. There are 2 methods of data from GATT Client to GATT Server - Write Request and Write Command. The GATT Server should handle the wirte request/command properly.

           

          Write Request: The GATT Client sends this request to the GATT Server to write an attribute value. The GATT Server responds to the GATT Client, indicating whether the value was written. A smartphone writing a value of 0x01 to the CCCD of a Battery Level characteristic to enable notifications is an example of a Write Request.

          Write Command: The GATT Client sends this command to the GATT Server to write an attribute value. The GATT Server does not send any response to this command. For example, the BLE Immediate Alert Service (IAS) uses a Write Command to trigger an alert (turn on an LED, ring a buzzer, drive a vibration motor, and so on) on an IAS Target device (for example, a BLE key fob) from an IAS locator (for example, a smartphone).

           

          Let me know if I get you purpose correctly.

          • 2. Re: Read Values from BLE Device
            MuNa_4652896

            Thank you for you feedback.

            Your explanation has been quite informative to me. This is very helpful.

            I have an additional question though, What if I want to send a large file over bluetooth? Do I use the same approach but change the datatype for the required characteristic?

            Lets say I will send a 3KB File from the GATT Client to the GATT Server to process. Do I use an array of uint8 of size 512? And use a buffer to write every 512bytes to an SD card?

            • 3. Re: Read Values from BLE Device
              ShipingW_81

              MuNa_4652896

              It's less common to transmit a large amount of data from GATT Client to GATT Server, and currently there might not be proper demo to demonstrate this kind data flow.

              However, you can do that using the two formats - write request / command to complete that. For the 2 actions, there should be target attribute on GATT Server side to receive the data.

              • 4. Re: Read Values from BLE Device
                MuNa_4652896

                I agree it is very uncommon to take this route. However, I was not able to find Object Transfer Protocol Service in the PSoC Creator 4.1. Can you shed some light on this?

                • 5. Re: Read Values from BLE Device
                  ShipingW_81

                  Object Transfer Protocol Service looks not in the list of PSoC Creator BLE library yet.

                  In addition, PSoC Creator 4.1 is not the latestet version. You can get the updated v4.2/4.3 from - https://www.cypress.com/products/psoc-creator-integrated-design-environment-ide