Skip to content

Commit

Permalink
FlyBeeper : use saved fanet id if available
Browse files Browse the repository at this point in the history
  • Loading branch information
brunotl committed Aug 1, 2024
1 parent 0931553 commit 6fc6073
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Common/Source/Devices/devFlyBeeper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,21 @@ Frame::payload_t serialize_name() {
}

MacAddr generate_id() {
MacAddr addr;

DeviceSettings settings(_T("FlyBeeper"));
try {
addr.manufacturer = settings.get<uint8_t>("fanet-manufacturer");
addr.id = settings.get<uint16_t>("fanet-id");
return {
settings.get<uint8_t>("fanet-manufacturer"),
settings.get<uint16_t>("fanet-id")
};
}
catch(std::exception& e) { }

std::random_device rd; // a seed source for the random number engine
std::mt19937 gen(rd()); // mersenne_twister_engine seeded with rd()
std::uniform_int_distribution<uint16_t> distrib(1, std::numeric_limits<uint16_t>::max());

addr.manufacturer = 0xFC;
addr.id = distrib(gen);
MacAddr addr = { 0xFC, distrib(gen) };

settings.set<int>("fanet-manufacturer", addr.manufacturer);
settings.set<int>("fanet-id", addr.id);
Expand Down

0 comments on commit 6fc6073

Please sign in to comment.