Skip to content

Commit

Permalink
rename peer(index) to peerat(index)
Browse files Browse the repository at this point in the history
  • Loading branch information
pa-pa committed Feb 15, 2021
1 parent 0481cbc commit c3b9cde
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
18 changes: 9 additions & 9 deletions Channel.h
Expand Up @@ -71,7 +71,7 @@ class Channel {

bool has (const Peer& p) const {
for( uint8_t i=0; i<peers(); ++i ) {
if( p == peer(i) ) {
if( p == peerat(i) ) {
return true;
}
}
Expand All @@ -80,14 +80,14 @@ class Channel {

uint8_t peerfor (const HMID& hmid) const {
for( uint8_t i=0; i<peers(); ++i ) {
if( hmid == peer(i) ) {
if( hmid == peerat(i) ) {
return i;
}
}
return 0xff;
}

Peer peer (uint8_t idx) const {
Peer peerat (uint8_t idx) const {
Peer result;
uint16_t paddr = peerAddress(idx);
if( paddr != 0 ) {
Expand Down Expand Up @@ -145,7 +145,7 @@ class Channel {

uint8_t findpeer () const {
for( int i=0; i<peers(); ++i ) {
if( peer(i).valid()==false ) {
if( peerat(i).valid()==false ) {
return i;
}
}
Expand All @@ -154,7 +154,7 @@ class Channel {

bool deletepeer (const Peer& p) const {
for( uint8_t i=0; i<peers(); ++i ) {
if( peer(i) == p ) {
if( peerat(i) == p ) {
deletepeer(i);
}
}
Expand Down Expand Up @@ -184,7 +184,7 @@ class Channel {
uint16_t liststart = 0x00;
if( hasList3() == true ) {
for( uint8_t i=0; i<peers(); ++i ) {
if( peer(i) == p ) {
if( peerat(i) == p ) {
liststart = peerAddress(i) + sizeof(Peer);
break;
}
Expand All @@ -197,7 +197,7 @@ class Channel {
uint16_t liststart = 0x00;
if( hasList4() == true ) {
for( uint8_t i=0; i<peers(); ++i ) {
if( peer(i) == p ) {
if( peerat(i) == p ) {
liststart = peerAddress(i) + sizeof(Peer) + List3::size();
break;
}
Expand Down Expand Up @@ -374,7 +374,7 @@ class VirtBaseChannel {
virtual bool inhibit () const = 0;
virtual bool aesActive () const = 0;
virtual bool has (const Peer& p) const = 0;
virtual Peer peer (uint8_t idx) const = 0;
virtual Peer peerat (uint8_t idx) const = 0;
virtual bool peer (const Peer& p) = 0;
virtual bool peer (const Peer& p1,const Peer& p2) = 0;
virtual bool deletepeer (const Peer& p) = 0;
Expand Down Expand Up @@ -423,7 +423,7 @@ class VirtChannel : public VirtBaseChannel<HalType,List0Type> {
virtual bool inhibit () const { return ch.inhibit(); }
virtual bool aesActive () const { return ch.aesActive(); }
virtual bool has (const Peer& p) const { return ch.has(p); };
virtual Peer peer (uint8_t idx) const { return ch.peer(idx); }
virtual Peer peerat (uint8_t idx) const { return ch.peerat(idx); }
virtual bool peer (const Peer& p) { return ch.peer(p); }
virtual bool peer (const Peer& p1,const Peer& p2) { return ch.peer(p1,p2); }
virtual bool deletepeer (const Peer& p) { return ch.deletepeer(p); }
Expand Down
6 changes: 3 additions & 3 deletions Device.h
Expand Up @@ -447,7 +447,7 @@ class Device {
uint8_t current=0;
uint8_t* buf=pm.data();
for( uint8_t i=0; i<channel.peers(); ++i ) {
Peer p = channel.peer(i);
Peer p = channel.peerat(i);
if( p.valid() == true ) {
memcpy(buf,&p,sizeof(Peer));
buf+=sizeof(Peer);
Expand Down Expand Up @@ -479,7 +479,7 @@ class Device {
void sendPeerEvent (Message& msg,const ChannelType& ch) {
bool sendtopeer=false;
for( int i=0; i<ch.peers(); ++i ){
Peer p = ch.peer(i);
Peer p = ch.peerat(i);
if( p.valid() == true ) {
// skip if this is not the first peer of that device
if( ch.peerfor(p) < i ) {
Expand Down Expand Up @@ -530,7 +530,7 @@ class Device {
// go over all peers, get first external device
// check if one of the peers needs a burst to wakeup
for( uint8_t i=0; i<ch.peers(); ++i ) {
Peer p = ch.peer(i);
Peer p = ch.peerat(i);
if( p.valid() == true ) {
if( msg.from() != p ) {
if( todev.valid() == false ) {
Expand Down
3 changes: 1 addition & 2 deletions examples/HM-SEC-SD/HM-SEC-SD.ino
Expand Up @@ -112,8 +112,7 @@ public:
if( state != newstate ) {
state = newstate;
// get team leader - peer 0
uint8_t idx = 0;
Peer leader = peer(idx);
Peer leader = peerat(0);
if( leader.valid() == true ) {
SensorEventMsg& msg = (SensorEventMsg&)device().message();
msg.init(device().nextcount(),number(),count++,state,device().battery().low());
Expand Down

0 comments on commit c3b9cde

Please sign in to comment.