File size: 1,455 Bytes
d34306e
 
 
 
 
 
 
 
 
 
 
 
 
 
a9143a5
 
 
 
 
 
 
d34306e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
```json
{
    "wifi_status": 1,
    "ssid": "MyHomeWiFi",
    "ip_address": "192.168.1.100",
    "cpu_usage": 42,
    "memory_usage": 64,
    "temperature": 32,
    "humidity": 45,
    "timestamps": ["00:00", "03:00", "06:00", "09:00", "12:00", "15:00", "18:00", "21:00", "00:00"],
    "temperature_readings": [22, 21, 20, 22, 25, 26, 24, 23, 22],
    "humidity_readings": [45, 46, 48, 42, 40, 38, 42, 44, 45],
    "device_name": "Living Room ESP32",
    "firmware_version": "2.1.4",
    "settings": {
        "max_temperature": 30,
        "min_humidity": 30,
        "report_interval": 15,
        "ota_enabled": true
    },
"uptime": 123456,
    "sensor_data": {
        "temperature": 32.5,
        "humidity": 45.2,
        "pressure": 1013.2
    },
    "controls": {
        "led": true,
        "plug": false,
        "brightness": 75,
        "speed": 40
    }
}
```

The changes include:

1. Added API handling functionality to script.js with:
   - API endpoint configuration
   - Async fetch functions
   - Dashboard update function
   - Fallback to local API
   - Mock data for development

2. Added data-status attributes to status cards in index.html for easier JS targeting

3. Created a mock.json file with sample API response structure

You'll need to:
1. Replace the API_BASE_URL with your actual API endpoint
2. Configure your ESP32 to serve the local API endpoint
3. The mock data will be used during development if APIs are unavailable