HF-TMC51x0 Driver (TMC5130 & TMC5160) 0.1.0-dev
Hardware Agnostic C++ Driver for the TMC51x0 (TMC5130 & TMC5160)
Loading...
Searching...
No Matches
PeerStore Namespace Reference

Functions

void Init (SecuritySettings &sec, const uint8_t *preconfigured_mac=nullptr, DeviceType preconfigured_type=DeviceType::Unknown, const char *preconfigured_name=nullptr) noexcept
 Initialize peer storage and load approved peers from NVS.
 
bool AddPeer (SecuritySettings &sec, const uint8_t mac[6], DeviceType type, const char *name) noexcept
 Add a new approved peer to storage.
 
bool RemovePeer (SecuritySettings &sec, const uint8_t mac[6]) noexcept
 Remove a peer by MAC address.
 
bool IsPeerApproved (const SecuritySettings &sec, const uint8_t mac[6]) noexcept
 Check if a MAC address is in the approved peer list.
 
const ApprovedPeerGetPeer (const SecuritySettings &sec, const uint8_t mac[6]) noexcept
 Get peer information by MAC address.
 
bool GetFirstPeerOfType (const SecuritySettings &sec, DeviceType type, uint8_t mac_out[6]) noexcept
 Get the first valid peer MAC of a specific device type.
 
void Save (const SecuritySettings &sec) noexcept
 Save the current peer list to NVS.
 
size_t GetPeerCount (const SecuritySettings &sec) noexcept
 Get the number of valid approved peers.
 
void ClearAll (SecuritySettings &sec) noexcept
 Clear all approved peers (factory reset).
 
void LogPeers (const SecuritySettings &sec) noexcept
 Log all approved peers (for debugging).
 

Function Documentation

◆ AddPeer()

bool PeerStore::AddPeer ( SecuritySettings & sec,
const uint8_t mac[6],
DeviceType type,
const char * name )
noexcept

Add a new approved peer to storage.

If the peer already exists (by MAC), updates the existing entry.

Parameters
secSecurity settings structure
macPeer's MAC address
typePeer's device type
nameHuman-readable name for the peer
Returns
true if added/updated successfully, false if no room
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearAll()

void PeerStore::ClearAll ( SecuritySettings & sec)
noexcept

Clear all approved peers (factory reset).

Parameters
secSecurity settings structure
Here is the call graph for this function:

◆ GetFirstPeerOfType()

bool PeerStore::GetFirstPeerOfType ( const SecuritySettings & sec,
DeviceType type,
uint8_t mac_out[6] )
noexcept

Get the first valid peer MAC of a specific device type.

Useful for getting the default target MAC when sending messages.

Parameters
secSecurity settings structure
typeDevice type to find
mac_outOutput buffer for MAC address (6 bytes)
Returns
true if found, false if no peer of that type exists

◆ GetPeer()

const ApprovedPeer * PeerStore::GetPeer ( const SecuritySettings & sec,
const uint8_t mac[6] )
noexcept

Get peer information by MAC address.

Parameters
secSecurity settings structure
macMAC address to look up
Returns
Pointer to peer info, or nullptr if not found
Here is the call graph for this function:

◆ GetPeerCount()

size_t PeerStore::GetPeerCount ( const SecuritySettings & sec)
noexcept

Get the number of valid approved peers.

Parameters
secSecurity settings structure
Returns
Number of approved peers (0 to MAX_APPROVED_PEERS)
Here is the caller graph for this function:

◆ Init()

void PeerStore::Init ( SecuritySettings & sec,
const uint8_t * preconfigured_mac = nullptr,
DeviceType preconfigured_type = DeviceType::Unknown,
const char * preconfigured_name = nullptr )
noexcept

Initialize peer storage and load approved peers from NVS.

Parameters
secSecurity settings structure to populate
preconfigured_macOptional pre-configured MAC from compile-time config. If non-zero, this MAC is always trusted (backward compatibility).
preconfigured_typeDeviceType of the pre-configured MAC
preconfigured_nameName for the pre-configured peer
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsPeerApproved()

bool PeerStore::IsPeerApproved ( const SecuritySettings & sec,
const uint8_t mac[6] )
noexcept

Check if a MAC address is in the approved peer list.

Parameters
secSecurity settings structure
macMAC address to check
Returns
true if peer is approved
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LogPeers()

void PeerStore::LogPeers ( const SecuritySettings & sec)
noexcept

Log all approved peers (for debugging).

Parameters
secSecurity settings structure
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemovePeer()

bool PeerStore::RemovePeer ( SecuritySettings & sec,
const uint8_t mac[6] )
noexcept

Remove a peer by MAC address.

Parameters
secSecurity settings structure
macMAC address of peer to remove
Returns
true if removed, false if not found
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Save()

void PeerStore::Save ( const SecuritySettings & sec)
noexcept

Save the current peer list to NVS.

Called automatically by AddPeer/RemovePeer, but can be called manually if needed.

Parameters
secSecurity settings structure
Here is the caller graph for this function: