               Serial.println(F("Evt Device Started: Standby"));
               //Looking for an iPhone by sending radio advertisements
               //When an iPhone connects to us we will get an ACI_EVT_CONNECTED event from the nRF8001
+              if (aci_evt->params.device_started.hw_error)
+              {
+                //do nothing, wait for the HW-error.
+              }
+              else
+              {
               lib_aci_connect(180/* in seconds */, 0x0050 /* advertising interval 50ms*/);
               Serial.println(F("Advertising started"));
+              }
+              
               break;
           }
         }

	Tell the ACI library, the MCU to nRF8001 pin connections.
	The Active pin is optional and can be marked UNUSED
	*/	  	
	aci_state.aci_pins.board_name = BOARD_DEFAULT; //See boards.h for details
	aci_state.aci_pins.reqn_pin   = 10;
	aci_state.aci_pins.rdyn_pin   = 8;
	aci_state.aci_pins.mosi_pin   = MOSI;
	aci_state.aci_pins.miso_pin   = MISO;
	aci_state.aci_pins.sck_pin    = SCK;
	
	aci_state.aci_pins.spi_clock_divider          = SPI_CLOCK_DIV8;
	  
	aci_state.aci_pins.reset_pin                  = 4;
	aci_state.aci_pins.active_pin                 = UNUSED;
	aci_state.aci_pins.optional_chip_sel_pin      = UNUSED;
	  
	aci_state.aci_pins.interface_is_interrupt	  = false;
	aci_state.aci_pins.interrupt_number			  = 1;

          aci_state.data_credit_available++;
        }
        break;
      
        //test code start
      case ACI_EVT_HW_ERROR:
        Serial.print(F("HW error: "));
        Serial.println(aci_evt->params.hw_error.line_num, DEC);
        
        for(uint8_t counter = 0; counter <= (aci_evt->len - 3); counter++)
        {
        Serial.write(aci_evt->params.hw_error.file_name[counter]); //uint8_t file_name[20];
        }
        Serial.println();
        lib_aci_connect(180/* in seconds */, 0x0050 /* advertising interval 50ms*/);
        Serial.println(F("Advertising started"));
        break;
        //test code end
           
    }
  }
