-
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
Changes from 6 commits
fce159b
6ad55b1
dfda96f
cba161a
f7435ea
864cb2f
3091020
2141523
e9be9c6
96519b6
8a0c0f8
f3de826
ff338ac
d451e29
29a483b
a6368a4
a517758
a7f8f18
b732b22
9d733b1
d5a6f5d
068350c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,26 @@ | ||
## 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 most read and write operations to offer a single API that can be used to read or write characteristics values. Application code does not have to handle the fragmentation/reassembly process necessary if the attribute value to transported cannot fit in a single data packet. | ||
|
||
#### Server Initiated events | ||
|
||
If a characteristic has to notify or indicate a property set; then, a client may register to a notification or indication from the characteristic. When the server updates the characteristic value, the server can forward the new value to the registered clients. The notification/indication mechanism prevents polling from the client and therefore minimise the transactions involved between a client and a server. | ||
|
||
Registration is made by writing the Client Characteristic Configuration Descriptor, which is present in the characteristic if the notify or indicate properties are set. The client discovers that descriptor if it intends to register to server initiated events. | ||
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. Clarification needed on this 1st sentence. At present, it sounds like 'writing to' the client characteristic configuration descriptor' (also why capitals here?), or do you mean writing the descriptor itself? And if so, writing it where? The 2nd sentence is more confusing. It sounds like you're trying to say that if the notify/indicate properties are set, then this descriptor is present in the characteristic, and the client can find this descriptor and use it to register by writing something somewhere. Please clarify and I can restructure the sentences a bit. 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. It's capitalised to indicate a specific term often abbreviated. Give me a moment to rework this. 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. hopefully that's clearer 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. Yes, much clearer! |
||
|
||
### GattClient 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? |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,30 @@ | ||
## 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 GattCharacteristic enclosed in the service, as well as all the characteristics descriptors (see GattAttribute) these characteristics contain. Service registration assigns a unique handle to the various attributes being part of the service; this handle should be used for subsequent read or write of these components. | ||
|
||
There are no primitives defined to remove a single service; however, a call to the function `reset()` removes all services previously registered in the GattServer. | ||
|
||
#### Characteristic and attributes access | ||
|
||
Values of the characteristic and the characteristic descriptor present in the GattServer must be accessed through the handle assigned to them when the service has been registered; the GattServer class offers several flavours of `read()` and `write()` functions that retrieve or mutate an attribute value. | ||
|
||
Application code can query if a client has subscribed to a given characteristic's value update by invoking the function `areUpdatesEnabled()`. | ||
|
||
#### Events | ||
|
||
The GattServer allows application code to register several event handlers that can be used to monitor client and server activities: | ||
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. Query: Who or what can use the event handlers to monitor client and server activities? You, the user? 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. Yes, application code means code written by users. |
||
- `onDataSent`: Register an event handler that is called when a characteristic value update has been sent to a client. | ||
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. Query: Who or what calls the event handler? You, the user? Or someone else? Also, who or what sends a characteristic value update to a client? 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. For the record I find the naming confusing too. This function lets you register a handler. You, the user, call this function and pass in a handler that we, the GattServer will call later. The server (our code) calls the handler you registered (users code). |
||
- `onDataWriten`: Register an event handler that is called when a client has written an attribute of the server. | ||
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. Query: Who or what calls the event handler? Also, who or what writes an attribute of the server? 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. The server (our code) calls the handler you registered (users code). |
||
- `onDataRead`: Register an event handler that is called when a client has read an attribute of the server. | ||
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. Query: Who or what calls the event handler? Also, who or what reads an attribute of the server? 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. Server calls the handler when a client has read an attribute. |
||
- `onUpdatesEnabled`: Register an event handler that is called when a client subscribes to updates of a characteristic. | ||
- `onUpdatesDisabled`: Register an event handler that is called when a client unsubscribes from updates of a characteristic. | ||
- `onConfimationReceived`: Register an event handler that is called when a client acknowledges a characteristic value notification. | ||
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. Query: Who or what calls the event handler? 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. The server (our code) calls the handler you registered (users code). |
||
|
||
The term characteristic value update is used to represent Characteristic Value Notification and Characteristic Value Indication when the nature of the server initiated is not relevant. | ||
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. Query: Could we say "The term "characteristic value update" represents Characteristic..."? |
||
|
||
### 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? |
||
|
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.
I don't understand what 'most' is doing in this 1st sentence (so deleted). 'read and write' is repetitive, but I am also confused about the overall meaning of the sentence. I'm assuming you means that the abstracts read/write operations, and that these operations offer a single API?
2nd sentence: "attribute value to transported" something is wrong here. Is it the attribute value to be transported (that will be transported)?