Extensions: Offer an opportunity to communicate with a dead device

This commit is contained in:
Paul Hollinsky
2021-04-23 22:32:42 -04:00
parent 4cd7bafca7
commit 218648ae5a
3 changed files with 65 additions and 26 deletions
+2
View File
@@ -283,6 +283,8 @@ private:
std::vector<Network> supportedTXNetworks;
std::vector<Network> supportedRXNetworks;
APIEvent::Type attemptToBeginCommunication();
// Use heartbeatSuppressed instead when reading
std::atomic<int> heartbeatSuppressedByUser{0};
bool heartbeatSuppressed() const { return heartbeatSuppressedByUser > 0 || (settings && settings->applyingSettings); }
@@ -17,7 +17,12 @@ public:
virtual ~DeviceExtension() = default;
virtual const char* getName() const = 0;
virtual void onDeviceOpen() {}
// Return false to block opening
virtual bool onDeviceOpen() { return true; }
// Return true to indicate that communication should now be back
virtual bool onDeviceCommunicationDead() { return false; }
virtual void onGoOnline() {}
virtual void onGoOffline() {}
virtual void onDeviceClose() {}