private void completeSearch(PEQTableEntrySearch winner) { PEQTableEntryRouting outRoute = null; if (winner == null) return; // should perform completeSearch(sinkID) first! bool found = false; // End Search, Update Route foreach (PEQTableEntryRouting route in _tableRouting) { if ((route._SinkID == winner._SinkID) && (!route._Valid)) { found = true; route._Valid = true; route._DestinationID = winner._DestinationID; route._nextHopCheat = winner._nextHopCheat; outRoute = route; } } // Add route if (!found) { PEQTableEntryRouting route = new PEQTableEntryRouting(_NUM_ID_BYTES); route._DestinationID = winner._DestinationID; route._SinkID = winner._SinkID; route._nextHopCheat = winner._nextHopCheat; _tableRouting.Add(route); outRoute = route; } updateRoutingTable(); if (winner._DataMessage is PEQMessageNotify) sendNotify(outRoute, (PEQMessageNotify)winner._DataMessage); }
private void startSearch(VarID SinkID, PEQMessage dataMessage) { clearTableSearch(SinkID); // Set all neighbors to 0xFF hops (unreachable) foreach (VarID neighborID in _tableNeighbor) { PEQTableEntrySearch entry = new PEQTableEntrySearch(); entry._SinkID = SinkID; entry._HopCount = 0xFF; entry._DestinationID = neighborID; entry._DataMessage = dataMessage; _tableSearch.Add(entry); } sendSearch(SinkID); _searchAggregator.IncrementSearches(); updateRoutingTable(); }