To turn off Wifi and/or Spark.connection at startup:
#include "application.h"
#include "spark_disable_wlan.h"
#include "spark_disable_cloud.h"
To turn Wifi on/off in your loop():
WiFi.on();
WiFi.off();
To check Wifi status:
WiFi_Status_TypeDef current_wifi_status = WiFi.status(); //save in current_wifi_status
The conditions available for WiFi.status()
WIFI_CONNECTING
WIFI_ON
WIFI_OFF
To connect to Spark.cloud on/off in your loop():
Spark.connect();
Spark.disconnect();