ble_gatt_client
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
att.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include "att-types.h"

Go to the source code of this file.

Typedefs

typedef void(* bt_att_response_func_t )(uint8_t opcode, const void *pdu, uint16_t length, void *user_data)
 
typedef void(* bt_att_notify_func_t )(uint8_t opcode, const void *pdu, uint16_t length, void *user_data)
 
typedef void(* bt_att_destroy_func_t )(void *user_data)
 
typedef void(* bt_att_debug_func_t )(const char *str, void *user_data)
 
typedef void(* bt_att_timeout_func_t )(unsigned int id, uint8_t opcode, void *user_data)
 
typedef void(* bt_att_disconnect_func_t )(int err, void *user_data)
 
typedef bool(* bt_att_counter_func_t )(uint32_t *sign_cnt, void *user_data)
 

Functions

struct bt_attbt_att_new (int fd, bool ext_signed)
 
struct bt_attbt_att_ref (struct bt_att *att)
 
void bt_att_unref (struct bt_att *att)
 
bool bt_att_set_close_on_unref (struct bt_att *att, bool do_close)
 
int bt_att_get_fd (struct bt_att *att)
 
bool bt_att_set_debug (struct bt_att *att, bt_att_debug_func_t callback, void *user_data, bt_att_destroy_func_t destroy)
 
uint16_t bt_att_get_mtu (struct bt_att *att)
 
bool bt_att_set_mtu (struct bt_att *att, uint16_t mtu)
 
bool bt_att_set_timeout_cb (struct bt_att *att, bt_att_timeout_func_t callback, void *user_data, bt_att_destroy_func_t destroy)
 
unsigned int bt_att_send (struct bt_att *att, uint8_t opcode, const void *pdu, uint16_t length, bt_att_response_func_t callback, void *user_data, bt_att_destroy_func_t destroy)
 
bool bt_att_cancel (struct bt_att *att, unsigned int id)
 
bool bt_att_cancel_all (struct bt_att *att)
 
unsigned int bt_att_send_error_rsp (struct bt_att *att, uint8_t opcode, uint16_t handle, int error)
 
unsigned int bt_att_register (struct bt_att *att, uint8_t opcode, bt_att_notify_func_t callback, void *user_data, bt_att_destroy_func_t destroy)
 
bool bt_att_unregister (struct bt_att *att, unsigned int id)
 
unsigned int bt_att_register_disconnect (struct bt_att *att, bt_att_disconnect_func_t callback, void *user_data, bt_att_destroy_func_t destroy)
 
bool bt_att_unregister_disconnect (struct bt_att *att, unsigned int id)
 
bool bt_att_unregister_all (struct bt_att *att)
 
int bt_att_get_security (struct bt_att *att)
 
bool bt_att_set_security (struct bt_att *att, int level)
 
bool bt_att_set_local_key (struct bt_att *att, uint8_t sign_key[16], bt_att_counter_func_t func, void *user_data)
 
bool bt_att_set_remote_key (struct bt_att *att, uint8_t sign_key[16], bt_att_counter_func_t func, void *user_data)
 
bool bt_att_has_crypto (struct bt_att *att)
 

Typedef Documentation

typedef bool(* bt_att_counter_func_t)(uint32_t *sign_cnt, void *user_data)

Definition at line 49 of file att.h.

typedef void(* bt_att_debug_func_t)(const char *str, void *user_data)

Definition at line 45 of file att.h.

typedef void(* bt_att_destroy_func_t)(void *user_data)

Definition at line 44 of file att.h.

typedef void(* bt_att_disconnect_func_t)(int err, void *user_data)

Definition at line 48 of file att.h.

typedef void(* bt_att_notify_func_t)(uint8_t opcode, const void *pdu, uint16_t length, void *user_data)

Definition at line 42 of file att.h.

typedef void(* bt_att_response_func_t)(uint8_t opcode, const void *pdu, uint16_t length, void *user_data)

Definition at line 40 of file att.h.

typedef void(* bt_att_timeout_func_t)(unsigned int id, uint8_t opcode, void *user_data)

Definition at line 46 of file att.h.

Function Documentation

int bt_att_get_fd ( struct bt_att att)

Definition at line 1087 of file att.c.

References bt_att::fd.

uint16_t bt_att_get_mtu ( struct bt_att att)
bool bt_att_has_crypto ( struct bt_att att)

Definition at line 1524 of file att.c.

References bt_att::crypto.

struct bt_att* bt_att_ref ( struct bt_att att)

Definition at line 1055 of file att.c.

References bt_att::ref_count.

Referenced by bt_att_new(), bt_gatt_client_new(), can_read_data(), disconnect_cb(), and handle_notify().

