#pragma once

#include <lmic.h>
#include <hal/hal.h>
#include <SPI.h>

#include "settings.custom.h"

/*
 * This is the main settings file - customise it to match your setup.
 * Don't forget that you need to take a copy of settings.custom.cpp.example as
 * settings.custom.cpp, and fill in the private keys the program needs to talk 
 * over LORaWAN.
 */

//////////////////////////////////
////////////// Main //////////////
//////////////////////////////////

// The speed at which we should talk over our main hardware serial connection.
#define BAUD_PC 		115200

// Multiple devices can use the same SPI data pin AFAIKT, but some libraries 
// *cough* SD *cough* are too stupid to figure out which pin it is on their own.
#define PIN_SPI_DATA	9

// The 'done' pin to pulse to signal to the TPL5111
#define PIN_TPL_DONE	A0

// Uncomment to print RAM diagnostics at regular intervals.
//#define ENABLE_MEMORY_DIAGNOSTICS

/////////////
/// RFM95 ///
/////////////

// Whether to actually enable LMIC-based transmission or not.
#define ENABLE_RADIO

// The SPI chip-select pin for the RFM 95
#define PIN_SPI_CS_RFM95	10

// Pin mapping - see settings.custom.cpp

/////////////////////////////////
////////////// GPS //////////////
/////////////////////////////////

// The *TX* gin of the GPS device.
// This is swapped because we receive the GPS device's message on our side on 
// the RX pin, and the GPS device transmits messages on the TX.
#define PIN_GPS_RX	5
// The *RX* pin on the GPS device.
// This is swapped because where the GPS device is receiving, we aresending and 
// vice versa.
// The TX / RX here are according to *our* side, not the GPS device's side.
#define PIN_GPS_TX	4
// The speed at which we should talk to the GPS device. Some GPS devices 
// require a certain speed in order to use certain commands, so it's important 
// that you check the datasheets for the device you're using.
// 9600 is the correct speed for a NEO-6M.
#define BAUD_GPS	9600

// Uncomment to cause the system to check the newest GPS value against the last one, and only transmit a reading if they differ by more than (0.0003, 0.0002) - ~(20m, 14m).
// Unhelpful for debugging, but useful in production to reduce the number of messages sent when stationary.
// #define GPS_DELTA_CHECK

#define GPS_DELTA_MIN_LAT	0.0003
#define GPS_DELTA_MIN_LNG	0.0002

//////////////////////////////////
////////// microSD Card //////////
//////////////////////////////////

// The chip select pin that activates the connection to the microSD card over SPI.
#define PIN_SPI_CS_SD		3

// The filename on the microSD card to store data in.
#define SD_FILENAME "DATA.TSV"

// Whether to write debug information to the filename below. This could compromise privacy, so it should be commented out for production.
// #define SD_DEBUG_ENABLED

// The filename on the microSD card to store debug information in
#define SD_FILENAME_DEBUG "DEBUG.LOG"