Skip to content

Commit

Permalink
always use team leader address for event
Browse files Browse the repository at this point in the history
  • Loading branch information
pa-pa committed Feb 14, 2018
1 parent 3117bcd commit eb6a9c1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
8 changes: 6 additions & 2 deletions Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ class Device {
msg.to(to);
getDeviceID(msg.from());
msg.setRpten(); // has to be set always
return send(msg);
}

bool send(Message& msg) {
bool result = false;
uint8_t maxsend = 6;
led().set(LedStates::send);
Expand All @@ -219,7 +223,7 @@ class Device {
DPRINT(F("<- "));
msg.dump();
maxsend--;
if( result == true && msg.ackRequired() == true && to.valid() == true ) {
if( result == true && msg.ackRequired() == true && msg.to().valid() == true ) {
Message response;
if( (result=waitResponse(msg,response,60)) ) { // 600ms
#ifdef USE_AES
Expand All @@ -232,7 +236,7 @@ class Device {
{
result = response.isAck();
// we request wakeup
// we got the fag to stay awake
// we got the flag to stay awake
if( msg.isWakeMeUp() || response.isKeepAwake() ) {
activity().stayAwake(millis2ticks(500));
}
Expand Down
4 changes: 4 additions & 0 deletions Message.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ class Message {
return toID;
}

HMID& to () {
return toID;
}

void type (uint8_t t) {
typ=t;
}
Expand Down
9 changes: 6 additions & 3 deletions examples/HM-SEC-SD/HM-SEC-SD.ino
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,15 @@ public:
SensorEventMsg& msg = (SensorEventMsg&)device().message();
msg.init(device().nextcount(),number(),count++,state,device().battery().low());
msg.flags(Message::BCAST | Message::BURST); // original smoke detector is burst device
msg.setRpten();
msg.to(leader);
device().getDeviceID(msg.to());

process(msg); // we first

device().send(msg,leader);
device().send(msg,leader);
device().send(msg,leader);
device().send(msg);
device().send(msg);
device().send(msg);
}
}
// reactivate for next measure
Expand Down

0 comments on commit eb6a9c1

Please sign in to comment.