Checking in work so I don't lose it. Nothing's broke with the build.

1.2-legacy
Jm 2021-01-01 21:20:34 -08:00
rodzic 925829dc58
commit 8295b88d96
6 zmienionych plików z 57 dodań i 37 usunięć

Wyświetl plik

@ -17,27 +17,27 @@ uint32_t secSinceBoot = 0;
// Don't read out of this directly. Use the helper functions.
struct airtimeStruct {
uint16_t periodTX[periodsToLog];
uint16_t periodRX[periodsToLog];
uint16_t periodRX_ALL[periodsToLog];
uint16_t periodTX[periodsToLog]; // AirTime transmitted
uint16_t periodRX[periodsToLog]; // AirTime received and repeated (Only valid mesh packets)
uint16_t periodRX_ALL[periodsToLog]; // AirTime received regardless of valid mesh packet. Could include noise.
uint8_t lastPeriodIndex;
} airtimes;
void AirTime::logAirtime(reportTypes reportType, uint32_t airtime_ms)
{
DEBUG_MSG("Packet - logAirtime()\n");
// DEBUG_MSG("Packet - logAirtime()\n");
if (reportType == TX_LOG) {
DEBUG_MSG("Packet transmitted = %u\n", (uint32_t)round(airtime_ms / 1000));
DEBUG_MSG("AirTime - Packet transmitted : %us %ums\n", (uint32_t)round((float)airtime_ms / (float)1000), airtime_ms);
airtimes.periodTX[0] = airtimes.periodTX[0] + round(airtime_ms / 1000);
} else if (reportType == RX_LOG) {
DEBUG_MSG("Packet received = %u\n", (uint32_t)round(airtime_ms / 1000));
DEBUG_MSG("AirTime - Packet received : %us %ums\n", (uint32_t)round((float)airtime_ms / (float)1000), airtime_ms);
airtimes.periodRX[0] = airtimes.periodRX[0] + round(airtime_ms / 1000);
} else if (reportType == RX_ALL_LOG) {
DEBUG_MSG("Packet received (noise?) = %u\n", (uint32_t)round(airtime_ms / 1000));
DEBUG_MSG("AirTime - Packet received (noise?) : %us %ums\n", (uint32_t)round((float)airtime_ms / (float)1000), airtime_ms);
airtimes.periodRX_ALL[0] = airtimes.periodRX_ALL[0] + round(airtime_ms / 1000);
} else {
// Unknown report type
DEBUG_MSG("AirTime - Unknown report time. This should never happen!!\n");
}
}
@ -67,7 +67,6 @@ void airtimeRotatePeriod()
uint16_t *airtimeReport(reportTypes reportType)
{
// currentHourIndexReset();
if (reportType == TX_LOG) {
return airtimes.periodTX;
@ -98,10 +97,17 @@ AirTime::AirTime() : concurrency::OSThread("AirTime") {}
int32_t AirTime::runOnce()
{
DEBUG_MSG("AirTime::runOnce()\n");
// DEBUG_MSG("AirTime::runOnce()\n");
airtimeRotatePeriod();
secSinceBoot++;
return 1000;
/*
This actually doesn't need to be run once per second but we currently use it for the
secSinceBoot counter.
If we have a better counter of how long the device has been online (and not millis())
then we can change this to something less frequent. Maybe once ever 5 seconds?
*/
return (1000 * 1);
}

Wyświetl plik

@ -21,6 +21,7 @@
#include "main.h"
#include "meshwifi/meshhttp.h"
#include "meshwifi/meshwifi.h"
#include "meshwifi/WebServerThread.h"
#include "sleep.h"
#include "target_specific.h"
#include <OneButton.h>

Wyświetl plik

@ -0,0 +1,14 @@
#include "meshwifi/WebServerThread.h"
#include <Arduino.h>
// Thread for the HTTP Server
WebServerThread webServerThread;
WebServerThread::WebServerThread() : concurrency::OSThread("WebServerThread") {}
int32_t WebServerThread::runOnce()
{
DEBUG_MSG("WebServerThread::runOnce()\n");
return (1000 * 1);
}

Wyświetl plik

@ -0,0 +1,22 @@
#pragma once
#include "concurrency/OSThread.h"
#include "concurrency/Periodic.h"
#include <Arduino.h>
#include <functional>
#include "configuration.h"
class WebServerThread : private concurrency::OSThread
{
public:
WebServerThread();
protected:
virtual int32_t runOnce();
};
extern WebServerThread webServerThread;

Wyświetl plik

@ -49,6 +49,7 @@ HTTPServer *insecureServer;
// Our API to handle messages to and from the radio.
HttpAPI webAPI;
// Declare some handler functions for the various URLs on the server
void handleAPIv1FromRadio(HTTPRequest *req, HTTPResponse *res);
void handleAPIv1ToRadio(HTTPRequest *req, HTTPResponse *res);
@ -1213,13 +1214,3 @@ void replaceAll(std::string &str, const std::string &from, const std::string &to
start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx'
}
}
HttpServer::HttpServer() : concurrency::OSThread("HttpServer") {
DEBUG_MSG("22**********************************\n");
}
int32_t HttpServer::runOnce()
{
DEBUG_MSG("11**********************************\n");
return 200; // Poll our GPIOs every 200ms (FIXME, make adjustable via protobuf arg)
}

Wyświetl plik

@ -25,6 +25,8 @@ void handleJSONChatHistoryDummy();
void replaceAll(std::string &str, const std::string &from, const std::string &to);
// Interface to the PhoneAPI to access the protobufs with messages
class HttpAPI : public PhoneAPI
{
@ -37,19 +39,3 @@ class HttpAPI : public PhoneAPI
protected:
// Nothing here yet
};
/**
* A plugin that provides easy low-level remote access to device hardware.
*/
class HttpServer : public concurrency::OSThread
{
public:
// Nothing here
// RemoteHardwarePlugin();
HttpServer();
protected:
virtual int32_t runOnce();
};
// extern HttpServer httpServer;