Add Poll message
This commit is contained in:
parent
734af9453c
commit
23e92af6fa
2 changed files with 27 additions and 1 deletions
|
@ -33,7 +33,8 @@ m_address(),
|
||||||
m_port(gatewayPort),
|
m_port(gatewayPort),
|
||||||
m_debug(debug),
|
m_debug(debug),
|
||||||
m_enabled(false),
|
m_enabled(false),
|
||||||
m_buffer(2000U, "FM Network")
|
m_buffer(2000U, "FM Network"),
|
||||||
|
m_pollTimer(1000U, 5U)
|
||||||
{
|
{
|
||||||
assert(gatewayPort > 0U);
|
assert(gatewayPort > 0U);
|
||||||
assert(!gatewayAddress.empty());
|
assert(!gatewayAddress.empty());
|
||||||
|
@ -52,6 +53,8 @@ bool CFMNetwork::open()
|
||||||
if (m_address.s_addr == INADDR_NONE)
|
if (m_address.s_addr == INADDR_NONE)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
m_pollTimer.start();
|
||||||
|
|
||||||
return m_socket.open();
|
return m_socket.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,6 +94,12 @@ bool CFMNetwork::writeEOT()
|
||||||
|
|
||||||
void CFMNetwork::clock(unsigned int ms)
|
void CFMNetwork::clock(unsigned int ms)
|
||||||
{
|
{
|
||||||
|
m_pollTimer.clock(ms);
|
||||||
|
if (m_pollTimer.hasExpired()) {
|
||||||
|
writePoll();
|
||||||
|
m_pollTimer.start();
|
||||||
|
}
|
||||||
|
|
||||||
unsigned char buffer[BUFFER_LENGTH];
|
unsigned char buffer[BUFFER_LENGTH];
|
||||||
|
|
||||||
in_addr address;
|
in_addr address;
|
||||||
|
@ -159,3 +168,17 @@ void CFMNetwork::enable(bool enabled)
|
||||||
|
|
||||||
m_enabled = enabled;
|
m_enabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CFMNetwork::writePoll()
|
||||||
|
{
|
||||||
|
unsigned char buffer[3U];
|
||||||
|
|
||||||
|
buffer[0U] = 'F';
|
||||||
|
buffer[1U] = 'M';
|
||||||
|
buffer[2U] = 'P';
|
||||||
|
|
||||||
|
if (m_debug)
|
||||||
|
CUtils::dump(1U, "FM Network Poll Sent", buffer, 3U);
|
||||||
|
|
||||||
|
return m_socket.write(buffer, 3U, m_address, m_port);
|
||||||
|
}
|
||||||
|
|
|
@ -54,6 +54,9 @@ private:
|
||||||
bool m_debug;
|
bool m_debug;
|
||||||
bool m_enabled;
|
bool m_enabled;
|
||||||
CRingBuffer<unsigned char> m_buffer;
|
CRingBuffer<unsigned char> m_buffer;
|
||||||
|
CTimer m_pollTimer;
|
||||||
|
|
||||||
|
bool writePoll();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue