1
0
Fork 0

Works around weird initial rules for H5 state machine (initial ack must be 0?)

This commit is contained in:
Shawn Nock 2019-08-02 16:03:45 -04:00
parent 7597c384e8
commit 70c7a8f590
1 changed files with 10 additions and 2 deletions

View File

@ -140,6 +140,7 @@ static struct h5 {
PAYLOAD, PAYLOAD,
END, END,
} rx_state; } rx_state;
bool initializing;
} h5; } h5;
//static u8_t unack_queue_len; //static u8_t unack_queue_len;
@ -547,7 +548,13 @@ static void unproc_thread(void) {
LOG_DBG("Header: seq %d, ack %d, rel: %s, has_crc16: %s", hdr.seq, hdr.ack, LOG_DBG("Header: seq %d, ack %d, rel: %s, has_crc16: %s", hdr.seq, hdr.ack,
hdr.is_reliable ? "true" : "false", hdr.is_reliable ? "true" : "false",
hdr.crc_after_payload ? "true" : "false"); hdr.crc_after_payload ? "true" : "false");
u8_t expected_seq = next_seq(h5.last_seen_seq_from_host); u8_t expected_seq;
if (h5.initializing) {
expected_seq = 0;
h5.initializing = false;
} else {
expected_seq = next_seq(h5.last_seen_seq_from_host);
}
if (hdr.seq != expected_seq) { if (hdr.seq != expected_seq) {
LOG_ERR("Seq expected %u got %u. Drop packet", expected_seq, hdr.seq); LOG_ERR("Seq expected %u got %u. Drop packet", expected_seq, hdr.seq);
goto next; goto next;
@ -882,8 +889,9 @@ static linkstate_t do_init(struct net_buf const *buf) {
return INIT; return INIT;
case H5_CONFIG_RESPONSE: case H5_CONFIG_RESPONSE:
h5.tx_win = conf_rsp[2] & 0x7; h5.tx_win = conf_rsp[2] & 0x7;
h5.last_seen_seq_from_host = 7; h5.last_seen_seq_from_host = 0;
h5.local_seq = 0; h5.local_seq = 0;
h5.initializing = true;
LOG_DBG("Finished H5 configuration, tx_win %u: INIT -> ACTIVE", h5.tx_win); LOG_DBG("Finished H5 configuration, tx_win %u: INIT -> ACTIVE", h5.tx_win);
return ACTIVE; return ACTIVE;
default: default: