improve handling of when to process bluetooth state change and add TODO for reading OBD2 data

This commit is contained in:
Sem van der Hoeven
2024-01-14 13:02:14 +01:00
parent a81322e46d
commit 5c774752ab

View File

@@ -32,19 +32,28 @@ void obd2_bt_get_state(obd2_bt_t *bt, char *state)
default: default:
strcpy(state, "Unknown "); strcpy(state, "Unknown ");
break; break;
} }
} }
void obd2_bt_process(obd2_bt_t *bt) void obd2_bt_process(obd2_bt_t *bt)
{ {
__UINT32_TYPE__ bt_state = digitalRead(BT_STATE_PIN); if (bt->state != BT_CONNECTED)
if (bt_state)
{ {
bt->state = BT_CONNECTED; __UINT32_TYPE__ bt_state = digitalRead(BT_STATE_PIN);
if (bt_state != bt->state)
{
if (bt_state)
{
bt->state = BT_CONNECTED;
}
else
{
bt->state = BT_INITIALISING;
}
bt->on_state_change();
}
} }
else
{ /* TODO read from Serial1 to read OBD2 data */
bt->state = BT_INITIALISING;
}
bt->on_state_change();
} }