         && evnt.opcode == SERIAL_EVT_OPCODE_CMD_RSP){
         state = ready;
         
+        // save the response value of SPI slave into buffer
+        // can be read via callback function
         lastResponse = evnt.params.cmd_rsp.response.val_get.data[0];
     }
     
-    Serial.print(state);
-    Serial.print("  ");
-    Serial.println(initState);
-}+    //Serial.print(state);
+    //Serial.print("  ");
+    //Serial.println(initState);
+}

#include "nrf8001-ble-uart-spark-io/serial_evt.h"


enum state_t{
    init,
    ready,
    waitingForEvent
};

int state = init;

int lastResponse;

int set_val(String args){

    if(state != ready){

  return;
}

// sending intialization commands to SPI slave
// alternating sending of commands and waiting for response
int initState = 0;
bool newMessage = false;

