     // Arduino can go to sleep now
     // Wakeup from sleep from the RDYN line
   }
+  
+  /* 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;
+    }
+  }
 }
 


 */
#include <SPI.h>
#include <avr/pgmspace.h>
#include <ble_system.h>
#include <lib_aci.h>
#include <lib_traces.h>

            When the device is in the setup mode
            */
            Serial.println(F("Evt Device Started: Setup"));
			setup_required = true;
            break;

            case ACI_DEVICE_STANDBY:
