 static uint8_t         uart_buffer_len = 0;
 static uint8_t         dummychar = 0;
 
+int initDone = 0;
+
 int set_val(String args){
 
+    if(!initDone){
+        return -1;
+    }
 
     uint8_t handle = args[0] - '0';
     uint8_t value  = args[1] - '0';

  pins.interrupt_number       = 1;

  rbc_mesh_hw_init(&pins);
 
  Spark.function("set_val", set_val);
  Spark.variable("tmp", &tmp, INT);

  return;
}

    return rbc_mesh_value_set(handle, &value, (uint8_t) 1);
}

void setup(void)
{
  Serial.begin(9600);

  pins.board_name = BOARD_DEFAULT; //See board.h for details REDBEARLAB_SHIELD_V1_1 or BOARD_DEFAULT
  pins.reqn_pin   = D4; //SS for Nordic board, 9 for REDBEARLAB_SHIELD_V1_1
  pins.rdyn_pin   = D3; //3 for Nordic board, 8 for REDBEARLAB_SHIELD_V1_1
