Browse Source

improved error handling of OW devices

led
wiebel 8 years ago
parent
commit
19af87f548
  1. 20
      src/CANNode.cpp
  2. 10
      src/Node_3_def.h

20
src/CANNode.cpp

@ -29,7 +29,7 @@
#define DS2406_WRITE_STATUS 0x55 #define DS2406_WRITE_STATUS 0x55
#define DS2406_READ_STATUS 0xaa #define DS2406_READ_STATUS 0xaa
#define DS2406_CHANNEL_ACCESS 0xf5 #define DS2406_CHANNEL_ACCESS 0xf5
#define DS2406_CHANNEL_CONTROL1 0x4c // 01001100 - Read Both Pins #define DS2406_CHANNEL_CONTROL1 0xcc // 11001100 - Read Both Pins, reset alarm
#define DS2406_CHANNEL_CONTROL2 0xff // for future dev #define DS2406_CHANNEL_CONTROL2 0xff // for future dev
#define SKIP_ROM 0xCC #define SKIP_ROM 0xCC
#define PIO_A 0x20 #define PIO_A 0x20
@ -260,9 +260,25 @@ void loop(void)
} }
} }
if (METRO_OW_read.check() ) { if (METRO_OW_read.check() ) {
int8_t retry = 0;
for (uint8_t s_idx = 0; switches[s_idx].nick != 0; ++s_idx ){ for (uint8_t s_idx = 0; switches[s_idx].nick != 0; ++s_idx ){
readout = read_DS2406(switches[s_idx].addr); readout = read_DS2406(switches[s_idx].addr);
//if ((switches_state[s_idx] != readout) && (readout & 1<<7)) { if (readout == 255){
if (switches_state[s_idx] != 255) {
++retry;
if (retry <= 3) {
#if DEBUG
Serial.print(F("Retrying "));
Serial.print(switches[s_idx].nick);
Serial.print(F(" for "));
Serial.println(retry);
#endif /* DEBUG */
--s_idx; }
else { retry=0;}
}
continue;
}
// if ((switches_state[s_idx] != readout) && (readout != 255 )) {
if (switches_state[s_idx] != readout) { if (switches_state[s_idx] != readout) {
tmp = readout ^ switches_state[s_idx]; tmp = readout ^ switches_state[s_idx];
switches_state[s_idx] = readout; switches_state[s_idx] = readout;

10
src/Node_3_def.h

@ -28,14 +28,12 @@
static uint8_t node_id PROGMEM= { NODE_ID }; static uint8_t node_id PROGMEM= { NODE_ID };
static OW_switch_t switches[N_SWITCHES] PROGMEM={ static OW_switch_t switches[N_SWITCHES] PROGMEM={
// nick, addr[8], event_tag[pioA_FALL, pioA_RISE, pioB_FALL, pioB_RISE] // nick, addr[8], event_tag[pioA_FALL, pioA_RISE, pioB_FALL, pioB_RISE]
{ 255, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, { 0, 0, 0, 0 } }, { 11, { 0x12, 0xF2, 0x2A, 0x66, 0x0, 0x0, 0x0, 0x41 }, { 1, 1, 0, 0 } }, // EZ -> Flur
{ 11, { 0x12, 0xF2, 0x2A, 0x66, 0x0, 0x0, 0x0, 0x41 }, { 0, 0, 0, 0 } }, // EZ -> Flur { 12, { 0x12, 0x37, 0x8A, 0x4F, 0x0, 0x0, 0x0, 0xE5 }, { 2, 2, 2, 2 } }, // im keller TEST
{ 12, { 0x12, 0x37, 0x8A, 0x4F, 0x0, 0x0, 0x0, 0xE5 }, { 10, 10, 10, 10 } },
{ 13, { 0x12, 0x71, 0x51, 0x57, 0x0, 0x0, 0x0, 0x28 }, { 2, 2, 0, 0 } }, // Küche Kühlschank { 13, { 0x12, 0x71, 0x51, 0x57, 0x0, 0x0, 0x0, 0x28 }, { 2, 2, 0, 0 } }, // Küche Kühlschank
{ 21, { 0x12, 0x86, 0xB4, 0x54, 0x0, 0x0, 0x0, 0x5F }, { 3, 3, 4, 4 } }, //{ 21, { 0x12, 0x86, 0xB4, 0x54, 0x0, 0x0, 0x0, 0x5F }, { 3, 3, 4, 4 } },
{ 22, { 0x12, 0x84, 0xAD, 0x4F, 0x0, 0x0, 0x0, 0x12 }, { 1, 1, 2, 2 } }, // EZ -> Küche { 22, { 0x12, 0x84, 0xAD, 0x4F, 0x0, 0x0, 0x0, 0x12 }, { 1, 1, 2, 2 } }, // EZ -> Küche
{ 31, { 0x12, 0x88, 0xDD, 0x53, 0x0, 0x0, 0x0, 0x28 }, { 210, 211, 220, 221 } }, // Roldenschalter (A - UP, B - DOWN) // { 31, { 0x12, 0x88, 0xDD, 0x53, 0x0, 0x0, 0x0, 0x28 }, { 210, 211, 220, 221 } }, // Roldenschalter (A - UP, B - DOWN)
{ 0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, { 0, 0, 0, 0 } }
}; };
static uint8_t switches_state[N_SWITCHES]; static uint8_t switches_state[N_SWITCHES];
static outputs_t outputs[N_OUTPUTS] PROGMEM={ static outputs_t outputs[N_OUTPUTS] PROGMEM={

Loading…
Cancel
Save