mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-26 12:35:25 +00:00
better debug output for le connections
This commit is contained in:
parent
252bfddcb7
commit
1f479f8c7c
@ -9,7 +9,7 @@ ARCHS = armv6 arm64
|
||||
LIBRARY_NAME = libBTstack
|
||||
libBTstack_FILES = btstack.c hci_cmds.c linked_list.c
|
||||
libBTstack_FILES += run_loop.c run_loop_cocoa.m run_loop_posix.c sdp_util.c socket_connection.c utils.c
|
||||
libBTstack_CFLAGS = -I../include -I../ble -I../src -I..
|
||||
libBTstack_CFLAGS = -I../include -I../ble -I../src -I..
|
||||
|
||||
TOOL_NAME = BTdaemon
|
||||
BTdaemon_FILES = $(libBTstack_FILES) \
|
||||
@ -33,7 +33,7 @@ BTdaemon_FILES = $(libBTstack_FILES) \
|
||||
sdp_query_rfcomm.c \
|
||||
sdp_query_util.c \
|
||||
../SpringBoardAccess/SpringBoardAccess.c
|
||||
BTdaemon_CFLAGS = -I../include -I..
|
||||
BTdaemon_CFLAGS = -I../include -I../ble -I../src -I..
|
||||
BTdaemon_LDFLAGS += $(SYSROOT)/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
|
||||
|
||||
after-BTdaemon-stage::
|
||||
|
@ -346,6 +346,9 @@ static int btstack_command_handler(connection_t *connection, uint8_t *packet, ui
|
||||
uint16_t serviceSearchPatternLen;
|
||||
uint16_t attributeIDListLen;
|
||||
|
||||
// verbose log info before other info to allow for better tracking
|
||||
hci_dump_packet( HCI_COMMAND_DATA_PACKET, 1, packet, size);
|
||||
|
||||
// BTstack internal commands - 16 Bit OpCode, 8 Bit ParamLen, Params...
|
||||
switch (READ_CMD_OCF(packet)){
|
||||
case BTSTACK_GET_STATE:
|
||||
@ -701,9 +704,6 @@ static int btstack_command_handler(connection_t *connection, uint8_t *packet, ui
|
||||
break;
|
||||
}
|
||||
|
||||
// verbose log info on command before dumped command unknown to PacketLogger or Wireshark
|
||||
hci_dump_packet( HCI_COMMAND_DATA_PACKET, 1, packet, size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
12
src/hci.c
12
src/hci.c
@ -418,7 +418,7 @@ static void acl_handler(uint8_t *packet, int size){
|
||||
}
|
||||
|
||||
static void hci_shutdown_connection(hci_connection_t *conn){
|
||||
log_info("Connection closed: handle %u, %s\n", conn->con_handle, bd_addr_to_str(conn->address));
|
||||
log_info("Connection closed: handle 0x%x, %s\n", conn->con_handle, bd_addr_to_str(conn->address));
|
||||
|
||||
run_loop_remove_timer(&conn->timeout);
|
||||
|
||||
@ -1593,11 +1593,13 @@ void hci_run(){
|
||||
hci_send_cmd_packet(hci_stack->hci_packet_buffer, 3 + hci_stack->hci_packet_buffer[2]);
|
||||
break;
|
||||
case 2: // LOCAL BAUD CHANGE
|
||||
log_info("Local baud rate change");
|
||||
hci_stack->hci_transport->set_baudrate(((hci_uart_config_t *)hci_stack->config)->baudrate_main);
|
||||
hci_stack->substate += 2;
|
||||
// break missing here for fall through
|
||||
|
||||
case 3:
|
||||
log_info("Custom init");
|
||||
// Custom initialization
|
||||
if (hci_stack->control && hci_stack->control->next_cmd){
|
||||
int valid_cmd = (*hci_stack->control->next_cmd)(hci_stack->config, hci_stack->hci_packet_buffer);
|
||||
@ -2244,16 +2246,17 @@ void le_central_set_scan_parameters(uint8_t scan_type, uint16_t scan_interval, u
|
||||
|
||||
le_command_status_t le_central_connect(bd_addr_t * addr, bd_addr_type_t addr_type){
|
||||
hci_connection_t * conn = hci_connection_for_bd_addr_and_type(addr, addr_type);
|
||||
log_info("le_central_connect, conn struct %p", conn);
|
||||
if (!conn){
|
||||
log_info("le_central_connect: no connection exists yet, creating context");
|
||||
conn = create_connection_for_bd_addr_and_type(*addr, addr_type);
|
||||
if (!conn){
|
||||
// notify client that alloc failed
|
||||
hci_emit_le_connection_complete(conn, BTSTACK_MEMORY_ALLOC_FAILED);
|
||||
log_info("le_central_connect: failed to alloc context");
|
||||
return BLE_PERIPHERAL_NOT_CONNECTED; // don't sent packet to controller
|
||||
}
|
||||
conn->state = SEND_CREATE_CONNECTION;
|
||||
log_info("le_central_connect, state %u", conn->state);
|
||||
log_info("le_central_connect: send create connection next");
|
||||
hci_run();
|
||||
return BLE_PERIPHERAL_OK;
|
||||
}
|
||||
@ -2262,10 +2265,11 @@ le_command_status_t le_central_connect(bd_addr_t * addr, bd_addr_type_t addr_typ
|
||||
conn->state == SEND_CREATE_CONNECTION ||
|
||||
conn->state == SENT_CREATE_CONNECTION) {
|
||||
hci_emit_le_connection_complete(conn, ERROR_CODE_COMMAND_DISALLOWED);
|
||||
log_error("le_central_connect: classic connection or connect is already being created");
|
||||
return BLE_PERIPHERAL_IN_WRONG_STATE;
|
||||
}
|
||||
|
||||
log_info("le_central_connect, state %u", conn->state);
|
||||
log_info("le_central_connect: context exists with state %u", conn->state);
|
||||
hci_emit_le_connection_complete(conn, 0);
|
||||
hci_run();
|
||||
return BLE_PERIPHERAL_OK;
|
||||
|
Loading…
x
Reference in New Issue
Block a user