Skip to content

Commit

Permalink
First go at System Fusion networking.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed May 16, 2016
1 parent 1d5ed69 commit 9ed2c00
Show file tree
Hide file tree
Showing 25 changed files with 573 additions and 173 deletions.
5 changes: 3 additions & 2 deletions Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,16 @@ void CDisplay::clearDMR(unsigned int slotNo)
}
}

void CDisplay::writeFusion(const char* source, const char* dest)
void CDisplay::writeFusion(const char* source, const char* dest, const char* type)
{
assert(source != NULL);
assert(dest != NULL);
assert(type != NULL);

m_timer1.start();
m_mode1 = MODE_IDLE;

writeFusionInt(source, dest);
writeFusionInt(source, dest, type);
}

void CDisplay::clearFusion()
Expand Down
4 changes: 2 additions & 2 deletions Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class CDisplay
void writeDMR(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type);
void clearDMR(unsigned int slotNo);

void writeFusion(const char* source, const char* dest);
void writeFusion(const char* source, const char* dest, const char* type);
void clearFusion();

virtual void close() = 0;
Expand All @@ -59,7 +59,7 @@ class CDisplay
virtual void writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type) = 0;
virtual void clearDMRInt(unsigned int slotNo) = 0;

virtual void writeFusionInt(const char* source, const char* dest) = 0;
virtual void writeFusionInt(const char* source, const char* dest, const char* type) = 0;
virtual void clearFusionInt() = 0;

private:
Expand Down
3 changes: 2 additions & 1 deletion HD44780.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,10 +593,11 @@ void CHD44780::clearDMRInt(unsigned int slotNo)
}
}

void CHD44780::writeFusionInt(const char* source, const char* dest)
void CHD44780::writeFusionInt(const char* source, const char* dest, const char* type)
{
assert(source != NULL);
assert(dest != NULL);
assert(type != NULL);

#ifdef ADAFRUIT_DISPLAY
adafruitLCDColour(AC_RED);
Expand Down
2 changes: 1 addition & 1 deletion HD44780.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class CHD44780 : public CDisplay
virtual void writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type);
virtual void clearDMRInt(unsigned int slotNo);

virtual void writeFusionInt(const char* source, const char* dest);
virtual void writeFusionInt(const char* source, const char* dest, const char* type);
virtual void clearFusionInt();

private:
Expand Down
52 changes: 50 additions & 2 deletions MMDVMHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ m_conf(confFile),
m_modem(NULL),
m_dstarNetwork(NULL),
m_dmrNetwork(NULL),
m_ysfNetwork(NULL),
m_display(NULL),
m_mode(MODE_IDLE),
m_modeTimer(1000U),
Expand Down Expand Up @@ -241,6 +242,12 @@ int CMMDVMHost::run()
return 1;
}

if (m_ysfEnabled && m_conf.getFusionNetworkEnabled()) {
ret = createYSFNetwork();
if (!ret)
return 1;
}

if (m_conf.getCWIdEnabled()) {
unsigned int time = m_conf.getCWIdTime();

Expand Down Expand Up @@ -309,7 +316,7 @@ int CMMDVMHost::run()
LogInfo(" Callsign: %s", m_callsign.c_str());
LogInfo(" Timeout: %us", timeout);

ysf = new CYSFControl(m_callsign, m_display, timeout, m_duplex);
ysf = new CYSFControl(m_callsign, m_ysfNetwork, m_display, timeout, m_duplex);
}

m_modeTimer.setTimeout(m_conf.getModeHang());
Expand Down Expand Up @@ -529,12 +536,14 @@ int CMMDVMHost::run()
if (dmr != NULL)
dmr->clock();
if (ysf != NULL)
ysf->clock();
ysf->clock(ms);

if (m_dstarNetwork != NULL)
m_dstarNetwork->clock(ms);
if (m_dmrNetwork != NULL)
m_dmrNetwork->clock(ms);
if (m_ysfNetwork != NULL)
m_ysfNetwork->clock(ms);

