     Serial.print("RFM69 initialized");
     Serial.print(", key: ");
     Serial.println(KEY);
-  }
-  if(debug) {
-    DateTime now = rtc.now();
-    Serial.print("Current time is: ");
-    Serial.println(now.unixtime());
   }
 }
 

#include <RFM69.h>
#include <SPI.h>
#include "RTClib.h"
#include <SD.h>

#define NODE_ID     0 //Network Node ID. All Senders must send to this ID #
#define NETWORK_ID  101 //Network ID. All Nodes must be on the same Network
#define FREQUENCY   RF69_433MHZ //Match this to the frequency of your radio
#define KEY         "p6ZNvTmGfdY2hUXb" //has to be same 16 characters/bytes on all nodes.
#define LED         3 //LED Pin Number
#define debug       1 //debug false/true

/*==============|| DS3231_RTC ||==============*/
RTC_DS3231 rtc; //Initialize the Real Time Clock
DateTime now;

/*==============|| SD ||==============*/
const int CHIP_SELECT = 4; //SPI SS pin for SD card
const int CARD_DETECT = 5; //Card Detect Pin
int CARD_PRESENT; //var for Card Detect sensor reading

}

int badPacket(long utm) {
  CARD_PRESENT = digitalRead(CARD_DETECT);
  if (CARD_PRESENT == 0) {
    if (debug) Serial.println("Card Not Present");
    while (CARD_PRESENT == 0) {
      CARD_PRESENT = digitalRead(CARD_DETECT);
      Blink(LED, 100);
    }
    if (!SD.begin(CHIP_SELECT))  Blink(LED, 25);
    if (debug) Serial.println("SD card initialized");
  }
  if (!dataFile.open("log.txt", O_RDWR | O_CREAT | O_AT_END)) {
    if (debug) Serial.println("Error opening: log.txt");
    Blink(LED, 100);
    Blink(LED, 100);
    return 0;
  }
  dataFile.print("Bad Packet Recieved at: ");
  dataFile.print(utm);
  dataFile.println();
  dataFile.close();
  return 1;
}

void checkSdCard() {
  CARD_PRESENT = digitalRead(CARD_DETECT); //Check for card insertion
  if (CARD_PRESENT == 0) { //if card NOT present....Wait and blink until it is
    if (debug) Serial.println("Card Not Present");
    while (CARD_PRESENT == 0) {
//      CARD_PRESENT = digitalRead(CARD_DETECT);
      Blink(LED, 50);
    }
//    if (!SD.begin(CHIP_SELECT))
//      Blink(LED, 25);
//    if (debug) Serial.println("SD card initialized");
  }
}

