mirror of
https://github.com/SemvdH/OBD2-car-display.git
synced 2025-12-16 12:41:05 +00:00
add getting state string from bt driver
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "wiring_digital.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "obd2_bt.h"
|
||||
|
||||
void obd2_bt_init(obd2_bt_t *bt)
|
||||
@@ -6,6 +7,34 @@ void obd2_bt_init(obd2_bt_t *bt)
|
||||
bt->state = BT_INITIALISING;
|
||||
}
|
||||
|
||||
void obd2_bt_get_state(obd2_bt_t *bt, char *state)
|
||||
{
|
||||
// char bt_states[3][13] = {"Initializing", "Connecting ", "Connected "};
|
||||
// char bt_states;
|
||||
// (void) bt_states;
|
||||
|
||||
if (sizeof(state) != BT_STATE_LENGTH)
|
||||
{
|
||||
/* result string must be of size 13 */
|
||||
return;
|
||||
}
|
||||
switch (bt->state)
|
||||
{
|
||||
case BT_INITIALISING:
|
||||
strcpy(state, "Initializing");
|
||||
break;
|
||||
case BT_CONNECTING:
|
||||
strcpy(state, "Connecting ");
|
||||
break;
|
||||
case BT_CONNECTED:
|
||||
strcpy(state, "Connected ");
|
||||
break;
|
||||
default:
|
||||
strcpy(state, "Unknown ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void obd2_bt_process(obd2_bt_t *bt)
|
||||
{
|
||||
__UINT32_TYPE__ bt_state = digitalRead(BT_STATE_PIN);
|
||||
|
||||
Reference in New Issue
Block a user