Compare commits
7 Commits
29ae07da64
...
a01a151943
Author | SHA1 | Date | |
---|---|---|---|
|
a01a151943 | ||
|
1317644b3d | ||
|
f632ace6ed | ||
|
18e47f22d1 | ||
|
e36fca5326 | ||
|
49a37a34f3 | ||
|
a824610fb6 |
@ -19,15 +19,20 @@ ConnectivityManager::ConnectivityManager(SDCardManager &sdCardManager) : _error(
|
|||||||
if(!enableSTAAndAP(false))_error &= AP_AND_STA_ENABLED_ERR;
|
if(!enableSTAAndAP(false))_error &= AP_AND_STA_ENABLED_ERR;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
//SOFT AP PART
|
||||||
CFGFileParser cfgFileParser(sdCardManager, AP_CFG_FILE);
|
CFGFileParser cfgFileParser(sdCardManager, AP_CFG_FILE);
|
||||||
CFGDictionary<CFGParameterValue> *cfgDictionary = (CFGDictionary<CFGParameterValue> *) cfgFileParser.parseFile();
|
CFGDictionary<CFGParameterValue> *cfgDictionary = (CFGDictionary<CFGParameterValue> *) cfgFileParser.parseFile();
|
||||||
if(cfgDictionary == NULL)
|
if(cfgDictionary == NULL)
|
||||||
{
|
{
|
||||||
if(!softAP("ESP8266SwissArmyBoard", NULL, 1, false, 8))_error &= AP_SETUP_ERR;
|
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)
|
else if((*cfgDictionary)("SSID") != NULL && (*cfgDictionary)("PASSWORD") != NULL && (*cfgDictionary)("CHANNEL") != NULL && (*cfgDictionary)("SSID_HIDDEN") != NULL && (*cfgDictionary)("AP_MAX_CONNECTION") != NULL && (*cfgDictionary)("ENABLED") != 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;
|
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;
|
||||||
|
}
|
||||||
delete cfgDictionary;
|
delete cfgDictionary;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -35,17 +40,20 @@ ConnectivityManager::ConnectivityManager(SDCardManager &sdCardManager) : _error(
|
|||||||
if(!softAP("ESP8266SwissArmyBoard", NULL, 1, false, 8))_error &= AP_SETUP_ERR;
|
if(!softAP("ESP8266SwissArmyBoard", NULL, 1, false, 8))_error &= AP_SETUP_ERR;
|
||||||
delete cfgDictionary;
|
delete cfgDictionary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//STATION PART
|
||||||
CFGFileParser cfgFileParserSTA(sdCardManager, STA_CFG_FILE);
|
CFGFileParser cfgFileParserSTA(sdCardManager, STA_CFG_FILE);
|
||||||
cfgDictionary = (CFGDictionary<CFGParameterValue> *) cfgFileParserSTA.parseFile();
|
cfgDictionary = (CFGDictionary<CFGParameterValue> *) cfgFileParserSTA.parseFile();
|
||||||
if(cfgDictionary != NULL)
|
if(cfgDictionary != NULL)
|
||||||
{
|
{
|
||||||
if((*cfgDictionary)("SSID") != NULL && (*cfgDictionary)("PASSWORD") != NULL)
|
if((*cfgDictionary)("SSID") != NULL && (*cfgDictionary)("PASSWORD") != NULL && (*cfgDictionary)("ENABLED") != NULL)
|
||||||
{
|
{
|
||||||
if(!begin((*cfgDictionary)("SSID")->stringValue(), (*cfgDictionary)("PASSWORD")->stringValue()))
|
if((*cfgDictionary)("ENABLED")->booleanValue())
|
||||||
_error &= AP_SETUP_ERR;
|
{
|
||||||
|
if(!begin((*cfgDictionary)("SSID")->stringValue(), (*cfgDictionary)("PASSWORD")->stringValue()))
|
||||||
|
_error &= AP_SETUP_ERR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete cfgDictionary;
|
delete cfgDictionary;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,6 +64,16 @@ boolean ConnectivityManager::enableSTAAndAP(boolean enabled)
|
|||||||
return enableSTA(enabled) && enableAP(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()
|
unsigned char ConnectivityManager::RSSIPercent()
|
||||||
{
|
{
|
||||||
int RSSIdBm = RSSI();
|
int RSSIdBm = RSSI();
|
||||||
|
@ -16,7 +16,9 @@ class ConnectivityManager : public ESP8266WiFiClass
|
|||||||
friend class SAB;
|
friend class SAB;
|
||||||
public:
|
public:
|
||||||
boolean enableSTAAndAP(boolean enable);
|
boolean enableSTAAndAP(boolean enable);
|
||||||
|
boolean isSTAEnabled();
|
||||||
|
boolean isAPEnabled();
|
||||||
|
|
||||||
unsigned char RSSIPercent();
|
unsigned char RSSIPercent();
|
||||||
unsigned char getError() const;
|
unsigned char getError() const;
|
||||||
protected:
|
protected:
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include "WEBServer.h"
|
#include "WEBServer.h"
|
||||||
#include "TCPClient.h"
|
#include "TCPClient.h"
|
||||||
#include "Dictionary.h"
|
|
||||||
|
|
||||||
class WEBClient : public TCPClient
|
class WEBClient : public TCPClient
|
||||||
{
|
{
|
||||||
|
@ -13,8 +13,8 @@ SAB sab;
|
|||||||
unsigned long currentMs = 0, buttonMs = 0;
|
unsigned long currentMs = 0, buttonMs = 0;
|
||||||
volatile boolean ioStateChange(false);
|
volatile boolean ioStateChange(false);
|
||||||
View1Packet v1p = {sab.getRtcManager().getDateTime(), sab.getSdCardManager().getSize(GBYTE), sab.getPowerManager().getPowerInfo(),0, sab.getSoftVersion(), &sab};
|
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()};
|
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()};
|
ViewSTAPacket vstap = {sab.getConnectivityManager().macAddress(), sab.getConnectivityManager().localIP(), sab.getConnectivityManager().RSSI(), sab.getConnectivityManager().isSTAEnabled()};
|
||||||
ViewIoInfoPacket vio = {{0},{0}};
|
ViewIoInfoPacket vio = {{0},{0}};
|
||||||
SdCardApiPacket sdCardApiPacket = {NULL, NULL};
|
SdCardApiPacket sdCardApiPacket = {NULL, NULL};
|
||||||
|
|
||||||
|
@ -16,5 +16,6 @@
|
|||||||
#define SOFT_VERSION "1.2.0" //Added new PowerManager class
|
#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.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.0" //Implemented multi-client non blocking webserver
|
||||||
|
#define SOFT_VERSION "1.3.1" //Fixed sdCardUnmount api call
|
||||||
|
|
||||||
#endif //VERSIONS_H
|
#endif //VERSIONS_H
|
||||||
|
@ -39,8 +39,12 @@ boolean view_2(Adafruit_SSD1306 &display, void *pData)
|
|||||||
char conn_str[300];
|
char conn_str[300];
|
||||||
|
|
||||||
ViewAPPacket *p = (ViewAPPacket *) pData;
|
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.println(conn_str);
|
||||||
|
|
||||||
display.setCursor(0,56);
|
display.setCursor(0,56);
|
||||||
@ -54,8 +58,12 @@ boolean view_3(Adafruit_SSD1306 &display, void *pData)
|
|||||||
char conn_str[300];
|
char conn_str[300];
|
||||||
|
|
||||||
ViewSTAPacket *p = (ViewSTAPacket *) pData;
|
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.println(conn_str);
|
||||||
|
|
||||||
display.setCursor(0,56);
|
display.setCursor(0,56);
|
||||||
|
@ -22,6 +22,7 @@ typedef struct viewAPPacket
|
|||||||
String ssid;
|
String ssid;
|
||||||
IPAddress ipAddr;
|
IPAddress ipAddr;
|
||||||
uint8_t nbOfCon;
|
uint8_t nbOfCon;
|
||||||
|
boolean enabled;
|
||||||
} ViewAPPacket;
|
} ViewAPPacket;
|
||||||
|
|
||||||
//AP info
|
//AP info
|
||||||
@ -32,6 +33,7 @@ typedef struct viewSTAPacket
|
|||||||
String macAddr;
|
String macAddr;
|
||||||
IPAddress ipAddr;
|
IPAddress ipAddr;
|
||||||
int sigStrength;
|
int sigStrength;
|
||||||
|
boolean enabled;
|
||||||
} ViewSTAPacket;
|
} ViewSTAPacket;
|
||||||
|
|
||||||
//STA info
|
//STA info
|
||||||
|
@ -121,7 +121,7 @@ boolean sdCardMountApi(WEBServer<WEBClient>::HttpRequestData &HRD, WiFiClient *w
|
|||||||
float *sdCardSize = (float *) &pV->pView->sdCardSize;
|
float *sdCardSize = (float *) &pV->pView->sdCardSize;
|
||||||
char buffer[200];
|
char buffer[200];
|
||||||
|
|
||||||
if(p->getSdCardManager().begin(p->getSdCardConfig().getSPISpeed(), p->getPinConfig().getSPI_sdCard_cs()))
|
if(p->getSdCardManager().begin(p->getPinConfig().getSPI_sdCard_cs(), p->getSdCardConfig().getSPISpeed()))
|
||||||
{
|
{
|
||||||
sprintf(buffer,"HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n{ \"status\" : \"ok\", \"card\" : \"mounted\" }");
|
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);
|
*sdCardSize = p->getSdCardManager().getSize(GBYTE);
|
||||||
|
1
src/software_test/tcpServer_test/FTPClient.cpp
Normal file
1
src/software_test/tcpServer_test/FTPClient.cpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "FTPClient.h"
|
13
src/software_test/tcpServer_test/FTPClient.h
Normal file
13
src/software_test/tcpServer_test/FTPClient.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef FTPCLIENT_H
|
||||||
|
#define FTPCLIENT_H
|
||||||
|
|
||||||
|
#include "TCPClient.h"
|
||||||
|
|
||||||
|
class FTPClient
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
protected:
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //FTPCLIENT_H
|
32
src/software_test/tcpServer_test/FTPServer.h
Normal file
32
src/software_test/tcpServer_test/FTPServer.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#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,7 +3,6 @@
|
|||||||
|
|
||||||
#include "WEBServer.h"
|
#include "WEBServer.h"
|
||||||
#include "TCPClient.h"
|
#include "TCPClient.h"
|
||||||
#include "Dictionary.h"
|
|
||||||
|
|
||||||
class WEBClient : public TCPClient
|
class WEBClient : public TCPClient
|
||||||
{
|
{
|
||||||
|
@ -7,12 +7,14 @@
|
|||||||
#include "TCPServer.h"
|
#include "TCPServer.h"
|
||||||
#include "WEBServer.h"
|
#include "WEBServer.h"
|
||||||
#include "WEBClient.h"
|
#include "WEBClient.h"
|
||||||
|
#include "FTPServer.h"
|
||||||
|
#include "FTPClient.h"
|
||||||
|
|
||||||
uint32_t lastFreeMem(0);
|
uint32_t lastFreeMem(0);
|
||||||
uint16_t lastClientCount(0);
|
uint16_t lastClientCount(0);
|
||||||
|
|
||||||
TCPServer<TCPClient> server(80, MAX_CLIENT, 5);
|
//TCPServer<TCPClient> server(80, MAX_CLIENT, 5);
|
||||||
WEBServer<WEBClient> webServer(8080);
|
//WEBServer<WEBClient> webServer(8080);
|
||||||
|
|
||||||
WiFiEventHandler gotIpEventHandler, disconnectedEventHandler;
|
WiFiEventHandler gotIpEventHandler, disconnectedEventHandler;
|
||||||
|
|
||||||
@ -39,17 +41,17 @@ void debugInfo()
|
|||||||
Serial.print("Heap Frag : ");Serial.println(frag);
|
Serial.print("Heap Frag : ");Serial.println(frag);
|
||||||
lastFreeMem = freeMem;
|
lastFreeMem = freeMem;
|
||||||
}
|
}
|
||||||
if(lastClientCount != server.getConnectedClientsCount())
|
/*if(lastClientCount != server.getConnectedClientsCount())
|
||||||
{
|
{
|
||||||
lastClientCount = server.getConnectedClientsCount();
|
lastClientCount = server.getConnectedClientsCount();
|
||||||
Serial.print("Connected client(s) : ");Serial.println(lastClientCount);
|
Serial.print("Connected client(s) : ");Serial.println(lastClientCount);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// put your main code here, to run repeatedly:
|
// put your main code here, to run repeatedly:
|
||||||
server.runServer();
|
//server.runServer();
|
||||||
webServer.runServer();
|
//webServer.runServer();
|
||||||
debugInfo();
|
debugInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user