Compare commits
2 Commits
83ab65b062
...
1b00c6a05b
| Author | SHA1 | Date |
|---|---|---|
|
|
1b00c6a05b | |
|
|
ebf9409c18 |
|
|
@ -554,26 +554,28 @@ bool Device::goOnline() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
assignedClientId = com->getClientIDSync();
|
if(supportsNetworkMutex()) {
|
||||||
if(assignedClientId) {
|
assignedClientId = com->getClientIDSync();
|
||||||
// firmware supports clientid/mutex
|
if(assignedClientId) {
|
||||||
networkMutexCallbackHandle = lockAllNetworks(std::numeric_limits<uint32_t>::max(), std::numeric_limits<uint32_t>::max(), NetworkMutexType::Shared, [this](std::shared_ptr<Message> message) {
|
// firmware supports clientid/mutex
|
||||||
auto netMutexMsg = std::static_pointer_cast<NetworkMutexMessage>(message);
|
networkMutexCallbackHandle = lockAllNetworks(std::numeric_limits<uint32_t>::max(), std::numeric_limits<uint32_t>::max(), NetworkMutexType::Shared, [this](std::shared_ptr<Message> message) {
|
||||||
if(netMutexMsg->networks.size() && netMutexMsg->event.has_value()) {
|
auto netMutexMsg = std::static_pointer_cast<NetworkMutexMessage>(message);
|
||||||
switch(*netMutexMsg->event) {
|
if(netMutexMsg->networks.size() && netMutexMsg->event.has_value()) {
|
||||||
case NetworkMutexEvent::Acquired:
|
switch(*netMutexMsg->event) {
|
||||||
lockedNetworks.emplace(*netMutexMsg->networks.begin());
|
case NetworkMutexEvent::Acquired:
|
||||||
break;
|
lockedNetworks.emplace(*netMutexMsg->networks.begin());
|
||||||
case NetworkMutexEvent::Released: {
|
break;
|
||||||
auto it = lockedNetworks.find(*netMutexMsg->networks.begin());
|
case NetworkMutexEvent::Released: {
|
||||||
if (it != lockedNetworks.end())
|
auto it = lockedNetworks.find(*netMutexMsg->networks.begin());
|
||||||
lockedNetworks.erase(it);
|
if (it != lockedNetworks.end())
|
||||||
break;
|
lockedNetworks.erase(it);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// (re)start the keeponline
|
// (re)start the keeponline
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,8 @@ struct BootloaderPhase {
|
||||||
Finalize,
|
Finalize,
|
||||||
Reconnect,
|
Reconnect,
|
||||||
EnterBootloader,
|
EnterBootloader,
|
||||||
Wait
|
Wait,
|
||||||
|
EnterApplication
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual Type getType() const = 0;
|
virtual Type getType() const = 0;
|
||||||
|
|
@ -70,6 +71,16 @@ 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;
|
||||||
|
|
|
||||||
|
|
@ -67,10 +67,23 @@ 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;
|
||||||
|
|
|
||||||
|
|
@ -146,10 +146,23 @@ 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;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue