remove connectionStatus
This commit is contained in:
@@ -55,9 +55,9 @@ bool Aperio::Connected()
|
||||
return _state == AperioState::RUNNING;
|
||||
}
|
||||
|
||||
void Aperio::ExecuteAperio(nsapi_connection_status_t status)
|
||||
void Aperio::ExecuteAperio(bool connected)
|
||||
{
|
||||
if(status == NSAPI_STATUS_LOCAL_UP || status == NSAPI_STATUS_GLOBAL_UP)
|
||||
if(connected)
|
||||
{
|
||||
switch (_state)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ class Aperio
|
||||
|
||||
static void begin();
|
||||
static bool Connected();
|
||||
static void ExecuteAperio(nsapi_connection_status_t status);
|
||||
static void ExecuteAperio(bool connected);
|
||||
static void Disconnect();
|
||||
static void CredentialRequest(MF700::reader_t *readerdata);
|
||||
static void SendState(uint8_t input, uint8_t state);
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
time_t lastNTPUpdate = 0;
|
||||
const double UpdateSeconds = 86000;
|
||||
|
||||
void NTP::checkUpdateTime(nsapi_connection_status_t status)
|
||||
void NTP::checkUpdateTime(bool connected)
|
||||
{
|
||||
if(status == NSAPI_STATUS_LOCAL_UP || status == NSAPI_STATUS_GLOBAL_UP)
|
||||
if(connected)
|
||||
{
|
||||
if(lastNTPUpdate == 0)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
class NTP{
|
||||
public:
|
||||
static void checkUpdateTime(nsapi_connection_status_t status);
|
||||
static void checkUpdateTime(bool connected);
|
||||
private:
|
||||
static void updateTime();
|
||||
static time_t get_timestamp(int timeout);
|
||||
|
||||
@@ -62,9 +62,9 @@ void WebServer::begin()
|
||||
app.post("/startupdate", std::bind(&WebServer::startFirmwareUpdate, std::placeholders::_1, std::placeholders::_2));
|
||||
}
|
||||
|
||||
void WebServer::listen(nsapi_connection_status_t status)
|
||||
void WebServer::listen(bool connected)
|
||||
{
|
||||
if(status == NSAPI_STATUS_LOCAL_UP || status == NSAPI_STATUS_GLOBAL_UP)
|
||||
if(connected)
|
||||
{
|
||||
if (_serverSocket == nullptr)
|
||||
{
|
||||
|
||||
@@ -15,8 +15,7 @@ class WebServer
|
||||
{
|
||||
public:
|
||||
static void begin();
|
||||
//static void Connect();
|
||||
static void listen(nsapi_connection_status_t status);
|
||||
static void listen(bool connected);
|
||||
private:
|
||||
static void notFound(HTTPWebServer::Request &req, HTTPWebServer::Response &res);
|
||||
static bool checkAuthentication(HTTPWebServer::Request &req, HTTPWebServer::Response &res);
|
||||
|
||||
15
src/main.cpp
15
src/main.cpp
@@ -28,9 +28,6 @@ constexpr uint32_t HEARTBEAT_NETWORKCONNECTED = (1 << 2);
|
||||
constexpr uint32_t HEARTBEAT_APERIOCONNECTED = (1 << 3);
|
||||
rtos::EventFlags heartBeatState;
|
||||
|
||||
|
||||
volatile nsapi_connection_status currentNetworkState = NSAPI_STATUS_DISCONNECTED;
|
||||
|
||||
struct MF700::reader_t reader;
|
||||
rtos::Mutex readerMutex;
|
||||
|
||||
@@ -276,8 +273,9 @@ void aperioTask()
|
||||
//Inputs::inputEvent_t *currentEvent = nullptr;
|
||||
bool connectionState = false;
|
||||
while(true)
|
||||
{
|
||||
Aperio::ExecuteAperio(currentNetworkState);
|
||||
{
|
||||
bool connected = (heartBeatState.get() & HEARTBEAT_NETWORKCONNECTED) == HEARTBEAT_NETWORKCONNECTED;
|
||||
Aperio::ExecuteAperio(connected);
|
||||
|
||||
if(connectionState != Aperio::Connected())
|
||||
{
|
||||
@@ -322,7 +320,6 @@ void aperioTask()
|
||||
void networkStatusChange(nsapi_event_t status, intptr_t param)
|
||||
{
|
||||
if (status == NSAPI_EVENT_CONNECTION_STATUS_CHANGE) {
|
||||
currentNetworkState = static_cast<nsapi_connection_status>(param);
|
||||
switch(param) {
|
||||
case NSAPI_STATUS_GLOBAL_UP:
|
||||
Serial.println("global up");
|
||||
@@ -480,9 +477,11 @@ void setup()
|
||||
|
||||
void loop()
|
||||
{
|
||||
WebServer::listen(currentNetworkState);
|
||||
bool connected = (heartBeatState.get() & HEARTBEAT_NETWORKCONNECTED) == HEARTBEAT_NETWORKCONNECTED;
|
||||
|
||||
WebServer::listen(connected);
|
||||
rtos::ThisThread::yield();
|
||||
|
||||
NTP::checkUpdateTime(currentNetworkState);
|
||||
NTP::checkUpdateTime(connected);
|
||||
rtos::ThisThread::yield();
|
||||
}
|
||||
Reference in New Issue
Block a user