Microchip® Advanced Software Framework

att_server.c File Reference
#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...
 

Variables

static btstack_packet_handler_t att_client_packet_handler = NULL
 
static uint8_t att_client_waiting_for_can_send
 
static btstack_linked_list_t can_send_now_clients
 
static
btstack_packet_callback_registration_t 
hci_event_callback_registration
 
static
btstack_packet_callback_registration_t 
sm_event_callback_registration
 

#define __BTSTACK_FILE__   "att_server.c"

static void att_emit_can_send_now_event ( void  )
static
static void att_emit_mtu_event ( hci_con_handle_t  con_handle,
uint16_t  mtu 
)
static
static void att_handle_value_indication_notify_client ( uint8_t  status,
uint16_t  client_handle,
uint16_t  attribute_handle 
)
static
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_register_can_send_now_callback ( btstack_context_callback_registration_t callback_registration,
hci_con_handle_t  con_handle 
)

Request callback when sending is possible.

Note
callback might happend during call to this function
Parameters
callback_registrationto 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)
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.

Note
ATT_EVENT_CAN_SEND_NOW might be emitted during call to this function so packet handler should be ready to handle it
Parameters
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().

uint8_t att_client_waiting_for_can_send
static
btstack_linked_list_t can_send_now_clients
static
btstack_packet_callback_registration_t hci_event_callback_registration
static
btstack_packet_callback_registration_t sm_event_callback_registration
static