diff --git a/README.md b/README.md index 7f3fe89..2444314 100644 --- a/README.md +++ b/README.md @@ -46,15 +46,13 @@ Control your ESP32 AI device from your phone with the Elato AI webapp. ## 🚀 Quick Start -1. Ensure `DEV_MODE` is set to `True` in your frontend, and server environment variables and enabled in the `Config.h` file of your firmware. This will allow you to skip the device registration process and get you up and running with the Realtime API AI chat. - -2. Install [Supabase CLI](https://supabase.com/docs/guides/local-development/cli/getting-started) and set up your Local Supabase Backend. From the root directory, run: +1. Install [Supabase CLI](https://supabase.com/docs/guides/local-development/cli/getting-started) and set up your Local Supabase Backend. From the root directory, run: ```bash brew install supabase/tap/supabase supabase start # Starts your local Supabase server with the default migrations and seed data. ``` -3. Set up your NextJS Frontend. ([See the Frontend README](frontend-nextjs/README.md)) From the `frontend-nextjs` directory, run the following commands. (**Login creds:** Email: admin@elatoai.com, Password: `admin`) +2. Set up your NextJS Frontend. ([See the Frontend README](frontend-nextjs/README.md)) From the `frontend-nextjs` directory, run the following commands. (**Login creds:** Email: admin@elatoai.com, Password: `admin`) ```bash cd frontend-nextjs npm install @@ -68,7 +66,7 @@ cp .env.example .env.local npm run dev ``` -4. Start the Deno server. ([See the Deno server README](server-deno/README.md)) +3. Start the Deno server. ([See the Deno server README](server-deno/README.md)) ```bash # Navigate to the server directory cd server-deno @@ -82,13 +80,13 @@ cp .env.example .env deno run -A --env-file=.env main.ts ``` -5. In `Config.cpp` set `ws_server` and `backend_server` to your local IP address. Run `ifconfig` in your console and find `en0` -> `inet` -> `192.168.1.100` (it may be different for your Wifi network). This tells the ESP32 device to connect to your NextJS frontend and Deno server running on your local machine. All services should be on the same Wifi network. +4. In `Config.cpp` set `ws_server` and `backend_server` to your local IP address. Run `ifconfig` in your console and find `en0` -> `inet` -> `192.168.1.100` (it may be different for your Wifi network). This tells the ESP32 device to connect to your NextJS frontend and Deno server running on your local machine. All services should be on the same Wifi network. -6. Build and upload the firmware to your ESP32 device. The ESP32 should open an `ELATO-DEVICE` captive portal to connect to Wifi. Connect to it and go to `http://192.168.4.1` to configure the device wifi. +5. Build and upload the firmware to your ESP32 device. The ESP32 should open an `ELATO-DEVICE` captive portal to connect to Wifi. Connect to it and go to `http://192.168.4.1` to configure the device wifi. -7. Once your Wifi credentials are configured, turn the device off and on again and it should connect to your Wifi and your server. +6. Once your Wifi credentials are configured, turn the device off and on again and it should connect to your Wifi and your server. -8. Now you can talk to your AI Character! +7. Now you can talk to your AI Character! ## 📦 Getting Started with multiple devices diff --git a/firmware-arduino/src/main.cpp b/firmware-arduino/src/main.cpp index a6fa52f..092f1f8 100644 --- a/firmware-arduino/src/main.cpp +++ b/firmware-arduino/src/main.cpp @@ -160,7 +160,7 @@ void touchTask(void* parameter) { void setupDeviceMetadata() { - // factoryResetDevice(); + factoryResetDevice(); deviceState = IDLE; getAuthTokenFromNVS(); diff --git a/frontend-nextjs/.env.example b/frontend-nextjs/.env.example index b17b706..4d1a841 100644 --- a/frontend-nextjs/.env.example +++ b/frontend-nextjs/.env.example @@ -1,7 +1,8 @@ +# If you want to skip device registration, set this to True. Set to False in production. +SKIP_DEVICE_REGISTRATION=True # Update these with your Supabase details from your project settings > API # https://app.supabase.com/project/_/settings/api -DEV_MODE=True NEXT_PUBLIC_SUPABASE_URL=http://127.0.0.1:54321 NEXT_PUBLIC_SUPABASE_ANON_KEY= JWT_SECRET_KEY=super-secret-jwt-token-with-at-least-32-characters-long diff --git a/frontend-nextjs/app/api/generate_auth_token/route.ts b/frontend-nextjs/app/api/generate_auth_token/route.ts index 5f51ed0..2bf4270 100644 --- a/frontend-nextjs/app/api/generate_auth_token/route.ts +++ b/frontend-nextjs/app/api/generate_auth_token/route.ts @@ -3,7 +3,7 @@ import jwt from "jsonwebtoken"; import { createClient } from "@/utils/supabase/server"; const ALGORITHM = "HS256"; -const isDevMode = process.env.DEV_MODE === "True"; +const skipDeviceRegistration = process.env.SKIP_DEVICE_REGISTRATION === "True"; interface TokenPayload { [key: string]: any; @@ -71,16 +71,16 @@ export async function GET(req: Request) { } /** - * If `DEV_MODE` is true, we use the dev user. - * Otherwise, we use the user by mac address. + * If `SKIP_DEVICE_REGISTRATION` is true, we use the default dev user. + * Otherwise, we use the user by given by the mac address. * * Steps to register your device: * 1: Register the device `mac_address` and `user_code` in the `devices` tables. * 2: Make sure the user adds the `user_code` to their account in Settings to link the device to their `user_id`. - * 3: When `DEV_MODE` is false, we then fetch the user by `mac_address`. + * 3: When `SKIP_DEVICE_REGISTRATION` is false, we then fetch the user by `mac_address`. */ let user; - if (isDevMode) { + if (skipDeviceRegistration) { user = await getDevUser(); } else { user = await getUserByMacAddress(macAddress); diff --git a/frontend-nextjs/app/components/Settings/AppSettings.tsx b/frontend-nextjs/app/components/Settings/AppSettings.tsx index 90ac28a..35546c6 100644 --- a/frontend-nextjs/app/components/Settings/AppSettings.tsx +++ b/frontend-nextjs/app/components/Settings/AppSettings.tsx @@ -88,7 +88,7 @@ const AppSettings: React.FC = ({ }); } - const isDevMode = process.env.DEV_MODE === "True"; + const skipDeviceRegistration = process.env.SKIP_DEVICE_REGISTRATION === "True"; return ( <> @@ -104,7 +104,7 @@ const AppSettings: React.FC = ({

Device settings

- {isDevMode &&
You don't need to register your device because you're in dev mode.
} + {skipDeviceRegistration &&
You don't need to register your device because you're in dev mode.
}
@@ -122,7 +122,7 @@ const AppSettings: React.FC = ({
setDeviceCode(e.target.value)} placeholder={isConnected ? "**********" : "Enter your device code"} maxLength={100} @@ -130,7 +130,7 @@ const AppSettings: React.FC = ({