From 7b2f72db638d5a5ce26aa1bc1a5c3f785fe4cf4f Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 7 May 2015 17:34:14 +0200 Subject: [PATCH] add instructions on HCI logging --- docs/manual/markdown/docs/how_to.md | 33 ++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/docs/manual/markdown/docs/how_to.md b/docs/manual/markdown/docs/how_to.md index 4fa8c01e9..a0b442271 100644 --- a/docs/manual/markdown/docs/how_to.md +++ b/docs/manual/markdown/docs/how_to.md @@ -273,4 +273,35 @@ data registered by *l2cap_create_channel_internal*; after that keyboard can reconnect by itself. For this, you need to register L2CAP services for the HID Control and HID Interrupt PSMs using *l2cap_register_service_internal*. In this call, you’ll also specify -a packet handler to accept and receive keyboard data. \ No newline at end of file +a packet handler to accept and receive keyboard data. + + +Bluetooth HCI Packet Logs +------------------------- + +If things don't work as expected, having a look at the data exchanged +between BTstack and the Bluetooth chipset often helps. + +For this, BTstack provides a configurable packet logging mechanism via hci_dump.h: + + // formats: HCI_DUMP_BLUEZ, HCI_DUMP_PACKETLOGGER, HCI_DUMP_STDOUT + void hci_dump_open(const char *filename, hci_dump_format_t format); + +On POSIX systems, you can call hci_dump_open with a path and HCI_DUMP_BLUEZ +or HCI_DUMP_PACKETLOGGER in the setup, i.e., before entering the run loop. +The resulting file can be analyzed with Wireshark +or the Apple's PacketLogger tool. + +On embedded systems without a file system, you still can call hci_dump_open(NULL, HCI_DUMP_STDOUT). +It will log all HCI packets to the consolve via printf. +If you capture the console output, incl. your own debug messages, you can use +the create_packet_log.py tool in the tools folder to convert a text output into a +PacketLogger file. + +In addition to the HCI packets, you can also enable BTstack's debug information by adding + + #define ENABLE_LOG_INFO + #define ENABLE_LOG_ERROR + +to the btstack-config.h and recompiling your application. +