mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-21 03:40:47 +00:00
removed packet logging functionality (hci_dump, hexdump) from hci transport implementations and use hci_dump in hci.c instead
This commit is contained in:
parent
1c1afe6ed3
commit
5bb5bc3ed8
@ -81,7 +81,6 @@
|
||||
#include "debug.h"
|
||||
#include "hci.h"
|
||||
#include "hci_transport.h"
|
||||
#include "hci_dump.h"
|
||||
|
||||
static int h4_process(struct data_source *ds);
|
||||
static void dummy_handler(uint8_t packet_type, uint8_t *packet, uint16_t size);
|
||||
@ -252,7 +251,6 @@ static int h4_send_packet(uint8_t packet_type, uint8_t * packet, int size){
|
||||
// wake Bluetooth module
|
||||
h4_enforce_wake_on();
|
||||
|
||||
hci_dump_packet( (uint8_t) packet_type, 0, packet, size);
|
||||
char *data = (char*) packet;
|
||||
int bytes_written = write(hci_transport_h4->uart_fd, &packet_type, 1);
|
||||
while (bytes_written < 1) {
|
||||
@ -277,7 +275,6 @@ static void h4_register_packet_handler(void (*handler)(uint8_t packet_type, ui
|
||||
|
||||
static void h4_deliver_packet(void){
|
||||
if (read_pos < 3) return; // sanity check
|
||||
hci_dump_packet( hci_packet[0], 1, &hci_packet[1], read_pos-1);
|
||||
packet_handler(hci_packet[0], &hci_packet[1], read_pos-1);
|
||||
|
||||
h4_state = H4_W4_PACKET_TYPE;
|
||||
@ -324,19 +321,13 @@ static int h4_process(struct data_source *ds) {
|
||||
if (hci_transport_h4->uart_fd == 0) return -1;
|
||||
|
||||
int read_now = bytes_to_read;
|
||||
// if (read_now > 100) {
|
||||
// read_now = 100;
|
||||
// }
|
||||
|
||||
// read up to bytes_to_read data in
|
||||
ssize_t bytes_read = read(hci_transport_h4->uart_fd, &hci_packet[read_pos], read_now);
|
||||
// printf("h4_process: bytes read %u\n", bytes_read);
|
||||
if (bytes_read < 0) {
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
// hexdump(&hci_packet[read_pos], bytes_read);
|
||||
|
||||
|
||||
bytes_to_read -= bytes_read;
|
||||
read_pos += bytes_read;
|
||||
if (bytes_to_read > 0) {
|
||||
|
@ -61,7 +61,6 @@
|
||||
#include "debug.h"
|
||||
#include "hci.h"
|
||||
#include "hci_transport.h"
|
||||
#include "hci_dump.h"
|
||||
|
||||
#if (USB_VENDOR_ID != 0) && (USB_PRODUCT_ID != 0)
|
||||
#define HAVE_USB_VENDOR_ID_AND_PRODUCT_ID
|
||||
@ -265,19 +264,13 @@ static void handle_completed_transfer(struct libusb_transfer *transfer){
|
||||
int resubmit = 0;
|
||||
|
||||
if (transfer->endpoint == event_in_addr) {
|
||||
hci_dump_packet( HCI_EVENT_PACKET, 1, transfer-> buffer,
|
||||
transfer->actual_length);
|
||||
packet_handler(HCI_EVENT_PACKET, transfer-> buffer,
|
||||
transfer->actual_length);
|
||||
packet_handler(HCI_EVENT_PACKET, transfer-> buffer, transfer->actual_length);
|
||||
resubmit = 1;
|
||||
}
|
||||
|
||||
else if (transfer->endpoint == acl_in_addr) {
|
||||
// log_info("-> acl");
|
||||
hci_dump_packet( HCI_ACL_DATA_PACKET, 1, transfer-> buffer,
|
||||
transfer->actual_length);
|
||||
packet_handler(HCI_ACL_DATA_PACKET, transfer-> buffer,
|
||||
transfer->actual_length);
|
||||
packet_handler(HCI_ACL_DATA_PACKET, transfer-> buffer, transfer->actual_length);
|
||||
|
||||
resubmit = 1;
|
||||
} else if (transfer->endpoint == acl_out_addr){
|
||||
@ -662,8 +655,6 @@ static int usb_send_cmd_packet(uint8_t *packet, int size){
|
||||
return -1;
|
||||
}
|
||||
|
||||
hci_dump_packet( HCI_COMMAND_DATA_PACKET, 0, packet, size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -690,10 +681,6 @@ static int usb_send_acl_packet(uint8_t *packet, int size){
|
||||
return -1;
|
||||
}
|
||||
|
||||
hci_dump_packet( HCI_ACL_DATA_PACKET, 0, packet, size);
|
||||
|
||||
// log_info("usb_send_acl_packet exit");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,6 @@
|
||||
#include "debug.h"
|
||||
#include "hci.h"
|
||||
#include "hci_transport.h"
|
||||
#include "hci_dump.h"
|
||||
|
||||
static int h4_process(struct data_source *ds);
|
||||
static void dummy_handler(uint8_t packet_type, uint8_t *packet, uint16_t size);
|
||||
@ -188,7 +187,6 @@ static int h4_send_packet(uint8_t packet_type, uint8_t * packet, int size){
|
||||
if (hci_transport_h4->ds == NULL) return -1;
|
||||
if (hci_transport_h4->uart_fd == 0) return -1;
|
||||
|
||||
hci_dump_packet( (uint8_t) packet_type, 0, packet, size);
|
||||
char *data = (char*) packet;
|
||||
int bytes_written = write(hci_transport_h4->uart_fd, &packet_type, 1);
|
||||
while (bytes_written < 1) {
|
||||
@ -213,7 +211,6 @@ static void h4_register_packet_handler(void (*handler)(uint8_t packet_type, ui
|
||||
|
||||
static void h4_deliver_packet(void){
|
||||
if (read_pos < 3) return; // sanity check
|
||||
hci_dump_packet( hci_packet[0], 1, &hci_packet[1], read_pos-1);
|
||||
packet_handler(hci_packet[0], &hci_packet[1], read_pos-1);
|
||||
|
||||
h4_state = H4_W4_PACKET_TYPE;
|
||||
@ -268,8 +265,6 @@ static int h4_process(struct data_source *ds) {
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
// hexdump(&hci_packet[read_pos], bytes_read);
|
||||
|
||||
bytes_to_read -= bytes_read;
|
||||
read_pos += bytes_read;
|
||||
if (bytes_to_read > 0) {
|
||||
|
@ -475,7 +475,7 @@ static int hci_send_acl_packet_fragments(hci_connection_t *connection){
|
||||
// send packet
|
||||
uint8_t * packet = &hci_stack->hci_packet_buffer[acl_header_pos];
|
||||
const int size = current_acl_data_packet_length + 4;
|
||||
// hexdump(packet, size);
|
||||
hci_dump_packet(HCI_ACL_DATA_PACKET, 0, packet, size);
|
||||
err = hci_stack->hci_transport->send_packet(HCI_ACL_DATA_PACKET, packet, size);
|
||||
|
||||
// done yet?
|
||||
@ -818,6 +818,7 @@ static void hci_initializing_state_machine(){
|
||||
case 1: // SEND BAUD CHANGE
|
||||
hci_stack->control->baudrate_cmd(hci_stack->config, ((hci_uart_config_t *)hci_stack->config)->baudrate_main, hci_stack->hci_packet_buffer);
|
||||
hci_stack->last_cmd_opcode = READ_BT_16(hci_stack->hci_packet_buffer, 0);
|
||||
hci_dump_packet(HCI_COMMAND_DATA_PACKET, 0, hci_stack->hci_packet_buffer, 3 + hci_stack->hci_packet_buffer[2]);
|
||||
hci_send_cmd_packet(hci_stack->hci_packet_buffer, 3 + hci_stack->hci_packet_buffer[2]);
|
||||
break;
|
||||
case 2: // LOCAL BAUD CHANGE
|
||||
@ -834,6 +835,7 @@ static void hci_initializing_state_machine(){
|
||||
if (valid_cmd){
|
||||
int size = 3 + hci_stack->hci_packet_buffer[2];
|
||||
hci_stack->last_cmd_opcode = READ_BT_16(hci_stack->hci_packet_buffer, 0);
|
||||
hci_dump_packet(HCI_COMMAND_DATA_PACKET, 0, hci_stack->hci_packet_buffer, size);
|
||||
hci_stack->hci_transport->send_packet(HCI_COMMAND_DATA_PACKET, hci_stack->hci_packet_buffer, size);
|
||||
hci_stack->substate = 4; // more init commands
|
||||
break;
|
||||
@ -1379,6 +1381,7 @@ static void event_handler(uint8_t *packet, int size){
|
||||
}
|
||||
|
||||
static void packet_handler(uint8_t packet_type, uint8_t *packet, uint16_t size){
|
||||
hci_dump_packet(packet_type, 1, packet, size);
|
||||
switch (packet_type) {
|
||||
case HCI_EVENT_PACKET:
|
||||
event_handler(packet, size);
|
||||
@ -2169,6 +2172,8 @@ int hci_send_cmd_packet(uint8_t *packet, int size){
|
||||
#endif
|
||||
|
||||
hci_stack->num_cmd_packets--;
|
||||
|
||||
hci_dump_packet(HCI_COMMAND_DATA_PACKET, 0, packet, size);
|
||||
int err = hci_stack->hci_transport->send_packet(HCI_COMMAND_DATA_PACKET, packet, size);
|
||||
|
||||
// free packet buffer for synchronous transport implementations
|
||||
|
@ -47,7 +47,6 @@
|
||||
|
||||
#include "debug.h"
|
||||
#include "hci.h"
|
||||
#include "hci_dump.h"
|
||||
#include "hci_transport.h"
|
||||
#include <btstack/run_loop.h>
|
||||
|
||||
@ -239,18 +238,6 @@ static void h4_register_packet_handler(void (*handler)(uint8_t packet_type, uint
|
||||
packet_handler = handler;
|
||||
}
|
||||
|
||||
// #define DUMP
|
||||
|
||||
#ifdef DUMP
|
||||
static void dump(uint8_t *data, uint16_t len){
|
||||
int i;
|
||||
for (i=0; i<len;i++){
|
||||
printf("%02X ", ((uint8_t *)data)[i]);
|
||||
}
|
||||
printf("\n\r");
|
||||
}
|
||||
#endif
|
||||
|
||||
static int h4_process(struct data_source *ds) {
|
||||
|
||||
// notify about packet sent
|
||||
@ -262,19 +249,7 @@ static int h4_process(struct data_source *ds) {
|
||||
}
|
||||
|
||||
if (h4_state != H4_PACKET_RECEIVED) return 0;
|
||||
|
||||
// log packet
|
||||
#ifdef DUMP
|
||||
printf("RX: ");
|
||||
dump(hci_packet, read_pos);
|
||||
#endif
|
||||
|
||||
if (hci_packet[0] == HCI_EVENT_PACKET){
|
||||
hci_dump_packet( HCI_EVENT_PACKET, 0, &hci_packet[1], read_pos-1);
|
||||
}
|
||||
if (hci_packet[0] == HCI_ACL_DATA_PACKET){
|
||||
hci_dump_packet( HCI_ACL_DATA_PACKET, 1, &hci_packet[1], read_pos-1);
|
||||
}
|
||||
|
||||
packet_handler(hci_packet[0], &hci_packet[1], read_pos-1);
|
||||
|
||||
h4_init_sm();
|
||||
@ -290,18 +265,6 @@ static int h4_send_packet(uint8_t packet_type, uint8_t *packet, int size){
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef DUMP
|
||||
printf("TX: %02x ", packet_type);
|
||||
dump(packet, size);
|
||||
#endif
|
||||
|
||||
if (packet_type == HCI_COMMAND_DATA_PACKET){
|
||||
hci_dump_packet( HCI_COMMAND_DATA_PACKET, 0, packet, size);
|
||||
}
|
||||
if (packet_type == HCI_ACL_DATA_PACKET){
|
||||
hci_dump_packet( HCI_ACL_DATA_PACKET, 0, packet, size);
|
||||
}
|
||||
|
||||
tx_packet_type = packet_type;
|
||||
tx_data = packet;
|
||||
tx_len = size;
|
||||
|
@ -52,7 +52,6 @@
|
||||
|
||||
#include "debug.h"
|
||||
#include "hci.h"
|
||||
#include "hci_dump.h"
|
||||
#include "hci_transport.h"
|
||||
#include <btstack/run_loop.h>
|
||||
|
||||
@ -62,7 +61,6 @@
|
||||
// #define GPIO_DEBUG_0 GPIO1
|
||||
// #define GPIO_DEBUG_1 GPIO2
|
||||
|
||||
// #define DUMP
|
||||
// #define LOG_EHCILL
|
||||
|
||||
// eHCILL commands (+interal CTS signal)
|
||||
@ -360,20 +358,6 @@ static void h4_block_sent(void){
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DUMP
|
||||
static void dump(uint8_t *data, uint16_t len){
|
||||
int i;
|
||||
for (i=0; i<len;i++){
|
||||
printf("%02X ", ((uint8_t *)data)[i]);
|
||||
if(i>30) {
|
||||
printf("... %u more bytes", len - i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
static int h4_process(struct data_source *ds) {
|
||||
|
||||
// notify about packet sent
|
||||
@ -389,19 +373,7 @@ static int h4_process(struct data_source *ds) {
|
||||
}
|
||||
|
||||
if (h4_state != H4_PACKET_RECEIVED) return 0;
|
||||
|
||||
// log packet
|
||||
#ifdef DUMP
|
||||
printf("RX: ");
|
||||
dump(hci_packet, read_pos);
|
||||
#endif
|
||||
|
||||
if (hci_packet[0] == HCI_EVENT_PACKET){
|
||||
hci_dump_packet( HCI_EVENT_PACKET, 0, &hci_packet[1], read_pos-1);
|
||||
}
|
||||
if (hci_packet[0] == HCI_ACL_DATA_PACKET){
|
||||
hci_dump_packet( HCI_ACL_DATA_PACKET, 1, &hci_packet[1], read_pos-1);
|
||||
}
|
||||
|
||||
packet_handler(hci_packet[0], &hci_packet[1], read_pos-1);
|
||||
|
||||
h4_rx_init_sm();
|
||||
@ -528,18 +500,6 @@ static int ehcill_send_packet(uint8_t packet_type, uint8_t *packet, int size){
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef DUMP
|
||||
printf("TX: %02x ", packet_type);
|
||||
dump(packet, size);
|
||||
#endif
|
||||
|
||||
if (packet_type == HCI_COMMAND_DATA_PACKET){
|
||||
hci_dump_packet( HCI_COMMAND_DATA_PACKET, 0, packet, size);
|
||||
}
|
||||
if (packet_type == HCI_ACL_DATA_PACKET){
|
||||
hci_dump_packet( HCI_ACL_DATA_PACKET, 1, packet, size);
|
||||
}
|
||||
|
||||
tx_packet_type = packet_type;
|
||||
tx_data = packet;
|
||||
tx_len = size;
|
||||
|
@ -50,8 +50,6 @@
|
||||
|
||||
#include "hci.h"
|
||||
#include "hci_transport.h"
|
||||
#include "hci_dump.h"
|
||||
|
||||
|
||||
typedef struct hci_transport_h5 {
|
||||
hci_transport_t transport;
|
||||
@ -177,8 +175,6 @@ static int h5_send_packet(uint8_t packet_type, uint8_t *packet, int size){
|
||||
if (hci_transport_h5->ds == NULL) return -1;
|
||||
if (hci_transport_h5->ds->fd == 0) return -1;
|
||||
char *data = (char*) packet;
|
||||
|
||||
hci_dump_packet( (uint8_t) packet_type, 0, packet, size);
|
||||
|
||||
write(hci_transport_h5->ds->fd, &packet_type, 1);
|
||||
while (size > 0) {
|
||||
@ -232,7 +228,6 @@ static void h5_slip_process( h5_slip_t * sm, uint8_t input, uint8_t in){
|
||||
if (sm->length < 6) break;
|
||||
type = sm->data[1] & 0x0f;
|
||||
if (type < 1 || type > 4) break;
|
||||
hci_dump_packet( type, in, &sm->data[4], sm->length-4-2); // -4 header, -2 crc for reliable
|
||||
switch (type) {
|
||||
case HCI_ACL_DATA_PACKET:
|
||||
acl_packet_handler( &sm->data[4], sm->length-4-2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user