 #include "nrf8001-ble-uart-spark-io/serial_evt.h"
 
 
+// defining the state of the system for communication
 enum state_t{
-    init,
-    ready,
-    waitingForEvent
+    init,           // not yet initialized
+    ready,          // no external command in work
+    waitingForEvent // external command in work, waiting for answer from SPI slave
 };
 
 int state = init;
 
+// buffer for the last value send by the SPI slave
 int lastResponse;
 
+// callback function for http command to set a handle value
 int set_val(String args){
 
     if(state != ready){

        && evnt.opcode == SERIAL_EVT_OPCODE_CMD_RSP){
        state = ready;
        
        lastResponse = evnt.params.cmd_rsp.response.val_get.data[0];
    }
    
    Serial.print(state);
    Serial.print("  ");
    Serial.println(initState);
}
    return rbc_mesh_value_set(handle, &value, (uint8_t) 1);
}

// callback function for http command to get a handle value
int get_val_req(String args){

    if(state != ready){
