   digitalWrite(pin2, LOW);
 }
 
+// Generates a sensor report, sending it to the RF gateway
+void sendToRF(byte type, byte component) {
+  memset(&outbound, 0, sizeof(outbound));
+  outbound.msg.type = type;
+  outbound.msg.source = NODEID;
+  outbound.msg.destination = 0;
+  outbound.msg.component = component;
+  outbound.msg.rssi = 0;
+  memcpy(&outbound.msg.data, sensorData, sizeof(*sensorData));
+    
+  #if DEBUG
+    Serial.print("Broadcasting report to gateway...");
+  #endif
+  if (radio.sendWithRetry(GATEWAYID, outbound.raw, MSG_LENGTH)) {
+    #if DEBUG
+      Serial.println("ACK");
+    #endif
+  } else {
+    #if DEBUG
+      Serial.println("No ACK!");
+    #endif
+  }
+}
+
 void waterLeakChange() {
   #if DEBUG
     Serial.println("WATER LEAK Change");

  
  setupPorts();
  setupLeds();
  setupSensors();
}


/* -----------------------------------------------------------------------------
   Laundry Mote Sensor
  
   Monitors a washer and dryer.
 
   Circuit:
   * Moteino R4 w/ RFM69HW RF module
   * A0 - Battery voltage monitor
   * A1 - Light detector
   * A2 - Temperature
   * D3 - Water Leak detector
 
   Created 12-APR-2015 by Jon Brule
----------------------------------------------------------------------------- */
#include <LowPower.h>
#include <Message.h>
#include <RFM69.h>
#include <Reading.h>
#include <SPI.h>
#include "Sensors.h"

#define VERSION    "v0.1"

#define SERIAL     1
#define DEBUG      1
#define BAUD_RATE  9600

#define REPORT_PERIOD  1000 * 1000

#define NODEID         7   // unique for each node on same network
#define GATEWAYID      1
#define NETWORKID      99  // same for all nodes that talk to each other
#define FREQUENCY      RF69_915MHZ

const int MOTE_LED_PIN = 9;
const int EXTR_LED_PIN = 13;

Sensors* sensors;
SensorData* sensorData;

RFM69 radio;
Message inbound, outbound;


//-----------------------------------------------------------------------------
