diff --git a/Conf.cpp b/Conf.cpp index fbbc209..1e0d230 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -235,6 +235,7 @@ m_oledBrightness(0U), m_oledInvert(false), m_oledScroll(false), m_oledRotate(false), +m_oledCast(false), m_lcdprocAddress(), m_lcdprocPort(0U), m_lcdprocLocalPort(0U), @@ -779,6 +780,8 @@ bool CConf::read() m_oledScroll = ::atoi(value) == 1; else if (::strcmp(key, "Rotate") == 0) m_oledRotate = ::atoi(value) == 1; + else if (::strcmp(key, "Cast") == 0) + m_oledCast = ::atoi(value) == 1; } else if (section == SECTION_LCDPROC) { if (::strcmp(key, "Address") == 0) m_lcdprocAddress = value; @@ -1675,6 +1678,11 @@ bool CConf::getOLEDRotate() const return m_oledRotate; } +bool CConf::getOLEDCast() const +{ + return m_oledCast; +} + std::string CConf::getLCDprocAddress() const { return m_lcdprocAddress; diff --git a/Conf.h b/Conf.h index 31ee617..7016308 100644 --- a/Conf.h +++ b/Conf.h @@ -254,6 +254,7 @@ public: bool getOLEDInvert() const; bool getOLEDScroll() const; bool getOLEDRotate() const; + bool getOLEDCast() const; // The LCDproc section std::string getLCDprocAddress() const; @@ -469,6 +470,7 @@ private: bool m_oledInvert; bool m_oledScroll; bool m_oledRotate; + bool m_oledCast; std::string m_lcdprocAddress; unsigned int m_lcdprocPort; diff --git a/Display.cpp b/Display.cpp index ded3088..1ee9b64 100644 --- a/Display.cpp +++ b/Display.cpp @@ -459,13 +459,12 @@ void CDisplay::writeNXDNBERInt(float ber) { } - /* Factory method extracted from MMDVMHost.cpp - BG5HHP */ CDisplay* CDisplay::createDisplay(const CConf& conf, CUMP* ump, CModem* modem) { - CDisplay *display = NULL; + CDisplay *display = NULL; - std::string type = conf.getDisplay(); + std::string type = conf.getDisplay(); unsigned int dmrid = conf.getDMRId(); LogInfo("Display Parameters"); @@ -528,10 +527,10 @@ CDisplay* CDisplay::createDisplay(const CConf& conf, CUMP* ump, CModem* modem) } else if (port == "ump") { if (ump != NULL) { display = new CNextion(conf.getCallsign(), dmrid, ump, brightness, displayClock, utc, idleBrightness, screenLayout, txFrequency, rxFrequency, displayTempInF, conf.getLocation()); - } else { - LogInfo(" NullDisplay loaded"); - display = new CNullDisplay; - } + } else { + LogInfo(" NullDisplay loaded"); + display = new CNullDisplay; + } } else { SERIAL_SPEED baudrate = SERIAL_9600; if (screenLayout==4U) @@ -601,15 +600,16 @@ CDisplay* CDisplay::createDisplay(const CConf& conf, CUMP* ump, CModem* modem) display = new CHD44780(rows, columns, conf.getCallsign(), dmrid, pins, i2cAddress, pwm, pwmPin, pwmBright, pwmDim, displayClock, utc, conf.getDuplex()); } #endif - #if defined(OLED) } else if (type == "OLED") { - unsigned char type = conf.getOLEDType(); - unsigned char brightness = conf.getOLEDBrightness(); - bool invert = conf.getOLEDInvert(); - bool scroll = conf.getOLEDScroll(); - bool rotate = conf.getOLEDRotate(); - display = new COLED(type, brightness, invert, scroll, rotate, conf.getDMRNetworkSlot1(), conf.getDMRNetworkSlot2()); + unsigned char type = conf.getOLEDType(); + unsigned char brightness = conf.getOLEDBrightness(); + bool invert = conf.getOLEDInvert(); + bool scroll = conf.getOLEDScroll(); + bool rotate = conf.getOLEDRotate(); + bool cast = conf.getOLEDCast(); + + display = new COLED(type, brightness, invert, scroll, rotate, conf.getDMRNetworkSlot1(), conf.getDMRNetworkSlot2(), cast ? modem : NULL); #endif } else { LogWarning("No valid display found, disabling"); diff --git a/MMDVM.ini b/MMDVM.ini index 17c9d65..85e3925 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -233,6 +233,7 @@ Brightness=0 Invert=0 Scroll=1 Rotate=0 +Cast=0 [LCDproc] Address=localhost diff --git a/Modem.cpp b/Modem.cpp index d3708c6..8df71cf 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -1138,68 +1138,68 @@ bool CModem::writeTransparentData(const unsigned char* data, unsigned int length return true; } -bool CModem::writeDStarInfo(bool network, const unsigned char* my1, const unsigned char* my2, const unsigned char* your, const unsigned char* rpt1, const unsigned char* rpt2, const unsigned char* reflector) +bool CModem::writeDStarInfo(const char* my1, const char* my2, const char* your, const char* type, const char* reflector) { assert(m_serial != NULL); assert(my1 != NULL); assert(my2 != NULL); assert(your != NULL); - assert(rpt1 != NULL); - assert(rpt2 != NULL); + assert(type != NULL); assert(reflector != NULL); unsigned char buffer[50U]; buffer[0U] = MMDVM_FRAME_START; - buffer[1U] = 49U; + buffer[1U] = 33U; buffer[2U] = MMDVM_QSO_INFO; buffer[3U] = MODE_DSTAR; - buffer[4U] = network ? 1U : 0U; - ::memcpy(buffer + 5U, my1, DSTAR_LONG_CALLSIGN_LENGTH); - ::memcpy(buffer + 13U, my2, DSTAR_SHORT_CALLSIGN_LENGTH); + ::memcpy(buffer + 4U, my1, DSTAR_LONG_CALLSIGN_LENGTH); + ::memcpy(buffer + 12U, my2, DSTAR_SHORT_CALLSIGN_LENGTH); - ::memcpy(buffer + 17U, your, DSTAR_LONG_CALLSIGN_LENGTH); + ::memcpy(buffer + 16U, your, DSTAR_LONG_CALLSIGN_LENGTH); - ::memcpy(buffer + 25U, rpt1, DSTAR_LONG_CALLSIGN_LENGTH); - ::memcpy(buffer + 33U, rpt2, DSTAR_LONG_CALLSIGN_LENGTH); + ::memcpy(buffer + 24U, type, 1U); - ::memcpy(buffer + 41U, reflector, DSTAR_LONG_CALLSIGN_LENGTH); + ::memcpy(buffer + 25U, reflector, DSTAR_LONG_CALLSIGN_LENGTH); - return m_serial->write(buffer, 49U) != 49; + return m_serial->write(buffer, 33U) != 33; } -bool CModem::writeDMRInfo(bool network, unsigned int slotNo, unsigned int src, bool group, unsigned int dest) +bool CModem::writeDMRInfo(unsigned int slotNo, const std::string& src, bool group, const std::string& dest, const char* type) { assert(m_serial != NULL); + assert(type != NULL); - unsigned char buffer[30U]; + unsigned char buffer[50U]; buffer[0U] = MMDVM_FRAME_START; - buffer[1U] = 23U; + buffer[1U] = 47U; buffer[2U] = MMDVM_QSO_INFO; buffer[3U] = MODE_DMR; - buffer[4U] = network ? 1U : 0U; - buffer[5U] = slotNo; + buffer[4U] = slotNo; - ::sprintf((char*)(buffer + 6U), "%08u", src); // 24-bits + ::sprintf((char*)(buffer + 5U), "%20.20s", src.c_str()); - buffer[14U] = group ? 'G' : 'I'; + buffer[25U] = group ? 'G' : 'I'; - ::sprintf((char*)(buffer + 15U), "%08u", dest); // 24-bits + ::sprintf((char*)(buffer + 26U), "%20.20s", dest.c_str()); - return m_serial->write(buffer, 23U) != 23; + ::memcpy(buffer + 46U, type, 1U); + + return m_serial->write(buffer, 47U) != 47; } -bool CModem::writeYSFInfo(bool network, const unsigned char* src, const unsigned char* dest, const unsigned char* reflector) +bool CModem::writeYSFInfo(const char* source, const char* dest, const char* type, const char* origin) { assert(m_serial != NULL); - assert(src != NULL); + assert(source != NULL); assert(dest != NULL); - assert(reflector != NULL); + assert(type != NULL); + assert(origin != NULL); unsigned char buffer[50U]; @@ -1208,80 +1208,109 @@ bool CModem::writeYSFInfo(bool network, const unsigned char* src, const unsigned buffer[2U] = MMDVM_QSO_INFO; buffer[3U] = MODE_YSF; - buffer[4U] = network ? 1U : 0U; - ::memcpy(buffer + 5U, src, YSF_CALLSIGN_LENGTH); - ::memcpy(buffer + 15U, dest, YSF_CALLSIGN_LENGTH); + ::memcpy(buffer + 4U, source, YSF_CALLSIGN_LENGTH); + ::memcpy(buffer + 14U, dest, YSF_CALLSIGN_LENGTH); - ::memcpy(buffer + 25U, reflector, YSF_CALLSIGN_LENGTH); + ::memcpy(buffer + 24U, type, 1U); + + ::memcpy(buffer + 25U, origin, YSF_CALLSIGN_LENGTH); return m_serial->write(buffer, 35U) != 35; } -bool CModem::writeP25Info(bool network, unsigned int src, bool group, unsigned int dest) +bool CModem::writeP25Info(const char* source, bool group, unsigned int dest, const char* type) { assert(m_serial != NULL); + assert(source != NULL); + assert(type != NULL); - unsigned char buffer[30U]; + unsigned char buffer[40U]; buffer[0U] = MMDVM_FRAME_START; - buffer[1U] = 19U; + buffer[1U] = 31U; buffer[2U] = MMDVM_QSO_INFO; buffer[3U] = MODE_DMR; - buffer[4U] = network ? 1U : 0U; - ::sprintf((char*)(buffer + 5U), "%08u", src); // 24-bits + ::sprintf((char*)(buffer + 4U), "%20.20s", source); - buffer[13U] = group ? 'G' : 'I'; + buffer[24U] = group ? 'G' : 'I'; - ::sprintf((char*)(buffer + 14U), "%05u", dest); // 16-bits + ::sprintf((char*)(buffer + 25U), "%05u", dest); // 16-bits - return m_serial->write(buffer, 19U) != 19; + ::memcpy(buffer + 30U, type, 1U); + + return m_serial->write(buffer, 31U) != 31; } -bool CModem::writeNXDNInfo(bool network, unsigned int src, bool group, unsigned int dest) +bool CModem::writeNXDNInfo(const char* source, bool group, unsigned int dest, const char* type) { assert(m_serial != NULL); + assert(source != NULL); + assert(type != NULL); - unsigned char buffer[50U]; + unsigned char buffer[40U]; buffer[0U] = MMDVM_FRAME_START; - buffer[1U] = 16U; + buffer[1U] = 31U; buffer[2U] = MMDVM_QSO_INFO; buffer[3U] = MODE_NXDN; - buffer[4U] = network ? 1U : 0U; - ::sprintf((char*)(buffer + 5U), "%05u", src); // 16-bits + ::sprintf((char*)(buffer + 4U), "%20.20s", source); - buffer[10U] = group ? 'G' : 'I'; + buffer[24U] = group ? 'G' : 'I'; - ::sprintf((char*)(buffer + 11U), "%05u", dest); // 16-bits + ::sprintf((char*)(buffer + 25U), "%05u", dest); // 16-bits - return m_serial->write(buffer, 16U) != 16; + ::memcpy(buffer + 30U, type, 1U); + + return m_serial->write(buffer, 31U) != 31; } -bool CModem::writePOCSAGInfo(unsigned int ric, const unsigned char* message, unsigned int length) +bool CModem::writePOCSAGInfo(unsigned int ric, const std::string& message) { assert(m_serial != NULL); - assert(message != NULL); + + size_t length = message.size(); unsigned char buffer[250U]; buffer[0U] = MMDVM_FRAME_START; - buffer[1U] = length + 10U; + buffer[1U] = length + 11U; buffer[2U] = MMDVM_QSO_INFO; buffer[3U] = MODE_POCSAG; ::sprintf((char*)(buffer + 4U), "%07u", ric); // 21-bits - ::memcpy(buffer + 11U, message, length); + ::memcpy(buffer + 11U, message.c_str(), length); - int ret = m_serial->write(buffer, length + 10U); + int ret = m_serial->write(buffer, length + 11U); - return ret != int(length + 10U); + return ret != int(length + 11U); +} + +bool CModem::writeIPInfo(const std::string& address) +{ + assert(m_serial != NULL); + + size_t length = address.size(); + + unsigned char buffer[25U]; + + buffer[0U] = MMDVM_FRAME_START; + buffer[1U] = length + 4U; + buffer[2U] = MMDVM_QSO_INFO; + + buffer[3U] = 250U; + + ::memcpy(buffer + 4U, address.c_str(), length); + + int ret = m_serial->write(buffer, length + 4U); + + return ret != int(length + 4U); } bool CModem::writeSerial(const unsigned char* data, unsigned int length) diff --git a/Modem.h b/Modem.h index 8d52a1d..9c8b6c0 100644 --- a/Modem.h +++ b/Modem.h @@ -81,12 +81,13 @@ public: bool writeTransparentData(const unsigned char* data, unsigned int length); - bool writeDStarInfo(bool network, const unsigned char* my1, const unsigned char* my2, const unsigned char* your, const unsigned char* rpt1, const unsigned char* rpt2, const unsigned char* reflector); - bool writeDMRInfo(bool network, unsigned int slotNo, unsigned int src, bool group, unsigned int dest); - bool writeYSFInfo(bool network, const unsigned char* src, const unsigned char* dest, const unsigned char* reflector); - bool writeP25Info(bool network, unsigned int src, bool group, unsigned int dest); - bool writeNXDNInfo(bool network, unsigned int src, bool group, unsigned int dest); - bool writePOCSAGInfo(unsigned int ric, const unsigned char* message, unsigned int length); + bool writeDStarInfo(const char* my1, const char* my2, const char* your, const char* type, const char* reflector); + bool writeDMRInfo(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type); + bool writeYSFInfo(const char* source, const char* dest, const char* type, const char* origin); + bool writeP25Info(const char* source, bool group, unsigned int dest, const char* type); + bool writeNXDNInfo(const char* source, bool group, unsigned int dest, const char* type); + bool writePOCSAGInfo(unsigned int ric, const std::string& message); + bool writeIPInfo(const std::string& address); bool writeDMRStart(bool tx); bool writeDMRShortLC(const unsigned char* lc); diff --git a/OLED.cpp b/OLED.cpp index 6545d94..47ea13f 100644 --- a/OLED.cpp +++ b/OLED.cpp @@ -169,14 +169,17 @@ const unsigned char logo_POCSAG_bmp [] = 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; -COLED::COLED(unsigned char displayType, unsigned char displayBrightness, bool displayInvert, bool displayScroll, bool displayRotate, bool slot1Enabled, bool slot2Enabled) : +COLED::COLED(unsigned char displayType, unsigned char displayBrightness, bool displayInvert, bool displayScroll, bool displayRotate, bool slot1Enabled, bool slot2Enabled, CModem* modem) : m_displayType(displayType), m_displayBrightness(displayBrightness), m_displayInvert(displayInvert), m_displayScroll(displayScroll), m_displayRotate(displayRotate), m_slot1Enabled(slot1Enabled), -m_slot2Enabled(slot2Enabled) +m_slot2Enabled(slot2Enabled), +m_modem(modem), +m_ipaddress(), +m_display() { } @@ -255,10 +258,12 @@ void COLED::setIdleInt() m_ipaddress = (char*)info; delete m_network; + if (m_modem != NULL) + m_modem->writeIPInfo(m_ipaddress); + networkInfoInitialized = true; passCounter = 0; } - } void COLED::setErrorInt(const char* text) @@ -325,6 +330,9 @@ void COLED::writeDStarInt(const char* my1, const char* my2, const char* your, co OLED_statusbar(); display.display(); + + if (m_modem != NULL) + m_modem->writeDStarInfo(my1, my2, your, type, reflector); } void COLED::clearDStarInt() @@ -385,7 +393,9 @@ void COLED::writeDMRInt(unsigned int slotNo,const std::string& src,bool group,co OLED_statusbar(); display.display(); - } + if (m_modem != NULL) + m_modem->writeDMRInfo(slotNo, src, group, dest, type); +} void COLED::clearDMRInt(unsigned int slotNo) { @@ -431,6 +441,9 @@ void COLED::writeFusionInt(const char* source, const char* dest, const char* typ OLED_statusbar(); display.display(); + + if (m_modem != NULL) + m_modem->writeYSFInfo(source, dest, type, origin); } void COLED::clearFusionInt() @@ -461,6 +474,9 @@ void COLED::writeP25Int(const char* source, bool group, unsigned int dest, const OLED_statusbar(); display.display(); + + if (m_modem != NULL) + m_modem->writeP25Info(source, group, dest, type); } void COLED::clearP25Int() @@ -491,6 +507,9 @@ void COLED::writeNXDNInt(const char* source, bool group, unsigned int dest, cons OLED_statusbar(); display.display(); + + if (m_modem != NULL) + m_modem->writeNXDNInfo(source, group, dest, type); } void COLED::clearNXDNInt() @@ -521,6 +540,9 @@ void COLED::writePOCSAGInt(uint32_t ric, const std::string& message) OLED_statusbar(); display.display(); + + if (m_modem != NULL) + m_modem->writePOCSAGInfo(ric, message); } void COLED::clearPOCSAGInt() diff --git a/OLED.h b/OLED.h index f246f1b..3a11435 100644 --- a/OLED.h +++ b/OLED.h @@ -36,11 +36,12 @@ #include "Adafruit_GFX.h" #include "ArduiPi_OLED.h" #include "NetworkInfo.h" +#include "Modem.h" class COLED : public CDisplay { public: - COLED(unsigned char displayType, unsigned char displayBrighness, bool displayInvert, bool displayScroll, bool displayRotate, bool slot1Enabled, bool slot2Enabled); + COLED(unsigned char displayType, unsigned char displayBrighness, bool displayInvert, bool displayScroll, bool displayRotate, bool slot1Enabled, bool slot2Enabled, CModem* modem); virtual ~COLED(); virtual bool open(); @@ -51,7 +52,6 @@ public: virtual void setLockoutInt(); virtual void setQuitInt(); - virtual void writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector); virtual void clearDStarInt(); @@ -84,11 +84,12 @@ private: bool m_displayInvert; bool m_displayScroll; bool m_displayRotate; - bool m_slot1Enabled; - bool m_slot2Enabled; + bool m_slot1Enabled; + bool m_slot2Enabled; + CModem* m_modem; std::string m_ipaddress; - - ArduiPi_OLED display; + ArduiPi_OLED m_display; + void OLED_statusbar(); };