Skip to content

Commit

Permalink
1.16.beta
Browse files Browse the repository at this point in the history
* true/false quote remove
* RSSI Support
* Info Table Fixes
  • Loading branch information
fashberg committed Aug 2, 2020
1 parent e45aba5 commit dce28ea
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 7 deletions.
1 change: 1 addition & 0 deletions WAdapter/WDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const char* DEVICE_TYPE_TEMPERATURE_SENSOR = "TemperatureSensor";
const char* DEVICE_TYPE_THERMOSTAT = "Thermostat";
const char* DEVICE_TYPE_LOG = "Log";
const char* DEVICE_TYPE_TEXT_DISPLAY = "TextDisplay";
const char* DEVICE_TYPE_NETWORK = "Network";

class WNetwork;

Expand Down
2 changes: 0 additions & 2 deletions WAdapter/WJson.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,7 @@ class WJson {
WJson& boolean(bool value) {
if (!separatorAlreadyCalled)
ifSeparator();
stream->print(QUOTE);
stream->print(value ? "true" : "false");
stream->print(QUOTE);
return *this;
}

Expand Down
28 changes: 23 additions & 5 deletions WAdapter/WNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,6 @@ class WNetwork {
}
});





wlog->notice(F("firmware: %s"), firmwareVersion.c_str());

Expand Down Expand Up @@ -422,8 +419,10 @@ true ||
//if ((WiFi.status() != WL_CONNECTED) || (!this->isSupportingWebThing())) {
webServer->on("/", HTTP_GET, std::bind(&WNetwork::handleHttpRootRequest, this));
webServer->on("/config", HTTP_GET, std::bind(&WNetwork::handleHttpRootRequest, this));
// Android Captive Portal Detection
webServer->on("/generate_204", HTTP_GET, std::bind(&WNetwork::handleHttpRootRequest, this));
//webServer->on("/generate_204", HTTP_GET, std::bind(&WNetwork::handleCaptivePortal, this));
// Apple Captive Portal Detection
webServer->on("/hotspot-detect.html", HTTP_GET, std::bind(&WNetwork::handleHttpRootRequest, this));

WDevice *device = this->firstDevice;
while (device != nullptr) {
Expand Down Expand Up @@ -1094,43 +1093,61 @@ true ||
page->print("<tr><th>Chip ID:</th><td>");
page->print(ESP.getChipId());
page->print("</td></tr>");

page->print("<tr><th>Flash Chip ID:</th><td>");
page->print(ESP.getFlashChipId());
page->print("</td></tr>");

page->print("<tr><th>IDE Flash Size:</th><td>");
page->print(ESP.getFlashChipSize());
page->print("</td></tr>");

page->print("<tr><th>Real Flash Size:</th><td>");
page->print(ESP.getFlashChipRealSize());
page->print("</td></tr>");

page->print("<tr><th>IP address:</th><td>");
page->print(this->getDeviceIp().toString());
page->print("</td></tr>");

page->print("<tr><th>MAC address:</th><td>");
page->print(WiFi.macAddress());
page->print("</td></tr>");

page->print("<tr><th>Current WiFi RSSI:</th><td>");
page->print(WiFi.RSSI());
page->print(" dBm");
page->print("</td></tr>");

page->print("<tr><th>Flash Chip size:</th><td>");
page->print(ESP.getFlashChipSize());
page->print(" kByte");
page->print("</td></tr>");

page->print("<tr><th>Current sketch size:</th><td>");
page->print(ESP.getSketchSize());
page->print(" kByte");
page->print("</td></tr>");

page->print("<tr><th>Available sketch size:</th><td>");
page->print(ESP.getFreeSketchSpace());
page->print(" kByte");
page->print("</td></tr>");

page->print("<tr><th>Free heap size:</th><td>");
page->print(ESP.getFreeHeap());
page->print(" kByte");
page->print("</td></tr>");

page->print("<tr><th>Largest free heap block:</th><td>");
page->print(ESP.getMaxFreeBlockSize());
page->print(" kByte");
page->print("</td></tr>");

page->print("<tr><th>Heap fragmentation:</th><td>");
page->print(ESP.getHeapFragmentation());
page->print(" %</td></tr>");
page->print("</td></tr>");

page->print("<tr><th>Uptime:</th><td>");
unsigned long secs=millis()/1000;
unsigned int days = secs / (60 * 60 * 24);
Expand All @@ -1142,6 +1159,7 @@ true ||
page->printf_P("%dd, %dh, %dm, %ds",
days, hours, minutes, secs);
page->print("</td></tr>");

page->print("</table>");
page->print(FPSTR(HTTP_HOME_BUTTON));
page->webserverSendAndFlush(webServer);
Expand Down
70 changes: 70 additions & 0 deletions WAdapter/WNetworkDevice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#ifndef NETWORKDEVICE_H
#define NETWORKDEVICE_H

#include "Arduino.h"
#include <ESP8266WiFi.h>
#include <EEPROM.h>
#include "WDevice.h"

class WNetworkDev: public WDevice {
public:

WNetworkDev(WNetwork* network, String applicationName)
: WDevice(network, "network", "network", network->getIdx(), DEVICE_TYPE_NETWORK) {

this->providingConfigPage = false;
this->configNeedsReboot = false;
this->stateNotifyInterval = 30000;
this->mainDevice = false;

lastLongLoop = lastVeryLongLoop = 0;

/* properties */
this->rssi = new WProperty("rssi", "rssi", INTEGER);
this->rssi->setReadOnly(true);
this->rssi->setMqttSendChangedValues(true);
this->rssi->setOnValueRequest([this](WProperty* p) {updateRssi();});
this->addProperty(this->rssi);

}

virtual void printConfigPage(WStringStream* page) {

}
void saveConfigPage(ESP8266WebServer* webServer) {

}

void loop(unsigned long now) {
// to tasks only every second
if (lastLongLoop + 1000 < now ){
lastLongLoop=now;
}
// to tasks only every 30 seconds
if (lastVeryLongLoop + 30000 < now ){
lastVeryLongLoop=now;
}

// properties are getting read during stateNotify
}

void handleUnknownMqttCallback(String stat_topic, String partialTopic, String payload, unsigned int length) {
//logCommand(((String)"handleUnknownMqttCallback " + stat_topic + " / " + partialTopic + " / " + payload).c_str());
}


void updateRssi() {
this->rssi->setInteger(WiFi.RSSI());
}

void connectionChange(){
this->rssi->setInteger(WiFi.RSSI());
}

private:
WProperty* rssi;
unsigned long lastLongLoop, lastVeryLongLoop;
};


#endif

0 comments on commit dce28ea

Please # to comment.