Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions MMDVM-Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ int CMMDVMHost::run()

std::vector<std::pair<std::string, void (*)(const unsigned char*, unsigned int)>> subscriptions;
subscriptions.push_back(std::make_pair("display-in", CMMDVMHost::onDisplay));
subscriptions.push_back(std::make_pair("qso-info", CMMDVMHost::onQSOInfo));

if (m_conf.getRemoteControlEnabled())
subscriptions.push_back(std::make_pair("command", CMMDVMHost::onCommand));
Expand Down Expand Up @@ -3221,3 +3222,12 @@ void CMMDVMHost::onDisplay(const unsigned char* message, unsigned int length)

host->writeSerial(message, length);
}

void CMMDVMHost::onQSOInfo(const unsigned char* message, unsigned int length)
{
assert(host != nullptr);
assert(message != nullptr);

if (host->m_modem != nullptr)
host->m_modem->writeQSOInfo(message, length);
}
1 change: 1 addition & 0 deletions MMDVM-Host.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ class CMMDVMHost
void writeJSONMessage(const std::string& message);

static void onDisplay(const unsigned char* message, unsigned int length);
static void onQSOInfo(const unsigned char* message, unsigned int length);
static void onCommand(const unsigned char* command, unsigned int length);
};

Expand Down
25 changes: 25 additions & 0 deletions Modem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1943,6 +1943,31 @@ bool CModem::writeSerialData(const unsigned char* data, unsigned int length)
return true;
}

// A QSO information frame built by the caller (mode byte first), for a
// modem with its own screen such as the DVMega CAST. Queued with the
// serial data so it is written from the modem's own thread.
bool CModem::writeQSOInfo(const unsigned char* data, unsigned int length)
{
assert(data != nullptr);

if (length == 0U || length > 250U)
return false;

unsigned char buffer[255U];

buffer[0U] = MMDVM_FRAME_START;
buffer[1U] = length + 3U;
buffer[2U] = MMDVM_QSO_INFO;

::memcpy(buffer + 3U, data, length);

unsigned char len = length + 3U;
m_txSerialData.addData(&len, 1U);
m_txSerialData.addData(buffer, len);

return true;
}

bool CModem::hasTX() const
{
return m_tx;
Expand Down
1 change: 1 addition & 0 deletions Modem.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ class CModem {
unsigned int readTransparentData(unsigned char* data);

bool writeSerialData(const unsigned char* data, unsigned int length);
bool writeQSOInfo(const unsigned char* data, unsigned int length);
unsigned int readSerialData(unsigned char* data);

unsigned char getMode() const;
Expand Down