Skip to content

Commit

Permalink
Add the transmit function.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Oct 27, 2021
1 parent f65d52b commit 5474513
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
16 changes: 15 additions & 1 deletion CalM17.cpp
Expand Up @@ -33,20 +33,34 @@ const uint8_t PREAMBLE[] = {0x00U,
0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U,
0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U};

CCalM17::CCalM17()
CCalM17::CCalM17() :
m_transmit(false)
{
}

void CCalM17::process()
{
m17TX.process();

if (!m_transmit)
return;

uint16_t space = m17TX.getSpace();
if (space < 2U)
return;

m17TX.writeData(PREAMBLE, M17_FRAME_LENGTH_BYTES + 1U);
}

uint8_t CCalM17::write(const uint8_t* data, uint16_t length)
{
if (length != 1U)
return 4U;

m_transmit = data[0U] == 1U;

return 0U;
}

#endif

3 changes: 3 additions & 0 deletions CalM17.h
Expand Up @@ -31,7 +31,10 @@ class CCalM17 {

void process();

uint8_t write(const uint8_t* data, uint16_t length);

private:
bool m_transmit;
};

#endif
Expand Down
2 changes: 1 addition & 1 deletion SerialPort.cpp
Expand Up @@ -1109,7 +1109,7 @@ void CSerialPort::processMessage(uint8_t type, const uint8_t* buffer, uint16_t l
#endif
#if defined(MODE_M17)
if (m_modemState == STATE_M17CAL)
err = 0U;
err = calM17.write(buffer, length);
#endif
#if defined(MODE_POCSAG)
if (m_modemState == STATE_POCSAGCAL)
Expand Down

0 comments on commit 5474513

Please sign in to comment.