Delegate all SYNC/CONFIG link pkts to tx_thread; log incoming headers
This commit is contained in:
parent
8797feba2f
commit
6e241ea8c1
33
src/main.c
33
src/main.c
|
@ -227,21 +227,23 @@ static void process_unack(void)
|
||||||
number_removed--;
|
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",
|
LOG_DBG("%s REL: seq %u ack %u crc %u type %u len %u",
|
||||||
str, H5_HDR_SEQ(hdr), H5_HDR_ACK(hdr),
|
label, hdr->seq, hdr->ack,
|
||||||
H5_HDR_CRC(hdr), H5_HDR_PKT_TYPE(hdr),
|
hdr->checksum, hdr->packet_type,
|
||||||
H5_HDR_LEN(hdr));
|
hdr->len);
|
||||||
} else {
|
} else {
|
||||||
LOG_DBG("%s UNREL: ack %u crc %u type %u len %u",
|
LOG_DBG("%s UNREL: ack %u crc %u type %u len %u",
|
||||||
str, H5_HDR_ACK(hdr), H5_HDR_CRC(hdr),
|
label, hdr->ack, hdr->checksum,
|
||||||
H5_HDR_PKT_TYPE(hdr), H5_HDR_LEN(hdr));
|
hdr->packet_type, hdr->len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
static u8_t h5_slip_byte(u8_t byte)
|
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);
|
buf = net_buf_get(&h5.unprocessed_queue, K_FOREVER);
|
||||||
|
|
||||||
h5_hdr_t hdr = {0};
|
h5_hdr_t hdr = {0};
|
||||||
if (pull_header1(buf, &hdr) < 0) {
|
int r;
|
||||||
// Header is invalid
|
if ((r = pull_header1(buf, &hdr) < 0)) {
|
||||||
|
LOG_WRN("Bad h5 header: %d", r);
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h5_print_header(&hdr, "unproc_thread");
|
||||||
|
|
||||||
struct net_buf *rx_buf = NULL;
|
struct net_buf *rx_buf = NULL;
|
||||||
|
|
||||||
if (h5.link_state < ACTIVE && hdr.packet_type != HCI_3WIRE_LINK_PKT) {
|
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();
|
h5_send_sync_response();
|
||||||
return UNINIT;
|
return UNINIT;
|
||||||
case H5_SYNC_RESPONSE:
|
case H5_SYNC_RESPONSE:
|
||||||
h5_send_config();
|
//h5_send_config();
|
||||||
LOG_DBG("RX'd SYNC RESPONSE: UNINIT -> INIT");
|
LOG_DBG("RX'd SYNC RESPONSE: UNINIT -> INIT");
|
||||||
return INIT;
|
return INIT;
|
||||||
default:
|
default:
|
||||||
LOG_DBG("RX'd Incorrect Type: UNINIT -> UNINIT");
|
LOG_DBG("RX'd Incorrect Type: UNINIT -> UNINIT");
|
||||||
/* SYNC is the answer to any non-SYNC_RESP packets in UNINIT state */
|
/* SYNC is the answer to any non-SYNC_RESP packets in UNINIT state */
|
||||||
h5_send_sync();
|
//h5_send_sync();
|
||||||
return UNINIT;
|
return UNINIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -859,11 +864,11 @@ static linkstate_t do_active(struct net_buf *buf) {
|
||||||
switch (packet_get_type(buf)) {
|
switch (packet_get_type(buf)) {
|
||||||
case H5_SYNC:
|
case H5_SYNC:
|
||||||
LOG_WRN("SYNC in ACTIVE state, peer reset: ACTIVE -> UNINIT");
|
LOG_WRN("SYNC in ACTIVE state, peer reset: ACTIVE -> UNINIT");
|
||||||
h5_send_sync();
|
//h5_send_sync();
|
||||||
return UNINIT;
|
return UNINIT;
|
||||||
case H5_SYNC_RESPONSE:
|
case H5_SYNC_RESPONSE:
|
||||||
LOG_DBG("SYNC_RESPONSE in ACTIVE state: ACTIVE -> UNINIT");
|
LOG_DBG("SYNC_RESPONSE in ACTIVE state: ACTIVE -> UNINIT");
|
||||||
h5_send_sync();
|
//h5_send_sync();
|
||||||
return UNINIT;
|
return UNINIT;
|
||||||
case H5_CONFIG:
|
case H5_CONFIG:
|
||||||
h5_send_config_response();
|
h5_send_config_response();
|
||||||
|
|
Loading…
Reference in New Issue