Skip to content

Commit

Permalink
devFlyBeeper : fix Fanet-id range
Browse files Browse the repository at this point in the history
  • Loading branch information
brunotl committed Aug 4, 2024
1 parent 23173c7 commit c51a522
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions Common/Source/Devices/devFlyBeeper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,22 +112,16 @@ MacAddr generate_id() {

DeviceSettings settings(_T("FlyBeeper"));
try {
return {
settings.get<uint8_t>("fanet-manufacturer"),
settings.get<uint16_t>("fanet-id")
};
return MacAddr{ settings.get<uint32_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());
std::uniform_int_distribution<uint16_t> distrib(1, 0xFFFE);

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

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

settings.set<int>("fanet-id", addr.get());
return addr;
}

Expand Down

0 comments on commit c51a522

Please sign in to comment.