diff --git a/.DS_Store b/.DS_Store index 63d8d76..6af0f90 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/firmware-arduino/.DS_Store b/firmware-arduino/.DS_Store new file mode 100644 index 0000000..ebd2fba Binary files /dev/null and b/firmware-arduino/.DS_Store differ diff --git a/firmware-cpp/.gitignore b/firmware-arduino/.gitignore similarity index 100% rename from firmware-cpp/.gitignore rename to firmware-arduino/.gitignore diff --git a/firmware-cpp/.vscode/extensions.json b/firmware-arduino/.vscode/extensions.json similarity index 100% rename from firmware-cpp/.vscode/extensions.json rename to firmware-arduino/.vscode/extensions.json diff --git a/firmware-cpp/README.md b/firmware-arduino/README.md similarity index 100% rename from firmware-cpp/README.md rename to firmware-arduino/README.md diff --git a/firmware-cpp/data/startup.mp3 b/firmware-arduino/data/startup.mp3 similarity index 100% rename from firmware-cpp/data/startup.mp3 rename to firmware-arduino/data/startup.mp3 diff --git a/firmware-cpp/include/README b/firmware-arduino/include/README similarity index 100% rename from firmware-cpp/include/README rename to firmware-arduino/include/README diff --git a/firmware-cpp/lib/README b/firmware-arduino/lib/README similarity index 100% rename from firmware-cpp/lib/README rename to firmware-arduino/lib/README diff --git a/firmware-cpp/partition.csv b/firmware-arduino/partition.csv similarity index 100% rename from firmware-cpp/partition.csv rename to firmware-arduino/partition.csv diff --git a/firmware-cpp/platformio.ini b/firmware-arduino/platformio.ini similarity index 82% rename from firmware-cpp/platformio.ini rename to firmware-arduino/platformio.ini index 9f7ff1a..64e61a9 100644 --- a/firmware-cpp/platformio.ini +++ b/firmware-arduino/platformio.ini @@ -17,11 +17,10 @@ monitor_speed = 115200 lib_deps = bblanchon/ArduinoJson@^7.1.0 links2004/WebSockets@^2.4.1 - https://github.com/esp-arduino-libs/ESP32_Button.git + ESP32Async/ESPAsyncWebServer@^3.7.6 + https://github.com/esp-arduino-libs/ESP32_Button.git#v0.0.1 https://github.com/pschatzmann/arduino-audio-tools.git#v1.0.1 - https://github.com/pschatzmann/arduino-libopus.git - ESP32Async/AsyncTCP - ESP32Async/ESPAsyncWebServer + https://github.com/pschatzmann/arduino-libopus.git#a1.1.0 ; board_build.arduino.memory_type = qio_opi ; board_build.flash_mode = qio @@ -40,4 +39,4 @@ build_flags = -std=gnu++17 -D CORE_DEBUG_LEVEL=5 -D DEBUG_ESP_PORT=Serial - -D TOUCH_SENSOR_ENABLE=1 \ No newline at end of file + -D TOUCH_SENSOR_ENABLE=1 ; Enable touch sensor driver \ No newline at end of file diff --git a/firmware-cpp/src/Audio.cpp b/firmware-arduino/src/Audio.cpp similarity index 89% rename from firmware-cpp/src/Audio.cpp rename to firmware-arduino/src/Audio.cpp index e325c42..d2fd452 100644 --- a/firmware-cpp/src/Audio.cpp +++ b/firmware-arduino/src/Audio.cpp @@ -183,43 +183,15 @@ I2SStream i2sInput; StreamCopy micToWsCopier(wsStream, i2sInput); const int MIC_COPY_SIZE = 64; -void micTask1(void *parameter) { - auto i2sConfig = i2sInput.defaultConfig(RX_MODE); - i2sConfig.bits_per_sample = BITS_PER_SAMPLE; - i2sConfig.sample_rate = SAMPLE_RATE; - i2sConfig.channels = CHANNELS; - i2sConfig.i2s_format = I2S_LEFT_JUSTIFIED_FORMAT; - i2sConfig.channel_format = I2S_CHANNEL_FMT_ONLY_LEFT; - - i2sConfig.pin_bck = I2S_SCK; - i2sConfig.pin_ws = I2S_WS; - i2sConfig.pin_data = I2S_SD; - i2sConfig.port_no = I2S_PORT_IN; - i2sInput.begin(i2sConfig); - - while (1) { - if (scheduleListeningRestart && millis() >= scheduledTime) { - transitionToListening(); - } - - if (deviceState == LISTENING && webSocket.isConnected()) { - micToWsCopier.copyBytes(MIC_COPY_SIZE); - } - - vTaskDelay(1); - } -} - void micTask(void *parameter) { - // start I2S input stream. + // Configure and start I2S input stream. auto i2sConfig = i2sInput.defaultConfig(RX_MODE); i2sConfig.bits_per_sample = BITS_PER_SAMPLE; i2sConfig.sample_rate = SAMPLE_RATE; i2sConfig.channels = CHANNELS; i2sConfig.i2s_format = I2S_LEFT_JUSTIFIED_FORMAT; i2sConfig.channel_format = I2S_CHANNEL_FMT_ONLY_LEFT; - - // I2S input pins a + // Configure your I2S input pins appropriately here: i2sConfig.pin_bck = I2S_SCK; i2sConfig.pin_ws = I2S_WS; i2sConfig.pin_data = I2S_SD; @@ -227,16 +199,16 @@ void micTask(void *parameter) { i2sInput.begin(i2sConfig); while (1) { - // Checking to see if a transition to listening mode is scheduled. + // Check to see if a transition to listening mode is scheduled. if (scheduleListeningRestart && millis() >= scheduledTime) { transitionToListening(); } if (deviceState == LISTENING && webSocket.isConnected()) { - // smaller chunk size to avoid blocking too long + // Use smaller chunk size to avoid blocking too long micToWsCopier.copyBytes(MIC_COPY_SIZE); - // yielding frequently + // Yield more frequently vTaskDelay(1); } else { vTaskDelay(10); @@ -278,7 +250,7 @@ void webSocketEvent(WStype_t type, uint8_t *payload, size_t length) currentVolume = doc["volume_control"].as(); bool is_ota = doc["is_ota"].as(); bool is_reset = doc["is_reset"].as(); - volume.setVolume(currentVolume / 100.0f); // Setting initial volume (e.g., 70/100 = 0.7) + volume.setVolume(currentVolume / 100.0f); // Set initial volume (e.g., 70/100 = 0.7) if (is_ota) { Serial.println("OTA update received"); diff --git a/firmware-cpp/src/Audio.h b/firmware-arduino/src/Audio.h similarity index 100% rename from firmware-cpp/src/Audio.h rename to firmware-arduino/src/Audio.h diff --git a/firmware-cpp/src/Config.cpp b/firmware-arduino/src/Config.cpp similarity index 62% rename from firmware-cpp/src/Config.cpp rename to firmware-arduino/src/Config.cpp index 838f8b7..2d4a8fd 100644 --- a/firmware-cpp/src/Config.cpp +++ b/firmware-arduino/src/Config.cpp @@ -6,18 +6,32 @@ Preferences preferences; OtaStatus otaState = OTA_IDLE; bool factory_reset_status = false; -// websocket_setup("192.168.1.166", 8000, "/"); -// websocket_setup("talkedge.deno.dev",443, "/"); -// websocket_setup("xygbupeczfhwamhqnucy.supabase.co", 443, "/functions/v1/relay"); -// websocket_setup("https://emkmtesvjrqhvx2mo2mxslvmmy0zsuhq.lambda-url.us-east-1.on.aws/", 8000, "/"); -// Runtime WebSocket server details +/** + * Configuration for Elato Firmware + * + * DEVELOPMENT vs PRODUCTION SETUP: + * -------------------------------- + * 1. Define `DEV_MODE` in your config.h file to use local development servers + * 2. `DEV_MODE` requires updating the IP addresses to your local network IP + * 3. Without `DEV_MODE` defined, the firmware will use your production servers + * + * Development Mode (find your local IP address using ifconfig): + * - WebSocket: Your local IP (e.g., 192.168.1.100:8000) + * - Backend: Your local IP (e.g., 192.168.1.100:3000) + * - No SSL certificates required + * + * Production Mode: + * - WebSocket: .deno.dev (port 443) + * - Backend: (port 3000) + * - Uses pre-configured SSL certificates (set in Config.cpp) + */ #ifdef DEV_MODE -const char *ws_server = "10.2.1.25"; +const char *ws_server = "10.2.1.187"; const uint16_t ws_port = 8000; const char *ws_path = "/"; // Backend server details -const char *backend_server = "10.2.1.25"; +const char *backend_server = "10.2.1.187"; const uint16_t backend_port = 3000; #else @@ -60,21 +74,20 @@ const gpio_num_t BUTTON_PIN = GPIO_NUM_2; // Only RTC IO are allowed - ESP32 Pin #endif -// supabase CA cert -// const char *CA_cert = R"EOF( -// -----BEGIN CERTIFICATE----- -// -// -----END CERTIFICATE----- -// )EOF"; - const char *Vercel_CA_cert = R"EOF( -----BEGIN CERTIFICATE----- -----END CERTIFICATE----- )EOF"; +// Supabase Edge Functions CA cert +// const char *CA_cert = R"EOF( +// -----BEGIN CERTIFICATE----- +// +// -----END CERTIFICATE----- +// )EOF"; -// talkedge.deno.dev CA cert +// Deno Edge Functions CA cert const char *CA_cert = R"EOF( -----BEGIN CERTIFICATE----- diff --git a/firmware-cpp/src/Config.h b/firmware-arduino/src/Config.h similarity index 100% rename from firmware-cpp/src/Config.h rename to firmware-arduino/src/Config.h diff --git a/firmware-cpp/src/FactoryReset.h b/firmware-arduino/src/FactoryReset.h similarity index 100% rename from firmware-cpp/src/FactoryReset.h rename to firmware-arduino/src/FactoryReset.h diff --git a/firmware-cpp/src/LEDHandler.cpp b/firmware-arduino/src/LEDHandler.cpp similarity index 100% rename from firmware-cpp/src/LEDHandler.cpp rename to firmware-arduino/src/LEDHandler.cpp diff --git a/firmware-cpp/src/LEDHandler.h b/firmware-arduino/src/LEDHandler.h similarity index 100% rename from firmware-cpp/src/LEDHandler.h rename to firmware-arduino/src/LEDHandler.h diff --git a/firmware-cpp/src/OTA.cpp b/firmware-arduino/src/OTA.cpp similarity index 93% rename from firmware-cpp/src/OTA.cpp rename to firmware-arduino/src/OTA.cpp index e121885..0caaab6 100644 --- a/firmware-cpp/src/OTA.cpp +++ b/firmware-arduino/src/OTA.cpp @@ -6,15 +6,15 @@ HttpsOTAStatus_t otastatus; // OTA firmware url #ifdef TOUCH_MODE -const char *ota_firmware_url = "https://elato.s3.us-east-1.amazonaws.com/firmware-touch.bin"; +const char *ota_firmware_url = " - TOUCH MODE"; #else -const char *ota_firmware_url = "https://elato.s3.us-east-1.amazonaws.com/firmware-button.bin"; +const char *ota_firmware_url = " - BUTTON MODE"; #endif const char *server_certificate = R"EOF( -----BEGIN CERTIFICATE----- - + -----END CERTIFICATE----- )EOF"; diff --git a/firmware-cpp/src/OTA.h b/firmware-arduino/src/OTA.h similarity index 100% rename from firmware-cpp/src/OTA.h rename to firmware-arduino/src/OTA.h diff --git a/firmware-cpp/src/WifiManager.cpp b/firmware-arduino/src/WifiManager.cpp similarity index 100% rename from firmware-cpp/src/WifiManager.cpp rename to firmware-arduino/src/WifiManager.cpp diff --git a/firmware-cpp/src/WifiManager.h b/firmware-arduino/src/WifiManager.h similarity index 100% rename from firmware-cpp/src/WifiManager.h rename to firmware-arduino/src/WifiManager.h diff --git a/firmware-cpp/src/main.cpp b/firmware-arduino/src/main.cpp similarity index 86% rename from firmware-cpp/src/main.cpp rename to firmware-arduino/src/main.cpp index a5ecb2a..a6fa52f 100644 --- a/firmware-cpp/src/main.cpp +++ b/firmware-arduino/src/main.cpp @@ -117,6 +117,7 @@ void setupWiFi() webServer.begin(); } + void touchTask(void* parameter) { touch_pad_init(); touch_pad_config(TOUCH_PAD_NUM2); @@ -124,6 +125,7 @@ void touchTask(void* parameter) { bool touched = false; unsigned long pressStartTime = 0; unsigned long lastTouchTime = 0; + const unsigned long LONG_PRESS_DURATION = 500; // 500ms for long press while (1) { // Read the touch sensor @@ -131,50 +133,32 @@ void touchTask(void* parameter) { bool isTouched = (touchValue > TOUCH_THRESHOLD); unsigned long currentTime = millis(); - // Debounced touch detection + // Initial touch detection if (isTouched && !touched && (currentTime - lastTouchTime > TOUCH_DEBOUNCE_DELAY)) { touched = true; + pressStartTime = currentTime; // Start timing the press lastTouchTime = currentTime; - enterSleep(); + } - // if (!webSocket.isConnected()) { - // enterSleep(); - // } else if (deviceState == SPEAKING) { - // // First, set the flag to prevent further audio processing - // // deviceState = PROCESSING; - // scheduleListeningRestart = true; - // scheduledTime = millis() + 100; // Shorter delay - - // unsigned long audio_end_ms = getSpeakingDuration(); - - // // Use ArduinoJson to create the message - // JsonDocument doc; - // doc["type"] = "instruction"; - // doc["msg"] = "INTERRUPT"; - // doc["audio_end_ms"] = audio_end_ms; - - // String jsonString; - // serializeJson(doc, jsonString); - - // // Take mutex to ensure clean WebSocket access - // if (xSemaphoreTake(wsMutex, pdMS_TO_TICKS(10)) == pdTRUE) { - // webSocket.sendTXT(jsonString); - // xSemaphoreGive(wsMutex); - // } - // } + // Check for long press while touched + if (touched && isTouched) { + if (currentTime - pressStartTime >= LONG_PRESS_DURATION) { + enterSleep(); // Only enter sleep after 500ms of continuous touch + } } // Release detection if (!isTouched && touched) { touched = false; + pressStartTime = 0; // Reset the press timer } vTaskDelay(20); // Reduced from 50ms to 20ms for better responsiveness } - // (This point is never reached.) vTaskDelete(NULL); } + void setupDeviceMetadata() { // factoryResetDevice(); deviceState = IDLE; diff --git a/firmware-cpp/test/README b/firmware-arduino/test/README similarity index 100% rename from firmware-cpp/test/README rename to firmware-arduino/test/README diff --git a/firmware-cpp/test/WifiSetup.h b/firmware-arduino/test/WifiSetup.h similarity index 100% rename from firmware-cpp/test/WifiSetup.h rename to firmware-arduino/test/WifiSetup.h diff --git a/firmware-cpp/test/audio_stream_test.cpp b/firmware-arduino/test/audio_stream_test.cpp similarity index 100% rename from firmware-cpp/test/audio_stream_test.cpp rename to firmware-arduino/test/audio_stream_test.cpp diff --git a/firmware-cpp/test/eduroam_wifi_test.cpp b/firmware-arduino/test/eduroam_wifi_test.cpp similarity index 100% rename from firmware-cpp/test/eduroam_wifi_test.cpp rename to firmware-arduino/test/eduroam_wifi_test.cpp diff --git a/firmware-cpp/test/fetch_auth_token_test.cpp b/firmware-arduino/test/fetch_auth_token_test.cpp similarity index 100% rename from firmware-cpp/test/fetch_auth_token_test.cpp rename to firmware-arduino/test/fetch_auth_token_test.cpp diff --git a/firmware-cpp/test/light_button_test.cpp b/firmware-arduino/test/light_button_test.cpp similarity index 100% rename from firmware-cpp/test/light_button_test.cpp rename to firmware-arduino/test/light_button_test.cpp diff --git a/firmware-cpp/test/mic_test.cpp b/firmware-arduino/test/mic_test.cpp similarity index 100% rename from firmware-cpp/test/mic_test.cpp rename to firmware-arduino/test/mic_test.cpp diff --git a/firmware-cpp/test/opus_audio_loop_test.cpp b/firmware-arduino/test/opus_audio_loop_test.cpp similarity index 100% rename from firmware-cpp/test/opus_audio_loop_test.cpp rename to firmware-arduino/test/opus_audio_loop_test.cpp diff --git a/firmware-cpp/test/opus_test.cpp b/firmware-arduino/test/opus_test.cpp similarity index 100% rename from firmware-cpp/test/opus_test.cpp rename to firmware-arduino/test/opus_test.cpp diff --git a/firmware-cpp/test/ota_test.cpp b/firmware-arduino/test/ota_test.cpp similarity index 100% rename from firmware-cpp/test/ota_test.cpp rename to firmware-arduino/test/ota_test.cpp diff --git a/firmware-cpp/test/print_mac_address_test.cpp b/firmware-arduino/test/print_mac_address_test.cpp similarity index 100% rename from firmware-cpp/test/print_mac_address_test.cpp rename to firmware-arduino/test/print_mac_address_test.cpp diff --git a/firmware-cpp/test/rgb_led_test.cpp b/firmware-arduino/test/rgb_led_test.cpp similarity index 100% rename from firmware-cpp/test/rgb_led_test.cpp rename to firmware-arduino/test/rgb_led_test.cpp diff --git a/firmware-cpp/test/simple_led_test.cpp b/firmware-arduino/test/simple_led_test.cpp similarity index 100% rename from firmware-cpp/test/simple_led_test.cpp rename to firmware-arduino/test/simple_led_test.cpp diff --git a/firmware-cpp/test/speaker_radio_shutdown_test.cpp b/firmware-arduino/test/speaker_radio_shutdown_test.cpp similarity index 100% rename from firmware-cpp/test/speaker_radio_shutdown_test.cpp rename to firmware-arduino/test/speaker_radio_shutdown_test.cpp diff --git a/firmware-cpp/test/speaker_radio_test.cpp b/firmware-arduino/test/speaker_radio_test.cpp similarity index 100% rename from firmware-cpp/test/speaker_radio_test.cpp rename to firmware-arduino/test/speaker_radio_test.cpp diff --git a/firmware-cpp/test/touch_led_test.cpp b/firmware-arduino/test/touch_led_test.cpp similarity index 100% rename from firmware-cpp/test/touch_led_test.cpp rename to firmware-arduino/test/touch_led_test.cpp diff --git a/firmware-cpp/test/touch_sleep.cpp b/firmware-arduino/test/touch_sleep.cpp similarity index 100% rename from firmware-cpp/test/touch_sleep.cpp rename to firmware-arduino/test/touch_sleep.cpp diff --git a/firmware-cpp/test/touch_test.cpp b/firmware-arduino/test/touch_test.cpp similarity index 100% rename from firmware-cpp/test/touch_test.cpp rename to firmware-arduino/test/touch_test.cpp diff --git a/firmware-cpp/test/wifi_manager_test.cpp b/firmware-arduino/test/wifi_manager_test.cpp similarity index 100% rename from firmware-cpp/test/wifi_manager_test.cpp rename to firmware-arduino/test/wifi_manager_test.cpp diff --git a/frontend-nextjs/.env.example b/frontend-nextjs/.env.example index bee8eb2..a44dc28 100644 --- a/frontend-nextjs/.env.example +++ b/frontend-nextjs/.env.example @@ -6,7 +6,6 @@ NEXT_PUBLIC_SUPABASE_ANON_KEY= JWT_SECRET_KEY= ENCRYPTION_KEY= OPENAI_API_KEY= -ENCRYPTION_KEY= # NEXT_PUBLIC_SUPABASE_URL=http://localhost:54321 GOOGLE_OAUTH=True diff --git a/frontend-nextjs/app/(auth-pages)/login/page.tsx b/frontend-nextjs/app/(auth-pages)/login/page.tsx index 2239a63..176fd0d 100644 --- a/frontend-nextjs/app/(auth-pages)/login/page.tsx +++ b/frontend-nextjs/app/(auth-pages)/login/page.tsx @@ -101,12 +101,9 @@ export default async function Login({ searchParams }: LoginProps) { /> )} - {/* -
- Elato Login -
*/} + - {/*
+ @@ -147,7 +144,7 @@ export default async function Login({ searchParams }: LoginProps) { {searchParams.message}

)} -
*/} + diff --git a/frontend-nextjs/app/components/Footer.tsx b/frontend-nextjs/app/components/Footer.tsx index 96bb6a1..787ea0d 100644 --- a/frontend-nextjs/app/components/Footer.tsx +++ b/frontend-nextjs/app/components/Footer.tsx @@ -3,15 +3,14 @@ import { Label } from "@/components/ui/label"; import { Button } from "@/components/ui/button"; import { Mail } from "lucide-react"; -import { ThemeSwitcher } from "@/components/theme-switcher"; -import { Separator } from "@/components/ui/separator"; -import { FaDiscord, FaGithub } from "react-icons/fa"; +import { FaDiscord, FaGithub, FaTiktok } from "react-icons/fa"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { discordInviteLink, githubPublicLink, feedbackFormLink, + tiktokLink, } from "@/lib/data"; import { useMediaQuery } from "@/hooks/useMediaQuery"; @@ -19,14 +18,12 @@ export default function Footer() { const pathname = usePathname(); const isHome = pathname.includes("/home"); const isMobile = useMediaQuery("(max-width: 768px)"); - const isRoot = pathname === "/"; + // const isRoot = pathname === "/"; return (