#include "btstack_config.h"
#include <inttypes.h>
#include "hci.h"
#include "btstack_slip.h"
#include "btstack_debug.h"
#include "hci_transport.h"
#include "btstack_uart_block.h"
Macros | |
#define | __BTSTACK_FILE__ "hci_transport_h5.c" |
#define | ENABLE_LOG_DEBUG |
#define | LINK_ACKNOWLEDGEMENT_TYPE 0x00 |
#define | LINK_CONFIG_DATA_INTEGRITY_CHECK 1 |
#define | LINK_CONFIG_FIELD (LINK_CONFIG_SLIDING_WINDOW_SIZE | (LINK_CONFIG_OOF_FLOW_CONTROL << 3) | (LINK_CONFIG_DATA_INTEGRITY_CHECK << 4) | (LINK_CONFIG_VERSION_NR << 5)) |
#define | LINK_CONFIG_OOF_FLOW_CONTROL 0 |
#define | LINK_CONFIG_SLIDING_WINDOW_SIZE 1 |
#define | LINK_CONFIG_VERSION_NR 0 |
#define | LINK_CONTROL_MAX_LEN 3 |
#define | LINK_CONTROL_PACKET_TYPE 0x0f |
#define | LINK_PERIOD_MS 250 |
#define | LINK_SLIP_TX_CHUNK_LEN 64 |
#define | LINK_WAKEUP_MS 50 |
Enumerations | |
enum | hci_transport_link_actions_t { HCI_TRANSPORT_LINK_SEND_SYNC = 1 << 0, HCI_TRANSPORT_LINK_SEND_SYNC_RESPONSE = 1 << 1, HCI_TRANSPORT_LINK_SEND_CONFIG = 1 << 2, HCI_TRANSPORT_LINK_SEND_CONFIG_RESPONSE_EMPTY = 1 << 3, HCI_TRANSPORT_LINK_SEND_CONFIG_RESPONSE = 1 << 4, HCI_TRANSPORT_LINK_SEND_SLEEP = 1 << 5, HCI_TRANSPORT_LINK_SEND_WOKEN = 1 << 6, HCI_TRANSPORT_LINK_SEND_WAKEUP = 1 << 7, HCI_TRANSPORT_LINK_SEND_QUEUED_PACKET = 1 << 8, HCI_TRANSPORT_LINK_SEND_ACK_PACKET = 1 << 9, HCI_TRANSPORT_LINK_ENTER_SLEEP = 1 << 10 } |
enum | hci_transport_link_state_t { LINK_UNINITIALIZED, LINK_INITIALIZED, LINK_ACTIVE } |
Functions | |
static uint16_t | btstack_reverse_bits_16 (uint16_t value) |
static uint16_t | crc16_calc_for_slip_frame (const uint8_t *header, const uint8_t *payload, uint16_t len) |
static uint16_t | crc16_ccitt_update (uint16_t crc, uint8_t ch) |
static void | hci_transport_h5_block_received (void) |
static void | hci_transport_h5_block_sent (void) |
static int | hci_transport_h5_can_send_packet_now (uint8_t packet_type) |
static int | hci_transport_h5_close (void) |
static void | hci_transport_h5_emit_sleep_state (int sleep_active) |
void | hci_transport_h5_enable_bcsp_mode (void) |
static void | hci_transport_h5_init (const void *transport_config) |
const hci_transport_t * | hci_transport_h5_instance (const btstack_uart_block_t *uart_driver) |
static int | hci_transport_h5_open (void) |
static void | hci_transport_h5_process_frame (uint16_t frame_size) |
static void | hci_transport_h5_queue_packet (uint8_t packet_type, uint8_t *packet, int size) |
static void | hci_transport_h5_read_next_byte (void) |
static void | hci_transport_h5_register_packet_handler (void(*handler)(uint8_t packet_type, uint8_t *packet, uint16_t size)) |
static void | hci_transport_h5_reset_link (void) |
static int | hci_transport_h5_send_packet (uint8_t packet_type, uint8_t *packet, int size) |
void | hci_transport_h5_set_auto_sleep (uint16_t inactivity_timeout_ms) |
static int | hci_transport_h5_set_baudrate (uint32_t baudrate) |
static void | hci_transport_inactivity_timeout_handler (btstack_timer_source_t *ts) |
static void | hci_transport_inactivity_timer_set (void) |
static void | hci_transport_link_calc_header (uint8_t *header, uint8_t sequence_nr, uint8_t acknowledgement_nr, uint8_t data_integrity_check_present, uint8_t reliable_packet, uint8_t packet_type, uint16_t payload_length) |
static uint16_t | hci_transport_link_calc_resend_timeout (uint32_t baudrate) |
static void | hci_transport_link_clear_queue (void) |
static int | hci_transport_link_have_outgoing_packet (void) |
static int | hci_transport_link_inc_seq_nr (int seq_nr) |
static void | hci_transport_link_init (void) |
static void | hci_transport_link_run (void) |
static void | hci_transport_link_send_ack_packet (void) |
static void | hci_transport_link_send_config (void) |
static void | hci_transport_link_send_config_response (void) |
static void | hci_transport_link_send_config_response_empty (void) |
static void | hci_transport_link_send_control (const uint8_t *message, int message_len) |
static void | hci_transport_link_send_queued_packet (void) |
static void | hci_transport_link_send_sleep (void) |
static void | hci_transport_link_send_sync (void) |
static void | hci_transport_link_send_sync_response (void) |
static void | hci_transport_link_send_wakeup (void) |
static void | hci_transport_link_send_woken (void) |
static void | hci_transport_link_set_timer (uint16_t timeout_ms) |
static void | hci_transport_link_timeout_handler (btstack_timer_source_t *timer) |
static void | hci_transport_link_update_resend_timeout (uint32_t baudrate) |
static void | hci_transport_slip_encode_chunk_and_send (int pos) |
static void | hci_transport_slip_init (void) |
static void | hci_transport_slip_send_frame (const uint8_t *header, const uint8_t *packet, uint16_t packet_size, uint16_t data_integrity_check) |
static void | hci_transport_slip_send_next_chunk (void) |
#define __BTSTACK_FILE__ "hci_transport_h5.c" |
#define ENABLE_LOG_DEBUG |
#define LINK_ACKNOWLEDGEMENT_TYPE 0x00 |
Referenced by hci_transport_h5_process_frame(), and hci_transport_link_send_ack_packet().
#define LINK_CONFIG_DATA_INTEGRITY_CHECK 1 |
#define LINK_CONFIG_FIELD (LINK_CONFIG_SLIDING_WINDOW_SIZE | (LINK_CONFIG_OOF_FLOW_CONTROL << 3) | (LINK_CONFIG_DATA_INTEGRITY_CHECK << 4) | (LINK_CONFIG_VERSION_NR << 5)) |
#define LINK_CONFIG_OOF_FLOW_CONTROL 0 |
#define LINK_CONFIG_SLIDING_WINDOW_SIZE 1 |
#define LINK_CONFIG_VERSION_NR 0 |
#define LINK_CONTROL_MAX_LEN 3 |
#define LINK_CONTROL_PACKET_TYPE 0x0f |
Referenced by hci_transport_h5_process_frame(), and hci_transport_link_send_control().
#define LINK_PERIOD_MS 250 |
#define LINK_SLIP_TX_CHUNK_LEN 64 |
Referenced by hci_transport_slip_encode_chunk_and_send().
#define LINK_WAKEUP_MS 50 |
Referenced by hci_transport_h5_send_packet(), and hci_transport_link_timeout_handler().
|
static |
Referenced by crc16_calc_for_slip_frame().
|
static |
References btstack_reverse_bits_16(), and crc16_ccitt_update().
Referenced by hci_transport_h5_process_frame(), hci_transport_link_send_control(), and hci_transport_link_send_queued_packet().
|
static |
References crc16_ccitt_table.
Referenced by crc16_calc_for_slip_frame().
|
static |
References btstack_uart_config_t::baudrate, btstack_run_loop_get_time_ms(), btstack_slip_decoder_frame_size(), btstack_slip_decoder_process(), BTSTACK_SLIP_SOF, hci_transport_h5_process_frame(), hci_transport_h5_read_next_byte(), hci_transport_h5_receive_start, hci_transport_link_read_byte, hci_transport_slip_init(), and log_info.
Referenced by hci_transport_h5_init().
|
static |
References btstack_slip_encoder_has_data(), btstack_uart_sleep_mode, hci_transport_h5_emit_sleep_state(), hci_transport_link_actions, HCI_TRANSPORT_LINK_ENTER_SLEEP, hci_transport_link_run(), hci_transport_slip_send_next_chunk(), log_info, btstack_uart_block_t::set_sleep, and slip_write_active.
Referenced by hci_transport_h5_init().
|
static |
References hci_transport_link_have_outgoing_packet(), LINK_ACTIVE, and link_state.
Referenced by hci_transport_h5_send_packet().
|
static |
References btstack_uart_block_t::close.
|
static |
References HCI_EVENT_PACKET, HCI_EVENT_TRANSPORT_SLEEP_MODE, log_info, and packet_handler.
Referenced by hci_transport_h5_block_sent(), hci_transport_h5_process_frame(), and hci_transport_h5_send_packet().
void hci_transport_h5_enable_bcsp_mode | ( | void | ) |
References hci_transport_bcsp_mode.
|
static |
References btstack_uart_config_t::baudrate, hci_transport_config_uart_t::baudrate_init, btstack_uart_config_t::device_name, hci_transport_config_uart_t::device_name, btstack_uart_config_t::flowcontrol, hci_transport_config_uart_t::flowcontrol, HCI_TRANSPORT_CONFIG_UART, hci_transport_h5_block_received(), hci_transport_h5_block_sent(), btstack_uart_block_t::init, log_error, btstack_uart_block_t::set_block_received, and btstack_uart_block_t::set_block_sent.
const hci_transport_t* hci_transport_h5_instance | ( | const btstack_uart_block_t * | uart_driver | ) |
References hci_transport_h5, and uart_driver.
|
static |
References btstack_uart_config_t::baudrate, BTSTACK_UART_SLEEP_MASK_RTS_LOW_WAKE_ON_RX_EDGE, btstack_uart_sleep_mode, BTSTACK_UART_SLEEP_OFF, BTSTACK_UART_SLEEP_RTS_LOW_WAKE_ON_RX_EDGE, btstack_uart_block_t::get_supported_sleep_modes, hci_transport_bcsp_mode, hci_transport_h5_read_next_byte(), hci_transport_link_init(), hci_transport_link_update_resend_timeout(), hci_transport_slip_init(), log_info, btstack_uart_block_t::open, and btstack_uart_block_t::set_parity.
|
static |
References big_endian_read_16(), btstack_run_loop_remove_timer(), btstack_uart_sleep_mode, crc16_calc_for_slip_frame(), HCI_ACL_DATA_PACKET, HCI_EVENT_PACKET, HCI_EVENT_TRANSPORT_PACKET_SENT, HCI_INCOMING_PRE_BUFFER_SIZE, hci_packet_with_pre_buffer, HCI_SCO_DATA_PACKET, hci_transport_h5_emit_sleep_state(), hci_transport_inactivity_timer_set(), hci_transport_link_actions, hci_transport_link_clear_queue(), hci_transport_link_have_outgoing_packet(), hci_transport_link_inc_seq_nr(), hci_transport_link_run(), HCI_TRANSPORT_LINK_SEND_ACK_PACKET, HCI_TRANSPORT_LINK_SEND_CONFIG, HCI_TRANSPORT_LINK_SEND_CONFIG_RESPONSE, HCI_TRANSPORT_LINK_SEND_CONFIG_RESPONSE_EMPTY, HCI_TRANSPORT_LINK_SEND_SYNC_RESPONSE, HCI_TRANSPORT_LINK_SEND_WOKEN, hci_transport_link_set_timer(), link_ack_nr, LINK_ACKNOWLEDGEMENT_TYPE, LINK_ACTIVE, link_control_config, link_control_config_prefix_len, link_control_config_response, link_control_config_response_prefix_len, LINK_CONTROL_PACKET_TYPE, link_control_sleep, link_control_sync, link_control_sync_response, link_control_wakeup, link_control_woken, LINK_INITIALIZED, link_peer_asleep, link_peer_supports_data_integrity_check, LINK_PERIOD_MS, link_seq_nr, link_state, LINK_UNINITIALIZED, log_debug, log_debug_hexdump(), log_info, packet_handler, btstack_uart_block_t::set_parity, and btstack_uart_block_t::set_sleep.
Referenced by hci_transport_h5_block_received().
|
static |
References hci_packet, hci_packet_size, and hci_packet_type.
Referenced by hci_transport_h5_send_packet().
|
static |
References hci_transport_link_read_byte, and btstack_uart_block_t::receive_block.
Referenced by hci_transport_h5_block_received(), and hci_transport_h5_open().
|
static |
References packet_handler.
|
static |
|
static |
References btstack_uart_sleep_mode, BTSTACK_UART_SLEEP_OFF, hci_transport_h5_can_send_packet_now(), hci_transport_h5_emit_sleep_state(), hci_transport_h5_queue_packet(), hci_transport_link_actions, hci_transport_link_run(), HCI_TRANSPORT_LINK_SEND_QUEUED_PACKET, HCI_TRANSPORT_LINK_SEND_WAKEUP, hci_transport_link_set_timer(), link_peer_asleep, link_resend_timeout_ms, link_state, LINK_WAKEUP_MS, log_error, log_info, and btstack_uart_block_t::set_sleep.
void hci_transport_h5_set_auto_sleep | ( | uint16_t | inactivity_timeout_ms | ) |
References link_inactivity_timeout_ms.
|
static |
|
static |
|
static |
References btstack_run_loop_add_timer(), btstack_run_loop_remove_timer(), btstack_run_loop_set_timer(), btstack_run_loop_set_timer_handler(), hci_transport_inactivity_timeout_handler(), and link_inactivity_timeout_ms.
Referenced by hci_transport_h5_process_frame(), and hci_transport_link_send_queued_packet().
|
static |
|
static |
References HCI_PACKET_BUFFER_SIZE, and log_info.
Referenced by hci_transport_link_update_resend_timeout().
|
static |
References btstack_run_loop_remove_timer(), hci_packet, and NULL.
Referenced by hci_transport_h5_process_frame(), and hci_transport_h5_reset_link().
|
static |
|
static |
Referenced by hci_transport_h5_process_frame().
|
static |
References hci_transport_link_actions, hci_transport_link_run(), HCI_TRANSPORT_LINK_SEND_SYNC, hci_transport_link_set_timer(), link_peer_asleep, link_peer_supports_data_integrity_check, LINK_PERIOD_MS, link_state, and LINK_UNINITIALIZED.
Referenced by hci_transport_h5_open(), and hci_transport_h5_reset_link().
|
static |
References hci_transport_link_actions, HCI_TRANSPORT_LINK_ENTER_SLEEP, HCI_TRANSPORT_LINK_SEND_ACK_PACKET, hci_transport_link_send_ack_packet(), HCI_TRANSPORT_LINK_SEND_CONFIG, hci_transport_link_send_config(), HCI_TRANSPORT_LINK_SEND_CONFIG_RESPONSE, hci_transport_link_send_config_response(), HCI_TRANSPORT_LINK_SEND_CONFIG_RESPONSE_EMPTY, hci_transport_link_send_config_response_empty(), HCI_TRANSPORT_LINK_SEND_QUEUED_PACKET, hci_transport_link_send_queued_packet(), HCI_TRANSPORT_LINK_SEND_SLEEP, hci_transport_link_send_sleep(), HCI_TRANSPORT_LINK_SEND_SYNC, hci_transport_link_send_sync(), HCI_TRANSPORT_LINK_SEND_SYNC_RESPONSE, hci_transport_link_send_sync_response(), HCI_TRANSPORT_LINK_SEND_WAKEUP, hci_transport_link_send_wakeup(), HCI_TRANSPORT_LINK_SEND_WOKEN, hci_transport_link_send_woken(), link_peer_asleep, and slip_write_active.
Referenced by hci_transport_h5_block_sent(), hci_transport_h5_process_frame(), hci_transport_h5_send_packet(), hci_transport_inactivity_timeout_handler(), hci_transport_link_init(), and hci_transport_link_timeout_handler().
|
static |
References hci_transport_link_calc_header(), hci_transport_slip_send_frame(), header, link_ack_nr, LINK_ACKNOWLEDGEMENT_TYPE, log_debug, and NULL.
Referenced by hci_transport_link_run().
|
static |
References hci_transport_link_send_control(), link_control_config, and log_debug.
Referenced by hci_transport_link_run().
|
static |
References hci_transport_link_send_control(), link_control_config_response, and log_debug.
Referenced by hci_transport_link_run().
|
static |
References hci_transport_link_send_control(), link_control_config_response_empty, and log_debug.
Referenced by hci_transport_link_run().
|
static |
References crc16_calc_for_slip_frame(), hci_transport_link_calc_header(), hci_transport_slip_send_frame(), header, LINK_CONTROL_PACKET_TYPE, link_peer_supports_data_integrity_check, log_debug, and log_debug_hexdump().
Referenced by hci_transport_link_send_config(), hci_transport_link_send_config_response(), hci_transport_link_send_config_response_empty(), hci_transport_link_send_sleep(), hci_transport_link_send_sync(), hci_transport_link_send_sync_response(), hci_transport_link_send_wakeup(), and hci_transport_link_send_woken().
|
static |
References crc16_calc_for_slip_frame(), hci_packet, hci_packet_size, hci_packet_type, hci_transport_inactivity_timer_set(), hci_transport_link_calc_header(), hci_transport_slip_send_frame(), header, link_ack_nr, link_peer_supports_data_integrity_check, link_seq_nr, log_debug, and log_debug_hexdump().
Referenced by hci_transport_link_run().
|
static |
References hci_transport_link_send_control(), link_control_sleep, and log_debug.
Referenced by hci_transport_link_run().
|
static |
References hci_transport_link_send_control(), link_control_sync, and log_debug.
Referenced by hci_transport_link_run().
|
static |
References hci_transport_link_send_control(), link_control_sync_response, and log_debug.
Referenced by hci_transport_link_run().
|
static |
References hci_transport_link_send_control(), link_control_wakeup, and log_debug.
Referenced by hci_transport_link_run().
|
static |
References hci_transport_link_send_control(), link_control_woken, and log_debug.
Referenced by hci_transport_link_run().
|
static |
|
static |
References hci_transport_link_actions, hci_transport_link_have_outgoing_packet(), hci_transport_link_run(), HCI_TRANSPORT_LINK_SEND_CONFIG, HCI_TRANSPORT_LINK_SEND_QUEUED_PACKET, HCI_TRANSPORT_LINK_SEND_SYNC, HCI_TRANSPORT_LINK_SEND_WAKEUP, hci_transport_link_set_timer(), LINK_ACTIVE, LINK_INITIALIZED, link_peer_asleep, LINK_PERIOD_MS, link_resend_timeout_ms, link_state, LINK_UNINITIALIZED, LINK_WAKEUP_MS, and log_info.
Referenced by hci_transport_link_set_timer().
|
static |
References hci_transport_link_calc_resend_timeout(), and link_resend_timeout_ms.
Referenced by hci_transport_h5_open(), and hci_transport_h5_set_baudrate().
|
static |
References big_endian_store_16(), btstack_slip_encoder_get_byte(), btstack_slip_encoder_has_data(), btstack_slip_encoder_start(), BTSTACK_SLIP_SOF, LINK_SLIP_TX_CHUNK_LEN, log_debug, btstack_uart_block_t::send_block, slip_outgoing_buffer, slip_outgoing_dic, slip_outgoing_dic_present, and slip_write_active.
Referenced by hci_transport_slip_send_frame(), and hci_transport_slip_send_next_chunk().
|
static |
|
static |
References btstack_slip_encoder_get_byte(), btstack_slip_encoder_has_data(), btstack_slip_encoder_start(), BTSTACK_SLIP_SOF, hci_transport_slip_encode_chunk_and_send(), slip_outgoing_buffer, slip_outgoing_dic, and slip_outgoing_dic_present.
Referenced by hci_transport_link_send_ack_packet(), hci_transport_link_send_control(), and hci_transport_link_send_queued_packet().
|
inlinestatic |
References hci_transport_slip_encode_chunk_and_send().
Referenced by hci_transport_h5_block_sent().
|
static |
|
static |
|
static |
Referenced by crc16_ccitt_update().
|
static |
|
static |
Referenced by hci_transport_h5_queue_packet(), and hci_transport_link_send_queued_packet().
|
static |
Referenced by hci_transport_h5_queue_packet(), and hci_transport_link_send_queued_packet().
|
static |
Referenced by hci_transport_h5_process_frame(), and hci_transport_slip_init().
|
static |
Referenced by hci_transport_h5_enable_bcsp_mode(), and hci_transport_h5_open().
|
static |
Referenced by hci_transport_h5_instance().
|
static |
Referenced by hci_transport_h5_block_received().
|
static |
|
static |
H5 Interface.
Referenced by hci_transport_h5_block_received(), and hci_transport_h5_read_next_byte().
|
static |
|
static |
|
static |
Referenced by hci_transport_h5_process_frame(), and hci_transport_link_send_config().
|
static |
Referenced by hci_transport_h5_process_frame().
|
static |
Referenced by hci_transport_h5_process_frame(), and hci_transport_link_send_config_response().
|
static |
Referenced by hci_transport_link_send_config_response_empty().
|
static |
Referenced by hci_transport_h5_process_frame().
|
static |
Referenced by hci_transport_h5_process_frame(), and hci_transport_link_send_sleep().
|
static |
Referenced by hci_transport_h5_process_frame(), and hci_transport_link_send_sync().
|
static |
Referenced by hci_transport_h5_process_frame(), and hci_transport_link_send_sync_response().
|
static |
Referenced by hci_transport_h5_process_frame(), and hci_transport_link_send_wakeup().
|
static |
Referenced by hci_transport_h5_process_frame(), and hci_transport_link_send_woken().
|
static |
Referenced by hci_transport_h5_set_auto_sleep(), and hci_transport_inactivity_timer_set().
|
static |
|
static |
|
static |
|
static |
Referenced by hci_transport_h5_process_frame(), and hci_transport_link_send_queued_packet().
|
static |
|
static |
|
static |
|
static |
Referenced by hci_transport_slip_encode_chunk_and_send(), and hci_transport_slip_send_frame().
|
static |
Referenced by hci_transport_slip_encode_chunk_and_send(), and hci_transport_slip_send_frame().
|
static |
Referenced by hci_transport_slip_encode_chunk_and_send(), and hci_transport_slip_send_frame().
|
static |
|
static |