mirror of
https://github.com/SemvdH/OBD2-car-display.git
synced 2025-12-14 19:51:04 +00:00
improve handling of when to process bluetooth state change and add TODO for reading OBD2 data
This commit is contained in:
@@ -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();
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user