Skip to content

Commit

Permalink
Confirm relay commands
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewturner committed Oct 25, 2023
1 parent ee62475 commit 7f605ac
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
4 changes: 4 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ board = uno
framework = arduino
monitor_filters = time, default
monitor_speed = 115200
build_flags =
-D EVENTUALLY_MAX_COMMANDS=5
-D EVENTUALLY_COMMAND_BUFFER_LENGTH=14
-D EVENTUALLY_DATA_BUFFER_LENGTH=10
lib_deps =
matthewturner/Eventually2@^2.0
matthewturner/EventuallyCommand@^0.4.0
Expand Down
32 changes: 17 additions & 15 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ void setup()
{
Serial.begin(115200);

pinMode(BT_RECEIVE_PIN, INPUT);
pinMode(BT_TRANSMIT_PIN, OUTPUT);
bluetoothSerial.begin(9600);
// pinMode(BT_RECEIVE_PIN, INPUT);
// pinMode(BT_TRANSMIT_PIN, OUTPUT);
// bluetoothSerial.begin(9600);

pinMode(WIFI_RECEIVE_PIN, INPUT);
pinMode(WIFI_TRANSMIT_PIN, OUTPUT);
wifiSerial.begin(115200);
wifiSerial.begin(9600);

pinMode(SHOW_PIN, INPUT_PULLUP);

Expand All @@ -24,14 +24,14 @@ void setup()

stateMachine.whenInterrupted(IDLE, SENDING);

bluetoothCommandListener.when("set", (EvtCommandAction)relaySet);
bluetoothCommandListener.when("set-schedule", (EvtCommandAction)relaySetSchedule);
bluetoothCommandListener.when("request-sync", (EvtCommandAction)relayRequestSync);

wifiCommandListener.when("request-sync", (EvtCommandAction)relayRequestSync);
wifiCommandListener.when("set-schedule", (EvtCommandAction)relaySetSchedule);
wifiCommandListener.when("set", (EvtCommandAction)relaySet);

mgr.addListener(&stateMachine);
mgr.addListener(&bluetoothCommandListener);
// mgr.addListener(&bluetoothCommandListener);
mgr.addListener(&wifiCommandListener);
mgr.addListener(&stateMachine);

attachInterrupt(digitalPinToInterrupt(SHOW_PIN), onInterrupt, FALLING);

Expand Down Expand Up @@ -69,9 +69,9 @@ bool relaySet(IEvtListener *, IEvtContext *, long data)
{
Serial.println(F("Relaying set command..."));

bluetoothSerial.print(F(">set:"));
bluetoothSerial.print(data);
bluetoothSerial.println(F("!"));
// bluetoothSerial.print(F(">set:"));
// bluetoothSerial.print(data);
// bluetoothSerial.println(F("!"));

return true;
}
Expand All @@ -80,9 +80,11 @@ bool relaySetSchedule(IEvtListener *, IEvtContext *, long data)
{
Serial.println(F("Relaying set-schedule command..."));

bluetoothSerial.print(F(">set-schedule:"));
bluetoothSerial.print(data);
bluetoothSerial.println(F("!"));
// bluetoothSerial.print(F(">set-schedule:"));
// bluetoothSerial.print(data);
// bluetoothSerial.println(F("!"));

return true;
}

void loop()
Expand Down

0 comments on commit 7f605ac

Please sign in to comment.