Fixes bad state transition logic to active
This commit is contained in:
parent
3cede6be0f
commit
e0854ae1c9
23
src/main.c
23
src/main.c
|
@ -705,6 +705,10 @@ void gpio_init() {
|
|||
}
|
||||
|
||||
static linkstate_t do_uninit(struct net_buf const *buf) {
|
||||
if (packet_is_sync(buf)) {
|
||||
h5_send_sync_response();
|
||||
return UNINIT;
|
||||
}
|
||||
if (packet_is_sync_response(buf)) {
|
||||
h5_send_config();
|
||||
LOG_DBG("RX'd SYNC RESPONSE: UNINIT -> INIT");
|
||||
|
@ -725,6 +729,12 @@ static linkstate_t do_init(struct net_buf const *buf) {
|
|||
LOG_DBG("Finished H5 configuration, tx_win %u: INIT -> ACTIVE", h5.tx_win);
|
||||
return ACTIVE;
|
||||
}
|
||||
|
||||
if (packet_is_sync(buf)) {
|
||||
LOG_DBG("RX'd SYNC: INIT -> INIT");
|
||||
h5_send_sync_response();
|
||||
}
|
||||
|
||||
if (packet_is_config(buf)) {
|
||||
LOG_DBG("RX'd CONFIG: INIT -> INIT");
|
||||
h5_send_config_response();
|
||||
|
@ -735,11 +745,15 @@ static linkstate_t do_init(struct net_buf const *buf) {
|
|||
}
|
||||
|
||||
static linkstate_t do_active(struct net_buf *buf) {
|
||||
if (packet_is_sync_response(buf) || packet_is_config(buf)) {
|
||||
if (packet_is_sync_response(buf)) {
|
||||
LOG_DBG("Bad packet for ACTIVE state: ACTIVE -> UNINIT");
|
||||
h5_send_sync();
|
||||
return UNINIT;
|
||||
}
|
||||
|
||||
if (packet_is_sync(buf)){
|
||||
LOG_DBG("SYNC in ACTIVE state: ACTIVE -> UNINIT");
|
||||
return UNINIT;
|
||||
}
|
||||
|
||||
if (packet_is_config(buf)) {
|
||||
|
@ -772,13 +786,6 @@ void main(void)
|
|||
while (true) {
|
||||
buf = net_buf_get(&h5.host_queue, K_FOREVER);
|
||||
|
||||
if (packet_is_sync(buf)) {
|
||||
LOG_DBG("RX'd SYNC: %d -> UNINIT", h5.link_state);
|
||||
h5.link_state = UNINIT;
|
||||
h5_send_sync_response();
|
||||
goto next;
|
||||
}
|
||||
|
||||
switch (h5.link_state) {
|
||||
case UNINIT:
|
||||
h5.link_state = do_uninit(buf);
|
||||
|
|
Loading…
Reference in New Issue