Browse Source

Actions customizable in configuration.

Matt Clark 8 months ago
parent
commit
b1c16f4557
5 changed files with 32 additions and 46 deletions
  1. 1 2
      README.md
  2. 16 3
      extras/ConfigScript/ConfigScript.ino
  3. 0 3
      firmware/BLEProps.h
  4. 13 36
      firmware/Commander.cpp
  5. 2 2
      firmware/Commander.h

+ 1 - 2
README.md

@@ -12,7 +12,7 @@ After a period of inactivity (12 seconds), the device will go back into a deep s
 
 A rotary encoder wheel in addition to 5 directional buttons are use for device operations.
 
-Supported features:
+Button functions can be customized by the user. Default actions are listed below.
 
 - N: Play Preset #1
 - E: Next Track
@@ -52,6 +52,5 @@ To build this firmware package you must have the following dependencies installe
 
 - ESP32 Core (2.0.2)
 - ArduinoJson (6.18.5)
-- ArylicHTTP (0.0.2)
 - ESP32Encoder (0.7.0)
 

+ 16 - 3
extras/ConfigScript/ConfigScript.ino

@@ -9,8 +9,15 @@
 
 #define NET_NAME "network.name"
 #define NET_PASS "<passphrase>"
-#define NET_DEV "192.168.1.200"
-#define DEV_TIMEOUT 15000
+#define DEV_TIMEOUT 20000
+
+#define ACTION_N  "http://10.3.106.120/httpapi.asp?command=MCUKeyShortClick:1"
+#define ACTION_E  "http://10.3.106.120/httpapi.asp?command=setPlayerCmd:next"
+#define ACTION_S  "http://10.3.106.120/httpapi.asp?command=multiroom:Ungroup"
+#define ACTION_W  "http://10.3.106.120/httpapi.asp?command=setPlayerCmd:prev"
+#define ACTION_C  "http://10.3.106.120/httpapi.asp?command=setPlayerCmd:onepause"
+#define ACTION_UP "http://10.3.106.120/httpapi.asp?command=setPlayerCmd:Vol--"
+#define ACTION_DN "http://10.3.106.120/httpapi.asp?command=setPlayerCmd:Vol%2B%2B"
 
 #include "PropKeys.h"
 
@@ -25,8 +32,14 @@ void setup() {
   conf.begin(A32, false);
   conf.putString(CONF_NET_NAME, NET_NAME);
   conf.putString(CONF_NET_PASS, NET_PASS);
-  conf.putString(CONF_DEV_MASTER, NET_DEV);
   conf.putInt(CONF_DEV_TIMEOUT, DEV_TIMEOUT);
+  conf.putString("_cmd-1", ACTION_N);
+  conf.putString("_cmd-2", ACTION_E);
+  conf.putString("_cmd-4", ACTION_S);
+  conf.putString("_cmd-8", ACTION_W);
+  conf.putString("_cmd-16", ACTION_C);
+  conf.putString("_cmd-97", ACTION_UP);
+  conf.putString("_cmd-99", ACTION_DN);
   conf.putBool(CONF_CONFIGURED, true);
   conf.end();
 

+ 0 - 3
firmware/BLEProps.h

@@ -19,9 +19,6 @@
 #define BLE_PROP_BTN_ID         "37ec4961-159e-4939-8423-0003d3a2a434"
 #define BLE_PROP_BTN_ACTION     "edb5c022-296f-4ef6-ab98-06eaf0146f72"
 
-#define BLE_SERVICE_WHA         "5ff643b6-5fb9-4faa-8a02-07dbf7776597"
-#define BLE_PROP_WHA_MASTER     "f73a8c7b-b9e3-4504-a180-cfa91cc53c3b"
-
 #define BLE_SERVICE_HWC         "0736ef5f-e515-4acf-a37b-ca7b8e82b069"
 #define BLE_PROP_HWC_TIMEOUT    "019e5126-62e8-4a81-a792-cefe2206d3d2"
 #define BLE_PROP_HWC_CONFIGURED "f75d106c-15cc-4e82-9b3b-d09b2bc3fe4b"

+ 13 - 36
firmware/Commander.cpp

@@ -5,8 +5,6 @@ Commander::Commander(Config* cfgMgr) {
 
   encMgr = new Wheel();
   btnMgr = new Buttons();
-
-  apiMgr = new ArylicHTTP(cfgMgr->getString(BLE_PROP_WHA_MASTER));
 }
 
 int Commander::getButtonCommand() {
@@ -22,41 +20,20 @@ int Commander::getButtonCommand() {
 boolean Commander::executeCommand(int cmd) {
   ESP_LOGD(A32, "Running command: %d", cmd);
 
-  switch (cmd) {
-    case 1: // N
-      apiMgr->preset(1);
-      break;
-    case 2: // E
-      apiMgr->playbackNext();
-      break;
-    case 3: // NE
-      break;
-    case 4: // S
-      apiMgr->groupLeave();
-      break;
-    case 6: // SE
-      break;
-    case 8: // W
-      apiMgr->playbackPrev();
-      break;
-    case 9: // NW
-      break;
-    case 12: // SW
-      break;
-    case 16: // C
-      apiMgr->playbackTogglePlay();
-      break;
-    case 97: // Jog Down
-      apiMgr->setVolumeStepDown();
-      break;
-    case 99: // Jog Up
-      apiMgr->setVolumeStepDown();
-      break;
-    default:
-      return false;
-      break;
-  }
+  String key = "_cmd-" + String(cmd);
+  String val = cfgMgr->getString(key.c_str());
+
+  get(val);
 
   btnMgr->clearButtons();
   return true;
 }
+
+String Commander::get(String url) {
+  HTTPClient http;
+  http.begin(url.c_str());
+  http.GET();
+  String body = http.getString();
+  http.end();
+  return body;
+}

+ 2 - 2
firmware/Commander.h

@@ -4,7 +4,7 @@
 #define A32 "Arylic32"
 
 #include <Arduino.h>
-#include <ArylicHTTP.h>
+#include <HTTPClient.h>
 
 #include "BLEProps.h"
 #include "Config.h"
@@ -16,7 +16,7 @@ class Commander {
     Config* cfgMgr;
     Wheel* encMgr;
     Buttons* btnMgr;
-    ArylicHTTP* apiMgr;
+    String get(String url);
 
   public:
     Commander(Config* cfgMgr);