From 6e241ea8c14329356ecec2a8f319be7fdddd92f6 Mon Sep 17 00:00:00 2001 From: Shawn Nock Date: Thu, 18 Jul 2019 14:16:18 -0400 Subject: [PATCH] Delegate all SYNC/CONFIG link pkts to tx_thread; log incoming headers --- src/main.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/main.c b/src/main.c index e774b58..2a00846 100644 --- a/src/main.c +++ b/src/main.c @@ -227,21 +227,23 @@ static void process_unack(void) number_removed--; } } + */ -static void h5_print_header(const u8_t *hdr, const char *str) +static void h5_print_header(h5_hdr_t *hdr, const char *str) { - if (H5_HDR_RELIABLE(hdr)) { + char const *label = str ? str : ""; + if (hdr->is_reliable) { LOG_DBG("%s REL: seq %u ack %u crc %u type %u len %u", - str, H5_HDR_SEQ(hdr), H5_HDR_ACK(hdr), - H5_HDR_CRC(hdr), H5_HDR_PKT_TYPE(hdr), - H5_HDR_LEN(hdr)); + label, hdr->seq, hdr->ack, + hdr->checksum, hdr->packet_type, + hdr->len); } else { LOG_DBG("%s UNREL: ack %u crc %u type %u len %u", - str, H5_HDR_ACK(hdr), H5_HDR_CRC(hdr), - H5_HDR_PKT_TYPE(hdr), H5_HDR_LEN(hdr)); + label, hdr->ack, hdr->checksum, + hdr->packet_type, hdr->len); } } -*/ + static u8_t h5_slip_byte(u8_t byte) { @@ -523,11 +525,14 @@ static void unproc_thread(void) { buf = net_buf_get(&h5.unprocessed_queue, K_FOREVER); h5_hdr_t hdr = {0}; - if (pull_header1(buf, &hdr) < 0) { - // Header is invalid + int r; + if ((r = pull_header1(buf, &hdr) < 0)) { + LOG_WRN("Bad h5 header: %d", r); goto next; } + h5_print_header(&hdr, "unproc_thread"); + struct net_buf *rx_buf = NULL; if (h5.link_state < ACTIVE && hdr.packet_type != HCI_3WIRE_LINK_PKT) { @@ -822,13 +827,13 @@ static linkstate_t do_uninit(struct net_buf const *buf) { h5_send_sync_response(); return UNINIT; case H5_SYNC_RESPONSE: - h5_send_config(); + //h5_send_config(); LOG_DBG("RX'd SYNC RESPONSE: UNINIT -> INIT"); return INIT; default: LOG_DBG("RX'd Incorrect Type: UNINIT -> UNINIT"); /* SYNC is the answer to any non-SYNC_RESP packets in UNINIT state */ - h5_send_sync(); + //h5_send_sync(); return UNINIT; } } @@ -859,11 +864,11 @@ static linkstate_t do_active(struct net_buf *buf) { switch (packet_get_type(buf)) { case H5_SYNC: LOG_WRN("SYNC in ACTIVE state, peer reset: ACTIVE -> UNINIT"); - h5_send_sync(); + //h5_send_sync(); return UNINIT; case H5_SYNC_RESPONSE: LOG_DBG("SYNC_RESPONSE in ACTIVE state: ACTIVE -> UNINIT"); - h5_send_sync(); + //h5_send_sync(); return UNINIT; case H5_CONFIG: h5_send_config_response();