improved error handling of OW devices
This commit is contained in:
		
							parent
							
								
									89165c54bd
								
							
						
					
					
						commit
						19af87f548
					
				@ -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
 | 
				
			||||||
@ -230,7 +230,7 @@ void loop(void)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  // service software timers based on Metro tick
 | 
					  // service software timers based on Metro tick
 | 
				
			||||||
  if ( METRO_OW_search.check() ) {
 | 
					  if ( METRO_OW_search.check() ) {
 | 
				
			||||||
    OW_1.reset_search();
 | 
					  OW_1.reset_search();
 | 
				
			||||||
    while(OW_1.search(addr) == 1) {
 | 
					    while(OW_1.search(addr) == 1) {
 | 
				
			||||||
        if ( OneWire::crc8( addr, 7) != addr[7]) {
 | 
					        if ( OneWire::crc8( addr, 7) != addr[7]) {
 | 
				
			||||||
            Serial.print("CRC is not valid!\n");
 | 
					            Serial.print("CRC is not valid!\n");
 | 
				
			||||||
@ -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;
 | 
				
			||||||
 | 
				
			|||||||
@ -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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user