1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2025-12-16 07:23:07 +01:00

intermediate: restructure serial handling

This commit is contained in:
andreas
2024-11-01 17:01:44 +01:00
parent 0ddc0d055d
commit 56ec7a0406
4 changed files with 32 additions and 18 deletions

View File

@@ -8,6 +8,7 @@
#include "GWConfig.h"
#include "GwJsonDocument.h"
#include "GwApi.h"
#include "GwSerial.h"
#include <HardwareSerial.h>
//NMEA message channels
@@ -23,12 +24,6 @@ class GwSocketServer;
class GwTcpClient;
class GwChannelList{
private:
class SerialWrapperBase{
public:
virtual void begin(GwLog* logger,unsigned long baud, uint32_t config=SERIAL_8N1, int8_t rxPin=-1, int8_t txPin=-1)=0;
virtual Stream *getStream()=0;
virtual int getId()=0;
};
GwLog *logger;
GwConfigHandler *config;
typedef std::vector<GwChannel *> ChannelList;
@@ -36,8 +31,8 @@ class GwChannelList{
std::map<int,String> modes;
GwSocketServer *sockets;
GwTcpClient *client;
void addSerial(SerialWrapperBase *stream,const String &mode,int rx,int tx);
void addSerial(SerialWrapperBase *stream,int type,int rx,int tx);
void addSerial(GwSerial::SerialWrapperBase *stream,const String &mode,int rx,int tx);
void addSerial(GwSerial::SerialWrapperBase *stream,int type,int rx,int tx);
public:
void addSerial(int id, int rx, int tx, int type);
GwChannelList(GwLog *logger, GwConfigHandler *config);