mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 09:28:40 +02:00
Device: Refactor online keep alive
This commit is contained in:
@@ -284,6 +284,7 @@ bool Encoder::encode(const Packetizer& packetizer, std::vector<uint8_t>& result,
|
|||||||
case Command::RequestSerialNumber:
|
case Command::RequestSerialNumber:
|
||||||
case Command::EnableNetworkCommunication:
|
case Command::EnableNetworkCommunication:
|
||||||
case Command::EnableNetworkCommunicationEx:
|
case Command::EnableNetworkCommunicationEx:
|
||||||
|
case Command::KeepAlive:
|
||||||
case Command::GetMainVersion:
|
case Command::GetMainVersion:
|
||||||
case Command::GetSecondaryVersions:
|
case Command::GetSecondaryVersions:
|
||||||
case Command::NeoReadMemory:
|
case Command::NeoReadMemory:
|
||||||
|
|||||||
+4
-1
@@ -585,7 +585,10 @@ bool Device::goOnline() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// (re)start the keeponline
|
// (re)start the keeponline
|
||||||
keeponline = std::make_unique<Periodic>([this] { return enableNetworkCommunication(true, onlineTimeoutMs); }, std::chrono::milliseconds(onlineTimeoutMs / 4));
|
keeponline = std::make_unique<Periodic>([this] {
|
||||||
|
static std::vector<uint8_t> timeoutBytes = std::vector<uint8_t>((uint8_t*)&onlineTimeoutMs, (uint8_t*)&onlineTimeoutMs + sizeof(onlineTimeoutMs));
|
||||||
|
return com->sendCommand(Command::KeepAlive, timeoutBytes);
|
||||||
|
}, std::chrono::milliseconds(onlineTimeoutMs / 4));
|
||||||
|
|
||||||
online = true;
|
online = true;
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ namespace icsneo {
|
|||||||
enum class Command : uint8_t {
|
enum class Command : uint8_t {
|
||||||
EnableNetworkCommunication = 0x07,
|
EnableNetworkCommunication = 0x07,
|
||||||
EnableNetworkCommunicationEx = 0x08,
|
EnableNetworkCommunicationEx = 0x08,
|
||||||
|
KeepAlive = 0x09,
|
||||||
NeoReadMemory = 0x40,
|
NeoReadMemory = 0x40,
|
||||||
NeoWriteMemory = 0x41,
|
NeoWriteMemory = 0x41,
|
||||||
ClearCoreMini = 0x42,
|
ClearCoreMini = 0x42,
|
||||||
|
|||||||
Reference in New Issue
Block a user