     // If No event in the ACI Event queue and No event in the ACI Command queue
     // Arduino can go to sleep
   }
+  
+  /* setup_required is set to true when the device starts up and enters setup mode.
+   * It indicates that do_aci_setup() should be called. The flag should be cleared if
+   * do_aci_setup() returns ACI_STATUS_TRANSACTION_COMPLETE.
+   */
+  if(setup_required)
+  {
+    if (SETUP_SUCCESS == do_aci_setup(&aci_state))
+    {
+      setup_required = false;
+    }
+  }
 }
 
 /*

  /** We reset the nRF8001 here by toggling the RESET line connected to the nRF8001
   *  and initialize the data structures required to setup the nRF8001
   */

  lib_aci_init(&aci_state);

	pinMode(6, INPUT); //Pin #6 on Arduino -> PAIRING CLEAR pin: Connect to 3.3v to clear the pairing
	if (0x01 == digitalRead(6))

 */

#include <SPI.h>
#include "services.h"
#include <ble_system.h>
#include <lib_aci.h>
