Compare commits
No commits in common. "a01a151943023c58320ddb9977f59e8e4fc55349" and "29ae07da64a8b978988bc7db25d04f4b3f447302" have entirely different histories.
a01a151943
...
29ae07da64
@ -19,20 +19,15 @@ ConnectivityManager::ConnectivityManager(SDCardManager &sdCardManager) : _error(
|
||||
if(!enableSTAAndAP(false))_error &= AP_AND_STA_ENABLED_ERR;
|
||||
else
|
||||
{
|
||||
//SOFT AP PART
|
||||
CFGFileParser cfgFileParser(sdCardManager, AP_CFG_FILE);
|
||||
CFGDictionary<CFGParameterValue> *cfgDictionary = (CFGDictionary<CFGParameterValue> *) cfgFileParser.parseFile();
|
||||
if(cfgDictionary == NULL)
|
||||
{
|
||||
if(!softAP("ESP8266SwissArmyBoard", NULL, 1, false, 8))_error &= AP_SETUP_ERR;
|
||||
}
|
||||
else if((*cfgDictionary)("SSID") != NULL && (*cfgDictionary)("PASSWORD") != NULL && (*cfgDictionary)("CHANNEL") != NULL && (*cfgDictionary)("SSID_HIDDEN") != NULL && (*cfgDictionary)("AP_MAX_CONNECTION") != NULL && (*cfgDictionary)("ENABLED") != NULL)
|
||||
{
|
||||
if((*cfgDictionary)("ENABLED")->booleanValue())
|
||||
{
|
||||
if(!softAP((*cfgDictionary)("SSID")->stringValue(), strcmp((*cfgDictionary)("PASSWORD")->stringValue(),"") == 0 ? NULL:(*cfgDictionary)("PASSWORD")->stringValue(), (*cfgDictionary)("CHANNEL")->intValue(), (*cfgDictionary)("SSID_HIDDEN")->booleanValue(), (*cfgDictionary)("AP_MAX_CONNECTION")->intValue()))
|
||||
_error &= AP_SETUP_ERR;
|
||||
}
|
||||
else if((*cfgDictionary)("SSID") != NULL && (*cfgDictionary)("PASSWORD") != NULL && (*cfgDictionary)("CHANNEL") != NULL && (*cfgDictionary)("SSID_HIDDEN") != NULL && (*cfgDictionary)("AP_MAX_CONNECTION") != NULL)
|
||||
{
|
||||
if(!softAP((*cfgDictionary)("SSID")->stringValue(), strcmp((*cfgDictionary)("PASSWORD")->stringValue(),"") == 0 ? NULL:(*cfgDictionary)("PASSWORD")->stringValue(), (*cfgDictionary)("CHANNEL")->intValue(), (*cfgDictionary)("SSID_HIDDEN")->booleanValue(), (*cfgDictionary)("AP_MAX_CONNECTION")->intValue()))_error &= AP_SETUP_ERR;
|
||||
delete cfgDictionary;
|
||||
}
|
||||
else
|
||||
@ -40,20 +35,17 @@ ConnectivityManager::ConnectivityManager(SDCardManager &sdCardManager) : _error(
|
||||
if(!softAP("ESP8266SwissArmyBoard", NULL, 1, false, 8))_error &= AP_SETUP_ERR;
|
||||
delete cfgDictionary;
|
||||
}
|
||||
|
||||
//STATION PART
|
||||
|
||||
CFGFileParser cfgFileParserSTA(sdCardManager, STA_CFG_FILE);
|
||||
cfgDictionary = (CFGDictionary<CFGParameterValue> *) cfgFileParserSTA.parseFile();
|
||||
if(cfgDictionary != NULL)
|
||||
{
|
||||
if((*cfgDictionary)("SSID") != NULL && (*cfgDictionary)("PASSWORD") != NULL && (*cfgDictionary)("ENABLED") != NULL)
|
||||
if((*cfgDictionary)("SSID") != NULL && (*cfgDictionary)("PASSWORD") != NULL)
|
||||
{
|
||||
if((*cfgDictionary)("ENABLED")->booleanValue())
|
||||
{
|
||||
if(!begin((*cfgDictionary)("SSID")->stringValue(), (*cfgDictionary)("PASSWORD")->stringValue()))
|
||||
_error &= AP_SETUP_ERR;
|
||||
}
|
||||
if(!begin((*cfgDictionary)("SSID")->stringValue(), (*cfgDictionary)("PASSWORD")->stringValue()))
|
||||
_error &= AP_SETUP_ERR;
|
||||
}
|
||||
|
||||
delete cfgDictionary;
|
||||
}
|
||||
}
|
||||
@ -64,16 +56,6 @@ boolean ConnectivityManager::enableSTAAndAP(boolean enabled)
|
||||
return enableSTA(enabled) && enableAP(enabled);
|
||||
}
|
||||
|
||||
boolean ConnectivityManager::isSTAEnabled()
|
||||
{
|
||||
return (getMode() == WIFI_AP_STA || getMode() == WIFI_STA);
|
||||
}
|
||||
|
||||
boolean ConnectivityManager::isAPEnabled()
|
||||
{
|
||||
return (getMode() == WIFI_AP_STA || getMode() == WIFI_AP);
|
||||
}
|
||||
|
||||
unsigned char ConnectivityManager::RSSIPercent()
|
||||
{
|
||||
int RSSIdBm = RSSI();
|
||||
|
@ -16,9 +16,7 @@ class ConnectivityManager : public ESP8266WiFiClass
|
||||
friend class SAB;
|
||||
public:
|
||||
boolean enableSTAAndAP(boolean enable);
|
||||
boolean isSTAEnabled();
|
||||
boolean isAPEnabled();
|
||||
|
||||
|
||||
unsigned char RSSIPercent();
|
||||
unsigned char getError() const;
|
||||
protected:
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "WEBServer.h"
|
||||
#include "TCPClient.h"
|
||||
#include "Dictionary.h"
|
||||
|
||||
class WEBClient : public TCPClient
|
||||
{
|
||||
|
@ -13,8 +13,8 @@ SAB sab;
|
||||
unsigned long currentMs = 0, buttonMs = 0;
|
||||
volatile boolean ioStateChange(false);
|
||||
View1Packet v1p = {sab.getRtcManager().getDateTime(), sab.getSdCardManager().getSize(GBYTE), sab.getPowerManager().getPowerInfo(),0, sab.getSoftVersion(), &sab};
|
||||
ViewAPPacket vap = {sab.getConnectivityManager().softAPmacAddress(), sab.getConnectivityManager().softAPSSID(), sab.getConnectivityManager().softAPIP(), sab.getConnectivityManager().softAPgetStationNum(), sab.getConnectivityManager().isAPEnabled()};
|
||||
ViewSTAPacket vstap = {sab.getConnectivityManager().macAddress(), sab.getConnectivityManager().localIP(), sab.getConnectivityManager().RSSI(), sab.getConnectivityManager().isSTAEnabled()};
|
||||
ViewAPPacket vap = {sab.getConnectivityManager().softAPmacAddress(), sab.getConnectivityManager().softAPSSID(), sab.getConnectivityManager().softAPIP(), sab.getConnectivityManager().softAPgetStationNum()};
|
||||
ViewSTAPacket vstap = {sab.getConnectivityManager().macAddress(), sab.getConnectivityManager().localIP(), sab.getConnectivityManager().RSSI()};
|
||||
ViewIoInfoPacket vio = {{0},{0}};
|
||||
SdCardApiPacket sdCardApiPacket = {NULL, NULL};
|
||||
|
||||
|
@ -16,6 +16,5 @@
|
||||
#define SOFT_VERSION "1.2.0" //Added new PowerManager class
|
||||
#define SOFT_VERSION "1.2.1" //Corrected a bug in the TaskSchedulerManager class
|
||||
#define SOFT_VERSION "1.3.0" //Implemented multi-client non blocking webserver
|
||||
#define SOFT_VERSION "1.3.1" //Fixed sdCardUnmount api call
|
||||
|
||||
#endif //VERSIONS_H
|
||||
|
@ -39,12 +39,8 @@ boolean view_2(Adafruit_SSD1306 &display, void *pData)
|
||||
char conn_str[300];
|
||||
|
||||
ViewAPPacket *p = (ViewAPPacket *) pData;
|
||||
|
||||
if(p->enabled)
|
||||
sprintf(conn_str,"Ip addr : %u.%u.%u.%u\nMac addr : \n%s\nConns : %u\nSSID : %s\n" ,p->ipAddr[0], p->ipAddr[1], p->ipAddr[2], p->ipAddr[3], p->macAddr.c_str(), p->nbOfCon, p->ssid.c_str());
|
||||
else
|
||||
sprintf(conn_str,"AP connectivity\nis not enabled\nCheck the cfg file\n");
|
||||
|
||||
sprintf(conn_str,"Ip addr : %u.%u.%u.%u\nMac addr : \n%s\nConns : %u\nSSID : %s\n" ,p->ipAddr[0], p->ipAddr[1], p->ipAddr[2], p->ipAddr[3], p->macAddr.c_str(), p->nbOfCon, p->ssid.c_str());
|
||||
display.println(conn_str);
|
||||
|
||||
display.setCursor(0,56);
|
||||
@ -58,12 +54,8 @@ boolean view_3(Adafruit_SSD1306 &display, void *pData)
|
||||
char conn_str[300];
|
||||
|
||||
ViewSTAPacket *p = (ViewSTAPacket *) pData;
|
||||
|
||||
if(p->enabled)
|
||||
sprintf(conn_str,"Ip addr : %u.%u.%u.%u\nMac addr : \n%s\nSignal : %d dBm\n", p->ipAddr[0], p->ipAddr[1], p->ipAddr[2], p->ipAddr[3], p->macAddr.c_str(), p->sigStrength);
|
||||
else
|
||||
sprintf(conn_str,"STA connectivity\nis not enabled\nCheck the cfg file\n");
|
||||
|
||||
sprintf(conn_str,"Ip addr : %u.%u.%u.%u\nMac addr : \n%s\nSignal : %d dBm\n", p->ipAddr[0], p->ipAddr[1], p->ipAddr[2], p->ipAddr[3], p->macAddr.c_str(), p->sigStrength);
|
||||
display.println(conn_str);
|
||||
|
||||
display.setCursor(0,56);
|
||||
|
@ -22,7 +22,6 @@ typedef struct viewAPPacket
|
||||
String ssid;
|
||||
IPAddress ipAddr;
|
||||
uint8_t nbOfCon;
|
||||
boolean enabled;
|
||||
} ViewAPPacket;
|
||||
|
||||
//AP info
|
||||
@ -33,7 +32,6 @@ typedef struct viewSTAPacket
|
||||
String macAddr;
|
||||
IPAddress ipAddr;
|
||||
int sigStrength;
|
||||
boolean enabled;
|
||||
} ViewSTAPacket;
|
||||
|
||||
//STA info
|
||||
|
@ -121,7 +121,7 @@ boolean sdCardMountApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *w
|
||||
float *sdCardSize = (float *) &pV->pView->sdCardSize;
|
||||
char buffer[200];
|
||||
|
||||
if(p->getSdCardManager().begin(p->getPinConfig().getSPI_sdCard_cs(), p->getSdCardConfig().getSPISpeed()))
|
||||
if(p->getSdCardManager().begin(p->getSdCardConfig().getSPISpeed(), p->getPinConfig().getSPI_sdCard_cs()))
|
||||
{
|
||||
sprintf(buffer,"HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{ \"status\" : \"ok\", \"card\" : \"mounted\" }");
|
||||
*sdCardSize = p->getSdCardManager().getSize(GBYTE);
|
||||
|
@ -1 +0,0 @@
|
||||
#include "FTPClient.h"
|
@ -1,13 +0,0 @@
|
||||
#ifndef FTPCLIENT_H
|
||||
#define FTPCLIENT_H
|
||||
|
||||
#include "TCPClient.h"
|
||||
|
||||
class FTPClient
|
||||
{
|
||||
public:
|
||||
protected:
|
||||
private:
|
||||
};
|
||||
|
||||
#endif //FTPCLIENT_H
|
@ -1,32 +0,0 @@
|
||||
#ifndef FTPSERVER_H
|
||||
#define FTPSERVER_H
|
||||
|
||||
#include "TCPServer.h"
|
||||
|
||||
template <typename T>
|
||||
class FTPServer : public TCPServer<T>
|
||||
{
|
||||
public:
|
||||
FTPServer(unsigned int port = 22, const char login = "", const char password = "", uint8_t maxClient = MAX_CLIENT, uint16_t clientCommandDataBufferSize = 255) : TCPServer<T>(port, maxClient, clientCommandDataBufferSize), _login(NULL), _password(NULL)
|
||||
{
|
||||
_login = (char *)malloc((sizeof(char) * strlen(login)) + 1);
|
||||
if(_login != NULL)
|
||||
strcpy(_login, login);
|
||||
|
||||
_password = (char *)malloc((sizeof(char) * strlen(password)) + 1);
|
||||
if(_password != NULL)
|
||||
strcpy(_password, password);
|
||||
}
|
||||
|
||||
virtual ~FTPServer()
|
||||
{
|
||||
free(_login);free(_password);
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
char *_login;
|
||||
char *_password;
|
||||
};
|
||||
|
||||
#endif //FTPSERVER_H
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "WEBServer.h"
|
||||
#include "TCPClient.h"
|
||||
#include "Dictionary.h"
|
||||
|
||||
class WEBClient : public TCPClient
|
||||
{
|
||||
|
@ -7,14 +7,12 @@
|
||||
#include "TCPServer.h"
|
||||
#include "WEBServer.h"
|
||||
#include "WEBClient.h"
|
||||
#include "FTPServer.h"
|
||||
#include "FTPClient.h"
|
||||
|
||||
uint32_t lastFreeMem(0);
|
||||
uint16_t lastClientCount(0);
|
||||
|
||||
//TCPServer<TCPClient> server(80, MAX_CLIENT, 5);
|
||||
//WEBServer<WEBClient> webServer(8080);
|
||||
TCPServer<TCPClient> server(80, MAX_CLIENT, 5);
|
||||
WEBServer<WEBClient> webServer(8080);
|
||||
|
||||
WiFiEventHandler gotIpEventHandler, disconnectedEventHandler;
|
||||
|
||||
@ -41,17 +39,17 @@ void debugInfo()
|
||||
Serial.print("Heap Frag : ");Serial.println(frag);
|
||||
lastFreeMem = freeMem;
|
||||
}
|
||||
/*if(lastClientCount != server.getConnectedClientsCount())
|
||||
if(lastClientCount != server.getConnectedClientsCount())
|
||||
{
|
||||
lastClientCount = server.getConnectedClientsCount();
|
||||
Serial.print("Connected client(s) : ");Serial.println(lastClientCount);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
//server.runServer();
|
||||
//webServer.runServer();
|
||||
server.runServer();
|
||||
webServer.runServer();
|
||||
debugInfo();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user