 #include <wino.h>
 #include "config.h" 
 
+#define LOG_OUTPUT_DEBUG            (1)
+#define LOG_OUTPUT_DEBUG_PREFIX     (1)
+
+#define logDebug(arg)\
+    do {\
+        if (LOG_OUTPUT_DEBUG)\
+        {\
+            if (LOG_OUTPUT_DEBUG_PREFIX)\
+            {\
+                SerialUSB.print("[LOG Debug: ");\
+                SerialUSB.print((const char*)__FILE__);\
+                SerialUSB.print(",");\
+                SerialUSB.print((unsigned int)__LINE__);\
+                SerialUSB.print(",");\
+                SerialUSB.print((const char*)__FUNCTION__);\
+                SerialUSB.print("] ");\
+            }\
+            SerialUSB.println(arg);\
+        }\
+    } while(0)
+
+
+
 int loopcnt = 0;
 int errcnt = 0;
 

void sensor_setup(void) {
  pinMode(powerPin, OUTPUT);  // Sensor Power
  pinMode(ledPin, OUTPUT);  // LED when measuring
}
  


void loop() {
  SerialUSB.print("loops (minutes) since restart: ");
  SerialUSB.println(loopcnt);
    
  loopcnt++;
  if ((loopcnt % 5) == 0) lg_heartbeat(); // every 5 loops
  if ((loopcnt % 5) == 0) lg_sensor(soil_measure());    // every 5 minutes
  blinkLed(200);

  delay(60000); // one loop per minute 
}

/* get local IP address. The wifi library gives a strig result like this: 
 *  
 *  +CIFSR:APIP,"xxx.xxx.xxx.xxx"
 *  +CIFSR:APMAC,"xx:xx:xx:xx:xx:xx"
 *  +CIFSR:STAIP,"xxx.xxx.xxx.xxx"
 *  +CIFSR:STAMAC,"xx:xx:xx:xx:xx:xx"
 * 
 * we need to cut out the value from the STAIP line (Station IP)
 *
 */

String getIP(bool cache) {
  static String ip = "";

    + "Content-Length: " + payload.length() + "\r\n"
    + "\r\n"
    + payload + "\r\n";
  http_post(request);
 }
 
 void lg_sensor(int val) {
