Skip to content
This repository has been archived by the owner on Feb 14, 2022. It is now read-only.

Commit

Permalink
completely rewritten action functions
Browse files Browse the repository at this point in the history
now they automatically select the method based on protocol version
  • Loading branch information
ggoraa committed Jul 27, 2021
1 parent 8edb388 commit 93ca9f6
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/util/Actions.mc
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ module Actions {
:responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON,
};

function triggerHorn(method) {
switch (method) {
case :ble: Communications.transmit("triggerHorn", null, new ActionConnectionListener()); break;
case :web: Communications.makeWebRequest("http://127.0.0.1:" + WheelData.webServerPort + "/actions/triggerHorn", null, options, null); break;
function triggerHorn() {
if (AppStorage.runtimeDb["comm_protocolVersion"] >= 3) {
Communications.transmit("triggerHorn", null, new ActionConnectionListener());
} else {
Communications.makeWebRequest("http://127.0.0.1:" + WheelData.webServerPort + "/actions/triggerHorn", null, options, null);
}

WatchUi.requestUpdate();
}

function toggleFrontLight(method) {
switch (method) {
case :ble: Communications.transmit("toggleFrontLight", null, new ActionConnectionListener()); break;
case :web: {
WheelData.areLightsOn = !WheelData.areLightsOn;
Communications.makeWebRequest("http://127.0.0.1:" + WheelData.webServerPort + "/actions/toggleFrontLight", null, options, null);
break;
}
function toggleFrontLight() {
if (AppStorage.runtimeDb["comm_protocolVersion"] >= 3) {
Communications.transmit("toggleFrontLight", null, new ActionConnectionListener())
} else {
Communications.makeWebRequest("http://127.0.0.1:" + WheelData.webServerPort + "/actions/toggleFrontLight", null, options, null);
}

WatchUi.requestUpdate();
}
}
Expand Down

0 comments on commit 93ca9f6

Please sign in to comment.