#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include "btstack_config.h"
#include "att_dispatch.h"
#include "ble/att_db.h"
#include "ble/att_server.h"
#include "ble/core.h"
#include "ble/le_device_db.h"
#include "ble/sm.h"
#include "btstack_debug.h"
#include "btstack_event.h"
#include "btstack_memory.h"
#include "btstack_run_loop.h"
#include "gap.h"
#include "hci.h"
#include "hci_dump.h"
#include "l2cap.h"
Macros | |
#define | __BTSTACK_FILE__ "att_server.c" |
Functions | |
static void | att_emit_can_send_now_event (void) |
static void | att_emit_mtu_event (hci_con_handle_t con_handle, uint16_t mtu) |
static void | att_event_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size) |
static void | att_handle_value_indication_notify_client (uint8_t status, uint16_t client_handle, uint16_t attribute_handle) |
static void | att_handle_value_indication_timeout (btstack_timer_source_t *ts) |
static void | att_packet_handler (uint8_t packet_type, uint16_t handle, uint8_t *packet, uint16_t size) |
static void | att_run_for_context (att_server_t *att_server) |
int | att_server_can_send_packet_now (hci_con_handle_t con_handle) |
static att_server_t * | att_server_for_handle (hci_con_handle_t con_handle) |
static void | att_server_handle_can_send_now (void) |
int | att_server_indicate (hci_con_handle_t con_handle, uint16_t attribute_handle, uint8_t *value, uint16_t value_len) |
void | att_server_init (uint8_t const *db, att_read_callback_t read_callback, att_write_callback_t write_callback) |
int | att_server_notify (hci_con_handle_t con_handle, uint16_t attribute_handle, uint8_t *value, uint16_t value_len) |
static int | att_server_process_validated_request (att_server_t *att_server) |
void | att_server_register_can_send_now_callback (btstack_context_callback_registration_t *callback_registration, hci_con_handle_t con_handle) |
Request callback when sending is possible. More... | |
void | att_server_register_packet_handler (btstack_packet_handler_t handler) |
void | att_server_request_can_send_now_event (hci_con_handle_t con_handle) |
Request emission of ATT_EVENT_CAN_SEND_NOW as soon as possible. More... | |
#define __BTSTACK_FILE__ "att_server.c" |
|
static |
References att_client_packet_handler, ATT_EVENT_CAN_SEND_NOW, and HCI_EVENT_PACKET.
Referenced by att_server_handle_can_send_now().
|
static |
References att_client_packet_handler, ATT_EVENT_MTU_EXCHANGE_COMPLETE, HCI_EVENT_PACKET, and little_endian_store_16().
Referenced by att_server_process_validated_request().
|
static |
References att_clear_transaction_queue(), ATT_DEFAULT_MTU, att_dispatch_server_request_can_send_now_event(), att_run_for_context(), att_server_for_handle(), con_handle, HCI_EVENT_DISCONNECTION_COMPLETE, hci_event_disconnection_complete_get_connection_handle(), HCI_EVENT_ENCRYPTION_CHANGE, HCI_EVENT_ENCRYPTION_KEY_REFRESH_COMPLETE, HCI_EVENT_LE_META, HCI_EVENT_PACKET, hci_event_packet_get_type(), HCI_SUBEVENT_LE_CONNECTION_COMPLETE, l2cap_max_le_mtu(), little_endian_read_16(), log_info, reverse_bd_addr(), sm_authenticated(), sm_encryption_key_size(), SM_EVENT_AUTHORIZATION_RESULT, SM_EVENT_IDENTITY_RESOLVING_FAILED, SM_EVENT_IDENTITY_RESOLVING_STARTED, SM_EVENT_IDENTITY_RESOLVING_SUCCEEDED, and UNUSED.
Referenced by att_server_init().
|
static |
References att_client_packet_handler, ATT_EVENT_HANDLE_VALUE_INDICATION_COMPLETE, HCI_EVENT_PACKET, little_endian_store_16(), and status.
Referenced by att_handle_value_indication_timeout(), and att_packet_handler().
|
static |
|
static |
References ATT_DATA_PACKET, att_handle_request(), ATT_HANDLE_VALUE_CONFIRMATION, att_handle_value_indication_notify_client(), att_run_for_context(), att_server_for_handle(), att_server_handle_can_send_now(), ATT_WRITE_COMMAND, btstack_run_loop_remove_timer(), HCI_EVENT_PACKET, L2CAP_EVENT_CAN_SEND_NOW, and log_info.
Referenced by att_server_init().
|
static |
int att_server_can_send_packet_now | ( | hci_con_handle_t | con_handle | ) |
References att_dispatch_server_can_send_now().
|
static |
References hci_connection_for_handle(), and NULL.
Referenced by att_event_packet_handler(), att_handle_value_indication_timeout(), att_packet_handler(), att_server_indicate(), and att_server_notify().
|
static |
References att_client_waiting_for_can_send, att_dispatch_server_can_send_now(), att_dispatch_server_request_can_send_now_event(), att_emit_can_send_now_event(), att_server_process_validated_request(), btstack_linked_list_empty(), btstack_linked_list_iterator_has_next(), btstack_linked_list_iterator_next(), btstack_linked_list_remove(), btstack_context_callback_registration_t::callback, con_handle, btstack_context_callback_registration_t::context, and hci_connections_get_iterator().
Referenced by att_packet_handler().
int att_server_indicate | ( | hci_con_handle_t | con_handle, |
uint16_t | attribute_handle, | ||
uint8_t * | value, | ||
uint16_t | value_len | ||
) |
References att_dispatch_server_can_send_now(), ATT_HANDLE_VALUE_INDICATION_IN_PROGRESS, att_handle_value_indication_timeout(), att_prepare_handle_value_indication(), att_server_for_handle(), ATT_TRANSACTION_TIMEOUT_MS, BTSTACK_ACL_BUFFERS_FULL, btstack_run_loop_add_timer(), btstack_run_loop_set_timer(), btstack_run_loop_set_timer_handler(), ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER, L2CAP_CID_ATTRIBUTE_PROTOCOL, l2cap_get_outgoing_buffer(), l2cap_reserve_packet_buffer(), and l2cap_send_prepared_connectionless().
void att_server_init | ( | uint8_t const * | db, |
att_read_callback_t | read_callback, | ||
att_write_callback_t | write_callback | ||
) |
References att_dispatch_register_server(), att_event_packet_handler(), att_packet_handler(), att_set_db(), att_set_read_callback(), att_set_write_callback(), btstack_packet_callback_registration_t::callback, hci_add_event_handler(), and sm_add_event_handler().
Referenced by le_counter_setup(), le_prov_app_setup(), and tss_app_setup().
int att_server_notify | ( | hci_con_handle_t | con_handle, |
uint16_t | attribute_handle, | ||
uint8_t * | value, | ||
uint16_t | value_len | ||
) |
References att_dispatch_server_can_send_now(), att_prepare_handle_value_notification(), att_server_for_handle(), BTSTACK_ACL_BUFFERS_FULL, ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER, L2CAP_CID_ATTRIBUTE_PROTOCOL, l2cap_get_outgoing_buffer(), l2cap_reserve_packet_buffer(), and l2cap_send_prepared_connectionless().
Referenced by battery_service_can_send_now(), hids_device_send_boot_keyboard_input_report(), hids_device_send_boot_mouse_input_report(), hids_device_send_input_report(), and packet_handler().
|
static |
References att_emit_mtu_event(), ATT_ERROR_INSUFFICIENT_AUTHORIZATION, ATT_ERROR_RESPONSE, ATT_EXCHANGE_MTU_RESPONSE, att_handle_request(), L2CAP_CID_ATTRIBUTE_PROTOCOL, l2cap_get_outgoing_buffer(), l2cap_release_packet_buffer(), l2cap_reserve_packet_buffer(), l2cap_send_prepared_connectionless(), sm_authorization_state(), and sm_request_pairing().
Referenced by att_server_handle_can_send_now().
void att_server_register_can_send_now_callback | ( | btstack_context_callback_registration_t * | callback_registration, |
hci_con_handle_t | con_handle | ||
) |
Request callback when sending is possible.
callback_registration | to point to callback function and context information |
con_handle |
References att_dispatch_server_can_send_now(), att_dispatch_server_request_can_send_now_event(), btstack_linked_list_add_tail(), btstack_context_callback_registration_t::callback, con_handle, and btstack_context_callback_registration_t::context.
Referenced by battery_service_server_set_battery_value(), and hids_device_request_can_send_now_event().
void att_server_register_packet_handler | ( | btstack_packet_handler_t | handler | ) |
References att_client_packet_handler.
Referenced by le_counter_setup(), le_prov_app_setup(), and tss_app_setup().
void att_server_request_can_send_now_event | ( | hci_con_handle_t | con_handle | ) |
Request emission of ATT_EVENT_CAN_SEND_NOW as soon as possible.
con_handle |
References att_client_waiting_for_can_send, att_dispatch_server_request_can_send_now_event(), and log_debug.
Referenced by att_write_callback(), heartbeat_handler(), packet_handler(), process_data(), and tss_server_return_credit().
|
static |
|
static |
Referenced by att_server_handle_can_send_now(), and att_server_request_can_send_now_event().
|
static |
|
static |
|
static |