mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Allow disconnections to be signaled by drivers
This allows for disconnections to be detected quickly where possible. It also makes sure other driver errors aren't thrown in the event of a disconnection.
This commit is contained in:
committed by
Paul Hollinsky
parent
dfe2d23d85
commit
a5b27a15b0
+6
-1
@@ -238,7 +238,7 @@ bool Device::open() {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
// Check if we got a message, and if not, if settings are being applied
|
||||
if(!receivedMessage && !settings->applyingSettings) {
|
||||
if(!stopHeartbeatThread)
|
||||
if(!stopHeartbeatThread && !isDisconnected())
|
||||
report(APIEvent::Type::DeviceDisconnected, APIEvent::Severity::Error);
|
||||
break;
|
||||
}
|
||||
@@ -316,6 +316,11 @@ bool Device::goOnline() {
|
||||
bool Device::goOffline() {
|
||||
forEachExtension([](const std::shared_ptr<DeviceExtension>& ext) { ext->onGoOffline(); return true; });
|
||||
|
||||
if(isDisconnected()) {
|
||||
online = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!com->sendCommand(Command::EnableNetworkCommunication, false))
|
||||
return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user