simplify details
This commit is contained in:
parent
963fcd1080
commit
7c633af9db
5 changed files with 19 additions and 20 deletions
16
README.md
16
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
|
||||
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ void touchTask(void* parameter) {
|
|||
|
||||
|
||||
void setupDeviceMetadata() {
|
||||
// factoryResetDevice();
|
||||
factoryResetDevice();
|
||||
deviceState = IDLE;
|
||||
|
||||
getAuthTokenFromNVS();
|
||||
|
|
|
|||
|
|
@ -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=<YOUR_SUPABASE_ANON_KEY>
|
||||
JWT_SECRET_KEY=super-secret-jwt-token-with-at-least-32-characters-long
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ const AppSettings: React.FC<AppSettingsProps> = ({
|
|||
});
|
||||
}
|
||||
|
||||
const isDevMode = process.env.DEV_MODE === "True";
|
||||
const skipDeviceRegistration = process.env.SKIP_DEVICE_REGISTRATION === "True";
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
@ -104,7 +104,7 @@ const AppSettings: React.FC<AppSettingsProps> = ({
|
|||
<h2 className="text-lg font-semibold border-b border-gray-200 pb-2">
|
||||
Device settings
|
||||
</h2>
|
||||
{isDevMode && <div className="flex flex-col text-purple-500 text-xs gap-2">You don't need to register your device because you're in dev mode.</div>}
|
||||
{skipDeviceRegistration && <div className="flex flex-col text-purple-500 text-xs gap-2">You don't need to register your device because you're in dev mode.</div>}
|
||||
<div className="flex flex-col gap-6">
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="flex flex-row items-center gap-2">
|
||||
|
|
@ -122,7 +122,7 @@ const AppSettings: React.FC<AppSettingsProps> = ({
|
|||
<div className="flex flex-row items-center gap-2 mt-2">
|
||||
<Input
|
||||
value={deviceCode}
|
||||
disabled={isConnected || isDevMode}
|
||||
disabled={isConnected || skipDeviceRegistration}
|
||||
onChange={(e) => setDeviceCode(e.target.value)}
|
||||
placeholder={isConnected ? "**********" : "Enter your device code"}
|
||||
maxLength={100}
|
||||
|
|
@ -130,7 +130,7 @@ const AppSettings: React.FC<AppSettingsProps> = ({
|
|||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
disabled={isConnected || isDevMode}
|
||||
disabled={isConnected || skipDeviceRegistration}
|
||||
onClick={async () => {
|
||||
const result = await connectUserToDevice(selectedUser.user_id, deviceCode);
|
||||
if (!result) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue