code clean up and small improvements

pull/1/head
Thomas Ballmann 4 years ago
parent 3e2a6c51cc
commit 27b0ad0fbe

@ -14,7 +14,10 @@ yarn --cwd app build
platformio run --target uploadfs
# send a picture to display over json
curl -F 'myImage=@blackPNG.png' http://192.168.178.62/api/face
curl -F '=@test3.png;filename=dithering' http://192.168.178.62/api/face
# get current picture as bmp
curl http://192.168.178.62/current-image --output current.bmp
# erase flash memory
pio run --target erase

@ -15,13 +15,20 @@
</v-navigation-drawer>
-->
<v-system-bar app dark color="primary">
<v-system-bar app dark color="primary" _window _lights-out>
<span>paperdash.io</span>
<v-spacer></v-spacer>
<span>boxxi</span>
<span>{{ settings.device.name }}</span>
<v-spacer></v-spacer>
<v-icon>{{ stats.wifi.rssi | wifiIcon(stats.wifi.secure) }}</v-icon>
<span>{{ stats.device.time | moment("LT") }}</span>
<template v-if="stats.wifi.connected">
<v-icon>{{ stats.wifi.rssi | wifiIcon(0) }}</v-icon>
<span>{{ stats.device.time | moment("LT") }}</span>
</template>
<template v-else>
<v-btn to="/setup/wifi" icon>
<v-icon color="red">$signalWifiOff</v-icon>
</v-btn>
</template>
</v-system-bar>
<!--
@ -84,25 +91,14 @@
},
data: () => ({
isLoading: true,
bottomNav: 3,
items: [
{title: 'Dashboard', icon: '$dashboard', to: '/'},
//{title: 'Sandbox', icon: '$sandbox', to: '/sandbox'},
{title: 'Wifi', icon: '$wifi', to: '/wifi'},
{title: 'Settings', icon: '$settings', to: '/settings'},
],
settings: null
}),
created () {
this.$vuetify.icons.values.device = {component: () => import(/* webpackChunkName: "icons" */'!vue-svg-loader!@material-icons/svg/svg/cast/baseline.svg')}
this.$vuetify.icons.values.dashboard = {component: () => import(/* webpackChunkName: "icons" */'!vue-svg-loader!@material-icons/svg/svg/dashboard/baseline.svg')}
this.$vuetify.icons.values.settings = {component: () => import(/* webpackChunkName: "icons" */'!vue-svg-loader!@material-icons/svg/svg/settings/baseline.svg')}
this.$vuetify.icons.values.wifi = {component: () => import(/* webpackChunkName: "icons" */'!vue-svg-loader!@material-icons/svg/svg/wifi/baseline.svg')}
this.$vuetify.icons.values.sandbox = {component: () => import(/* webpackChunkName: "icons" */'!vue-svg-loader!@material-icons/svg/svg/gesture/baseline.svg')} // gesture, brush, palette,
apiDevice.getSettings(settings => {
this.settings = settings;
this.autoReloadStats();
this.autoReloadStats();
});
},
watch: {
stats () {

@ -2,8 +2,8 @@
#define WLAN_H
#include <WiFi.h>
#include <ESPmDNS.h>
void setupWlan();
bool wlan_isConnected();
#endif

@ -1,6 +1,6 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x150000,
app1, app, ota_1, 0x160000,0x150000,
spiffs, data, spiffs, 0x2b0000,0x150000,
app0, app, ota_0, 0x10000, 0x170000,
app1, app, ota_1, 0x180000,0x170000,
spiffs, data, spiffs, 0x2f0000,0x110000,
1 # Name Type SubType Offset Size Flags
2 nvs data nvs 0x9000 0x5000
3 otadata data ota 0xe000 0x2000
4 app0 app ota_0 0x10000 0x150000 0x170000
5 app1 app ota_1 0x160000 0x180000 0x150000 0x170000
6 spiffs data spiffs 0x2b0000 0x2f0000 0x150000 0x110000

@ -36,7 +36,7 @@ void setup()
setupImage();
setupWlan();
if (wlan_isConnected())
if (WiFi.isConnected())
{
setupDateTime();
setupPlaylist();
@ -54,7 +54,7 @@ void loop()
{
// put your main code here, to run repeatedly:
if (wlan_isConnected())
if (WiFi.isConnected())
{
loopDateTime();

@ -10,14 +10,13 @@ void initAPMode();
void setupWlan()
{
Serial.println("setup Wlan");
WiFi.setHostname(deviceName);
// load wifi settings
String ssid = NVS.getString("wifi_ssid");
String password = NVS.getString("wifi_password");
String ssid = NVS.getString("wifi.ssid");
String password = NVS.getString("wifi.password");
// TODO count failed connecting wifiFailedCount <=3
if (!ssid.isEmpty() && !password.isEmpty()) // && wifiFailedCount <=3
if (!ssid.isEmpty() && !password.isEmpty() && wifiFailedCount <=3) // && wifiFailedCount <=3
{
// client mode
initClientMode(ssid.c_str(), password.c_str());
@ -28,34 +27,14 @@ void setupWlan()
initAPMode();
}
Serial.println("setup Wlan - done");
}
WiFi.setHostname(deviceName);
void ___connectToNetwork()
{
uint8_t veces = 10;
WiFi.begin("ssid", "password");
Serial.println("Establishing connection to WiFi..");
while (WiFi.status() != WL_CONNECTED)
{
delay(1000);
Serial.println(veces);
if (!veces--)
{
veces = 10;
WiFi.disconnect();
Serial.println("Wifi reset...");
delay(1000);
WiFi.begin("ssid", "password");
Serial.println("Establishing connection to WiFi..");
}
}
Serial.println("Connected to network");
Serial.println("setup Wlan - done");
}
void initClientMode(const char *ssid, const char *password)
{
uint8_t veces = 5;
uint8_t tryCount = 5;
long startMills = millis();
Serial.print(" Connecting to: ");
@ -71,13 +50,21 @@ void initClientMode(const char *ssid, const char *password)
{
delay(500);
Serial.print(".");
if (!veces--)
if (!tryCount--)
{
veces = 5;
WiFi.disconnect();
Serial.println(" wifi reset...");
delay(500);
WiFi.begin(ssid, password);
// todo, hier passt was nicht
wifiFailedCount++;
if (wifiFailedCount > 3) {
Serial.println(" wifi is not reachable...");
initAPMode();
return;
} else {
tryCount = 5;
WiFi.disconnect();
Serial.println(" wifi reset...");
delay(500);
WiFi.begin(ssid, password);
}
}
}
@ -85,6 +72,10 @@ void initClientMode(const char *ssid, const char *password)
Serial.print(" IP address: ");
Serial.println(WiFi.localIP());
if (!MDNS.begin(deviceName)) {
Serial.println("Error setting up MDNS responder!");
}
Serial.print(" connected in: ");
Serial.println(millis() - startMills);
}
@ -98,9 +89,4 @@ void initAPMode()
IPAddress IP = WiFi.softAPIP();
Serial.print(" AP IP address: ");
Serial.println(IP);
}
bool wlan_isConnected()
{
return WiFi.isConnected();
}
Loading…
Cancel
Save