m_cwIdTimer.clock(ms);
if (m_cwIdTimer.isRunning() && m_cwIdTimer.hasExpired()) {
Expand Down Expand Up @@ -584,6 +593,11 @@ int CMMDVMHost::run()
delete m_dmrNetwork;
}

if (m_ysfNetwork != NULL) {
m_ysfNetwork->close();
delete m_ysfNetwork;
}

delete dstar;
delete dmr;
delete ysf;
Expand Down Expand Up @@ -721,6 +735,30 @@ bool CMMDVMHost::createDMRNetwork()
return true;
}

bool CMMDVMHost::createYSFNetwork()
{
std::string address = m_conf.getFusionNetworkAddress();
unsigned int port = m_conf.getFusionNetworkPort();
bool debug = m_conf.getFusionNetworkDebug();

LogInfo("System Fusion Network Parameters");
LogInfo(" Reflector Address: %s", address.c_str());
LogInfo(" Reflector Port: %u", port);

m_ysfNetwork = new CYSFNetwork(address, port, m_callsign, debug);

bool ret = m_ysfNetwork->open();
if (!ret) {
delete m_ysfNetwork;
m_ysfNetwork = NULL;
return false;
}

m_ysfNetwork->enable(true);

return true;
}

void CMMDVMHost::readParams()
{
m_dstarEnabled = m_conf.getDStarEnabled();
Expand Down Expand Up @@ -808,6 +846,8 @@ void CMMDVMHost::setMode(unsigned char mode)
case MODE_DSTAR:
if (m_dmrNetwork != NULL)
m_dmrNetwork->enable(false);
if (m_ysfNetwork != NULL)
m_ysfNetwork->enable(false);
m_modem->setMode(MODE_DSTAR);
m_mode = MODE_DSTAR;
m_modeTimer.start();
Expand All @@ -816,6 +856,8 @@ void CMMDVMHost::setMode(unsigned char mode)
case MODE_DMR:
if (m_dstarNetwork != NULL)
m_dstarNetwork->enable(false);
if (m_ysfNetwork != NULL)
m_ysfNetwork->enable(false);
m_modem->setMode(MODE_DMR);
if (m_duplex) {
m_modem->writeDMRStart(true);
Expand All @@ -841,6 +883,8 @@ void CMMDVMHost::setMode(unsigned char mode)
m_dstarNetwork->enable(false);
if (m_dmrNetwork != NULL)
m_dmrNetwork->enable(false);
if (m_ysfNetwork != NULL)
m_ysfNetwork->enable(false);
if (m_mode == MODE_DMR && m_duplex && m_modem->hasTX()) {
m_modem->writeDMRStart(false);
m_dmrTXTimer.stop();
Expand All @@ -858,6 +902,8 @@ void CMMDVMHost::setMode(unsigned char mode)
m_dstarNetwork->enable(false);
if (m_dmrNetwork != NULL)
m_dmrNetwork->enable(false);
if (m_ysfNetwork != NULL)
m_ysfNetwork->enable(false);
if (m_mode == MODE_DMR && m_duplex && m_modem->hasTX()) {
m_modem->writeDMRStart(false);
m_dmrTXTimer.stop();
Expand All @@ -873,6 +919,8 @@ void CMMDVMHost::setMode(unsigned char mode)
m_dstarNetwork->enable(true);
if (m_dmrNetwork != NULL)
m_dmrNetwork->enable(true);
if (m_ysfNetwork != NULL)
m_ysfNetwork->enable(true);
if (m_mode == MODE_DMR && m_duplex && m_modem->hasTX()) {
m_modem->writeDMRStart(false);
m_dmrTXTimer.stop();
Expand Down
3 changes: 3 additions & 0 deletions MMDVMHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define MMDVMHOST_H

#include "DStarNetwork.h"
#include "YSFNetwork.h"
#include "DMRIPSC.h"
#include "Display.h"
#include "Timer.h"
Expand All @@ -41,6 +42,7 @@ class CMMDVMHost
CModem* m_modem;
CDStarNetwork* m_dstarNetwork;
CDMRIPSC* m_dmrNetwork;
CYSFNetwork* m_ysfNetwork;
CDisplay* m_display;
unsigned char m_mode;
CTimer m_modeTimer;
Expand All @@ -56,6 +58,7 @@ class CMMDVMHost
bool createModem();
bool createDStarNetwork();
bool createDMRNetwork();
bool createYSFNetwork();
void createDisplay();

void setMode(unsigned char mode);
Expand Down
2 changes: 2 additions & 0 deletions MMDVMHost.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@
<ClInclude Include="YSFConvolution.h" />
<ClInclude Include="YSFDefines.h" />
<ClInclude Include="YSFFICH.h" />
<ClInclude Include="YSFNetwork.h" />
<ClInclude Include="YSFPayload.h" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -238,6 +239,7 @@
<ClCompile Include="Timer.cpp" />
<ClCompile Include="UDPSocket.cpp" />
<ClCompile Include="Utils.cpp" />
<ClCompile Include="YSFNetwork.cpp" />
<ClCompile Include="YSFPayload.cpp" />
<ClCompile Include="YSFControl.cpp" />
<ClCompile Include="YSFConvolution.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions MMDVMHost.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@
<ClInclude Include="DMRLookup.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="YSFNetwork.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="BPTC19696.cpp">
Expand Down Expand Up @@ -295,5 +298,8 @@
<ClCompile Include="DMRLookup.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="YSFNetwork.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ OBJECTS = \
AMBEFEC.o BPTC19696.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedLC.o DMRFullLC.o DMRIPSC.o DMRLookup.o DMRLC.o \
DMRShortLC.o DMRSlot.o DMRSlotType.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o Golay24128.o Hamming.o Log.o MMDVMHost.o Modem.o \
Nextion.o NullDisplay.o QR1676.o RS129.o SerialController.o SHA256.o StopWatch.o Sync.o TFTSerial.o Timer.o UDPSocket.o Utils.o YSFControl.o YSFConvolution.o \
YSFFICH.o YSFPayload.o
YSFFICH.o YSFNetwork.o YSFPayload.o

all: MMDVMHost

Expand Down
2 changes: 1 addition & 1 deletion Makefile.Pi.Adafruit
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ OBJECTS = \
AMBEFEC.o BPTC19696.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedLC.o DMRFullLC.o DMRIPSC.o DMRLookup.o DMRLC.o \
DMRShortLC.o DMRSlot.o DMRSlotType.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o Golay24128.o Hamming.o HD44780.o Log.o MMDVMHost.o \
Modem.o Nextion.o NullDisplay.o QR1676.o RS129.o SerialController.o SHA256.o StopWatch.o Sync.o TFTSerial.o Timer.o UDPSocket.o Utils.o YSFControl.o \
YSFConvolution.o YSFFICH.o YSFPayload.o
YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o

all: MMDVMHost

Expand Down
2 changes: 1 addition & 1 deletion Makefile.Pi.HD44780
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ OBJECTS = \
AMBEFEC.o BPTC19696.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedLC.o DMRFullLC.o DMRIPSC.o DMRLookup.o DMRLC.o \
DMRShortLC.o DMRSlot.o DMRSlotType.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o Golay24128.o Hamming.o HD44780.o Log.o MMDVMHost.o \
Modem.o Nextion.o NullDisplay.o QR1676.o RS129.o SerialController.o SHA256.o StopWatch.o Sync.o TFTSerial.o Timer.o UDPSocket.o Utils.o YSFControl.o \
YSFConvolution.o YSFFICH.o YSFPayload.o
YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o

all: MMDVMHost

Expand Down
2 changes: 1 addition & 1 deletion Makefile.Pi.OLED
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ OBJECTS = \
AMBEFEC.o BPTC19696.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedLC.o DMRFullLC.o DMRIPSC.o DMRLookup.o DMRLC.o \
DMRShortLC.o DMRSlot.o DMRSlotType.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o Golay24128.o Hamming.o OLED.o Log.o MMDVMHost.o \
Modem.o Nextion.o NullDisplay.o QR1676.o RS129.o SerialController.o SHA256.o StopWatch.o Sync.o TFTSerial.o Timer.o UDPSocket.o Utils.o YSFControl.o \
YSFConvolution.o YSFFICH.o YSFPayload.o
YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o

all: MMDVMHost

Expand Down
7 changes: 4 additions & 3 deletions Nextion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,20 @@ void CNextion::clearDMRInt(unsigned int slotNo)
}
}

void CNextion::writeFusionInt(const char* source, const char* dest)
void CNextion::writeFusionInt(const char* source, const char* dest, const char* type)
{
assert(source != NULL);
assert(dest != NULL);
assert(type != NULL);

if (m_mode != MODE_YSF)
sendCommand("page YSF");

char text[30U];
::sprintf(text, "t0.txt=\"%.10s\"", source);
::sprintf(text, "t0.txt=\"%s %.10s\"", type, source);
sendCommand(text);

::sprintf(text, "t1.txt=\"%.10s\"", dest);
::sprintf(text, "t1.txt=\" %.10s\"", dest);
sendCommand(text);

m_mode = MODE_YSF;
Expand Down
2 changes: 1 addition & 1 deletion Nextion.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CNextion : public CDisplay
virtual void writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type);
virtual void clearDMRInt(unsigned int slotNo);

virtual void writeFusionInt(const char* source, const char* dest);
virtual void writeFusionInt(const char* source, const char* dest, const char* type);
virtual void clearFusionInt();

private:
Expand Down
2 changes: 1 addition & 1 deletion NullDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void CNullDisplay::clearDMRInt(unsigned int slotNo)
{
}

void CNullDisplay::writeFusionInt(const char* source, const char* dest)
void CNullDisplay::writeFusionInt(const char* source, const char* dest, const char* type)
{
}

Expand Down
2 changes: 1 addition & 1 deletion NullDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CNullDisplay : public CDisplay
virtual void writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type);
virtual void clearDMRInt(unsigned int slotNo);

virtual void writeFusionInt(const char* source, const char* dest);
virtual void writeFusionInt(const char* source, const char* dest, const char* type);
virtual void clearFusionInt();

private:
Expand Down
6 changes: 3 additions & 3 deletions OLED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,15 @@ void COLED::clearDMRInt(unsigned int slotNo)
display.display();
}

void COLED::writeFusionInt(const char* source, const char* dest)
void COLED::writeFusionInt(const char* source, const char* dest, const char* type)
{
m_mode = MODE_YSF;
display.fillRect(0, OLED_LINE1, display.width(), 10, BLACK);
display.setCursor(0,OLED_LINE1);
display.printf("%.10s", source);
display.printf("%s %.10s", type, source);
display.fillRect(0, OLED_LINE2, display.width(), 10, BLACK);
display.setCursor(0,OLED_LINE2);
display.printf("%.10s", dest);
display.printf(" %.10s", dest);
OLED_statusbar();
display.display();
}
Expand Down
2 changes: 1 addition & 1 deletion OLED.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class COLED : public CDisplay
virtual void writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type);
virtual void clearDMRInt(unsigned int slotNo);

virtual void writeFusionInt(const char* source, const char* dest);
virtual void writeFusionInt(const char* source, const char* dest, const char* type);
virtual void clearFusionInt();

virtual void close();
Expand Down
7 changes: 4 additions & 3 deletions TFTSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,11 @@ void CTFTSerial::clearDMRInt(unsigned int slotNo)
}
}

void CTFTSerial::writeFusionInt(const char* source, const char* dest)
void CTFTSerial::writeFusionInt(const char* source, const char* dest, const char* type)
{
assert(source != NULL);
assert(dest != NULL);
assert(type != NULL);

if (m_mode != MODE_YSF) {
// Clear the screen
Expand All @@ -275,12 +276,12 @@ void CTFTSerial::writeFusionInt(const char* source, const char* dest)
}

char text[30U];
::sprintf(text, "%.10s", source);
::sprintf(text, "%s %.10s", type, source);

gotoPosPixel(5U, 80U);
displayText(text);

::sprintf(text, "%.10s", dest);
::sprintf(text, " %.10s", dest);

gotoPosPixel(5U, 100U);
displayText(text);
Expand Down
Loading

0 comments on commit 9ed2c00

Please sign in to comment.