Skip to content

Commit

Permalink
use _delay_ms
Browse files Browse the repository at this point in the history
remove not used LED modes
  • Loading branch information
pa-pa committed Jan 31, 2017
1 parent ac47bdd commit 6091f13
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 20 deletions.
13 changes: 7 additions & 6 deletions Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ class Device {
msg.setRpten(); // has to be set always
bool result = false;
uint8_t maxsend = 6;
sled.set(StatusLed::send);
while( result == false && maxsend > 0 ) {
DPRINT(F("<- "));
msg.dump();
Expand All @@ -236,9 +237,8 @@ class Device {
DPRINT(F("waitAck: ")); DHEX((uint8_t)result); DPRINTLN(F(""));
}
}
if( sled.active() == false ) {
sled.set(StatusLed::send);
}
if( result == true ) sled.set(StatusLed::ack);
else sled.set(StatusLed::nack);
return result;
}

Expand Down Expand Up @@ -373,7 +373,7 @@ class Device {
if( radio->readAck(msg) == true ) {
return true;
}
delay(10); // wait 10ms
_delay_ms(10); // wait 10ms
timeout--;
}
while( timeout > 0 );
Expand All @@ -387,7 +387,7 @@ class Device {
msg.to() == response.from() ) {
return true;
}
delay(10); // wait 10ms
_delay_ms(10); // wait 10ms
timeout--;
}
while( timeout > 0 );
Expand Down Expand Up @@ -445,6 +445,7 @@ class Device {

bool processChallenge(const Message& msg,const uint8_t* challenge,uint8_t keyidx) {
if( kstore.challengeKey(challenge,keyidx) == true ) {
DPRINT("Process Challenge - Key: ");DHEXLN(keyidx);
AesResponseMsg answer;
answer.init(msg);
// fill initial vector with message to sign
Expand All @@ -469,7 +470,7 @@ class Device {
DPRINT(F("-> ")); answer.dump();
return true;
}
delay(10); // wait 10ms
_delay_ms(10); // wait 10ms
timeout--;
}
while( timeout > 0 );
Expand Down
19 changes: 8 additions & 11 deletions Led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,16 @@ namespace as {

StatusLed sled;

// patters reused from NewAskSin by <[email protected]>
const StatusLed::BlinkPattern pattern [11] PROGMEM = {

const StatusLed::BlinkPattern pattern [8] PROGMEM = {
{0, 0, {0 , 0 } }, // 0; define nothing
{2, 20, {5, 5,} }, // 1; define pairing string
{2, 1, {20, 0,} }, // 2; define pairing success
{2, 3, {1, 1,} }, // 3; define pairing error
{2, 1, {1, 1,} }, // 4; define send indicator
{0, 0, {0, 0,} }, // 5; define ack indicator
{0, 0, {0, 0,} }, // 6; define no ack indicator
{6, 3, {5, 1, 1, 1, 1, 10} }, // 7; define battery low indicator
{6, 3, {1, 1, 1, 1, 1, 10} }, // 8; define defect indicator
{6, 1, {1, 1, 5, 1, 5, 10} }, // 9; define welcome indicator
{2, 6, {2, 2, } }, // 10; key long indicator
{2, 1, {10, 1,} }, // 2; define send indicator
{0, 0, {0, 0,} }, // 3; define ack indicator
{0, 0, {0, 0,} }, // 4; define no ack indicator
{6, 3, {5, 1, 1, 1, 1, 10} }, // 5; define battery low indicator
{6, 1, {1, 1, 5, 1, 5, 10} }, // 6; define welcome indicator
{2, 6, {2, 2, } }, // 7; key long indicator
};

void StatusLed::copyPattern (Mode stat) {
Expand Down
4 changes: 2 additions & 2 deletions Led.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class StatusLed : public Alarm {

public:

enum Mode { nothing=0, pairing=1, pair_suc=2, pair_err=3, send=4, ack=5,
noack=6, bat_low=7, defect=8, welcome=9, key_long=10 };
enum Mode { nothing=0, pairing=1,send=2, ack=3,
nack=4, bat_low=5, welcome=6, key_long=7 };

struct BlinkPattern {
uint8_t length;
Expand Down
4 changes: 4 additions & 0 deletions Message.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ class Message {
return (flag & WKMEUP) == WKMEUP;
}

void setWakeMeUp () {
flag |= WKMEUP;
}

bool isRepeated () const {
return (flag & RPTED) == RPTED;
}
Expand Down
2 changes: 1 addition & 1 deletion Radio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ uint8_t CC1101::read (Message& msg, uint32_t timeout) {
do {
num = read(msg);
if( num == 0 ) {
delay(50); // wait 50ms
_delay_ms(50); // wait 50ms
time += 50;
}
}
Expand Down

0 comments on commit 6091f13

Please sign in to comment.