forked from letscontrolit/ESPEasy
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
254 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,39 @@ | ||
#include "ESPEasy_Now_peerInfo.h" | ||
#include "ESPEasy_Now_peerInfo.h" | ||
|
||
|
||
static uint64_t mac_to_key(const uint8_t *mac) | ||
{ | ||
uint64_t key = 0; | ||
|
||
for (byte i = 0; i < 6; ++i) { | ||
key = key << 8; | ||
key += mac[i]; | ||
} | ||
return key; | ||
} | ||
|
||
void ESPEasy_Now_peerInfo::addPeer(const uint8_t *mac, const ESPEasy_Now_peerInfo_meta& meta) | ||
{ | ||
uint64_t key = mac_to_key(mac); | ||
|
||
peer_map[key] = meta; | ||
} | ||
|
||
bool ESPEasy_Now_peerInfo::hasPeer(const uint8_t *mac) const | ||
{ | ||
uint64_t key = mac_to_key(mac); | ||
|
||
return peer_map.find(key) != peer_map.end(); | ||
} | ||
|
||
bool ESPEasy_Now_peerInfo::getPeer(const uint8_t *mac, | ||
ESPEasy_Now_peerInfo_meta& meta) const | ||
{ | ||
uint64_t key = mac_to_key(mac); | ||
auto it = peer_map.find(key); | ||
|
||
if (it == peer_map.end()) { return false; } | ||
meta = it->second; | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.