-
Notifications
You must be signed in to change notification settings - Fork 178
Gatt server and client docs #555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AnotherButler
merged 22 commits into
ARMmbed:development
from
paul-szczepanek-arm:new_engine
Aug 14, 2018
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
fce159b
Gatt Client docs
paul-szczepanek-arm 6ad55b1
Gatt Server docs
paul-szczepanek-arm dfda96f
consistent naming
paul-szczepanek-arm cba161a
Update GattClient.md
jen3andruska f7435ea
Update GattClient.md
jen3andruska 864cb2f
Update GattClient.md
jen3andruska 3091020
Update GattClient.md
jen3andruska 2141523
Update GattClient.md
jen3andruska e9be9c6
clarify CCCDs
paul-szczepanek-arm 96519b6
Update GattServer.md
jen3andruska 8a0c0f8
Update GattServer.md
jen3andruska f3de826
Update GattServer.md
jen3andruska ff338ac
Copy edit GattClient.md
d451e29
Copy edit GattServer.md
29a483b
Update GattClient.md
paul-szczepanek-arm a6368a4
active voice
paul-szczepanek-arm a517758
active voide and clarifications
paul-szczepanek-arm a7f8f18
active voice
paul-szczepanek-arm b732b22
Added PHY documentation
paul-szczepanek-arm 9d733b1
Add example to GattServer.md
d5a6f5d
Add example to GattClient.md
068350c
Fix link in GattServer.md
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,31 @@ | ||
## GattClient | ||
|
||
[Add description here.] | ||
GattClient defines procedures required for interacting with a remote GattServer. | ||
|
||
#### Discovery procedures | ||
|
||
A GattServer hosts a fixed set of services. These services are a logical composition of characteristics that may be discovered, read or written and can broadcast their state to a connected client. These characteristics may also contain metainformation and named characteristic descriptors. A characteristic descriptor may indicate the unit used for a characteristic value, describe the characteristic purpose in a textual form or allow a client to register for update notifications for the characteristic value. | ||
|
||
Prior to any interaction with a server characteristic, a GattClient discovers the layout of the services and characteristics present on the server. | ||
|
||
The layout of the descriptors of a characteristic may also be issued as an extra discovery step. | ||
|
||
#### Attribute manipulation | ||
|
||
As a result of the discovery process, the client can start interacting with the characteristic discovered. Depending on the characteristic properties (acquired during discovery), a client can read or write the value of a given characteristic. | ||
|
||
Mbed BLE abstracts read and write operations to offer a single API that can be used to read or write characteristic values. The application code does not have to handle the necessary fragmentation or reassembly process if the attribute value to be transported can't fit in a single data packet. | ||
|
||
#### Server initiated events | ||
|
||
When a server updates a characteristic value, it can forward the new value to any registered clients. Clients may register for these updates on a per-characteristic basis. The server sends the updates by using notifications (no confirmation from client) or indications (client confirms receipt). This mechanism minimizes the number of transactions between a client and a server by avoiding polling. | ||
|
||
Clients register for these updates by setting the Client Characteristic Configuration Descriptor (CCCD) value. This is an attribute, and the client needs to discover its descriptor. It is present in the characteristic if its notify or indicate properties are set. | ||
|
||
### GattClient class reference | ||
|
||
[](http://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/class_gatt_client.html) | ||
|
||
### GattClient example | ||
|
||
[Add example here.] | ||
[](https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-ble-GattClient/file/71d7cec222eb/main.cpp) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,36 @@ | ||
## GattServer | ||
|
||
[Add description here.] | ||
A GattServer is a collection of GattServices. These services contain characteristics that a peer connected to the device may read or write. These characteristics may also emit updates to subscribed clients when their values change. | ||
|
||
#### Server layout | ||
|
||
Application code can add a GattService object to the server with the help of the function `addService()`. That function registers all the GattCharacteristics enclosed in the service, as well as all the characteristic descriptors (see GattAttribute) that these characteristics contain. Service registration assigns a unique handle to the various attributes that are part of the service. The user must use this handle to read or write these components. | ||
|
||
There are no defined primitives that remove a single service; however, a call to the function `reset()` removes all services previously registered in the GattServer. | ||
|
||
#### Characteristic and attributes access | ||
|
||
You must access values of the characteristic and the characteristic descriptor present in the GattServer through the handle assigned to them when you registered the service. The GattServer class offers several types of `read()` and `write()` functions that retrieve or mutate an attribute value. | ||
|
||
You can query the server by invoking the function `areUpdatesEnabled()` to find out if a client has subscribed to a given characteristic's value update. | ||
|
||
#### Events | ||
|
||
You can register several event handlers with the GattServer that it will call to notify you of client (remote application connected to the server) and server activities: | ||
|
||
- `onDataSent`: Register an event handler with the GattServer that it will call to notify you when it sends a characteristic value update to a client. | ||
- `onDataWriten`: Register an event handler with the GattServer that it will call to notify you when a client has written an attribute of the server. | ||
- `onDataRead`: Register an event handler with the GattServer that it will call to notify you when a client has read an attribute of the server. | ||
- `onUpdatesEnabled`: Register an event handler with the GattServer that it will call to notify you when a client subscribes to updates for a characteristic. | ||
- `onUpdatesDisabled`: Register an event handler with the GattServer that it will call to notify you when a client unsubscribes from updates for a characteristic. | ||
- `onConfimationReceived`: Register an event handler with the GattServer that it will call to notify you when a client acknowledges a characteristic value notification. | ||
|
||
The term characteristic value update represents Characteristic Value Notification and Characteristic Value Indication when the nature of the server initiated is not relevant. | ||
|
||
### GattServer class reference | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have an example created for this? |
||
[](http://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/class_gatt_server.html) | ||
|
||
### GattServer example | ||
|
||
[Add example here.] | ||
[](https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-ble-GattServer/file/8fbed496a023/main.cpp) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have an example created for this?