-
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 12 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,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 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, and this handle should be used to subsequently read or write these components. | ||
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 should use this handle to read or write these components? 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 application. Code written by the user. |
||
|
||
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 | ||
|
||
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. | ||
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 must access the values of the characteristic and the characteristic descriptor present in the GattServer? Also, who or what has registered the service? Note to self: Remove the "u" from "flavors" for U.S. spelling. 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 user registers a service. When this happens a handle is created. This handle must be used to read and write the attribute both by the user code (local application) and by clients (remote applications). |
||
|
||
If a client has subscribed to a given characteristic's value update, then the application code can query 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 for a characteristic. | ||
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). |
||
- `onUpdatesDisabled`: Register an event handler that is called when a client unsubscribes from updates for a characteristic. | ||
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). |
||
- `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.
Do we have an example created for this?