Me again. I was thinking someone could provide some suggestions on my understanding of the BLE connection ( porfile, GATT, characteristic,value, etc...)
I finished reading all the BLE tutorials and would like to re-write my understanding about the tutorials and some other questions about where should I go next.
With my understanding by now, in order to transfer the data between server and client, first the server need to declare profiles depending on what kind of data it will send and how to send out to the client. The GATT profile is used for this purpose. The GATT profile will be used to define what and how to transfer the data. The GATT consists with a service or many services, each services is used for one purpose. For example, a heart rate device can have 2 service, one is used to transfer heart data, another one is used to transfer battery data.
Within a service, there are many characteristics, declarations and values which are used to either indicating what service it is or holding the actually sensor value. And at the client side, for example a phone app, the app should also be able to set up a similar profile which pairs to the device so that the phone app can quickly connect with the server and read or write data.
And in order to send data out, I need to do the things below:
make a GATT profile -> add service to the GATT profile based on what function I need for my device -> add declaration into service, so that when the client scan, it can know the device quickly and easily and know how to read data -> add data into the characteristic value declaration, this should be the data I want to send out -> set up other parameters, security, notification, etc...-> set up trigger event, timer or button press.
Above is my understanding from the tutorial. I have also go through the code example and successfully run through with my nRF51 DK. Here are some questions which I'm not sure about:
How to define the GATT itself ? As mentioned, the GATT is holding all the services and characteristics , etc... How can I declare a specific GATT in advance ? Say I'm using the heart rate GATT profile, is there a need to declare a heart rate GATT profile ? Or the GATT is defined with the service declaration ? Like in here in Table 1 first row, the attribute value 0X180D si the GATT declaration, which is the value from BL SIG
Is the data in the characteristic declaration value is the raw value when transmit to phone app? I have used some BLE module before where I don't really care about the pair or what kind of the data I need to transfer. For example, when I did my embedded design, I just add a BLE module and use RX/TX line on the BLE module to send and read data with between core chip and BLE, byte by byte, not really care about set service or profile or others. So, for now, say if I also need to develop an iphone app along with my project, when the phone connect with my device, the value I put into the characteristic value declaration is the value I want to transfer. Is that right?
The third question is about the phone app. I have all the time developing circuit and system but never did a app design. So, if I want to also have a app working with the nrf chip, where should I start? I have go through some android examples and have a draft app, it can scan my nrf51822 device, but cannot connect to it. So, is this because I didn't have a profile in the app?
What about multiple data sending out? I think with my understanding, if I want to send multiple data our, either enclose them into one service but at different index in the value bytes and send all the phone and de-format them later, or make multiple service and send them out together. But how should I design at the phone app side ?
Thanks for taking a read for my long post. If you have any feedback or suggestion please let me know.
The GATT profile describes a use case, roles, and general behaviors based on the GATT functionality. If you use a SIG profile, like the Heart Rate Profile, everything is defined, and it should be implemented according to the Heart Rate Profile spec, found here. You can make your own profile, then you implement it however you want. Let me know if I didn't answer your question.
Correct. If you just want something simple to transfer proprietary data you should have a look at the UART example. This is a proprietary profile, defined by us.
You should start by looking at our Android app examples, available here. Toolbox is a good starting point. If you have specific questions you can post them separately here.
This is up to you. You can use build your transfer using different characteristics, or you use one and then do the handling of the data at a higher level.
Thanks for your reply. I would like to know a more specific answer actually.
To implementing the GATT profile, what do I need to implement ? At the code level. From the tutorial, I got understand that for a heart rate GATT profile, I need to set up the service declaration, then set up the corresponding characteristic declaration as well as the characteristic value deceleration, is that the actual GATT profile at the code level?
And for the second question, if I would like to use the profile itself to hold and transfer the value, I should put them in the characteristic value declaration, is that correct?
And if I did that, used profile itself to transfer the data, I need to also did some similar in the phone app so it can hook up to the device and read the values from those characteristic value declaration, is that right?
Petter is out of office, and I will step in in the mean time.
The GATT profile essentially covers the following:
Each GATT service has it's own specification document listing the characteristics required for that service, and how those characteristics should look (what properties are used, what descriptors if any, what is the data format).
For an example of how to do this configuration I would have a look at one of the BLE examples, such as ble_app_hrs. All the service and characteristic configuration is handled by the service files, ble_hrs.c (HRS service), ble_dis.c (Device Information Service) and ble_bas.c ( Battery State service).
The service files will include functions to send data, and you can register a callback function that is used to process incoming data.
I would recommend you have a look at the example, in particular the service files, to get a better understanding of the software involved.
Most apps are designed for a specific GATT profile, that is correct. As Petter mentioned we have example apps available with source code showing you how to do this.