1
0
Fork 0

Fixes bad state transition logic to active

This commit is contained in:
Shawn Nock 2019-07-16 15:39:30 -04:00
parent 3cede6be0f
commit e0854ae1c9
1 changed files with 15 additions and 8 deletions

View File

@ -705,6 +705,10 @@ void gpio_init() {
} }
static linkstate_t do_uninit(struct net_buf const *buf) { 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)) { if (packet_is_sync_response(buf)) {
h5_send_config(); h5_send_config();
LOG_DBG("RX'd SYNC RESPONSE: UNINIT -> INIT"); 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); LOG_DBG("Finished H5 configuration, tx_win %u: INIT -> ACTIVE", h5.tx_win);
return ACTIVE; return ACTIVE;
} }
if (packet_is_sync(buf)) {
LOG_DBG("RX'd SYNC: INIT -> INIT");
h5_send_sync_response();
}
if (packet_is_config(buf)) { if (packet_is_config(buf)) {
LOG_DBG("RX'd CONFIG: INIT -> INIT"); LOG_DBG("RX'd CONFIG: INIT -> INIT");
h5_send_config_response(); 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) { 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"); LOG_DBG("Bad packet for ACTIVE state: ACTIVE -> UNINIT");
h5_send_sync(); h5_send_sync();
return UNINIT; return UNINIT;
}
if (packet_is_sync(buf)){
LOG_DBG("SYNC in ACTIVE state: ACTIVE -> UNINIT");
return UNINIT;
} }
if (packet_is_config(buf)) { if (packet_is_config(buf)) {
@ -772,13 +786,6 @@ void main(void)
while (true) { while (true) {
buf = net_buf_get(&h5.host_queue, K_FOREVER); 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) { switch (h5.link_state) {
case UNINIT: case UNINIT:
h5.link_state = do_uninit(buf); h5.link_state = do_uninit(buf);