This module describes functions and data structures used to implement an ATT server (peripheral).
More...
|
| Configuration |
| This module describes parameters used to configure ATT server layer.
|
|
|
bt_bool | bt_att_init (void) |
| Initialize the ATT layer. More...
|
|
bt_att_mgr_t * | bt_att_get_mgr (void) |
| Return a pointer to an instance of the ATT manager. More...
|
|
bt_bool | bt_att_register_listener (bt_att_listener_t *listener) |
| Register an ATT event listener. More...
|
|
void | bt_att_unregister_listener (bt_att_listener_t *listener) |
| Unregister an ATT event listener. More...
|
|
bt_bool | bt_att_update_conn_parameters (bt_att_session_t *session, bt_uint min_interval, bt_uint max_interval, bt_uint slave_latency, bt_uint supervision_timeout) |
| Request connection parameters update. More...
|
|
bt_bdaddr_t * | bt_att_get_remote_address (const bt_att_session_t *session) |
| Get the address of the remote device this device is connected to. More...
|
|
bt_bool | bt_att_server_start (bt_byte *att_var_db, bt_uint att_var_db_len, const bt_byte *att_const_db, bt_uint att_const_db_len, bt_bool listen_on_dynamic_channel) |
| Start ATT server. More...
|
|
void | bt_att_server_stop (void) |
| Stop ATT server. More...
|
|
void | bt_att_server_register_callback (bt_att_server_callback_fp callback, void *param) |
| Register a ATT application callback. More...
|
|
bt_byte | bt_att_server_write_attribute_value (bt_uint handle, const bt_byte *value, bt_uint value_len, bt_uint offset) |
| Write attribute's value. More...
|
|
bt_bool | bt_att_server_disconnect (bt_att_session_t *session) |
| Disconnect from a remote device. More...
|
|
void | bt_att_server_indicate_to_all (bt_att_attribute_t *attr) |
| Indicate attribute's value to all connected clients. More...
|
|
void | bt_att_server_indicate (bt_att_session_t *session, bt_att_attribute_t *attr) |
| Indicate attribute's value. More...
|
|
void | bt_att_server_notify_all (bt_att_attribute_t *attr) |
| Notify attribute's value to all connected clients. More...
|
|
void | bt_att_server_notify (bt_att_session_t *session, bt_att_attribute_t *attr) |
| Notify attribute's value. More...
|
|
void | bt_att_server_authorize_access (bt_att_session_t *session, bt_att_attribute_t *attr, bt_byte opcode, bt_bool authorize) |
| Authorize access to an attribute. More...
|
|
This module describes functions and data structures used to implement an ATT server (peripheral).
typedef void(* bt_att_mgr_callback_fp) (bt_int evt, void *evt_param, void *param) |
ATT application callback.
In order to be notified of various events a consumer of the ATT layer has to register a callback function. The stack will call this function whenever a new event has been generated passing the code of the event as the first parameter.
- Parameters
-
evt | ATT event |
evt_param | Event parameter. This can be one of the following values:
- ATT_SERVER_EVT_SESSION_CONNECTED A client connected to the server
- ATT_SERVER_EVT_SESSION_DISCONNECTED A client disconnected from the server
- ATT_SERVER_EVT_ATTR_VALUE_CHANGED_BY_SERVER Attribute's value has been changed locally on the server
- ATT_SERVER_EVT_ATTR_VALUE_CHANGED_BY_CLIENT A client has changed the attribute's value
- ATT_SERVER_EVT_ATTR_VALUE_NOTIFIED A value notification has bee sent to the client
- ATT_SERVER_EVT_ATTR_VALUE_INDICATED A value indication has been sent to the client
- ATT_SERVER_EVT_TRAN_TIMEOUT Operation timed out
- ATT_SERVER_EVT_AUTHORIZATION_REQUESTED Authorization is required in order to access the attribute's value
- ATT_SERVER_EVT_STOPPED Server stooped
|
callback_param | A pointer to an arbitrary data set by a call to bt_att_server_register_callback. |
Return a pointer to an instance of the ATT manager.
This function returns a pointer to an instance of the ATT manager. There is only one instance of the manager allocated by the stack.
bt_bdaddr_t* bt_att_get_remote_address |
( |
const bt_att_session_t * |
session | ) |
|
Get the address of the remote device this device is connected to.
- Parameters
-
- Returns
A
pointer to bt_bdaddr structure that contains the address of the remote device.
bt_bool bt_att_init |
( |
void |
| ) |
|
Initialize the ATT layer.
This function initializes the ATT layer of the stack. It must be called prior to any other ATT function can be called.
Register an ATT event listener.
In order to be notified of various events a consumer of the ATT layer may register an event listener. The listener is a structure that contains a pointer to a callback function and a callback parameter - a pointer to arbitrary data to be passed to the callback function. The stack will call the callback whenever a new event has been generated passing the code of the event as the first parameter. The event can be one of the following values:
- ATT_SERVER_EVT_SESSION_CONNECTED A client connected to the server
- ATT_SERVER_EVT_SESSION_DISCONNECTED A client disconnected from the server
- ATT_SERVER_EVT_ATTR_VALUE_CHANGED_BY_SERVER Attribute's value has been changed locally on the server
- ATT_SERVER_EVT_ATTR_VALUE_CHANGED_BY_CLIENT A client has changed the attribute's value
- ATT_SERVER_EVT_ATTR_VALUE_NOTIFIED A value notification has bee sent to the client
- ATT_SERVER_EVT_ATTR_VALUE_INDICATED A value indication has been sent to the client
- ATT_SERVER_EVT_TRAN_TIMEOUT Transaction timed out
- ATT_SERVER_EVT_AUTHORIZATION_REQUESTED Authorization is required in order to access the attribute's value
- ATT_SERVER_EVT_STOPPED Server stooped
- Parameters
-
listener | A pointer to a structure containing the listener parameters. The pointer has to be persistent, i.e., it cannot be allocate on the stack. |
void bt_att_server_authorize_access |
( |
bt_att_session_t * |
session, |
|
|
bt_att_attribute_t * |
attr, |
|
|
bt_byte |
opcode, |
|
|
bt_bool |
authorize |
|
) |
| |
Authorize access to an attribute.
If an attribute requires authorization before its value can be read or written, ATT generates a ATT_SERVER_EVT_AUTHORIZATION_REQUESTED event. In response to this event the application should obtain authorization (how this is done is implementation specific) and call bt_att_server_authorize_access.
- Parameters
-
session | ATT session. |
attr | Attribute. |
opcode | Attribute Opcode. The opcode that requires authorization is passed in the ATT_SERVER_EVT_AUTHORIZATION_REQUESTED event. The application should use the passed opcode when calling bt_att_server_authorize_access. The opcode can be one the following values:
- ATT_OPCODE_READ_REQUEST
- ATT_OPCODE_READ_BLOB_REQUEST
- ATT_OPCODE_READ_BY_TYPE_REQUEST
- ATT_OPCODE_READ_BY_GROUP_TYPE_REQUEST
- ATT_OPCODE_READ_MULTIPLE_REQUEST
- ATT_OPCODE_WRITE_REQUEST
- ATT_OPCODE_PREPARE_WRITE_REQUEST
|
authorize | Specifies whether access to the attribute has been authorized or not. |
bt_bool bt_att_server_disconnect |
( |
bt_att_session_t * |
session | ) |
|
Disconnect from a remote device.
This function closes a connection to a remote device.
- Parameters
-
- Returns
TRUE
if disconnection has been started.
FALSE
otherwise. No events will be generated.
Indicate attribute's value.
This function sends the attribute's value specified with the attr
parameter to a client specified with the session
parameter.
- Parameters
-
session | ATT session. |
attr | Attribute. |
Indicate attribute's value to all connected clients.
This function sends the attribute's value specified with the attr
parameter to all connected clients.
- Parameters
-
Notify attribute's value.
This function sends the attribute's value specified with the attr
parameter to a client specified with the session
parameter.
- Parameters
-
session | ATT session. |
attr | Attribute. |
Notify attribute's value to all connected clients.
This function sends the attribute's value specified with the attr
parameter to all connected clients.
- Parameters
-
session | ATT session. |
attr | Attribute. |
void bt_att_server_register_callback |
( |
bt_att_server_callback_fp |
callback, |
|
|
void * |
param |
|
) |
| |
Register a ATT application callback.
In order to be notified of various events a consumer of the ATT layer has to register a callback function. The stack will call this function whenever a new event has been generated passing the code of the event as the first parameter. The event can be one of the following values:
- ATT_SERVER_EVT_SESSION_CONNECTED A client connected to the server
- ATT_SERVER_EVT_SESSION_DISCONNECTED A client disconnected from the server
- ATT_SERVER_EVT_ATTR_VALUE_CHANGED_BY_SERVER Attribute's value has been changed locally on the server
- ATT_SERVER_EVT_ATTR_VALUE_CHANGED_BY_CLIENT A client has changed the attribute's value
- ATT_SERVER_EVT_ATTR_VALUE_NOTIFIED A value notification has bee sent to the client
- ATT_SERVER_EVT_ATTR_VALUE_INDICATED A value indication has been sent to the client
- ATT_SERVER_EVT_TRAN_TIMEOUT Transaction timed out
- ATT_SERVER_EVT_AUTHORIZATION_REQUESTED Authorization is required in order to access the attribute's value
- ATT_SERVER_EVT_STOPPED Server stooped
- Parameters
-
callback | The callback function that will be called when ATT generates an event. |
callback_param | A pointer to arbitrary data to be passed to the callback callback. |
bt_bool bt_att_server_start |
( |
bt_byte * |
att_var_db, |
|
|
bt_uint |
att_var_db_len, |
|
|
const bt_byte * |
att_const_db, |
|
|
bt_uint |
att_const_db_len, |
|
|
bt_bool |
listen_on_dynamic_channel |
|
) |
| |
Start ATT server.
This function starts the ATT server.
- Parameters
-
att_var_db | A pointer to ATT database that holds writable attributes. |
att_var_db_len | The length of the writable ATT database. |
att_const_db | A pinter to ATT database that holds read-only attributes. |
att_const_db_len | The length of the read-only ATT database. |
listen_on_dynamic_channel | Specifies whether ATT server should accept connections on BR/EDR links. |
- Returns
TRUE
if the function succeeds.
FALSE
otherwise.
void bt_att_server_stop |
( |
void |
| ) |
|
Stop ATT server.
This function stops the ATT server.
- Returns
TRUE
if the function succeeds.
FALSE
otherwise.
bt_byte bt_att_server_write_attribute_value |
( |
bt_uint |
handle, |
|
|
const bt_byte * |
value, |
|
|
bt_uint |
value_len, |
|
|
bt_uint |
offset |
|
) |
| |
Write attribute's value.
This function writes attribute's value.
- Parameters
-
handle | Attribute handle. |
value | Attribute value. |
value_len | Attribute value length. |
offset | Offset from which to write the value. |
- Returns
- Error code. This can be one of the following values:
- ATT_ERROR_SUCCESS
- ATT_ERROR_INVALID_HANDLE
- ATT_ERROR_READ_NOT_PERMITTED
- ATT_ERROR_WRITE_NOT_PERMITTED
- ATT_ERROR_INVALID_PDU
- ATT_ERROR_INSUFFICIENT_AUTHENTICATION
- ATT_ERROR_REQUEST_NOT_SUPPORTED
- ATT_ERROR_INVALID_OFFSET
- ATT_ERROR_INSUFFICIENT_AUTHORIZATION
- ATT_ERROR_PREPARE_QUEUE_FULL
- ATT_ERROR_ATTRIBUTE_NOT_FOUND
- ATT_ERROR_ATTRIBUTE_NOT_LONG
- ATT_ERROR_INSUFFICIENT_ENCRYPTION_KEY_SIZE
- ATT_ERROR_INVALID_ATTRIBUTE_VALUE_LENGTH
- ATT_ERROR_UNLIKELY_ERROR
- ATT_ERROR_INSUFFICIENT_ENCRYPTION
- ATT_ERROR_UNSUPPORTED_GROUP_TYPE
- ATT_ERROR_INSUFFICIENT_RESOURCES
Unregister an ATT event listener.
Remove a listener previously registered with bt_att_register_listener.
- Parameters
-
listener | A pointer to a structure containing the listener parameters. It has to be the the same pinter passed to bt_att_register_listener(). |
bt_bool bt_att_update_conn_parameters |
( |
bt_att_session_t * |
session, |
|
|
bt_uint |
min_interval, |
|
|
bt_uint |
max_interval, |
|
|
bt_uint |
slave_latency, |
|
|
bt_uint |
supervision_timeout |
|
) |
| |
Request connection parameters update.
This function sends a request to the client (central) to update connection parameters.
- Parameters
-
session | ATT session. |
min_interval | Minimum connection interval in milliseconds. |
max_interval | Maximum connection interval in milliseconds. |
slave_latency | Slave latency expressed as number of connection events. |
supervision_timeout | Link supervision timeout in milliseconds. |
- Returns
TRUE
if request has been sent to the central.
FALSE
otherwise.