Compare commits

..

No commits in common. "1b00c6a05be08a60db8e543a0a7da0ebc2ad5b7e" and "83ab65b062385967e17cc73d7efde82bba8cfb9e" have entirely different histories.

4 changed files with 18 additions and 57 deletions

View File

@ -554,28 +554,26 @@ bool Device::goOnline() {
return false; return false;
} }
if(supportsNetworkMutex()) { assignedClientId = com->getClientIDSync();
assignedClientId = com->getClientIDSync(); if(assignedClientId) {
if(assignedClientId) { // firmware supports clientid/mutex
// firmware supports clientid/mutex networkMutexCallbackHandle = lockAllNetworks(std::numeric_limits<uint32_t>::max(), std::numeric_limits<uint32_t>::max(), NetworkMutexType::Shared, [this](std::shared_ptr<Message> message) {
networkMutexCallbackHandle = lockAllNetworks(std::numeric_limits<uint32_t>::max(), std::numeric_limits<uint32_t>::max(), NetworkMutexType::Shared, [this](std::shared_ptr<Message> message) { auto netMutexMsg = std::static_pointer_cast<NetworkMutexMessage>(message);
auto netMutexMsg = std::static_pointer_cast<NetworkMutexMessage>(message); if(netMutexMsg->networks.size() && netMutexMsg->event.has_value()) {
if(netMutexMsg->networks.size() && netMutexMsg->event.has_value()) { switch(*netMutexMsg->event) {
switch(*netMutexMsg->event) { case NetworkMutexEvent::Acquired:
case NetworkMutexEvent::Acquired: lockedNetworks.emplace(*netMutexMsg->networks.begin());
lockedNetworks.emplace(*netMutexMsg->networks.begin()); break;
break; case NetworkMutexEvent::Released: {
case NetworkMutexEvent::Released: { auto it = lockedNetworks.find(*netMutexMsg->networks.begin());
auto it = lockedNetworks.find(*netMutexMsg->networks.begin()); if (it != lockedNetworks.end())
if (it != lockedNetworks.end()) lockedNetworks.erase(it);
lockedNetworks.erase(it); break;
break;
}
} }
} }
} }
); }
} );
} }
// (re)start the keeponline // (re)start the keeponline

View File

@ -28,8 +28,7 @@ struct BootloaderPhase {
Finalize, Finalize,
Reconnect, Reconnect,
EnterBootloader, EnterBootloader,
Wait, Wait
EnterApplication
}; };
virtual Type getType() const = 0; virtual Type getType() const = 0;
@ -71,16 +70,6 @@ struct EnterBootloaderPhase : public BootloaderPhase {
} }
}; };
struct EnterApplicationPhase : public BootloaderPhase {
Type getType() const override {
return Type::EnterApplication;
}
ChipID chip;
EnterApplicationPhase(ChipID chip) : chip(chip) {}
};
struct FlashPhase : public BootloaderPhase { struct FlashPhase : public BootloaderPhase {
Type getType() const override { Type getType() const override {
return Type::Flash; return Type::Flash;

View File

@ -67,23 +67,10 @@ public:
} }
} }
if(useNewBootloader) { if(useNewBootloader) {
auto mainChip = std::find_if(chipVersions.begin(), chipVersions.end(), [](const auto& chip) { return chip.name == "ZCHIP"; });
auto usbChip = std::find_if(chipVersions.begin(), chipVersions.end(), [](const auto& chip) { return chip.name == "USB ZCHIP"; });
ChipID mainChipID;
if(mainChip != chipVersions.end()) {
mainChipID = mainChip->id;
} else if(usbChip != chipVersions.end()) {
mainChipID = usbChip->id;
} else {
return {};
}
BootloaderPipeline pipeline; BootloaderPipeline pipeline;
for(const auto& version : chipVersions) { for(const auto& version : chipVersions) {
pipeline.add<FlashPhase>(version.id, BootloaderCommunication::RADMultiChip); pipeline.add<FlashPhase>(version.id, BootloaderCommunication::RADMultiChip);
} }
pipeline.add<EnterApplicationPhase>(mainChipID);
pipeline.add<ReconnectPhase>(); pipeline.add<ReconnectPhase>();
pipeline.add<WaitPhase>(std::chrono::milliseconds(3000)); pipeline.add<WaitPhase>(std::chrono::milliseconds(3000));
return pipeline; return pipeline;

View File

@ -146,23 +146,10 @@ public:
BootloaderPipeline getBootloader() override { BootloaderPipeline getBootloader() override {
auto chipVersions = getChipVersions(); auto chipVersions = getChipVersions();
auto mainChip = std::find_if(chipVersions.begin(), chipVersions.end(), [](const auto& chip) { return chip.name == "ZCHIP"; });
auto usbChip = std::find_if(chipVersions.begin(), chipVersions.end(), [](const auto& chip) { return chip.name == "USB ZCHIP"; });
ChipID mainChipID;
if(mainChip != chipVersions.end()) {
mainChipID = mainChip->id;
} else if(usbChip != chipVersions.end()) {
mainChipID = usbChip->id;
} else {
return {};
}
BootloaderPipeline pipeline; BootloaderPipeline pipeline;
for(const auto& version : chipVersions) { for(const auto& version : chipVersions) {
pipeline.add<FlashPhase>(version.id, BootloaderCommunication::RADMultiChip); pipeline.add<FlashPhase>(version.id, BootloaderCommunication::RADMultiChip);
} }
pipeline.add<EnterApplicationPhase>(mainChipID);
pipeline.add<ReconnectPhase>(); pipeline.add<ReconnectPhase>();
pipeline.add<WaitPhase>(std::chrono::milliseconds(3000)); pipeline.add<WaitPhase>(std::chrono::milliseconds(3000));
return pipeline; return pipeline;