Skip to content

File LinkRecovery.h

File List > Firmware > Libraries > SimGateway > LinkRecovery.h

Go to the documentation of this file

#pragma once
#include <stdint.h>

namespace OpenSkyhawk {

constexpr uint32_t LINK_BAD_MS          = 5000;   
constexpr uint32_t LINK_REATTACH_GAP_MS = 100;    
constexpr uint32_t LINK_REBOOT_AFTER_MS = 5000;   
constexpr uint32_t LINK_BACKOFF_MS      = 60000;  

enum class LinkAction : uint8_t {
    NONE,    
    DETACH,  
    ATTACH,  
    REBOOT,  
};

struct LinkRecovery {
    uint8_t  phase;      // internal: LinkPhase
    bool     backoff;    // a recovery reboot already happened and has not been followed by health
    uint32_t sinceMs;    // start of the current phase
};

void linkRecoveryBegin(LinkRecovery& s, bool afterRecoveryReboot);

LinkAction linkRecoveryStep(LinkRecovery& s, uint32_t now, bool healthy);

} // namespace OpenSkyhawk