unsigned int bt_att_register ( struct bt_att att,
uint8_t  opcode,
bt_att_notify_func_t  callback,
void *  user_data,
bt_att_destroy_func_t  destroy 
)
unsigned int bt_att_register_disconnect ( struct bt_att att,
bt_att_disconnect_func_t  callback,
void *  user_data,
bt_att_destroy_func_t  destroy 
)
unsigned int bt_att_send ( struct bt_att att,
uint8_t  opcode,
const void *  pdu,
uint16_t  length,
bt_att_response_func_t  callback,
void *  user_data,
bt_att_destroy_func_t  destroy 
)

encode & send an att message If (op-code type == ATT_OP_TYPE_REQ) process the response with callback function see att_opcode_type_table (att.c) for opcode type definition

Parameters
attstructure of the communication channel
opcodeatt message op-code
pduprotocol data unit buffer
lengthsize of pdu
callbackcallback function depending on opcode to process response
user_datarequest data when relevant
destroyfunction to manage user_data
Returns
att message sequence number or 0 if error

Definition at line 1220 of file att.c.

References ATT_OP_TYPE_CMD, ATT_OP_TYPE_CONF, ATT_OP_TYPE_IND, ATT_OP_TYPE_NOT, ATT_OP_TYPE_REQ, ATT_OP_TYPE_RSP, ATT_OP_TYPE_UNKNOWN, create_att_send_op(), att_send_op::id, bt_att::ind_queue, bt_att::io, bt_att::next_send_id, att_send_op::pdu, queue_push_tail(), bt_att::req_queue, att_send_op::type, wakeup_writer(), and bt_att::write_queue.

Referenced by bt_att_send_error_rsp(), bt_gatt_client_prepare_write(), bt_gatt_client_read_long_value(), bt_gatt_client_read_multiple(), bt_gatt_client_read_value(), bt_gatt_client_write_execute(), bt_gatt_client_write_long_value(), bt_gatt_client_write_value(), bt_gatt_client_write_without_response(), bt_gatt_discover_characteristics(), bt_gatt_discover_descriptors(), bt_gatt_discover_included_services(), bt_gatt_exchange_mtu(), bt_gatt_read_by_type(), cancel_long_write_req(), cancel_prep_write_session(), complete_write_long_op(), discover_chrcs_cb(), discover_descs_cb(), discover_included_cb(), discover_services(), find_by_type_val_cb(), handle_next_prep_write(), notify_cb(), notify_data_write_ccc(), read_by_grp_type_cb(), read_by_type_cb(), read_included(), read_included_cb(), read_long_cb(), and respond_not_supported().

unsigned int bt_att_send_error_rsp ( struct bt_att att,
uint8_t  opcode,
uint16_t  handle,
int  error 
)
bool bt_att_set_close_on_unref ( struct bt_att att,
bool  do_close 
)

Definition at line 1079 of file att.c.

References bt_att::io, and io_set_close_on_destroy().

Referenced by client_create().

bool bt_att_set_debug ( struct bt_att att,
bt_att_debug_func_t  callback,
void *  user_data,
bt_att_destroy_func_t  destroy 
)

Definition at line 1095 of file att.c.

References bt_att::debug_callback, bt_att::debug_data, and bt_att::debug_destroy.

Referenced by client_create().

bool bt_att_set_local_key ( struct bt_att att,
uint8_t  sign_key[16],
bt_att_counter_func_t  func,
void *  user_data 
)

Definition at line 1506 of file att.c.

References bt_att::local_sign, and sign_set_key().

Referenced by cmd_set_sign_key().

bool bt_att_set_mtu ( struct bt_att att,
uint16_t  mtu 
)

Definition at line 1119 of file att.c.

References BT_ATT_DEFAULT_LE_MTU, bt_att::buf, and bt_att::mtu.

Referenced by mtu_cb().

bool bt_att_set_remote_key ( struct bt_att att,
uint8_t  sign_key[16],
bt_att_counter_func_t  func,
void *  user_data 
)

Definition at line 1515 of file att.c.

References bt_att::remote_sign, and sign_set_key().

bool bt_att_set_security ( struct bt_att att,
int  level 
)
bool bt_att_set_timeout_cb ( struct bt_att att,
bt_att_timeout_func_t  callback,
void *  user_data,
bt_att_destroy_func_t  destroy 
)

Definition at line 1141 of file att.c.

References bt_att::timeout_callback, bt_att::timeout_data, and bt_att::timeout_destroy.

bool bt_att_unregister ( struct bt_att att,
unsigned int  id 
)
bool bt_att_unregister_all ( struct bt_att att)
bool bt_att_unregister_disconnect ( struct bt_att att,
unsigned int  id 
)