Skip to content

Commit

Permalink
Merge pull request #752 from Shmuma/bcd_send
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx authored Nov 26, 2022
2 parents 3314310 + 55ba123 commit 3202d73
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 0 deletions.
30 changes: 30 additions & 0 deletions MMDVMHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2641,6 +2641,36 @@ void CMMDVMHost::remoteControl()
m_pocsag->sendPage(ric, text);
}
break;
case RCD_PAGE_BCD:
if (m_pocsag != NULL) {
unsigned int ric = m_remoteControl->getArgUInt(0U);
std::string text;
for (unsigned int i = 1U; i < m_remoteControl->getArgCount(); i++) {
if (i > 1U)
text += " ";
text += m_remoteControl->getArgString(i);
}
m_pocsag->sendPageBCD(ric, text);
}
break;
case RCD_PAGE_A1:
if (m_pocsag != NULL) {
unsigned int ric = m_remoteControl->getArgUInt(0U);
m_pocsag->sendPageAlert1(ric);
}
break;
case RCD_PAGE_A2:
if (m_pocsag != NULL) {
unsigned int ric = m_remoteControl->getArgUInt(0U);
std::string text;
for (unsigned int i = 1U; i < m_remoteControl->getArgCount(); i++) {
if (i > 1U)
text += " ";
text += m_remoteControl->getArgString(i);
}
m_pocsag->sendPageAlert2(ric, text);
}
break;
case RCD_CW:
setMode(MODE_IDLE); // Force the modem to go idle so that we can send the CW text.
if (!m_modem->hasTX()) {
Expand Down
69 changes: 69 additions & 0 deletions POCSAGControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,75 @@ void CPOCSAGControl::sendPage(unsigned int ric, const std::string& text)
m_data.push_back(output);
}


void CPOCSAGControl::sendPageBCD(unsigned int ric, const std::string& text)
{
if (!m_enabled)
return;

POCSAGData* output = new POCSAGData;

output->m_ric = ric;
output->m_text = text;

addAddress(FUNCTIONAL_NUMERIC, ric, output->m_buffer);

LogDebug("Local message to %07u, func NUMERIC: \"%s\"", ric, text.c_str());

packNumeric(text, output->m_buffer);

// Ensure data is an even number of words
if ((output->m_buffer.size() % 2U) == 1U)
output->m_buffer.push_back(POCSAG_IDLE_WORD);

m_data.push_back(output);
}


void CPOCSAGControl::sendPageAlert1(unsigned int ric)
{
if (!m_enabled)
return;

POCSAGData* output = new POCSAGData;

output->m_ric = ric;

addAddress(FUNCTIONAL_ALERT1, ric, output->m_buffer);

LogDebug("Local message to %07u, func Alert1", ric);

// Ensure data is an even number of words
if ((output->m_buffer.size() % 2U) == 1U)
output->m_buffer.push_back(POCSAG_IDLE_WORD);

m_data.push_back(output);
}


void CPOCSAGControl::sendPageAlert2(unsigned int ric, const std::string& text)
{
if (!m_enabled)
return;

POCSAGData* output = new POCSAGData;

output->m_ric = ric;
output->m_text = text;

addAddress(FUNCTIONAL_ALERT2, ric, output->m_buffer);

LogDebug("Local message to %07u, func Alert2: \"%s\"", ric, text.c_str());

packASCII(text, output->m_buffer);

// Ensure data is an even number of words
if ((output->m_buffer.size() % 2U) == 1U)
output->m_buffer.push_back(POCSAG_IDLE_WORD);

m_data.push_back(output);
}

bool CPOCSAGControl::readNetwork()
{
if (m_network == NULL)
Expand Down
3 changes: 3 additions & 0 deletions POCSAGControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class CPOCSAGControl {
~CPOCSAGControl();

void sendPage(unsigned int ric, const std::string& text);
void sendPageBCD(unsigned int ric, const std::string& text);
void sendPageAlert1(unsigned int ric);
void sendPageAlert2(unsigned int ric, const std::string& text);

unsigned int readModem(unsigned char* data);

Expand Down
15 changes: 15 additions & 0 deletions RemoteControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ REMOTE_COMMAND CRemoteControl::getCommand()
} else if (m_args.at(0U) == "page" && m_args.size() >= PAGE_ARGS) {
// Page command is in the form of "page <ric> <message>"
m_command = RCD_PAGE;
} else if (m_args.at(0U) == "page_bcd" && m_args.size() >= PAGE_ARGS) {
// BCD page command is in the form of "page_bcd <ric> <bcd message>"
m_command = RCD_PAGE_BCD;
} else if (m_args.at(0U) == "page_a1" && m_args.size() == 2) {
// Alert1 page command is in the form of "page_a1 <ric>"
m_command = RCD_PAGE_A1;
} else if (m_args.at(0U) == "page_a2" && m_args.size() >= PAGE_ARGS) {
// Alert2 page command is in the form of "page_a2 <ric> <message>"
m_command = RCD_PAGE_A2;
} else if (m_args.at(0U) == "cw" && m_args.size() >= CW_ARGS) {
// CW command is in the form of "cw <message>"
m_command = RCD_CW;
Expand Down Expand Up @@ -192,6 +201,9 @@ unsigned int CRemoteControl::getArgCount() const
case RCD_MODE_M17:
return m_args.size() - SET_MODE_ARGS;
case RCD_PAGE:
case RCD_PAGE_BCD:
case RCD_PAGE_A1:
case RCD_PAGE_A2:
return m_args.size() - 1U;
case RCD_CW:
return m_args.size() - 1U;
Expand All @@ -214,6 +226,9 @@ std::string CRemoteControl::getArgString(unsigned int n) const
n += SET_MODE_ARGS;
break;
case RCD_PAGE:
case RCD_PAGE_BCD:
case RCD_PAGE_A1:
case RCD_PAGE_A2:
n += 1U;
break;
case RCD_CW:
Expand Down
3 changes: 3 additions & 0 deletions RemoteControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ enum REMOTE_COMMAND {
RCD_DISABLE_FM,
RCD_DISABLE_AX25,
RCD_PAGE,
RCD_PAGE_BCD,
RCD_PAGE_A1,
RCD_PAGE_A2,
RCD_CW,
RCD_RELOAD,
RCD_CONNECTION_STATUS,
Expand Down

0 comments on commit 3202d73

Please sign in to comment.