Allow the decoder to fail

This commit is contained in:
Paul Hollinsky
2018-10-18 14:06:58 -04:00
parent e5f1ba41b5
commit dd99f82324
7 changed files with 45 additions and 30 deletions
+4 -1
View File
@@ -31,7 +31,10 @@ public:
for(auto& payload : foundDev.discoveryPackets)
packetizer->input(payload);
for(auto& packet : packetizer->output()) {
auto msg = decoder->decodePacket(packet);
std::shared_ptr<Message> msg;
if(!decoder->decode(msg, packet))
continue; // We failed to decode this packet
if(!msg || msg->network.getNetID() != Network::NetID::Main51)
continue; // Not a message we care about
auto sn = std::dynamic_pointer_cast<SerialNumberMessage>(msg);
+4 -1
View File
@@ -42,7 +42,10 @@ public:
for(auto& payload : foundDev.discoveryPackets)
packetizer->input(payload);
for(auto& packet : packetizer->output()) {
auto msg = decoder->decodePacket(packet);
std::shared_ptr<Message> msg;
if(!decoder->decode(msg, packet))
continue; // We failed to decode this packet
if(!msg || msg->network.getNetID() != Network::NetID::Main51)
continue; // Not a message we care about
auto sn = std::dynamic_pointer_cast<SerialNumberMessage>(msg);
+4 -1
View File
@@ -35,7 +35,10 @@ public:
for(auto& payload : foundDev.discoveryPackets)
packetizer->input(payload);
for(auto& packet : packetizer->output()) {
auto msg = decoder->decodePacket(packet);
std::shared_ptr<Message> msg;
if(!decoder->decode(msg, packet))
continue; // We failed to decode this packet
if(!msg || msg->network.getNetID() != Network::NetID::Main51)
continue; // Not a message we care about
auto sn = std::dynamic_pointer_cast<SerialNumberMessage>(msg);