- If you have an OSKR/dev-unlocked bot; enter the bot's IP address and upload the bot's SSH key here, then click "Set up bot". After that, head to https://keriganc.com/vector-epod-setup and follow the instructions.
-
-
-
-
+
+ +
+ Edit/delete a custom intent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Authentication
+
+
+
+
+
+
+
+
+
Configure an OSKR/dev-unlocked robot
+ Works with firmware 1.4 and above
+
+
+ If you have an OSKR/dev-unlocked bot; enter the bot's IP
+ address and upload the bot's SSH key here, then click "Set up
+ bot". After that, use the above section to finish setting up
+ your bot.
+
+
+
+
Welcome to wire-pod! This is the final step of setup. Configure these options to your liking, then click the "Submit Settings" button at the bottom to finish setting up wire-pod.
-
-
-
-
-
Connection Option
-
-
-
-
-
+
+
+
+
Wire-Pod Setup
+
+
+ Welcome to wire-pod! This is the final step of setup. Configure these
+ options to your liking, then click the "Submit Settings" button at the
+ bottom to finish setting up wire-pod.
+
+
+
+
+
+
Connection Option
+
+
+
+
+
+
+
-
-
-
-
STT Language
-
-
-
-
-
-
-
-
-
Weather API
-
-
Select the weather provider you would like to use, then enter the required information.
-
-
-
OpenWeatherMap: free, has forecast and localization support. To use, create an account at openweathermap.org, create an API key, and enter it here.
-
WeatherAPI: requires payment, but is faster and is better at figuring out location. To use, create an account at weatherapi.com, and enter your API key here.
-
-
-
-
-
-
-
-
+
+
STT Language
+
+
+
+
+
+
-
-
Knowledge Graph Setup
-
-
Set the Knowledge Graph Provider you want to use
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
diff --git a/chipper/webroot/js/ble.js b/chipper/webroot/js/ble.js
index a2e0764b..61f3af14 100644
--- a/chipper/webroot/js/ble.js
+++ b/chipper/webroot/js/ble.js
@@ -1,380 +1,483 @@
-const vectorEpodSetup = "https://wpsetup.keriganc.com"
+const vectorEpodSetup = "https://wpsetup.keriganc.com";
-var authEl = document.getElementById("botAuth")
-var statusP = document.createElement("p")
-var externalSetup = document.createElement("a")
-externalSetup.href = vectorEpodSetup
-externalSetup.innerHTML = vectorEpodSetup
+var authEl = document.getElementById("botAuth");
+var statusP = document.createElement("p");
+var externalSetup = document.createElement("a");
+var OTAUpdating = false;
+externalSetup.href = vectorEpodSetup;
+externalSetup.innerHTML = vectorEpodSetup;
function showBotAuth() {
- GetLog = false
- document.getElementById("section-intents").style.display = "none";
- document.getElementById("section-language").style.display = "none";
- document.getElementById("section-log").style.display = "none";
- document.getElementById("section-botauth").style.display = "block";
- updateColor("icon-BotAuth");
- checkBLECapability()
-
+ GetLog = false;
+ document.getElementById("section-intents").style.display = "none";
+ document.getElementById("section-language").style.display = "none";
+ document.getElementById("section-log").style.display = "none";
+ document.getElementById("section-botauth").style.display = "block";
+ updateColor("icon-BotAuth");
+ checkBLECapability();
}
function checkBLECapability() {
- // fetch("/api-ble/init")
- // .then(response => response.text())
- // .then((response) => {
- // if (response.includes("success")) {
- // BeginBLESetup()
- // } else if (response.includes("error")) {
- // statusP.innerHTML = "Error initializing bluetooth on the device running wire-pod. Use the following site on any machine with Bluetooth for setup:"
- // authEl.innerHTML = ""
- // authEl.appendChild(statusP)
- // authEl.appendChild(document.createElement("br"))
- // authEl.appendChild(externalSetup)
- // }
- // })
- authEl.innerHTML = ""
- m1 = document.createElement("p")
- m2 = document.createElement("a")
- m3 = document.createElement("small")
- m1.innerHTML = "Head to the following site on any device with Bluetooth support to set up your Vector."
- m2.text = vectorEpodSetup
- m2.href = vectorEpodSetup
- m2.target = "_blank"
- m3.innerHTML = "Note: if you have an OSKR/dev-unlocked robot, do NOT use this site. Follow the instructions in the section below this one."
- m1.class = "center"
- m2.class = "center"
- m3.class = "center"
- authEl.appendChild(m1)
- //authEl.appendChild(document.createElement("br"))
- authEl.appendChild(m2)
- authEl.appendChild(document.createElement("br"))
- authEl.appendChild(m3)
+ updateAuthel("Checking if wire-pod can use BLE directly...");
+ fetch("/api-ble/init")
+ .then((response) => response.text())
+ .then((response) => {
+ if (response.includes("success")) {
+ BeginBLESetup();
+ } else {
+ authEl.innerHTML = "";
+ m1 = document.createElement("p");
+ m2 = document.createElement("a");
+ m3 = document.createElement("small");
+ m1.innerHTML =
+ "Head to the following site on any device with Bluetooth support to set up your Vector.";
+ m2.text = vectorEpodSetup;
+ m2.href = vectorEpodSetup;
+ m2.target = "_blank";
+ m3.innerHTML =
+ "Note: with OSKR/dev robots, it might give a warning about firmware. This can be ignored.";
+ m1.class = "center";
+ m2.class = "center";
+ m3.class = "center";
+ authEl.appendChild(m1);
+ //authEl.appendChild(document.createElement("br"))
+ authEl.appendChild(m2);
+ authEl.appendChild(document.createElement("br"));
+ authEl.appendChild(m3);
+ }
+ });
}
function BeginBLESetup() {
- authEl.innerHTML = ""
- m1 = document.createElement("p")
- m1.innerHTML = "1. Place Vector on the charger."
- m2 = document.createElement("p")
- m2.innerHTML = "2. Double press the button. A key should appear on screen."
- m3 = document.createElement("p")
- m3.innerHTML = "3. Click 'Begin Scanning' and pair with your Vector."
- button = document.createElement("button")
- button.innerHTML = "Begin Scanning"
- button.onclick = function(){ScanRobots(false)}
- authEl.appendChild(m1)
- authEl.appendChild(m2)
- authEl.appendChild(m3)
- authEl.appendChild(button)
-
+ authEl.innerHTML = "";
+ m1 = document.createElement("p");
+ m1.innerHTML = "1. Place Vector on the charger.";
+ m2 = document.createElement("p");
+ m2.innerHTML = "2. Double press the button. A key should appear on screen.";
+ m3 = document.createElement("p");
+ m3.innerHTML = "3. Click 'Begin Scanning' and pair with your Vector.";
+ button = document.createElement("button");
+ button.innerHTML = "Begin Scanning";
+ button.onclick = function () {
+ ScanRobots(false);
+ };
+ authEl.appendChild(m1);
+ authEl.appendChild(m2);
+ authEl.appendChild(m3);
+ authEl.appendChild(button);
}
-var Scanning = false
-var IsScanning = false
-
-function ScanRobots(returning) {
- disconnectButtonDiv = document.getElementById("disconnectButton")
- disconnectButton = document.createElement("button")
- disconnectButton.onclick = function(){Disconnect()}
- disconnectButton.innerHTML = "Disconnect"
- disconnectButtonDiv.appendChild(disconnectButton)
- Scanning = true
- authEl.innerHTML = ""
- statusDiv = document.createElement("div")
- buttonsDiv = document.createElement("div")
- buttonsDiv.class = "center"
- statusDiv.class = "center"
- if (returning) {
- incorrectPin = document.createElement("p")
- incorrectPin.innerHTML = "Incorrect PIN was entered, scanning again"
- statusDiv.appendChild(incorrectPin)
- }
- scanNotice = document.createElement("small")
- scanNotice.innerHTML = "Scanning..."
- statusDiv.appendChild(scanNotice)
- authEl.appendChild(statusDiv)
- IsScanning = true
- let xhr = new XMLHttpRequest();
- xhr.open("POST", "/api-ble/scan");
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- xhr.send();
- xhr.onload = function() {
- response = xhr.response
- IsScanning = false
- if (!Scanning) {
- clearInterval(interval)
- return
- }
- console.log(response)
- parsed = JSON.parse(response)
- buttonsDiv.innerHTML = ""
- authEl.innerHTML = ""
- for (var i = 0; i < parsed.length; i++) {
- button = document.createElement("button")
- id = parsed[i]["id"]
- button.innerHTML = parsed[i]["name"]
- button.onclick = function(){Scanning = false; ConnectRobot(id);}
- buttonsDiv.appendChild(button)
- }
- authEl.appendChild(buttonsDiv)
- }
- interval = setInterval(function(){
- if (!Scanning) {
- clearInterval(interval)
- return
- }
- scanNotice.innerHTML = "Scanning..."
- statusDiv.innerHTML = ""
- statusDiv.appendChild(scanNotice)
- IsScanning = true
- let xhr = new XMLHttpRequest();
- xhr.open("POST", "/api-ble/scan");
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- xhr.send();
- xhr.onload = function() {
- response = xhr.response
- IsScanning = false
- if (!Scanning) {
- clearInterval(interval)
- return
- }
- console.log(response)
- parsed = JSON.parse(response)
- buttonsDiv.innerHTML = ""
- authEl.innerHTML = ""
- for (var i = 0; i < parsed.length; i++) {
- button = document.createElement("button")
- id = parsed[i]["id"]
- button.innerHTML = parsed[i]["name"]
- button.onclick = (function(id) {
- return function() {
- Scanning = false;
- ConnectRobotBuffer(id);
- };
- })(id);
- buttonsDiv.appendChild(button)
- }
- authEl.appendChild(buttonsDiv)
- }
- }, 5000)
+function ReInitBLE() {
+ fetch("/api-ble/disconnect").then(() => fetch("/api-ble/init"));
}
-function ConnectRobotBuffer(id) {
- authEl.innerHTML = ""
- statusP.innerHTML = "Connecting to robot..."
- authEl.appendChild(statusP)
- // if scanning, dont make connection request
- if (IsScanning) {
- console.log("Scan request being made, wait to connect robot...")
- inte = setInterval(function(){
- if (!IsScanning) {
- setTimeout(function(){
- clearInterval(inte)
- console.log("connecting robot...")
- ConnectRobot(id)
- }, 1000)
- }
- }, 500)
+function ScanRobots(returning) {
+ disconnectButtonDiv = document.getElementById("disconnectButton");
+ disconnectButtonDiv.innerHTML = "";
+ disconnectButton = document.createElement("button");
+ disconnectButton.onclick = function () {
+ Disconnect();
+ };
+ disconnectButton.innerHTML = "Disconnect";
+ disconnectButtonDiv.appendChild(disconnectButton);
+ authEl.innerHTML = "";
+ statusDiv = document.createElement("div");
+ buttonsDiv = document.createElement("div");
+ buttonsDiv.class = "center";
+ statusDiv.class = "center";
+ if (returning) {
+ incorrectPin = document.createElement("p");
+ incorrectPin.innerHTML = "Incorrect PIN was entered, scanning again...";
+ statusDiv.appendChild(incorrectPin);
+ }
+ scanNotice = document.createElement("small");
+ scanNotice.innerHTML = "Scanning...";
+ statusDiv.appendChild(scanNotice);
+ authEl.appendChild(statusDiv);
+ var xhr = new XMLHttpRequest();
+ xhr.open("POST", "/api-ble/scan");
+ xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+ xhr.send();
+ xhr.onload = function () {
+ response = xhr.response;
+ console.log(response);
+ parsed = JSON.parse(response);
+ buttonsDiv.innerHTML = "";
+ authEl.innerHTML = "";
+ for (var i = 0; i < parsed.length; i++) {
+ button = document.createElement("button");
+ id = parsed[i]["id"];
+ button.innerHTML = parsed[i]["name"];
+ button.onclick = function () {
+ ConnectRobot(id);
+ };
+ buttonsDiv.appendChild(button);
}
+ rescanB = document.createElement("button");
+ rescanB.innerHTML = "Re-scan";
+ rescanB.onclick = function () {
+ updateAuthel("Reiniting BLE then scanning...");
+ fetch("/api-ble/disconnect").then(() =>
+ fetch("/api-ble/init").then(() => ScanRobots(false))
+ );
+ };
+ updateAuthel("Click on the robot you would like to pair with.");
+ authEl.appendChild(rescanB);
+ authEl.appendChild(buttonsDiv);
+ };
}
function Disconnect() {
- disconnectButtonDiv = document.getElementById("disconnectButton")
- disconnectButtonDiv.innerHTML = ""
- authEl.innerHTML = ""
- statusP.innerHTML = "Disconnecting..."
- authEl.appendChild(statusP)
- fetch("/api-ble/disconnect")
- .then((response) => {
- setTimeout(function(){
+ disconnectButtonDiv = document.getElementById("disconnectButton");
+ disconnectButtonDiv.innerHTML = "";
+ authEl.innerHTML = "";
+ statusP.innerHTML = "Disconnecting...";
+ authEl.appendChild(statusP);
+ if (OTAUpdating) {
+ OTAUpdating = false;
+ fetch("/api-ble/stop_ota").then(() =>
+ setTimeout(function () {
+ fetch("/api-ble/disconnect").then(() => {
+ setTimeout(function () {
+ checkBLECapability();
+ }, 2000);
+ });
+ }, 1000)
+ );
+ } else {
+ fetch("/api-ble/disconnect").then(() => {
+ setTimeout(function () {
checkBLECapability();
- }, 2000)
-})
+ }, 2000);
+ });
+ }
}
function ConnectRobot(id) {
- fetch("/api-ble/connect?id=" + id)
- .then(response => response.text())
+ updateAuthel("Connecting to robot...");
+ fetch("/api-ble/connect?id=" + id)
+ .then((response) => response.text())
.then((response) => {
- if (response.includes("success")) {
- statusP.innerHTML = "Connected to robot! Loading pin screen..."
- authEl.innerHTML = ""
- authEl.appendChild(statusP)
- CreatePinEntry()
- return
- }
- })
+ if (response.includes("success")) {
+ CreatePinEntry();
+ return;
+ }
+ });
}
function validateInput(input) {
- return input.value.length <= 6 && /^\d+$/.test(input.value);
- }
+ return input.value.length <= 6 && /^\d+$/.test(input.value);
+}
function CreatePinEntry() {
- authEl.innerHTML = ""
- statusDiv = document.createElement("div")
- statusP.innerHTML = "Enter the pin shown on Vector's screen."
- statusDiv.appendChild(statusP)
- authEl.appendChild(statusDiv)
- pinEntry = document.createElement("input")
- pinEntry.type = "text"
- pinEntry.id = "pinEntry"
- pinEntry.name = "pinEntry"
- pinEntry.placeholder = "Enter PIN here"
- pinEntry.setAttribute("type", "text");
- pinEntry.setAttribute("maxlength", "6");
- pinEntry.setAttribute("oninput", "validateInput(this)");
- button = document.createElement("button")
- button.onclick = function(){SendPin()}
- button.innerHTML = "Send PIN"
- authEl.appendChild(pinEntry)
- authEl.appendChild(document.createElement("br"))
- authEl.appendChild(button)
- return
+ authEl.innerHTML = "";
+ statusDiv = document.createElement("div");
+ statusP.innerHTML = "Enter the pin shown on Vector's screen.";
+ statusDiv.appendChild(statusP);
+ authEl.appendChild(statusDiv);
+ pinEntry = document.createElement("input");
+ pinEntry.type = "text";
+ pinEntry.id = "pinEntry";
+ pinEntry.name = "pinEntry";
+ pinEntry.placeholder = "Enter PIN here";
+ pinEntry.setAttribute("type", "text");
+ pinEntry.setAttribute("maxlength", "6");
+ pinEntry.setAttribute("oninput", function () {
+ validateInput(this);
+ });
+ button = document.createElement("button");
+ button.onclick = function () {
+ SendPin();
+ };
+ button.innerHTML = "Send PIN";
+ authEl.appendChild(pinEntry);
+ authEl.appendChild(document.createElement("br"));
+ authEl.appendChild(button);
+ return;
}
function SendPin() {
- pin = document.getElementById("pinEntry").value
- authEl.innerHTML = ""
- fetch("/api-ble/send_pin?pin=" + pin)
- .then(response => response.text())
+ pin = document.getElementById("pinEntry").value;
+ updateAuthel("Sending PIN...");
+ fetch("/api-ble/send_pin?pin=" + pin)
+ .then((response) => response.text())
.then((response) => {
- if (response.includes("incorrect pin")) {
- ScanRobots(true)
- } else {
- // create auth button
- WifiCheck()
- }
- return
- })
+ console.log(response);
+ if (
+ response.includes("incorrect pin") ||
+ response.includes("length of pin")
+ ) {
+ updateAuthel("Wrong PIN... Reiniting BLE then scanning...");
+ fetch("/api-ble/disconnect").then(() =>
+ fetch("/api-ble/init").then(() => ScanRobots(true))
+ );
+ } else {
+ WifiCheck();
+ }
+ return;
+ });
}
function WifiCheck() {
- fetch("/api-ble/get_wifi_status")
- .then(response => response.text())
+ fetch("/api-ble/get_wifi_status")
+ .then((response) => response.text())
.then((response) => {
- console.log(response)
- if (response == "1") {
- DoAuth()
- } else {
- ScanWifi()
- }
- return
- })
+ console.log(response);
+ if (response == "1") {
+ WhatToDo();
+ } else {
+ ScanWifi();
+ }
+ return;
+ });
}
-//var parsedScan
-
function ScanWifi() {
- authEl.innerHTML = ""
- statusP.innerHTML = "Scanning for Wi-Fi networks..."
- authEl.appendChild(statusP)
- var xhr = new XMLHttpRequest();
- xhr.open("GET", "/api-ble/scan_wifi", true);
- xhr.onreadystatechange = function() {
- if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
- authEl.innerHTML = ""
- // create scan again button
- var scanAgain = document.createElement("button")
- scanAgain.innerHTML = "Scan Again"
- scanAgain.onclick = function(){ScanWifi()}
- authEl.appendChild(scanAgain)
- authEl.appendChild(document.createElement("br"))
- // add network buttons
- var networks = JSON.parse(this.responseText);
- for (var i = 0; i < networks.length; i++) {
- var ssid = networks[i].ssid;
- if (ssid != "") {
- var authtype = networks[i].authtype;
- var btn = document.createElement("button");
- btn.innerHTML = ssid;
- btn.onclick = (function(ssid, authtype) {
- return function() {
- CreateWiFiPassEntry(ssid, authtype);
- };
- })(ssid, authtype);
- authEl.appendChild(btn);
- }
- }
- }
- };
- xhr.send();
+ authEl.innerHTML = "";
+ statusP.innerHTML = "Scanning for Wi-Fi networks...";
+ authEl.appendChild(statusP);
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", "/api-ble/scan_wifi", true);
+ xhr.onreadystatechange = function () {
+ if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
+ authEl.innerHTML = "";
+ updateAuthel("Select a Wi-Fi network to connect Vector to.");
+ // create scan again button
+ var scanAgain = document.createElement("button");
+ scanAgain.innerHTML = "Scan Again";
+ scanAgain.onclick = function () {
+ ScanWifi();
+ };
+ authEl.appendChild(scanAgain);
+ authEl.appendChild(document.createElement("br"));
+ // add network buttons
+ var networks = JSON.parse(this.responseText);
+ for (var i = 0; i < networks.length; i++) {
+ var ssid = networks[i].ssid;
+ if (ssid != "") {
+ var authtype = networks[i].authtype;
+ var btn = document.createElement("button");
+ btn.innerHTML = ssid;
+ btn.onclick = (function (ssid, authtype) {
+ return function () {
+ CreateWiFiPassEntry(ssid, authtype);
+ };
+ })(ssid, authtype);
+ authEl.appendChild(btn);
+ }
}
+ }
+ };
+ xhr.send();
+}
function CreateWiFiPassEntry(ssid, authtype) {
- console.log(ssid)
- console.log(authtype)
- authEl.innerHTML = ""
- againButton = document.createElement("button")
- againButton.innerHTML = "Scan Again"
- againButton.onclick = function(){ScanWifi()}
- authEl.appendChild
- statusDiv = document.createElement("div")
- statusP.innerHTML = "Enter the password for " + ssid
- statusDiv.appendChild(statusP)
- authEl.appendChild(statusDiv)
- pinEntry = document.createElement("input")
- pinEntry.type = "text"
- pinEntry.id = "passEntry"
- pinEntry.name = "passEntry"
- pinEntry.placeholder = "Password"
- button = document.createElement("button")
- button.onclick = function(){ConnectWifi(ssid, authtype)}
- button.innerHTML = "Connect to Wi-Fi"
- authEl.appendChild(pinEntry)
- authEl.appendChild(document.createElement("br"))
- authEl.appendChild(button)
- return
+ console.log(ssid);
+ console.log(authtype);
+ authEl.innerHTML = "";
+ againButton = document.createElement("button");
+ againButton.innerHTML = "Scan Again";
+ againButton.onclick = function () {
+ ScanWifi();
+ };
+ authEl.appendChild;
+ statusDiv = document.createElement("div");
+ statusP.innerHTML = "Enter the password for " + ssid;
+ statusDiv.appendChild(statusP);
+ authEl.appendChild(statusDiv);
+ pinEntry = document.createElement("input");
+ pinEntry.type = "text";
+ pinEntry.id = "passEntry";
+ pinEntry.name = "passEntry";
+ pinEntry.placeholder = "Password";
+ button = document.createElement("button");
+ button.onclick = function () {
+ ConnectWifi(ssid, authtype);
+ };
+ button.innerHTML = "Connect to Wi-Fi";
+ authEl.appendChild(pinEntry);
+ authEl.appendChild(document.createElement("br"));
+ authEl.appendChild(button);
+ return;
}
function ConnectWifi(ssid, authtype) {
- password = document.getElementById("passEntry").value
- authEl.innerHTML = ""
- passP = document.createElement("p")
- passP.innerHTML = "Connecting Vector to Wi-Fi..."
- authEl.appendChild(passP)
- fetch("/api-ble/connect_wifi?ssid=" + ssid + "&password=" + password + "&authType=" + authtype)
- .then(response => response.text())
+ password = document.getElementById("passEntry").value;
+ authEl.innerHTML = "";
+ passP = document.createElement("p");
+ passP.innerHTML = "Connecting Vector to Wi-Fi...";
+ authEl.appendChild(passP);
+ fetch(
+ "/api-ble/connect_wifi?ssid=" +
+ ssid +
+ "&password=" +
+ password +
+ "&authType=" +
+ authtype
+ )
+ .then((response) => response.text())
.then((response) => {
- if (!response.includes("255")) {
- alert("Error connecting, likely incorrect password")
- CreateWiFiPassEntry(ssid, authtype)
- } else {
- authEl.innerHTML = ""
- button = document.createElement("button")
- button.innerHTML = "Click to authenticate"
- button.onclick = function(){DoAuth()}
- authEl.appendChild(button)
- }
- })
+ if (!response.includes("255")) {
+ alert("Error connecting, likely incorrect password");
+ CreateWiFiPassEntry(ssid, authtype);
+ } else {
+ WhatToDo();
+ }
+ });
}
function CheckFirmware() {
- fetch("/api-ble/get_firmware")
- .then(response => response.text())
+ fetch("/api-ble/get_firmware")
+ .then((response) => response.text())
+ .then((response) => {
+ let splitFirmware = response.split("-");
+ console.log(splitFirmware);
+ });
+}
+
+function WhatToDo() {
+ fetch("/api-ble/get_robot_status")
+ .then((response) => response.text())
+ .then((response) => {
+ if (response == "in_recovery_prod") {
+ DoOTA("local");
+ } else if (response == "in_recovery_dev") {
+ DoOTA("http://wpsetup.keriganc.com:81/1.6.0.3331.ota");
+ } else if (response == "in_firmware_nonep") {
+ authEl.innerHTML = "";
+ m1 = document.createElement("p");
+ m1.innerHTML = "1. Place Vector on the charger.";
+ m2 = document.createElement("p");
+ m2.innerHTML =
+ "2. Hold the button for 15 seconds. He will turn off - keep holding it until he turns back on.";
+ m3 = document.createElement("p");
+ m3.innerHTML = "3. Click 'Begin Scanning' and pair with your Vector.";
+ button = document.createElement("button");
+ button.innerHTML = "Begin Scanning";
+ button.onclick = function () {
+ ScanRobots(false);
+ };
+ authEl.appendChild(m1);
+ authEl.appendChild(m2);
+ authEl.appendChild(m3);
+ authEl.appendChild(button);
+ alert(
+ "Your bot is not on the correct firmware for wire-pod. Follow the directions to put him in recovery mode."
+ );
+ } else if (response == "in_firmware_dev") {
+ alert(
+ "Your bot is a dev robot. Make sure you have done the 'Configure an OSKR/dev-unlocked robot' section before authentication. If you did already, you can ignore this warning."
+ );
+ authEl.innerHTML = "";
+ button = document.createElement("button");
+ button.innerHTML = "AUTHENTICATE";
+ button.onclick = function () {
+ DoAuth();
+ };
+ authEl.appendChild(button);
+ } else if (response == "in_firmware_ep") {
+ authEl.innerHTML = "";
+ button = document.createElement("button");
+ button.innerHTML = "AUTHENTICATE";
+ button.onclick = function () {
+ DoAuth();
+ };
+ authEl.appendChild(button);
+ }
+ });
+}
+
+function DoOTA(url) {
+ updateAuthel("Starting OTA update...");
+ fetch("/api-ble/start_ota?url=" + url)
+ .then((response) => response.text())
.then((response) => {
- let splitFirmware = response.split("-")
- console.log(splitFirmware)
- })
+ if (response.includes("success")) {
+ OTAUpdating = true;
+ inte = setInterval(function () {
+ fetch("/api-ble/get_ota_status")
+ .then((otaresp) => otaresp.text())
+ .then((otaresp) => {
+ if (otaresp.includes("complete")) {
+ updateAuthel(otaresp);
+ checkBLECapability();
+ alert(
+ "The OTA update is complete. When the bot reboots, follow the steps to re-pair the bot with wire-pod. wire-pod will then authenticate the robot and setup will be complete."
+ );
+ OTAUpdating = false;
+ clearInterval(inte);
+ } else if (otaresp.includes("stopped")) {
+ OTAUpdating = false;
+ clearInterval(inte);
+ } else if (!OTAUpdating) {
+ clearInterval(inte);
+ } else {
+ updateAuthel(otaresp);
+ }
+ });
+ }, 2000);
+ } else {
+ WhatToDo();
+ }
+ });
+}
+
+function updateAuthel(update) {
+ authEl.innerHTML = "";
+ authP = document.createElement("p");
+ authP.innerHTML = update;
+ authEl.appendChild(authP);
}
function DoAuth() {
- authEl.innerHTML = ""
- authP = document.createElement("p")
- authP.innerHTML = "Authenticating your Vector..."
- authEl.appendChild(authP)
- fetch("/api-ble/do_auth")
- .then(response => response.text())
+ updateAuthel("Authenticating your Vector...");
+ fetch("/api-ble/do_auth")
+ .then((response) => response.text())
.then((response) => {
- console.log(response)
- authEl.innerHTML = ""
- authP.innerHTML = "Authentication complete!"
- authEl.appendChild(authP)
- fetch("/api-ble/disconnect")
- disconnectButtonDiv = document.getElementById("disconnectButton")
- disconnectButtonDiv.innerHTML = ""
- disconnectButton = document.createElement("button")
- disconnectButton.onclick = function(){checkBLECapability()}
- disconnectButton.innerHTML = "Back to setup"
- disconnectButtonDiv.appendChild(disconnectButton)
- })
+ console.log(response);
+ if (response.includes("error")) {
+ updateAuthel(
+ "Authentication failure. Try again in ~15 seconds. If it happens again, check the troubleshooting guide:"
+ );
+ m2 = document.createElement("a");
+ m2.text = "https://github.com/kercre123/wire-pod/wiki/Troubleshooting";
+ m2.href =
+ "https://github.com/kercre123/wire-pod/wiki/Troubleshooting#error-logging-in-the-bot-is-likely-unable-to-communicate-with-your-wire-pod-instance";
+ m2.target = "_blank";
+ authEl.appendChild(document.createElement("br"));
+ authEl.appendChild(m2);
+ } else {
+ updateAuthel("Authentication was successful! How would you like to wake Vector up?");
+ wakeWithAnim = document.createElement("button");
+ wakeWithAnim.onclick = function () {
+ DoOnboard(true)
+ };
+ wakeWithAnim.innerHTML = "Wake with wake-up animation (recommended)";
+ wakeWithoutAnim = document.createElement("button");
+ wakeWithoutAnim.innerHTML = "Wake immediately, without wake-up animation";
+ wakeWithoutAnim.onclick = function () {
+ DoOnboard(false)
+ };
+ authEl.appendChild(wakeWithAnim)
+ authEl.appendChild(document.createElement("br"))
+ authEl.appendChild(wakeWithoutAnim)
+ }
+ });
+}
+
+function DoOnboard(wAnim) {
+ updateAuthel("Onboarding robot...")
+ fetch("/api-ble/onboard?with_anim=" + wAnim)
+ .then(() => {
+ fetch("/api-ble/disconnect");
+ updateAuthel("Vector is now fully set up! Use the Bot Settings tab to further configure your bot.");
+ disconnectButtonDiv = document.getElementById("disconnectButton");
+ disconnectButtonDiv.innerHTML = "";
+ disconnectButton = document.createElement("button");
+ disconnectButton.onclick = function () {
+ checkBLECapability();
+ };
+ disconnectButton.innerHTML = "Return to pair instructions";
+ disconnectButtonDiv.appendChild(disconnectButton);
+})
}
\ No newline at end of file
diff --git a/chipper/webroot/js/initial.js b/chipper/webroot/js/initial.js
index 1b5d6a05..4831cc2b 100644
--- a/chipper/webroot/js/initial.js
+++ b/chipper/webroot/js/initial.js
@@ -1,190 +1,216 @@
function checkLanguage() {
- let xhr = new XMLHttpRequest();
- xhr.open("GET", "/api/get_stt_info");
- xhr.send();
- xhr.onload = function() {
- parsed = JSON.parse(xhr.response)
- if (parsed["sttProvider"] != "vosk" && parsed["sttProvider"] != "whisper.cpp") {
- console.log("stt not vosk/whisper")
- document.getElementById("section-language").style.display = "none"
- document.getElementById("languageSelection").value = "en-US"
- } else {
- document.getElementById("section-language").style.display = "block"
- console.log(parsed["sttLanguage"])
- document.getElementById("languageSelection").value = "en-US"
- }
+ let xhr = new XMLHttpRequest();
+ xhr.open("GET", "/api/get_stt_info");
+ xhr.send();
+ xhr.onload = function () {
+ parsed = JSON.parse(xhr.response);
+ if (
+ parsed["sttProvider"] != "vosk" &&
+ parsed["sttProvider"] != "whisper.cpp"
+ ) {
+ console.log("stt not vosk/whisper");
+ document.getElementById("section-language").style.display = "none";
+ document.getElementById("languageSelection").value = "en-US";
+ } else {
+ document.getElementById("section-language").style.display = "block";
+ console.log(parsed["sttLanguage"]);
+ document.getElementById("languageSelection").value = "en-US";
}
+ };
}
function updateSetupStatus(statusString) {
- setupStatus = document.getElementById("setup-status")
- setupStatus.innerHTML = ""
- setupStatusP = document.createElement("p")
- setupStatusP.innerHTML = statusString
- setupStatus.appendChild(setupStatusP)
+ setupStatus = document.getElementById("setup-status");
+ setupStatus.innerHTML = "";
+ setupStatusP = document.createElement("p");
+ setupStatusP.innerHTML = statusString;
+ setupStatus.appendChild(setupStatusP);
}
function sendSetupInfo() {
- document.getElementById("config-options").style.display = "none"
- updateSetupStatus("Initiating setup...")
- language = document.getElementById("languageSelection").value
-
- // set language first
- var langData = "language=" + language;
- document.getElementById("languageSelectionDiv").style.display = "none"
- fetch("/api/set_stt_info?" + langData)
- .then(response => response.text())
- .then((response) => {
- if (response.includes("success")) {
- updateSetupStatus("Language set successfully.")
- initWeatherAPIKey()
- } else if (response.includes("downloading")) {
- updateSetupStatus("Downloading language model...")
- inte = setInterval(function(){
- fetch("/api/get_download_status")
- .then(response => response.text())
- .then((response => {
- statusText = response
- if (response.includes("success")) {
- updateSetupStatus("Language set successfully.")
- initWeatherAPIKey()
- clearInterval(inte)
- } else if (response.includes("error")) {
- document.getElementById("config-options").style.display = "block"
- } else if (response.includes("not downloading")) {
- statusText = "Initiating language model download..."
- }
- updateSetupStatus(statusText)
- }))
- }, 500)
- } else if (response.includes("vosk")) {
- initWeatherAPIKey()
- } else if (response.includes("error")) {
- updateSetupStatus(response)
- document.getElementById("config-options").style.display = "block"
- return
- }
+ document.getElementById("config-options").style.display = "none";
+ updateSetupStatus("Initiating setup...");
+ language = document.getElementById("languageSelection").value;
- })
+ // set language first
+ var langData = "language=" + language;
+ document.getElementById("languageSelectionDiv").style.display = "none";
+ fetch("/api/set_stt_info?" + langData)
+ .then((response) => response.text())
+ .then((response) => {
+ if (response.includes("success")) {
+ updateSetupStatus("Language set successfully.");
+ initWeatherAPIKey();
+ } else if (response.includes("downloading")) {
+ updateSetupStatus("Downloading language model...");
+ inte = setInterval(function () {
+ fetch("/api/get_download_status")
+ .then((response) => response.text())
+ .then((response) => {
+ statusText = response;
+ if (response.includes("success")) {
+ updateSetupStatus("Language set successfully.");
+ initWeatherAPIKey();
+ clearInterval(inte);
+ } else if (response.includes("error")) {
+ document.getElementById("config-options").style.display =
+ "block";
+ } else if (response.includes("not downloading")) {
+ statusText = "Initiating language model download...";
+ }
+ updateSetupStatus(statusText);
+ });
+ }, 500);
+ } else if (response.includes("vosk")) {
+ initWeatherAPIKey();
+ } else if (response.includes("error")) {
+ updateSetupStatus(response);
+ document.getElementById("config-options").style.display = "block";
+ return;
+ }
+ });
}
function initWeatherAPIKey() {
- var provider = document.getElementById("weatherProvider").value;
- if (provider != "") {
- updateSetupStatus("Setting weather API key...")
+ var provider = document.getElementById("weatherProvider").value;
+ if (provider != "") {
+ updateSetupStatus("Setting weather API key...");
var form = document.getElementById("weatherAPIAddForm");
- var data = "provider=" + provider + "&api_key=" + form.elements["apiKey"].value;
+ var data =
+ "provider=" + provider + "&api_key=" + form.elements["apiKey"].value;
fetch("/api/set_weather_api?" + data)
- .then(response => response.text())
- .then((response) => {
- updateSetupStatus(response)
- initKGAPIKey()
- })
- } else {
- initKGAPIKey()
- }
-}
+ .then((response) => response.text())
+ .then((response) => {
+ updateSetupStatus(response);
+ initKGAPIKey();
+ });
+ } else {
+ initKGAPIKey();
+ }
+}
function initKGAPIKey() {
- updateSetupStatus("Setting knowledge graph settings...")
- var provider = document.getElementById("kgProvider").value
- var openAIPrompt = ""
- var key = ""
- var id = ""
- var intentgraph = ""
- var robotName = ""
- var model = ""
- var saveChat = ""
- var doCommands = ""
+ updateSetupStatus("Setting knowledge graph settings...");
+ var provider = document.getElementById("kgProvider").value;
+ var openAIPrompt = "";
+ var key = "";
+ var id = "";
+ var intentgraph = "";
+ var robotName = "";
+ var model = "";
+ var saveChat = "";
+ var doCommands = "";
- if (provider == "openai") {
- key = document.getElementById("openAIKey").value
- openAIPrompt = document.getElementById("openAIPrompt").value
- if (document.getElementById("commandYes").checked == true) {
- doCommands = "true"
- } else {
- doCommands = "false"
- }
- if (document.getElementById("intentyes").checked == true) {
- intentgraph = "true"
- } else {
- intentgraph = "false"
- }
- if (document.getElementById("saveChatYes").checked == true) {
- saveChat = "true"
- } else {
- saveChat = "false"
- }
- } else if (provider == "together") {
- key = document.getElementById("togetherKey").value
- openAIPrompt = document.getElementById("togetherAIPrompt").value
- model = document.getElementById("togetherModel").value
- if (document.getElementById("togetherintentyes").checked == true) {
- intentgraph = "true"
- } else {
- intentgraph = "false"
- }
- if (document.getElementById("saveChatYes").checked == true) {
- saveChat = "true"
- } else {
- saveChat = "false"
- }
- } else if (provider == "houndify") {
- key = document.getElementById("houndKey").value
- id = document.getElementById("houndID").value
- intentgraph = "false"
+ if (provider == "openai") {
+ key = document.getElementById("openAIKey").value;
+ openAIPrompt = document.getElementById("openAIPrompt").value;
+ if (document.getElementById("commandYes").checked == true) {
+ doCommands = "true";
} else {
- key = ""
- id = ""
- intentgraph = "false"
+ doCommands = "false";
}
+ if (document.getElementById("intentyes").checked == true) {
+ intentgraph = "true";
+ } else {
+ intentgraph = "false";
+ }
+ if (document.getElementById("saveChatYes").checked == true) {
+ saveChat = "true";
+ } else {
+ saveChat = "false";
+ }
+ } else if (provider == "together") {
+ key = document.getElementById("togetherKey").value;
+ openAIPrompt = document.getElementById("togetherAIPrompt").value;
+ model = document.getElementById("togetherModel").value;
+ if (document.getElementById("togetherintentyes").checked == true) {
+ intentgraph = "true";
+ } else {
+ intentgraph = "false";
+ }
+ if (document.getElementById("saveChatYes").checked == true) {
+ saveChat = "true";
+ } else {
+ saveChat = "false";
+ }
+ } else if (provider == "houndify") {
+ key = document.getElementById("houndKey").value;
+ id = document.getElementById("houndID").value;
+ intentgraph = "false";
+ } else {
+ key = "";
+ id = "";
+ intentgraph = "false";
+ }
- var data = "provider=" + provider + "&api_key=" + key + "&api_id=" + id + "&model=" + model + "&intent_graph=" + intentgraph + "&robot_name=" + robotName + "&openai_prompt=" + openAIPrompt + "&save_chat=" + saveChat + "&commands_enable=" + doCommands
- fetch("/api/set_kg_api?" + data)
- .then(response => response.text())
- .then((response) => {
- updateSetupStatus(response)
- setConn()
- })
+ var data =
+ "provider=" +
+ provider +
+ "&api_key=" +
+ key +
+ "&api_id=" +
+ id +
+ "&model=" +
+ model +
+ "&intent_graph=" +
+ intentgraph +
+ "&robot_name=" +
+ robotName +
+ "&openai_prompt=" +
+ openAIPrompt +
+ "&save_chat=" +
+ saveChat +
+ "&commands_enable=" +
+ doCommands;
+ fetch("/api/set_kg_api?" + data)
+ .then((response) => response.text())
+ .then((response) => {
+ updateSetupStatus(response);
+ setConn();
+ });
}
function checkConn() {
- connValue = document.getElementById("connSelection").value
- if (connValue == "ip") {
- document.getElementById("portViz").style.display = "block"
- } else {
- document.getElementById("portViz").style.display = "none"
- }
+ connValue = document.getElementById("connSelection").value;
+ if (connValue == "ip") {
+ document.getElementById("portViz").style.display = "block";
+ } else {
+ document.getElementById("portViz").style.display = "none";
+ }
}
function setConn() {
- updateSetupStatus("Setting connection type (ep or ip)...")
- connValue = document.getElementById("connSelection").value
- port = document.getElementById("portInput").value
- if (port == "") {
- port = "443"
- }
- url = ""
- if (connValue == "ep") {
- url = "/api-chipper/use_ep"
- } else {
- url = "/api-chipper/use_ip?port=" + port
- }
- fetch(url)
- .then(response => response.text())
- .then((response) => {
- if (response == "") {
- updateSetupStatus("error setting up wire-pod, check the logs")
- document.getElementById("config-options").style.display = "block"
- return
- } else {
- updateSetupStatus("Setup is complete! Wire-pod has started. Redirecting to main page...")
- setTimeout(function(){window.location.href = "/";}, 3000)
- }
- })
+ updateSetupStatus("Setting connection type (ep or ip)...");
+ connValue = document.getElementById("connSelection").value;
+ port = document.getElementById("portInput").value;
+ if (port == "") {
+ port = "443";
+ }
+ url = "";
+ if (connValue == "ep") {
+ url = "/api-chipper/use_ep";
+ } else {
+ url = "/api-chipper/use_ip?port=" + port;
+ }
+ fetch(url)
+ .then((response) => response.text())
+ .then((response) => {
+ if (response == "") {
+ updateSetupStatus("error setting up wire-pod, check the logs");
+ document.getElementById("config-options").style.display = "block";
+ return;
+ } else {
+ updateSetupStatus(
+ "Setup is complete! Wire-pod has started. Redirecting to main page..."
+ );
+ setTimeout(function () {
+ window.location.href = "/";
+ }, 3000);
+ }
+ });
}
function directToIndex() {
- window.location.href = "/index.html"
-}
\ No newline at end of file
+ window.location.href = "/index.html";
+}
diff --git a/chipper/webroot/js/main.js b/chipper/webroot/js/main.js
index 55f8c676..5197f759 100755
--- a/chipper/webroot/js/main.js
+++ b/chipper/webroot/js/main.js
@@ -1,55 +1,54 @@
-var eventListenerAdded = false
+var eventListenerAdded = false;
-intentsJson = '["intent_greeting_hello", "intent_names_ask", "intent_imperative_eyecolor", "intent_character_age", "intent_explore_start", "intent_system_charger", "intent_system_sleep", "intent_greeting_goodmorning", "intent_greeting_goodnight", "intent_greeting_goodbye", "intent_seasonal_happynewyear", "intent_seasonal_happyholidays", "intent_amazon_signin", "intent_amazon_signin", "intent_imperative_forward", "intent_imperative_turnaround", "intent_imperative_turnleft", "intent_imperative_turnright", "intent_play_rollcube", "intent_play_popawheelie", "intent_play_fistbump", "intent_play_blackjack", "intent_imperative_affirmative", "intent_imperative_negative", "intent_photo_take_extend", "intent_imperative_praise", "intent_imperative_abuse", "intent_weather_extend", "intent_imperative_apologize", "intent_imperative_backup", "intent_imperative_volumedown", "intent_imperative_volumeup", "intent_imperative_lookatme", "intent_imperative_volumelevel_extend", "intent_imperative_shutup", "intent_names_username_extend", "intent_imperative_come", "intent_imperative_love", "intent_knowledge_promptquestion", "intent_clock_checktimer", "intent_global_stop_extend", "intent_clock_settimer_extend", "intent_clock_time", "intent_imperative_quiet", "intent_imperative_dance", "intent_play_pickupcube", "intent_imperative_fetchcube", "intent_imperative_findcube", "intent_play_anytrick", "intent_message_recordmessage_extend", "intent_message_playmessage_extend", "intent_blackjack_hit", "intent_blackjack_stand", "intent_play_keepaway"]'
+intentsJson =
+ '["intent_greeting_hello", "intent_names_ask", "intent_imperative_eyecolor", "intent_character_age", "intent_explore_start", "intent_system_charger", "intent_system_sleep", "intent_greeting_goodmorning", "intent_greeting_goodnight", "intent_greeting_goodbye", "intent_seasonal_happynewyear", "intent_seasonal_happyholidays", "intent_amazon_signin", "intent_amazon_signin", "intent_imperative_forward", "intent_imperative_turnaround", "intent_imperative_turnleft", "intent_imperative_turnright", "intent_play_rollcube", "intent_play_popawheelie", "intent_play_fistbump", "intent_play_blackjack", "intent_imperative_affirmative", "intent_imperative_negative", "intent_photo_take_extend", "intent_imperative_praise", "intent_imperative_abuse", "intent_weather_extend", "intent_imperative_apologize", "intent_imperative_backup", "intent_imperative_volumedown", "intent_imperative_volumeup", "intent_imperative_lookatme", "intent_imperative_volumelevel_extend", "intent_imperative_shutup", "intent_names_username_extend", "intent_imperative_come", "intent_imperative_love", "intent_knowledge_promptquestion", "intent_clock_checktimer", "intent_global_stop_extend", "intent_clock_settimer_extend", "intent_clock_time", "intent_imperative_quiet", "intent_imperative_dance", "intent_play_pickupcube", "intent_imperative_fetchcube", "intent_imperative_findcube", "intent_play_anytrick", "intent_message_recordmessage_extend", "intent_message_playmessage_extend", "intent_blackjack_hit", "intent_blackjack_stand", "intent_play_keepaway"]';
function updateIntentSelection(element) {
let xhr = new XMLHttpRequest();
xhr.open("GET", "/api/get_custom_intents_json");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Cache-Control", "no-cache, no-store, max-age=0");
- xhr.responseType = 'json';
+ xhr.responseType = "json";
xhr.send();
- xhr.onload = function() {
+ xhr.onload = function () {
document.getElementById("editIntentStatus").innerHTML = "";
document.getElementById("deleteIntentStatus").innerHTML = "";
- var listResponse = xhr.response
+ var listResponse = xhr.response;
var listNum = 0;
if (listResponse != null) {
- listNum = Object.keys(listResponse).length
+ listNum = Object.keys(listResponse).length;
}
if (listResponse != null && listNum != 0) {
- console.log(listNum)
+ console.log(listNum);
var select = document.createElement("select");
- document.getElementById(element).innerHTML = ""
+ document.getElementById(element).innerHTML = "";
select.name = element + "intents";
- select.id = element + "intents"
+ select.id = element + "intents";
for (const name in listResponse) {
- if (false==listResponse[name]["issystem"]) {
- console.log(listResponse[name]["name"])
+ if (false == listResponse[name]["issystem"]) {
+ console.log(listResponse[name]["name"]);
var option = document.createElement("option");
option.value = listResponse[name]["name"];
- option.text = listResponse[name]["name"]
+ option.text = listResponse[name]["name"];
select.appendChild(option);
}
}
var label = document.createElement("label");
- label.innerHTML = "Choose the intent: "
+ label.innerHTML = "Choose the intent: ";
label.htmlFor = element + "intents";
document.getElementById(element).appendChild(label).appendChild(select);
- select.addEventListener("change", function() {
- if (select.value) {
- hideEditIntents();
- }
+ select.addEventListener("change", function () {
+ if (select.value) {
+ hideEditIntents();
+ }
});
-
-
} else {
- console.log("No intents founda")
+ console.log("No intents founda");
var error1 = document.createElement("p");
var error2 = document.createElement("p");
- error1.innerHTML = "No intents found, you must add one first"
- error2.innerHTML = "No intents found, you must add one first"
+ error1.innerHTML = "No intents found, you must add one first";
+ error2.innerHTML = "No intents found, you must add one first";
document.getElementById("editIntentForm").innerHTML = "";
document.getElementById("editIntentStatus").innerHTML = "";
document.getElementById("deleteIntentStatus").innerHTML = "";
@@ -62,33 +61,39 @@ function updateIntentSelection(element) {
}
function checkInited() {
- fetch("/api/get_config")
- .then(response => response.text())
+ fetch("/api/get_version_info")
.then((response) => {
- parsed = JSON.parse(response)
- console.log(parsed)
- console.log(parsed["pastinitialsetup"])
+ if (!response.ok) {
+ alert("This webroot does not match with the wire-pod binary. Some functionality will be broken. There was either an error during the last update, or you did not precisely follow the update guide.")
+ }
+ })
+ fetch("/api/get_config")
+ .then((response) => response.text())
+ .then((response) => {
+ parsed = JSON.parse(response);
+ console.log(parsed);
+ console.log(parsed["pastinitialsetup"]);
if (parsed["pastinitialsetup"] == false) {
- window.location.href = "/initial.html"
+ window.location.href = "/initial.html";
}
- })
+ });
}
// function that creates select from intentsJson
function createIntentSelect(element) {
var select = document.createElement("select");
- document.getElementById(element).innerHTML = ""
+ document.getElementById(element).innerHTML = "";
select.name = element + "intents";
- select.id = element + "intents"
- var intents = JSON.parse(intentsJson)
+ select.id = element + "intents";
+ var intents = JSON.parse(intentsJson);
for (const name in intents) {
var option = document.createElement("option");
option.value = intents[name];
- option.text = intents[name]
+ option.text = intents[name];
select.appendChild(option);
}
var label = document.createElement("label");
- label.innerHTML = "Intent to send to robot after script executed:"
+ label.innerHTML = "Intent to send to robot after script executed:";
label.htmlFor = element + "intents";
document.getElementById(element).appendChild(label).appendChild(select);
}
@@ -96,188 +101,184 @@ function createIntentSelect(element) {
// get intent from editSelect element and create a form in div#editIntentForm to edit it
// options are: name, description, utterances, intent, paramname, paramvalue, exec
function editFormCreate() {
- var intentNumber = document.getElementById("editSelectintents").selectedIndex;
- var xhr = new XMLHttpRequest();
- xhr.open("GET", "/api/get_custom_intents_json");
- xhr.setRequestHeader("Content-Type", "application/json");
- xhr.setRequestHeader("Cache-Control", "no-cache, no-store, max-age=0");
- xhr.responseType = 'json';
- xhr.send();
- xhr.onload = function() {
- var intentResponse = xhr.response[intentNumber];
- if (intentResponse != null) {
- console.log(intentResponse)
- var form = document.createElement("form");
- form.id = "editIntentForm";
- form.name = "editIntentForm";
-
- var editIntentFrame = document.createElement("div");
- editIntentFrame.id = "editIntentFrame";
- editIntentFrame.name = "editIntentFrame";
-
- // name
- var name = document.createElement("input");
- name.type = "text";
- name.name = "name";
- name.id = "name";
- // create label for name
- var nameLabel = document.createElement("label");
- nameLabel.innerHTML = "Name: "
- nameLabel.htmlFor = "name";
- name.value = intentResponse["name"];
-
- // description
- var description = document.createElement("input");
- description.type = "text";
- description.name = "description";
- description.id = "description";
- // create label for description
- var descriptionLabel = document.createElement("label");
- descriptionLabel.innerHTML = "Description: "
- descriptionLabel.htmlFor = "description";
- description.value = intentResponse["description"];
-
- // utterances
- var utterances = document.createElement("input");
- utterances.type = "text";
- utterances.name = "utterances";
- utterances.id = "utterances";
- // create label for utterances
- var utterancesLabel = document.createElement("label");
- utterancesLabel.innerHTML = "Utterances: "
- utterancesLabel.htmlFor = "utterances";
- utterances.value = intentResponse["utterances"];
-
- // intent
- var intent = document.createElement("select");
- var intents = JSON.parse(intentsJson)
- for (const name in intents)
- {
- var option = document.createElement("option");
- option.value = intents[name];
- option.text = intents[name]
- intent.appendChild(option);
- }
- intent.type = "text";
- intent.name = "intent";
- intent.id = "intent";
- // create label for intent
- var intentLabel = document.createElement("label");
- intentLabel.innerHTML = "Intent: "
- intentLabel.htmlFor = "intent";
- intent.value = intentResponse["intent"];
-
- // paramname
- var paramname = document.createElement("input");
- paramname.type = "text";
- paramname.name = "paramname";
- paramname.id = "paramname";
- // create label for paramname
- var paramnameLabel = document.createElement("label");
- paramnameLabel.innerHTML = "Param Name: "
- paramnameLabel.htmlFor = "paramname";
- paramname.value = intentResponse["params"]["paramname"];
-
- // paramvalue
- var paramvalue = document.createElement("input");
- paramvalue.type = "text";
- paramvalue.name = "paramvalue";
- paramvalue.id = "paramvalue";
- // create label for paramvalue
- var paramvalueLabel = document.createElement("label");
- paramvalueLabel.innerHTML = "Param Value: "
- paramvalueLabel.htmlFor = "paramvalue";
- paramvalue.value = intentResponse["params"]["paramvalue"];
-
- // exec
- var exec = document.createElement("input");
- exec.type = "text";
- exec.name = "exec";
- exec.id = "exec";
- // create label for exec
- var execLabel = document.createElement("label");
- execLabel.innerHTML = "Exec: "
- execLabel.htmlFor = "exec";
- exec.value = intentResponse["exec"];
-
- // execargs
- var execargs = document.createElement("input");
- execargs.type = "text";
- execargs.name = "execargs";
- execargs.id = "execargs";
- // create label for execargs
- var execargsLabel = document.createElement("label");
- execargsLabel.innerHTML = "Exec Args: "
- execargsLabel.htmlFor = "execargs";
- execargs.value = intentResponse["execargs"];
-
- // create button that launches function
- var submit = document.createElement("button");
- submit.type = "button";
- submit.id = "submit";
- submit.innerHTML = "Submit";
- submit.onclick = function() {
- editIntent(intentNumber);
- }
- submit.style.position = "relative";
- submit.style.left = "50%";
- submit.style.top = "15px";
- submit.style.transform = "translate(-50%, -50%)";
-
-
-
- form.appendChild(nameLabel).appendChild(name);
- form.appendChild(document.createElement("br"));
- form.appendChild(descriptionLabel).appendChild(description);
- form.appendChild(document.createElement("br"));
- form.appendChild(utterancesLabel).appendChild(utterances);
- form.appendChild(document.createElement("br"));
- form.appendChild(intentLabel).appendChild(intent);
- form.appendChild(document.createElement("br"));
- form.appendChild(paramnameLabel).appendChild(paramname);
- form.appendChild(document.createElement("br"));
- form.appendChild(paramvalueLabel).appendChild(paramvalue);
- form.appendChild(document.createElement("br"));
- form.appendChild(execLabel).appendChild(exec);
- form.appendChild(document.createElement("br"));
- form.appendChild(execargsLabel).appendChild(execargs);
- form.appendChild(document.createElement("br"));
- form.appendChild(submit);
- document.getElementById("editIntentForm").innerHTML = "";
- document.getElementById("editIntentForm").appendChild(form);
-
- //editIntentFrame.appendChild(nameLabel);
- //editIntentFrame.appendChild(descriptionLabel);
- //editIntentFrame.appendChild(utterancesLabel);
- //editIntentFrame.appendChild(form);
-
- //document.body.appendChild(editIntentFrame);
- showEditIntents();
+ var intentNumber = document.getElementById("editSelectintents").selectedIndex;
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", "/api/get_custom_intents_json");
+ xhr.setRequestHeader("Content-Type", "application/json");
+ xhr.setRequestHeader("Cache-Control", "no-cache, no-store, max-age=0");
+ xhr.responseType = "json";
+ xhr.send();
+ xhr.onload = function () {
+ var intentResponse = xhr.response[intentNumber];
+ if (intentResponse != null) {
+ console.log(intentResponse);
+ var form = document.createElement("form");
+ form.id = "editIntentForm";
+ form.name = "editIntentForm";
+
+ var editIntentFrame = document.createElement("div");
+ editIntentFrame.id = "editIntentFrame";
+ editIntentFrame.name = "editIntentFrame";
+
+ // name
+ var name = document.createElement("input");
+ name.type = "text";
+ name.name = "name";
+ name.id = "name";
+ // create label for name
+ var nameLabel = document.createElement("label");
+ nameLabel.innerHTML = "Name: ";
+ nameLabel.htmlFor = "name";
+ name.value = intentResponse["name"];
+
+ // description
+ var description = document.createElement("input");
+ description.type = "text";
+ description.name = "description";
+ description.id = "description";
+ // create label for description
+ var descriptionLabel = document.createElement("label");
+ descriptionLabel.innerHTML = "Description: ";
+ descriptionLabel.htmlFor = "description";
+ description.value = intentResponse["description"];
+
+ // utterances
+ var utterances = document.createElement("input");
+ utterances.type = "text";
+ utterances.name = "utterances";
+ utterances.id = "utterances";
+ // create label for utterances
+ var utterancesLabel = document.createElement("label");
+ utterancesLabel.innerHTML = "Utterances: ";
+ utterancesLabel.htmlFor = "utterances";
+ utterances.value = intentResponse["utterances"];
+
+ // intent
+ var intent = document.createElement("select");
+ var intents = JSON.parse(intentsJson);
+ for (const name in intents) {
+ var option = document.createElement("option");
+ option.value = intents[name];
+ option.text = intents[name];
+ intent.appendChild(option);
+ }
+ intent.type = "text";
+ intent.name = "intent";
+ intent.id = "intent";
+ // create label for intent
+ var intentLabel = document.createElement("label");
+ intentLabel.innerHTML = "Intent: ";
+ intentLabel.htmlFor = "intent";
+ intent.value = intentResponse["intent"];
+
+ // paramname
+ var paramname = document.createElement("input");
+ paramname.type = "text";
+ paramname.name = "paramname";
+ paramname.id = "paramname";
+ // create label for paramname
+ var paramnameLabel = document.createElement("label");
+ paramnameLabel.innerHTML = "Param Name: ";
+ paramnameLabel.htmlFor = "paramname";
+ paramname.value = intentResponse["params"]["paramname"];
+
+ // paramvalue
+ var paramvalue = document.createElement("input");
+ paramvalue.type = "text";
+ paramvalue.name = "paramvalue";
+ paramvalue.id = "paramvalue";
+ // create label for paramvalue
+ var paramvalueLabel = document.createElement("label");
+ paramvalueLabel.innerHTML = "Param Value: ";
+ paramvalueLabel.htmlFor = "paramvalue";
+ paramvalue.value = intentResponse["params"]["paramvalue"];
+
+ // exec
+ var exec = document.createElement("input");
+ exec.type = "text";
+ exec.name = "exec";
+ exec.id = "exec";
+ // create label for exec
+ var execLabel = document.createElement("label");
+ execLabel.innerHTML = "Exec: ";
+ execLabel.htmlFor = "exec";
+ exec.value = intentResponse["exec"];
+
+ // execargs
+ var execargs = document.createElement("input");
+ execargs.type = "text";
+ execargs.name = "execargs";
+ execargs.id = "execargs";
+ // create label for execargs
+ var execargsLabel = document.createElement("label");
+ execargsLabel.innerHTML = "Exec Args: ";
+ execargsLabel.htmlFor = "execargs";
+ execargs.value = intentResponse["execargs"];
+
+ // create button that launches function
+ var submit = document.createElement("button");
+ submit.type = "button";
+ submit.id = "submit";
+ submit.innerHTML = "Submit";
+ submit.onclick = function () {
+ editIntent(intentNumber);
+ };
+ submit.style.position = "relative";
+ submit.style.left = "50%";
+ submit.style.top = "15px";
+ submit.style.transform = "translate(-50%, -50%)";
+
+ form.appendChild(nameLabel).appendChild(name);
+ form.appendChild(document.createElement("br"));
+ form.appendChild(descriptionLabel).appendChild(description);
+ form.appendChild(document.createElement("br"));
+ form.appendChild(utterancesLabel).appendChild(utterances);
+ form.appendChild(document.createElement("br"));
+ form.appendChild(intentLabel).appendChild(intent);
+ form.appendChild(document.createElement("br"));
+ form.appendChild(paramnameLabel).appendChild(paramname);
+ form.appendChild(document.createElement("br"));
+ form.appendChild(paramvalueLabel).appendChild(paramvalue);
+ form.appendChild(document.createElement("br"));
+ form.appendChild(execLabel).appendChild(exec);
+ form.appendChild(document.createElement("br"));
+ form.appendChild(execargsLabel).appendChild(execargs);
+ form.appendChild(document.createElement("br"));
+ form.appendChild(submit);
+ document.getElementById("editIntentForm").innerHTML = "";
+ document.getElementById("editIntentForm").appendChild(form);
- } else {
- console.log("No intents founda")
- var error1 = document.createElement("p");
- var error2 = document.createElement("p");
- error1.innerHTML = "No intents found, you must add one first"
- error2.innerHTML = "No intents found, you must add one first"
- document.getElementById("editIntentForm").innerHTML = "";
- document.getElementById("editIntentStatus").innerHTML = "";
- document.getElementById("deleteIntentStatus").innerHTML = "";
- document.getElementById("editSelect").innerHTML = "";
- document.getElementById("deleteSelect").innerHTML = "";
- document.getElementById("deleteIntentStatus").appendChild(error1);
- document.getElementById("editIntentStatus").appendChild(error2);
- }
- };
+ //editIntentFrame.appendChild(nameLabel);
+ //editIntentFrame.appendChild(descriptionLabel);
+ //editIntentFrame.appendChild(utterancesLabel);
+ //editIntentFrame.appendChild(form);
+
+ //document.body.appendChild(editIntentFrame);
+ showEditIntents();
+ } else {
+ console.log("No intents founda");
+ var error1 = document.createElement("p");
+ var error2 = document.createElement("p");
+ error1.innerHTML = "No intents found, you must add one first";
+ error2.innerHTML = "No intents found, you must add one first";
+ document.getElementById("editIntentForm").innerHTML = "";
+ document.getElementById("editIntentStatus").innerHTML = "";
+ document.getElementById("deleteIntentStatus").innerHTML = "";
+ document.getElementById("editSelect").innerHTML = "";
+ document.getElementById("deleteSelect").innerHTML = "";
+ document.getElementById("deleteIntentStatus").appendChild(error1);
+ document.getElementById("editIntentStatus").appendChild(error2);
+ }
+ };
}
// create editIntent function that sends post to /api/edit_custom_intent, get index of intent to edit
// form data should include the intent number, name, description, utterances, intent, paramname, paramvalue, exec
function editIntent(intentNumber) {
- console.log(intentNumber)
-
+ console.log(intentNumber);
+
var formData = new FormData();
- formData.append("number", intentNumber+1);
+ formData.append("number", intentNumber + 1);
formData.append("name", document.getElementById("name").value);
formData.append("description", document.getElementById("description").value);
formData.append("utterances", document.getElementById("utterances").value);
@@ -289,80 +290,93 @@ function editIntent(intentNumber) {
var xhr = new XMLHttpRequest();
xhr.open("POST", "/api/edit_custom_intent");
xhr.send(formData);
- xhr.onload = function() {
+ xhr.onload = function () {
var response = xhr.response;
console.log(response);
- console.log("Intent edited")
+ console.log("Intent edited");
var success = document.createElement("p");
- success.innerHTML = "Intent edited successfully"
+ success.innerHTML = "Intent edited successfully";
document.getElementById("editIntentStatus").innerHTML = "";
document.getElementById("editIntentStatus").appendChild(success);
- }
+ };
}
-updateIntentSelection("editSelect")
-updateIntentSelection("deleteSelect")
-createIntentSelect("intentAddSelect")
+updateIntentSelection("editSelect");
+updateIntentSelection("deleteSelect");
+createIntentSelect("intentAddSelect");
-var HttpClient = function() {
- this.get = function(aUrl, aCallback) {
- var anHttpRequest = new XMLHttpRequest();
- anHttpRequest.onreadystatechange = function() {
- if (anHttpRequest.readyState == 4 && anHttpRequest.status == 200)
- aCallback(anHttpRequest.responseText);
- }
- anHttpRequest.open( "GET", aUrl, true );
- anHttpRequest.send( null );
- }
-}
+var HttpClient = function () {
+ this.get = function (aUrl, aCallback) {
+ var anHttpRequest = new XMLHttpRequest();
+ anHttpRequest.onreadystatechange = function () {
+ if (anHttpRequest.readyState == 4 && anHttpRequest.status == 200)
+ aCallback(anHttpRequest.responseText);
+ };
+ anHttpRequest.open("GET", aUrl, true);
+ anHttpRequest.send(null);
+ };
+};
function deleteSelectedIntent() {
var intentNumber = document.getElementById("editSelectintents").selectedIndex;
-
+
var formData = new FormData();
- formData.append("number", intentNumber+1);
- console.log(intentNumber+1)
+ formData.append("number", intentNumber + 1);
+ console.log(intentNumber + 1);
var xhr = new XMLHttpRequest();
xhr.open("POST", "/api/remove_custom_intent");
xhr.send(formData);
- xhr.onload = function() {
+ xhr.onload = function () {
var response = xhr.response;
console.log(response);
- console.log("Intent deleted")
- hideEditIntents()
- updateIntentSelection("editSelect")
- updateIntentSelection("deleteSelect")
- }
+ console.log("Intent deleted");
+ hideEditIntents();
+ updateIntentSelection("editSelect");
+ updateIntentSelection("deleteSelect");
+ };
}
function sendIntentAdd() {
- const form = document.getElementById('intentAddForm');
- var data = "name=" + form.elements['nameAdd'].value + "&description=" + form.elements['descriptionAdd'].value + "&utterances=" + form.elements['utterancesAdd'].value + "&intent=" + form.elements['intentAddSelectintents'].value + "¶mname=" + form.elements['paramnameAdd'].value + "¶mvalue=" + form.elements['paramvalueAdd'].value + "&exec=" + form.elements['execAdd'].value + "&execargs=" + form.elements['execAddArgs'].value;
+ const form = document.getElementById("intentAddForm");
+ var data =
+ "name=" +
+ form.elements["nameAdd"].value +
+ "&description=" +
+ form.elements["descriptionAdd"].value +
+ "&utterances=" +
+ form.elements["utterancesAdd"].value +
+ "&intent=" +
+ form.elements["intentAddSelectintents"].value +
+ "¶mname=" +
+ form.elements["paramnameAdd"].value +
+ "¶mvalue=" +
+ form.elements["paramvalueAdd"].value +
+ "&exec=" +
+ form.elements["execAdd"].value +
+ "&execargs=" +
+ form.elements["execAddArgs"].value;
var client = new HttpClient();
- var result = document.getElementById('addIntentStatus');
- const resultP = document.createElement('p');
- resultP.textContent = "Adding...";
- result.innerHTML = '';
+ var result = document.getElementById("addIntentStatus");
+ const resultP = document.createElement("p");
+ resultP.textContent = "Adding...";
+ result.innerHTML = "";
result.appendChild(resultP);
fetch("/api/add_custom_intent?" + data)
- .then(response => response.text())
- .then((response) => {
- resultP.innerHTML = response
- result.innerHTML = '';
- result.appendChild(resultP);
- updateIntentSelection("editSelect")
- updateIntentSelection("deleteSelect")
- })
+ .then((response) => response.text())
+ .then((response) => {
+ resultP.innerHTML = response;
+ result.innerHTML = "";
+ result.appendChild(resultP);
+ updateIntentSelection("editSelect");
+ updateIntentSelection("deleteSelect");
+ });
}
-
-
-
// Toggle Headllines
function toggleSection(sectionToToggle, sectionToClose, foldableID) {
const toggleSect = document.getElementById(sectionToToggle);
const closeSect = document.getElementById(sectionToClose);
-
+
if (toggleSect.style.display === "block") {
closeSection(toggleSect, foldableID);
} else {
@@ -379,7 +393,6 @@ function closeSection(sectionID, foldableID) {
sectionID.style.display = "none";
}
-
/*
function togglePlusMinusSymbols() {
var h2Elements = document.querySelectorAll("h2[id='foldable']");
@@ -398,386 +411,463 @@ function togglePlusMinusSymbols() {
// Changes color of the clicked icon
function updateColor(id) {
-
- let body_styles = window.getComputedStyle(document.getElementsByTagName("body")[0]);
+ let body_styles = window.getComputedStyle(
+ document.getElementsByTagName("body")[0]
+ );
let fgColor = body_styles.getPropertyValue("--fg-color");
let bgColorAlt = body_styles.getPropertyValue("--bg-color-alt");
- l_id = id.replace("section","icon");
+ l_id = id.replace("section", "icon");
let elements = document.getElementsByName("icon");
for (let i = 0; i < elements.length; i++) {
- document.getElementById(elements[i].id).style.color = bgColorAlt;
+ document.getElementById(elements[i].id).style.color = bgColorAlt;
}
document.getElementById(l_id).style.color = fgColor;
}
-GetLog = false
+GetLog = false;
function showLog() {
- document.getElementById("section-intents").style.display = "none";
- document.getElementById("section-language").style.display = "none";
- document.getElementById("section-log").style.display = "block";
- document.getElementById("section-botauth").style.display = "none";
- updateColor("icon-Logs");
-
- GetLog = true
- logDivArea = document.getElementById("botTranscriptedTextArea")
- document.getElementById("logscrollbottom").checked = true
- logP = document.createElement("p")
- interval = setInterval(function() {
- if (GetLog == false) {
- clearInterval(interval)
- return
- }
- let xhr = new XMLHttpRequest();
- if (document.getElementById("logdebug").checked) {
- xhr.open("GET", "/api/get_debug_logs");
+ document.getElementById("section-intents").style.display = "none";
+ document.getElementById("section-language").style.display = "none";
+ document.getElementById("section-log").style.display = "block";
+ document.getElementById("section-botauth").style.display = "none";
+ document.getElementById("section-version").style.display = "none";
+ updateColor("icon-Logs");
+
+ GetLog = true;
+ logDivArea = document.getElementById("botTranscriptedTextArea");
+ document.getElementById("logscrollbottom").checked = true;
+ logP = document.createElement("p");
+ interval = setInterval(function () {
+ if (GetLog == false) {
+ clearInterval(interval);
+ return;
+ }
+ let xhr = new XMLHttpRequest();
+ if (document.getElementById("logdebug").checked) {
+ xhr.open("GET", "/api/get_debug_logs");
+ } else {
+ xhr.open("GET", "/api/get_logs");
+ }
+ xhr.send();
+ xhr.onload = function () {
+ logDivArea.innerHTML = "";
+ if (xhr.response == "") {
+ logP.innerHTML =
+ "No logs yet, you must say a command to Vector. (this updates automatically)";
+ } else {
+ logP.innerHTML = xhr.response;
+ }
+ if (document.getElementById("logscrollbottom").checked) {
+ logDivArea.value = logP.innerHTML;
+ logDivArea.scrollTop = logDivArea.scrollHeight;
+ } else {
+ logDivArea.value = logP.innerHTML;
+ }
+ };
+ }, 500);
+}
+
+//
+//
+
+function checkUpdate() {
+ cVersion = document.getElementById("cVersion");
+ aUpdate = document.getElementById("aUpdate");
+ cVersion.innerHTML = "Checking for updates...";
+ aUpdate.innerHTML = "";
+ fetch("/api/get_version_info")
+ .then((response) => response.text())
+ .then((response) => {
+ if (response.includes("error")) {
+ cVersion.innerHTML =
+ "There was an error. This is likely because this version of wire-pod was compiled from source, and this section only works with official WirePod releases.";
+ document.getElementById("updateGuideLink").style.display = "none";
+ } else {
+ parsed = JSON.parse(response);
+ cVersion.innerHTML = "Current Version: " + parsed.installed;
+ if (parsed.avail) {
+ aUpdate.innerHTML =
+ "A newer version of WirePod (" +
+ parsed.current +
+ ") is available! Use this guide to update WirePod: ";
+ document.getElementById("updateGuideLink").style.display = "block";
} else {
- xhr.open("GET", "/api/get_logs");
+ aUpdate.innerHTML = "You are on the latest version.";
+ document.getElementById("updateGuideLink").style.display = "none";
}
- xhr.send();
- xhr.onload = function() {
- logDivArea.innerHTML = ""
- if (xhr.response == "") {
- logP.innerHTML = "No logs yet, you must say a command to Vector. (this updates automatically)"
- } else {
- logP.innerHTML = xhr.response
- }
- if (document.getElementById("logscrollbottom").checked) {
- logDivArea.value = logP.innerHTML;
- logDivArea.scrollTop = logDivArea.scrollHeight;
- } else {
- logDivArea.value = logP.innerHTML;
- }
- }
- }, 500)
+ }
+ });
}
function showLanguage() {
- GetLog = false
+ GetLog = false;
document.getElementById("section-weather").style.display = "none";
document.getElementById("section-stt").style.display = "none";
document.getElementById("section-restart").style.display = "none";
document.getElementById("section-kg").style.display = "none";
document.getElementById("section-language").style.display = "block";
updateColor("icon-Language");
- let xhr = new XMLHttpRequest();
- xhr.open("GET", "/api/get_stt_info");
- xhr.send();
- xhr.onload = function() {
- parsed = JSON.parse(xhr.response)
- if (parsed["sttProvider"] != "vosk" && parsed["sttProvider"] != "whisper.cpp") {
- error = document.createElement("p")
- error.innerHTML = "To set the STT language, the provider must be Vosk or Whisper. The current one is '" + parsed["sttProvider"] + "'."
- document.getElementById("languageStatus").appendChild(error)
- document.getElementById("languageSelectionDiv").style.display = "none"
- } else {
- document.getElementById("languageSelectionDiv").style.display = "block"
- console.log(parsed["sttLanguage"])
- document.getElementById("languageSelection").value = parsed["sttLanguage"]
- }
+ let xhr = new XMLHttpRequest();
+ xhr.open("GET", "/api/get_stt_info");
+ xhr.send();
+ xhr.onload = function () {
+ parsed = JSON.parse(xhr.response);
+ if (
+ parsed["sttProvider"] != "vosk" &&
+ parsed["sttProvider"] != "whisper.cpp"
+ ) {
+ error = document.createElement("p");
+ error.innerHTML =
+ "To set the STT language, the provider must be Vosk or Whisper. The current one is '" +
+ parsed["sttProvider"] +
+ "'.";
+ document.getElementById("languageStatus").appendChild(error);
+ document.getElementById("languageSelectionDiv").style.display = "none";
+ } else {
+ document.getElementById("languageSelectionDiv").style.display = "block";
+ console.log(parsed["sttLanguage"]);
+ document.getElementById("languageSelection").value =
+ parsed["sttLanguage"];
}
+ };
+}
+
+function showVersion() {
+ GetLog = false;
+ checkUpdate();
+ document.getElementById("section-log").style.display = "none";
+ document.getElementById("section-language").style.display = "none";
+ document.getElementById("section-botauth").style.display = "none";
+ document.getElementById("section-intents").style.display = "none";
+ document.getElementById("section-version").style.display = "block";
+ updateColor("icon-Version");
}
function showIntents() {
- GetLog = false
- document.getElementById("section-log").style.display = "none";
- document.getElementById("section-language").style.display = "none";
- document.getElementById("section-botauth").style.display = "none";
- document.getElementById("section-intents").style.display = "block";
- updateColor("icon-Intents");
+ GetLog = false;
+ document.getElementById("section-log").style.display = "none";
+ document.getElementById("section-language").style.display = "none";
+ document.getElementById("section-botauth").style.display = "none";
+ document.getElementById("section-intents").style.display = "block";
+ document.getElementById("section-version").style.display = "none";
+ updateColor("icon-Intents");
}
function showWeather() {
- document.getElementById("section-weather").style.display = "block";
- document.getElementById("section-stt").style.display = "none";
- document.getElementById("section-restart").style.display = "none";
- document.getElementById("section-language").style.display = "none";
- document.getElementById("section-kg").style.display = "none";
- updateColor("icon-Weather");
+ document.getElementById("section-weather").style.display = "block";
+ document.getElementById("section-stt").style.display = "none";
+ document.getElementById("section-restart").style.display = "none";
+ document.getElementById("section-language").style.display = "none";
+ document.getElementById("section-kg").style.display = "none";
+ document.getElementById("section-version").style.display = "none";
+ updateColor("icon-Weather");
}
function showKG() {
- document.getElementById("section-weather").style.display = "none";
- document.getElementById("section-stt").style.display = "none";
- document.getElementById("section-restart").style.display = "none";
- document.getElementById("section-language").style.display = "none";
- document.getElementById("section-kg").style.display = "block";
- updateColor("icon-KG");
+ document.getElementById("section-weather").style.display = "none";
+ document.getElementById("section-stt").style.display = "none";
+ document.getElementById("section-restart").style.display = "none";
+ document.getElementById("section-language").style.display = "none";
+ document.getElementById("section-kg").style.display = "block";
+ document.getElementById("section-version").style.display = "none";
+ updateColor("icon-KG");
}
function showSTT() {
- document.getElementById("section-weather").style.display = "none";
- document.getElementById("section-kg").style.display = "none";
- document.getElementById("section-stt").style.display = "block";
- document.getElementById("section-restart").style.display = "none";
- updateColor("icon-STT");
+ document.getElementById("section-weather").style.display = "none";
+ document.getElementById("section-kg").style.display = "none";
+ document.getElementById("section-stt").style.display = "block";
+ document.getElementById("section-restart").style.display = "none";
+ document.getElementById("section-version").style.display = "none";
+ updateColor("icon-STT");
}
function showRestart() {
- document.getElementById("section-weather").style.display = "none";
- document.getElementById("section-kg").style.display = "none";
- document.getElementById("section-stt").style.display = "none";
- document.getElementById("section-restart").style.display = "block";
- updateColor("icon-Restart");
+ document.getElementById("section-weather").style.display = "none";
+ document.getElementById("section-kg").style.display = "none";
+ document.getElementById("section-stt").style.display = "none";
+ document.getElementById("section-restart").style.display = "block";
+ document.getElementById("section-version").style.display = "none";
+ updateColor("icon-Restart");
}
function checkWeather() {
- if (document.getElementById("weatherProvider").value=="") {
- document.getElementById("apiKey").value = "";
- document.getElementById("apiKeySpan").style.display = "none";
- }
- else {
- document.getElementById("apiKeySpan").style.display = "block";
- }
+ if (document.getElementById("weatherProvider").value == "") {
+ document.getElementById("apiKey").value = "";
+ document.getElementById("apiKeySpan").style.display = "none";
+ } else {
+ document.getElementById("apiKeySpan").style.display = "block";
+ }
}
function sendWeatherAPIKey() {
- var form = document.getElementById("weatherAPIAddForm");
- var provider = document.getElementById("weatherProvider").value;
-
- var data = "provider=" + provider + "&api_key=" + form.elements["apiKey"].value;
- var result = document.getElementById('addWeatherProviderAPIStatus');
- const resultP = document.createElement('p');
- resultP.textContent = "Saving...";
- result.innerHTML = '';
- result.appendChild(resultP);
- fetch("/api/set_weather_api?" + data)
- .then(response => response.text())
- .then((response) => {
- resultP.innerHTML = response
- result.innerHTML = '';
- result.appendChild(resultP);
- })
+ var form = document.getElementById("weatherAPIAddForm");
+ var provider = document.getElementById("weatherProvider").value;
+
+ var data =
+ "provider=" + provider + "&api_key=" + form.elements["apiKey"].value;
+ var result = document.getElementById("addWeatherProviderAPIStatus");
+ const resultP = document.createElement("p");
+ resultP.textContent = "Saving...";
+ result.innerHTML = "";
+ result.appendChild(resultP);
+ fetch("/api/set_weather_api?" + data)
+ .then((response) => response.text())
+ .then((response) => {
+ resultP.innerHTML = response;
+ result.innerHTML = "";
+ result.appendChild(resultP);
+ });
}
function updateWeatherAPI() {
- fetch("/api/get_weather_api")
- .then(response => response.text())
- .then((response) => {
- obj = JSON.parse(response);
- document.getElementById("weatherProvider").value = obj.weatherProvider;
- document.getElementById("apiKey").value = obj.weatherApiKey;
- checkWeather();
- })
+ fetch("/api/get_weather_api")
+ .then((response) => response.text())
+ .then((response) => {
+ obj = JSON.parse(response);
+ document.getElementById("weatherProvider").value = obj.weatherProvider;
+ document.getElementById("apiKey").value = obj.weatherApiKey;
+ checkWeather();
+ });
}
function checkKG() {
- if (document.getElementById("kgProvider").value=="") {
- document.getElementById("houndifyInput").style.display = "none";
- document.getElementById("togetherInput").style.display = "none";
- document.getElementById("openAIInput").style.display = "none";
- document.getElementById("saveChatInput").style.display = "none";
- } else if (document.getElementById("kgProvider").value=="houndify") {
- document.getElementById("togetherInput").style.display = "none";
- document.getElementById("openAIInput").style.display = "none";
- document.getElementById("houndifyInput").style.display = "block";
- document.getElementById("saveChatInput").style.display = "none";
- } else if (document.getElementById("kgProvider").value=="openai") {
- document.getElementById("openAIInput").style.display = "block";
- document.getElementById("togetherInput").style.display = "none";
- document.getElementById("houndifyInput").style.display = "none";
- document.getElementById("saveChatInput").style.display = "block";
-
- } else if (document.getElementById("kgProvider").value=="together") {
- document.getElementById("togetherInput").style.display = "block";
- document.getElementById("openAIInput").style.display = "none";
- document.getElementById("houndifyInput").style.display = "none";
- document.getElementById("saveChatInput").style.display = "block";
- }
+ if (document.getElementById("kgProvider").value == "") {
+ document.getElementById("houndifyInput").style.display = "none";
+ document.getElementById("togetherInput").style.display = "none";
+ document.getElementById("openAIInput").style.display = "none";
+ document.getElementById("saveChatInput").style.display = "none";
+ } else if (document.getElementById("kgProvider").value == "houndify") {
+ document.getElementById("togetherInput").style.display = "none";
+ document.getElementById("openAIInput").style.display = "none";
+ document.getElementById("houndifyInput").style.display = "block";
+ document.getElementById("saveChatInput").style.display = "none";
+ } else if (document.getElementById("kgProvider").value == "openai") {
+ document.getElementById("openAIInput").style.display = "block";
+ document.getElementById("togetherInput").style.display = "none";
+ document.getElementById("houndifyInput").style.display = "none";
+ document.getElementById("saveChatInput").style.display = "block";
+ } else if (document.getElementById("kgProvider").value == "together") {
+ document.getElementById("togetherInput").style.display = "block";
+ document.getElementById("openAIInput").style.display = "none";
+ document.getElementById("houndifyInput").style.display = "none";
+ document.getElementById("saveChatInput").style.display = "block";
+ }
}
function sendKGAPIKey() {
- var provider = document.getElementById("kgProvider").value
- var key = ""
- var openAIPrompt = ""
- var id = ""
- var intentgraph = ""
- var robotName = ""
- var model = ""
- var saveChat = ""
- var doCommands = ""
-
- if (provider == "openai") {
- key = document.getElementById("openAIKey").value
- openAIPrompt = document.getElementById("openAIPrompt").value
- if (document.getElementById("commandYes").checked == true) {
- doCommands = "true"
- } else {
- doCommands = "false"
- }
- if (document.getElementById("intentyes").checked == true) {
- intentgraph = "true"
- } else {
- intentgraph = "false"
- }
- if (document.getElementById("saveChatYes").checked == true) {
- saveChat = "true"
- } else {
- saveChat = "false"
- }
- } else if (provider == "together") {
- key = document.getElementById("togetherKey").value
- model = document.getElementById("togetherModel").value
- openAIPrompt = document.getElementById("togetherAIPrompt").value
- if (document.getElementById("togetherintentyes").checked == true) {
- intentgraph = "true"
- } else {
- intentgraph = "false"
- }
- if (document.getElementById("saveChatYes").checked == true) {
- saveChat = "true"
- } else {
- saveChat = "false"
- }
- } else if (provider == "houndify") {
- key = document.getElementById("houndKey").value
- model = ""
- id = document.getElementById("houndID").value
- intentgraph = "false"
+ var provider = document.getElementById("kgProvider").value;
+ var key = "";
+ var openAIPrompt = "";
+ var id = "";
+ var intentgraph = "";
+ var robotName = "";
+ var model = "";
+ var saveChat = "";
+ var doCommands = "";
+
+ if (provider == "openai") {
+ key = document.getElementById("openAIKey").value;
+ openAIPrompt = document.getElementById("openAIPrompt").value;
+ if (document.getElementById("commandYes").checked == true) {
+ doCommands = "true";
+ } else {
+ doCommands = "false";
+ }
+ if (document.getElementById("intentyes").checked == true) {
+ intentgraph = "true";
+ } else {
+ intentgraph = "false";
+ }
+ if (document.getElementById("saveChatYes").checked == true) {
+ saveChat = "true";
+ } else {
+ saveChat = "false";
+ }
+ } else if (provider == "together") {
+ key = document.getElementById("togetherKey").value;
+ model = document.getElementById("togetherModel").value;
+ openAIPrompt = document.getElementById("togetherAIPrompt").value;
+ if (document.getElementById("togetherintentyes").checked == true) {
+ intentgraph = "true";
} else {
- key = ""
- id = ""
- model = ""
- intentgraph = "false"
+ intentgraph = "false";
}
+ if (document.getElementById("saveChatYes").checked == true) {
+ saveChat = "true";
+ } else {
+ saveChat = "false";
+ }
+ } else if (provider == "houndify") {
+ key = document.getElementById("houndKey").value;
+ model = "";
+ id = document.getElementById("houndID").value;
+ intentgraph = "false";
+ } else {
+ key = "";
+ id = "";
+ model = "";
+ intentgraph = "false";
+ }
- var data = "provider=" + provider + "&api_key=" + key + "&model=" + model + "&api_id=" + id + "&intent_graph=" + intentgraph + "&robot_name=" + robotName + "&openai_prompt=" + openAIPrompt + "&save_chat=" + saveChat + "&commands_enable=" + doCommands
- var result = document.getElementById('addKGProviderAPIStatus');
- const resultP = document.createElement('p');
- resultP.textContent = "Saving...";
- result.innerHTML = '';
- result.appendChild(resultP);
- fetch("/api/set_kg_api?" + data)
- .then(response => response.text())
- .then((response) => {
- resultP.innerHTML = response
- result.innerHTML = '';
- result.appendChild(resultP);
- alert(response);
- })
+ var data =
+ "provider=" +
+ provider +
+ "&api_key=" +
+ key +
+ "&model=" +
+ model +
+ "&api_id=" +
+ id +
+ "&intent_graph=" +
+ intentgraph +
+ "&robot_name=" +
+ robotName +
+ "&openai_prompt=" +
+ openAIPrompt +
+ "&save_chat=" +
+ saveChat +
+ "&commands_enable=" +
+ doCommands;
+ var result = document.getElementById("addKGProviderAPIStatus");
+ const resultP = document.createElement("p");
+ resultP.textContent = "Saving...";
+ result.innerHTML = "";
+ result.appendChild(resultP);
+ fetch("/api/set_kg_api?" + data)
+ .then((response) => response.text())
+ .then((response) => {
+ resultP.innerHTML = response;
+ result.innerHTML = "";
+ result.appendChild(resultP);
+ alert(response);
+ });
}
function deleteSavedChats() {
- if(confirm("Are you sure? This will delete all saved chats.")){
+ if (confirm("Are you sure? This will delete all saved chats.")) {
fetch("/api/delete_chats")
- .then(response => response.text())
+ .then((response) => response.text())
.then((response) => {
- //console.log(response)
- alert("Successfully deleted all saved chats.")
- })
+ //console.log(response)
+ alert("Successfully deleted all saved chats.");
+ });
}
}
function updateKGAPI() {
- fetch("/api/get_kg_api")
- .then(response => response.text())
- .then((response) => {
- obj = JSON.parse(response);
- document.getElementById("kgProvider").value = obj.kgProvider;
- if (obj.kgProvider == "openai") {
- document.getElementById("openAIKey").value = obj.kgApiKey;
- document.getElementById("openAIPrompt").value = obj.kgOpenAIPrompt;
- if (obj.kgCommandsEnable == "true") {
- document.getElementById("commandYes").checked = true;
- } else {
- document.getElementById("commandNo").checked = true;
- }
- if (obj.kgIntentGraph == "true") {
- document.getElementById("intentyes").checked = true;
- } else {
- document.getElementById("intentno").checked = true;
- }
- if (obj.kgSaveChat == "true") {
- document.getElementById("saveChatYes").checked = true;
- } else {
- document.getElementById("saveChatNo").checked = true;
- }
- } else if (obj.kgProvider == "together") {
- document.getElementById("togetherKey").value = obj.kgApiKey;
- document.getElementById("togetherModel").value = obj.kgModel;
- document.getElementById("togetherAIPrompt").value = obj.kgOpenAIPrompt;
- if (obj.kgIntentGraph == "true") {
- document.getElementById("intentyes").checked = true;
- document.getElementById("togetherintentyes").checked = true;
- } else {
- document.getElementById("intentno").checked = true;
- document.getElementById("togetherintentyes").checked = true;
- }
- if (obj.kgSaveChat == "true") {
- document.getElementById("saveChatYes").checked = true;
- } else {
- document.getElementById("saveChatNo").checked = true;
- }
- } else if (obj.kgProvider == "houndify") {
- document.getElementById("houndKey").value = obj.kgApiKey;
- document.getElementById("houndID").value = obj.kgApiID;
- }
- checkKG();
- })
+ fetch("/api/get_kg_api")
+ .then((response) => response.text())
+ .then((response) => {
+ obj = JSON.parse(response);
+ document.getElementById("kgProvider").value = obj.kgProvider;
+ if (obj.kgProvider == "openai") {
+ document.getElementById("openAIKey").value = obj.kgApiKey;
+ document.getElementById("openAIPrompt").value = obj.kgOpenAIPrompt;
+ if (obj.kgCommandsEnable == "true") {
+ document.getElementById("commandYes").checked = true;
+ } else {
+ document.getElementById("commandNo").checked = true;
+ }
+ if (obj.kgIntentGraph == "true") {
+ document.getElementById("intentyes").checked = true;
+ } else {
+ document.getElementById("intentno").checked = true;
+ }
+ if (obj.kgSaveChat == "true") {
+ document.getElementById("saveChatYes").checked = true;
+ } else {
+ document.getElementById("saveChatNo").checked = true;
+ }
+ } else if (obj.kgProvider == "together") {
+ document.getElementById("togetherKey").value = obj.kgApiKey;
+ document.getElementById("togetherModel").value = obj.kgModel;
+ document.getElementById("togetherAIPrompt").value = obj.kgOpenAIPrompt;
+ if (obj.kgIntentGraph == "true") {
+ document.getElementById("intentyes").checked = true;
+ document.getElementById("togetherintentyes").checked = true;
+ } else {
+ document.getElementById("intentno").checked = true;
+ document.getElementById("togetherintentyes").checked = true;
+ }
+ if (obj.kgSaveChat == "true") {
+ document.getElementById("saveChatYes").checked = true;
+ } else {
+ document.getElementById("saveChatNo").checked = true;
+ }
+ } else if (obj.kgProvider == "houndify") {
+ document.getElementById("houndKey").value = obj.kgApiKey;
+ document.getElementById("houndID").value = obj.kgApiID;
+ }
+ checkKG();
+ });
}
function setSTTLanguage() {
- var language = document.getElementById("languageSelection").value;
- var data = "language=" + language;
- document.getElementById("languageSelectionDiv").style.display = "none"
- var result = document.getElementById('languageStatus');
- var resultP = document.createElement('p');
- resultP.textContent = "Setting...";
- result.innerHTML = '';
- result.appendChild(resultP);
- fetch("/api/set_stt_info?" + data)
- .then(response => response.text())
- .then((response) => {
- resultP.innerHTML = response
- result.innerHTML = '';
- if (response.includes("success")) {
- resultP.innerHTML = "Language switched successfully."
- document.getElementById("languageSelectionDiv").style.display = "block"
- } else if (response.includes("downloading")) {
- resultP.innerHTML = "Downloading model..."
- result.appendChild(resultP);
- updateSTTLanguageDownload()
- return
- } else if (response.includes("error")) {
- document.getElementById("languageSelectionDiv").style.display = "block"
- resultP.innerHTML = response
- }
- result.appendChild(resultP);
- })
+ var language = document.getElementById("languageSelection").value;
+ var data = "language=" + language;
+ document.getElementById("languageSelectionDiv").style.display = "none";
+ var result = document.getElementById("languageStatus");
+ var resultP = document.createElement("p");
+ resultP.textContent = "Setting...";
+ result.innerHTML = "";
+ result.appendChild(resultP);
+ fetch("/api/set_stt_info?" + data)
+ .then((response) => response.text())
+ .then((response) => {
+ resultP.innerHTML = response;
+ result.innerHTML = "";
+ if (response.includes("success")) {
+ resultP.innerHTML = "Language switched successfully.";
+ document.getElementById("languageSelectionDiv").style.display = "block";
+ } else if (response.includes("downloading")) {
+ resultP.innerHTML = "Downloading model...";
+ result.appendChild(resultP);
+ updateSTTLanguageDownload();
+ return;
+ } else if (response.includes("error")) {
+ document.getElementById("languageSelectionDiv").style.display = "block";
+ resultP.innerHTML = response;
+ }
+ result.appendChild(resultP);
+ });
}
function updateSTTLanguageDownload() {
- var resultP = document.createElement('p');
- var result = document.getElementById('languageStatus');
- interval = setInterval(function(){
+ var resultP = document.createElement("p");
+ var result = document.getElementById("languageStatus");
+ interval = setInterval(function () {
fetch("/api/get_download_status")
- .then(response => response.text())
- .then((response => {
- statusText = response
+ .then((response) => response.text())
+ .then((response) => {
+ statusText = response;
if (response.includes("success")) {
- statusText = "Language switched successfully."
- resultP.textContent = statusText
- result.innerHTML = '';
+ statusText = "Language switched successfully.";
+ resultP.textContent = statusText;
+ result.innerHTML = "";
result.appendChild(resultP);
- document.getElementById("languageSelectionDiv").style.display = "block"
- clearInterval(interval)
- return
+ document.getElementById("languageSelectionDiv").style.display =
+ "block";
+ clearInterval(interval);
+ return;
} else if (response.includes("error")) {
- resultP.textContent = statusText
- result.innerHTML = '';
+ resultP.textContent = statusText;
+ result.innerHTML = "";
result.appendChild(resultP);
- document.getElementById("languageSelectionDiv").style.display = "block"
- clearInterval(interval)
- return
+ document.getElementById("languageSelectionDiv").style.display =
+ "block";
+ clearInterval(interval);
+ return;
} else if (response.includes("not downloading")) {
- statusText = "Initiating download..."
+ statusText = "Initiating download...";
}
- resultP.textContent = statusText
- result.innerHTML = '';
+ resultP.textContent = statusText;
+ result.innerHTML = "";
result.appendChild(resultP);
- }))
- }, 500)
+ });
+ }, 500);
}
// function updateSTTLanguage() {
@@ -791,20 +881,20 @@ function updateSTTLanguageDownload() {
// }
function sendRestart() {
- fetch("/api/reset")
- .then(response => response.text())
- .then((response) => {
- resultP.innerHTML = response
- result.innerHTML = '';
- result.appendChild(resultP);
- })
+ fetch("/api/reset")
+ .then((response) => response.text())
+ .then((response) => {
+ resultP.innerHTML = response;
+ result.innerHTML = "";
+ result.appendChild(resultP);
+ });
}
function hideEditIntents() {
- document.getElementById("editIntentForm").style.display = "none";
- document.getElementById("editIntentStatus").innerHTML = "";
+ document.getElementById("editIntentForm").style.display = "none";
+ document.getElementById("editIntentStatus").innerHTML = "";
}
function showEditIntents() {
- document.getElementById("editIntentForm").style.display = "block";
+ document.getElementById("editIntentForm").style.display = "block";
}
diff --git a/chipper/webroot/js/ssh.js b/chipper/webroot/js/ssh.js
index 6bdfd93e..ecb026b9 100644
--- a/chipper/webroot/js/ssh.js
+++ b/chipper/webroot/js/ssh.js
@@ -1,64 +1,66 @@
function updateSSHStatus(statusString) {
- setupStatus = document.getElementById("oskrSetupProgress")
- setupStatus.innerHTML = ""
- setupStatusP = document.createElement("p")
- setupStatusP.innerHTML = statusString
- setupStatus.appendChild(setupStatusP)
+ setupStatus = document.getElementById("oskrSetupProgress");
+ setupStatus.innerHTML = "";
+ setupStatusP = document.createElement("p");
+ setupStatusP.innerHTML = statusString;
+ setupStatus.appendChild(setupStatusP);
}
function doSSHSetup() {
- const ip = document.getElementById('sshIp').value;
- const key = document.getElementById('sshKeyFile').files[0];
-
+ const ip = document.getElementById("sshIp").value;
+ const key = document.getElementById("sshKeyFile").files[0];
+
if (ip && key) {
const formData = new FormData();
- formData.append('key', key);
- formData.append('ip', ip);
-
- fetch('/api-ssh/setup', {
- method: 'POST',
- body: formData
- })
- .then(response => response.text())
- .then((response => {
- if (response.includes("running")) {
- document.getElementById("oskrSetup").style.display = "none"
- updateSSHSetup()
- return
- } else {
- updateSSHStatus(response)
- }
+ formData.append("key", key);
+ formData.append("ip", ip);
+
+ fetch("/api-ssh/setup", {
+ method: "POST",
+ body: formData,
})
- )
-} else {
- updateSSHStatus("You must enter an IP address and upload a key.")
-}
+ .then((response) => response.text())
+ .then((response) => {
+ if (response.includes("running")) {
+ document.getElementById("oskrSetup").style.display = "none";
+ updateSSHSetup();
+ return;
+ } else {
+ updateSSHStatus(response);
+ }
+ });
+ } else {
+ updateSSHStatus("You must enter an IP address and upload a key.");
+ }
}
function updateSSHSetup() {
- interval = setInterval(function(){
+ interval = setInterval(function () {
fetch("/api-ssh/get_setup_status")
- .then(response => response.text())
- .then((response => {
- statusText = response
+ .then((response) => response.text())
+ .then((response) => {
+ statusText = response;
if (response.includes("done")) {
- updateSSHStatus("File transfer complete! Use the above section to complete bot setup. The bot should eventually be on the onboarding screen.")
- document.getElementById("oskrSetup").style.display = "block"
- clearInterval(interval)
+ updateSSHStatus(
+ "File transfer complete! Use the above section to complete bot setup. The bot should eventually be on the onboarding screen."
+ );
+ document.getElementById("oskrSetup").style.display = "block";
+ clearInterval(interval);
} else if (response.includes("error")) {
- resp = response
+ resp = response;
if (response.includes("no route to host")) {
- resp = "Wire-pod was unable to connect to the robot. Make sure the robot is running OSKR/dev software and that it is on the same network as this wire-pod instance. Also double-check the IP."
+ resp =
+ "Wire-pod was unable to connect to the robot. Make sure the robot is running OSKR/dev software and that it is on the same network as this wire-pod instance. Also double-check the IP.";
}
- updateSSHStatus(resp)
- clearInterval(interval)
- document.getElementById("oskrSetup").style.display = "block"
- return
+ updateSSHStatus(resp);
+ clearInterval(interval);
+ document.getElementById("oskrSetup").style.display = "block";
+ return;
} else if (response.includes("not running")) {
- updateSSHStatus("Initiating SSH transfer...")
+ updateSSHStatus("Initiating SSH transfer...");
} else {
- updateSSHStatus(response)
+ updateSSHStatus(response);
}
- }))
- }, 500)
-}
\ No newline at end of file
+ });
+ }, 500);
+}
diff --git a/chipper/webroot/sdkapp/control.html b/chipper/webroot/sdkapp/control.html
index 3aab3332..38e13a51 100755
--- a/chipper/webroot/sdkapp/control.html
+++ b/chipper/webroot/sdkapp/control.html
@@ -1,69 +1,114 @@
-
- Vector Web App
-
-
-
-
-
+
+ Vector Web App
+
+
+
+
+
+
-
-
-
- To use Houndify, create an account at houndify.com, create a free domain, and enter the Client ID and Key here.
-
-
-
-
-
-
- To use Together, create an account at together.com, create a free domain, and enter the Model Name and Together Key here.
-
-
-
-
-
-
-
-
Would you like to enable the intent graph feature? This forwards the request to Together if the regular intent processor didn't understand what you said.
-
-
-
-
-
-
-
-
-
-
-
-
-
Would you like to enable the intent graph feature? This forwards the request to OpenAI if the regular intent processor didn't understand what you said.
-
-
-
-
-
Enable LLM commands (allows the LLM to play animations on the robot)? (BETA)
-
-
-
-
+
+
Knowledge Graph Setup
+
+
Set the Knowledge Graph Provider you want to use
+
+
+
+
+
+ To use Houndify, create an account at
+ houndify.com,
+ create a free domain, and enter the Client ID and Key
+ here.
+
+
+
+
+
+
+ To use Together, create an account at
+ together.com, create a
+ free domain, and enter the Model Name and Together Key
+ here.
+
+
+
+
+
+
+
+
+ Would you like to enable the intent graph feature? This
+ forwards the request to Together if the regular intent
+ processor didn't understand what you said.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Would you like to enable the intent graph feature? This
+ forwards the request to OpenAI if the regular intent processor
+ didn't understand what you said.
+
+
+
+
+
+
+ Enable LLM commands (allows the LLM to play animations on the
+ robot)? (BETA)
+
+
+
+
+
+
+
+
+
+ Would you like chats to be saved and used in the context of
+ future responses?
+
+
+
+
+
+
+
+
-
-
-
Would you like chats to be saved and used in the context of future responses?
-
-
-
-
-
+
-
-
-
+
+
-
-
-
-
-
+
-
-
Speech-To-Text Language
-
-
Set the STT language you want to use. Works only with VOSK or Whisper as STT provider.
-
-
-
-
-
-
-
+
+
Speech-To-Text Language
+
+
+ Set the STT language you want to use. Works only with VOSK or
+ Whisper as STT provider.
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
-
-
Restart Wire-Pod
-
-
Restart Wire-Pod to apply the initial setup settings immediately
-
-
-
-
+
+
Restart Wire-Pod
+
+
+ Restart Wire-Pod to apply the initial setup settings immediately
+
+
+
+
+
+
+
-
-
-
-
-
+
-
-
STT Language
-
-
-
-
-
-
-
+
+
STT Language
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
diff --git a/setup.sh b/setup.sh
index d4e824e4..bacdf295 100755
--- a/setup.sh
+++ b/setup.sh
@@ -13,26 +13,26 @@ if [[ ${UNAME} == *"Darwin"* ]]; then
ROOT="$HOME"
echo "macOS detected."
if [[ ! -f /usr/local/go/bin/go ]]; then
- if [[ -f /usr/local/bin/go ]]; then
- mkdir -p /usr/local/go/bin
- ln -s /usr/local/bin/go /usr/local/go/bin/go
- else
- echo "Go was not found. You must download it from https://go.dev/dl/ for your macOS."
- exit 1
- fi
+ if [[ -f /usr/local/bin/go ]]; then
+ mkdir -p /usr/local/go/bin
+ ln -s /usr/local/bin/go /usr/local/go/bin/go
+ else
+ echo "Go was not found. You must download it from https://go.dev/dl/ for your macOS."
+ exit 1
+ fi
fi
else
echo "macOS detected, but 'brew' was not found. Install it with the following command and try running setup.sh again:"
echo '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"'
exit 1
fi
-elif [[ -f /usr/bin/apt ]]; then
+ elif [[ -f /usr/bin/apt ]]; then
TARGET="debian"
echo "Debian-based Linux detected."
-elif [[ -f /usr/bin/pacman ]]; then
+ elif [[ -f /usr/bin/pacman ]]; then
TARGET="arch"
echo "Arch Linux detected."
-elif [[ -f /usr/bin/dnf ]]; then
+ elif [[ -f /usr/bin/dnf ]]; then
TARGET="fedora"
echo "Fedora/openSUSE detected."
else
@@ -47,10 +47,10 @@ fi
if [[ "${UNAME}" == *"x86_64"* ]]; then
ARCH="x86_64"
echo "amd64 architecture confirmed."
-elif [[ "${UNAME}" == *"aarch64"* ]] || [[ "${UNAME}" == *"arm64"* ]]; then
+ elif [[ "${UNAME}" == *"aarch64"* ]] || [[ "${UNAME}" == *"arm64"* ]]; then
ARCH="aarch64"
echo "aarch64 architecture confirmed."
-elif [[ "${UNAME}" == *"armv7l"* ]]; then
+ elif [[ "${UNAME}" == *"armv7l"* ]]; then
ARCH="armv7l"
echo "armv7l (32-bit) WARN: The Coqui and VOSK bindings are broken for this platform at the moment, so please choose Picovoice when the script asks. wire-pod is designed for 64-bit systems."
STT=""
@@ -91,13 +91,13 @@ function getPackages() {
if [[ ${TARGET} == "debian" ]]; then
apt update -y
apt install -y wget openssl net-tools libsox-dev libopus-dev make iproute2 xz-utils libopusfile-dev pkg-config gcc curl g++ unzip avahi-daemon git libasound2-dev libsodium-dev
- elif [[ ${TARGET} == "arch" ]]; then
+ elif [[ ${TARGET} == "arch" ]]; then
pacman -Sy --noconfirm
sudo pacman -S --noconfirm wget openssl net-tools sox opus make iproute2 opusfile curl unzip avahi git libsodium go pkg-config
- elif [[ ${TARGET} == "fedora" ]]; then
+ elif [[ ${TARGET} == "fedora" ]]; then
dnf update
dnf install -y wget openssl net-tools sox opus make opusfile curl unzip avahi git libsodium-devel
- elif [[ ${TARGET} == "darwin" ]]; then
+ elif [[ ${TARGET} == "darwin" ]]; then
sudo -u $SUDO_USER brew update
sudo -u $SUDO_USER brew install wget pkg-config opus opusfile
fi
@@ -111,10 +111,10 @@ function getPackages() {
if [[ ${ARCH} == "x86_64" ]]; then
wget -q --show-progress --no-check-certificate https://go.dev/dl/go1.19.4.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.19.4.linux-amd64.tar.gz
- elif [[ ${ARCH} == "aarch64" ]]; then
+ elif [[ ${ARCH} == "aarch64" ]]; then
wget -q --show-progress --no-check-certificate https://go.dev/dl/go1.19.4.linux-arm64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.19.4.linux-arm64.tar.gz
- elif [[ ${ARCH} == "armv7l" ]]; then
+ elif [[ ${ARCH} == "armv7l" ]]; then
wget -q --show-progress --no-check-certificate https://go.dev/dl/go1.19.4.linux-armv6l.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.19.4.linux-armv6l.tar.gz
fi
@@ -122,10 +122,10 @@ function getPackages() {
fi
else
echo "This is a macOS or arch target, assuming Go is installed already"
- if [[ ${TARGET} == "arch" ]] && [[ ! -d /usr/local/go/bin ]]; then
- mkdir -p /usr/local/go/bin
- ln -s /usr/bin/go /usr/local/go/bin/go
- fi
+ if [[ ${TARGET} == "arch" ]] && [[ ! -d /usr/local/go/bin ]]; then
+ mkdir -p /usr/local/go/bin
+ ln -s /usr/bin/go /usr/local/go/bin/go
+ fi
fi
cd ..
rm -rf golang
@@ -146,18 +146,18 @@ function getSTT() {
read -p "Enter a number (3): " sttServiceNum
if [[ ! -n ${sttServiceNum} ]]; then
sttService="vosk"
- elif [[ ${sttServiceNum} == "1" ]]; then
+ elif [[ ${sttServiceNum} == "1" ]]; then
if [[ ${TARGET} == "darwin" ]]; then
echo "Coqui is not supported for macOS. Please select another option."
sttServicePrompt
else
- sttService="coqui"
+ sttService="coqui"
fi
- elif [[ ${sttServiceNum} == "2" ]]; then
+ elif [[ ${sttServiceNum} == "2" ]]; then
sttService="leopard"
- elif [[ ${sttServiceNum} == "3" ]]; then
+ elif [[ ${sttServiceNum} == "3" ]]; then
sttService="vosk"
- elif [[ ${sttServiceNum} == "4" ]]; then
+ elif [[ ${sttServiceNum} == "4" ]]; then
sttService="whisper"
else
echo
@@ -185,9 +185,9 @@ function getSTT() {
}
picoApiPrompt
echo "export STT_SERVICE=leopard" >> ./chipper/source.sh
- echo "export PICOVOICE_APIKEY=${picoKey}" >> ./chipper/source.sh
+ echo "export PICOVOICE_APIKEY=${picoKey}" >> ./chipper/source.sh
echo "export PICOVOICE_APIKEY=${picoKey}" > ./chipper/pico.key
- elif [[ ${sttService} == "vosk" ]]; then
+ elif [[ ${sttService} == "vosk" ]]; then
echo "export STT_SERVICE=vosk" >> ./chipper/source.sh
origDir="$(pwd)"
if [[ ! -f ./vosk/completed ]]; then
@@ -199,11 +199,11 @@ function getSTT() {
if [[ ${TARGET} == "darwin" ]]; then
VOSK_VER="0.3.42"
VOSK_DIR="vosk-osx-${VOSK_VER}"
- elif [[ ${ARCH} == "x86_64" ]]; then
+ elif [[ ${ARCH} == "x86_64" ]]; then
VOSK_DIR="vosk-linux-x86_64-${VOSK_VER}"
- elif [[ ${ARCH} == "aarch64" ]]; then
+ elif [[ ${ARCH} == "aarch64" ]]; then
VOSK_DIR="vosk-linux-aarch64-${VOSK_VER}"
- elif [[ ${ARCH} == "armv7l" ]]; then
+ elif [[ ${ARCH} == "armv7l" ]]; then
VOSK_DIR="vosk-linux-armv7l-${VOSK_VER}"
fi
VOSK_ARCHIVE="$VOSK_DIR.zip"
@@ -211,7 +211,7 @@ function getSTT() {
unzip "$VOSK_ARCHIVE"
mv "$VOSK_DIR" libvosk
rm -fr "$VOSK_ARCHIVE"
-
+
cd ${origDir}/chipper
export CGO_ENABLED=1
export CGO_CFLAGS="-I${ROOT}/.vosk/libvosk"
@@ -222,7 +222,7 @@ function getSTT() {
/usr/local/go/bin/go install github.com/kercre123/vosk-api/go
cd ${origDir}
fi
- elif [[ ${sttService} == "whisper" ]]; then
+ elif [[ ${sttService} == "whisper" ]]; then
echo "export STT_SERVICE=whisper.cpp" >> ./chipper/source.sh
origDir="$(pwd)"
echo "Getting Whisper assets"
@@ -259,7 +259,7 @@ function getSTT() {
cd ${origDir}
echo "export WHISPER_MODEL=$whispermodel" >> ./chipper/source.sh
else
- echo "export STT_SERVICE=coqui" >> ./chipper/source.sh
+ echo "export STT_SERVICE=coqui" >> ./chipper/source.sh
if [[ ! -f ./stt/completed ]]; then
echo "Getting STT assets"
if [[ -d /root/.coqui ]]; then
@@ -276,11 +276,11 @@ function getSTT() {
fi
tar -xf native_client.tflite.Linux.tar.xz
rm -f ./native_client.tflite.Linux.tar.xz
- elif [[ ${ARCH} == "aarch64" ]]; then
+ elif [[ ${ARCH} == "aarch64" ]]; then
wget -q --show-progress --no-check-certificate https://github.com/coqui-ai/STT/releases/download/v1.3.0/native_client.tflite.linux.aarch64.tar.xz
tar -xf native_client.tflite.linux.aarch64.tar.xz
rm -f ./native_client.tflite.linux.aarch64.tar.xz
- elif [[ ${ARCH} == "armv7l" ]]; then
+ elif [[ ${ARCH} == "armv7l" ]]; then
wget -q --show-progress --no-check-certificate https://github.com/coqui-ai/STT/releases/download/v1.3.0/native_client.tflite.linux.armv7.tar.xz
tar -xf native_client.tflite.linux.armv7.tar.xz
rm -f ./native_client.tflite.linux.armv7.tar.xz
@@ -304,9 +304,9 @@ function getSTT() {
read -p "Enter a number (1): " sttModelNum
if [[ ! -n ${sttModelNum} ]]; then
sttModel="large_vocabulary"
- elif [[ ${sttModelNum} == "1" ]]; then
+ elif [[ ${sttModelNum} == "1" ]]; then
sttModel="large_vocabulary"
- elif [[ ${sttModelNum} == "2" ]]; then
+ elif [[ ${sttModelNum} == "2" ]]; then
sttModel="huge_vocabulary"
else
echo
@@ -323,7 +323,7 @@ function getSTT() {
wget -O model.tflite -q --show-progress --no-check-certificate https://coqui.gateway.scarf.sh/english/coqui/v1.0.0-large-vocab/model.tflite
echo "Getting STT scorer..."
wget -O model.scorer -q --show-progress --no-check-certificate https://coqui.gateway.scarf.sh/english/coqui/v1.0.0-large-vocab/large_vocabulary.scorer
- elif [[ ${sttModel} == "huge_vocabulary" ]]; then
+ elif [[ ${sttModel} == "huge_vocabulary" ]]; then
echo "Getting STT model..."
wget -O model.tflite -q --show-progress --no-check-certificate https://coqui.gateway.scarf.sh/english/coqui/v1.0.0-huge-vocab/model.tflite
echo "Getting STT scorer..."
@@ -353,7 +353,7 @@ function IPDNSPrompt() {
*)
echo "Please answer with 1, 2, 3, or 4."
IPDNSPrompt
- ;;
+ ;;
esac
}
@@ -487,7 +487,7 @@ function scpToBot() {
*)
echo "Please answer with 1 or 2."
rsaAddPrompt
- ;;
+ ;;
esac
}
rsaAddPrompt
@@ -558,22 +558,35 @@ function setupSystemd() {
cat wire-pod.service
echo
cd chipper
+ export GOTAGS="nolibopusfile"
+ if [[ ${USE_INBUILT_BLE} == "true" ]]; then
+ export GOTAGS="nolibopusfile,inbuiltble"
+ fi
if [[ ${STT_SERVICE} == "leopard" ]]; then
echo "wire-pod.service created, building chipper with Picovoice STT service..."
- /usr/local/go/bin/go build cmd/leopard/main.go
- elif [[ ${STT_SERVICE} == "vosk" ]]; then
+ /usr/local/go/bin/go build -tags $GOTAGS cmd/leopard/main.go
+ elif [[ ${STT_SERVICE} == "vosk" ]]; then
echo "wire-pod.service created, building chipper with VOSK STT service..."
export CGO_ENABLED=1
- export CGO_CFLAGS="-I$HOME/.vosk/libvosk"
- export CGO_LDFLAGS="-L $HOME/.vosk/libvosk -lvosk -ldl -lpthread"
- export LD_LIBRARY_PATH="$HOME/.vosk/libvosk:$LD_LIBRARY_PATH"
- /usr/local/go/bin/go build cmd/vosk/main.go
+ export CGO_CFLAGS="-I/root/.vosk/libvosk"
+ export CGO_LDFLAGS="-L /root/.vosk/libvosk -lvosk -ldl -lpthread"
+ export LD_LIBRARY_PATH="/root/.vosk/libvosk:$LD_LIBRARY_PATH"
+ /usr/local/go/bin/go build -tags $GOTAGS cmd/vosk/main.go
+ elif [[ ${STT_SERVICE} == "whisper.cpp" ]]; then
+ echo "wire-pod.service created, building chipper with Whisper.CPP STT service..."
+ export CGO_ENABLED=1
+ export C_INCLUDE_PATH="../whisper.cpp"
+ export LIBRARY_PATH="../whisper.cpp"
+ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$(pwd)/../whisper.cpp"
+ export CGO_LDFLAGS="-L$(pwd)/../whisper.cpp"
+ export CGO_CFLAGS="-I$(pwd)/../whisper.cpp"
+ /usr/local/go/bin/go build -tags $GOTAGS cmd/experimental/whisper.cpp/main.go
else
echo "wire-pod.service created, building chipper with Coqui STT service..."
- export CGO_LDFLAGS="-L$HOME/.coqui/"
- export CGO_CXXFLAGS="-I$HOME/.coqui/"
- export LD_LIBRARY_PATH="$HOME/.coqui/:$LD_LIBRARY_PATH"
- /usr/local/go/bin/go build cmd/coqui/main.go
+ export CGO_LDFLAGS="-L/root/.coqui/"
+ export CGO_CXXFLAGS="-I/root/.coqui/"
+ export LD_LIBRARY_PATH="/root/.coqui/:$LD_LIBRARY_PATH"
+ /usr/local/go/bin/go build -tags $GOTAGS cmd/coqui/main.go
fi
sync
mv main chipper