Skip to content

Commit 4525e08

Browse files
committed
idk wtf lol
1 parent b0602f4 commit 4525e08

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

src/Ducks/Duck.h

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,15 @@ class Duck {
7474
std::vector<uint8_t> app_data;
7575
app_data.insert(app_data.end(), data.begin(), data.end());
7676
CdpPacket txPacket = CdpPacket(targetDevice, topic, app_data, this->duid, this->getType());
77-
router.getFilter().assignUniqueMessageId(txPacket);
78-
err = sendToRadio(txPacket);
77+
78+
std::optional<Duid> nextHop = router.getBestNextHop(txPacket.dduid);
79+
if(nextHop.has_value() || txPacket.dduid == PAPADUCK_DUID || txPacket.dduid == BROADCAST_DUID){
80+
router.getFilter().assignUniqueMessageId(txPacket);
81+
err = sendToRadio(txPacket);
82+
} else {
83+
logdbg_ln("!!!!!!!!!!!!!!!! SEND DATA SENDING RREQ FOR SOME REASON !!!!!!!!!!!!!");
84+
sendRouteRequest(txPacket.dduid, getDuckId());
85+
}
7986
}
8087
return err;
8188
}
@@ -93,14 +100,20 @@ class Duck {
93100
logerr_ln("ERROR send data failed, topic is reserved.");
94101
return DUCKPACKET_ERR_TOPIC_INVALID;
95102
}
96-
103+
97104
if(router.getNetworkState() == NetworkState::PUBLIC){
98-
//check what next hop to send the packet to
99-
std::vector<uint8_t> app_data(length);
105+
std::vector<uint8_t> app_data;
100106
app_data.insert(app_data.end(), &data[0], &data[length]);
101107
CdpPacket txPacket = CdpPacket(targetDevice, topic, app_data, this->duid, this->getType());
102-
router.getFilter().assignUniqueMessageId(txPacket);
103-
err = sendToRadio(txPacket);
108+
109+
std::optional<Duid> nextHop = router.getBestNextHop(txPacket.dduid);
110+
if(nextHop.has_value() || txPacket.dduid == PAPADUCK_DUID || txPacket.dduid == BROADCAST_DUID){
111+
router.getFilter().assignUniqueMessageId(txPacket);
112+
err = sendToRadio(txPacket);
113+
} else {
114+
logdbg_ln("!!!!!!!!!!!!!!!! SEND DATA SENDING RREQ FOR SOME REASON !!!!!!!!!!!!!");
115+
sendRouteRequest(txPacket.dduid, getDuckId());
116+
}
104117
}
105118
return err;
106119
}

0 commit comments

Comments
 (0)