Setting up a custom GATT Client

Hello! 

I have a GATT Server in the form of a nrf52840-DK that has been given to me from a company that has a custom service on the server using CCCD. I have the full documentation of the service so all necessary information is available there for me.
However they want me to create a GATT Client, as a part of a thesis work, with another nrf52840-DK to handle the incoming data.
Since I am very new at this I am not really sure what to look for in terms of how to develop this, what is the correct way to do this? Is it called setting up a custom service or what is this called?

I have already finished the BLE academy course so I am somewhat familiar with the terminology but I am not sure what exactly to search for in terms of guides/documentation/walkthroughs to solve this problem.

Thank you in advance for the help and feel free to ask me if something is unclear.

Parents
  • Hi,

    Is it called setting up a custom service or what is this called?

    This can be called setting up a GATT client to communicate with a custom service.

    Since you mention that you have all the documentation of the custom service, you will need to note the information, like UUIDs of the custom service, it's characteristics, the properties of each characteristic and the format and type of data that each characteristic handles You will also need the CCCD.

    You will have to initialize the BLE stack, followed by a scan for devices and then connect to the GATT server. Then you can discover the custom service and it's characteristics, after connection. If the custom service uses notifications, write to the CCCD to enable them.

    We have the BLE Central tutorial.  I would also suggest you to take a look at the Devacademy course on the GATT operations.

    Regards,

    Priyanka

  • Thank you  ! Will do, while we are on the subject, do you have a sample code or tutorial that is fairly up to date on the GATT Server as well?

  • For nRF5 SDK, we do have this GATT Service Server example.

    But in the Devacademy course, it provides a good explanation and hands on for both client and server. 

    -Priyanka

  • Yes they are, I guess I was too much of a beginner to realize that when I was going through the tutorial.
    Final question:
    In my solution, the Server needs to accept Write without response from the client AND Notify the client.
    The client needs to notify the server and do a write without response to the server.
    Is there something special I need to think about when setting up the client and server for this solution?

    -Björn

  • Hi,

    You could keep in mind a few things. On the server side, you need to define the characteristics of your service to include both "Write without response" and "Notify". Please take a look at this ticket. On the client side, you need to use the bt_gatt_discover function to find the write characteristic, and then use bt_gatt_write_without_response to write to it. You also need to subscribe/enable notifications to receive the heartbeat message from the server. You can refer this ticket. Even with notifications and write(without response), there is acknowledgment on the link layer. So if a packet was not received, it will be re-transmitted.

  • Thank you again Priyanka! 
    I have figured most of this out during the weekend but one thing I keep struggling with is where in the attribute table I can find my value.
    So I had implemented the notify characteristic and everything worked fine when I have this function:


    , then I added a write without response and just added it in the service, changed NOTHING else and now the notification does not work anymore, meaning it does not send values.

    I am using the sample bluetooth peripheral and tried using this function to write without response: 


    I have read the Bluetooth academy course and I understand that the values are not sequential but how do I find where in the table the value is being stored?

Reply
  • Thank you again Priyanka! 
    I have figured most of this out during the weekend but one thing I keep struggling with is where in the attribute table I can find my value.
    So I had implemented the notify characteristic and everything worked fine when I have this function:


    , then I added a write without response and just added it in the service, changed NOTHING else and now the notification does not work anymore, meaning it does not send values.

    I am using the sample bluetooth peripheral and tried using this function to write without response: 


    I have read the Bluetooth academy course and I understand that the values are not sequential but how do I find where in the table the value is being stored?

Children
No Data
Related