2019-06-24 14:43:04 +00:00
# include "settings.h"
2019-06-12 19:18:37 +00:00
# include <Arduino.h>
2019-06-13 13:13:03 +00:00
# include <TinyGPS++.h>
2019-06-26 14:46:07 +00:00
# include <MemoryFree.h>
2019-06-12 19:18:37 +00:00
2019-06-13 13:33:08 +00:00
# include "random.h"
2019-06-13 13:47:40 +00:00
// BAD PRACTICE: For some extremely strange reason, the Arduino IDE doesn't pick up random.cpp like it does our other source files - so we've got to explicitly include it here. If we had control over the build process (which we don't), we've use a Makefile here that handled this better.
# include "random.cpp"
2019-06-12 19:18:37 +00:00
# include "gps.h"
2019-06-24 12:52:33 +00:00
# include "peripheral.h"
2019-06-24 13:31:33 +00:00
# include "storage.h"
# include "power.h"
2019-06-24 14:43:04 +00:00
# include "transmission.h"
2019-06-12 19:18:37 +00:00
2019-06-13 13:33:08 +00:00
2019-06-12 19:18:37 +00:00
void setup ( ) {
Serial . begin ( BAUD_PC ) ;
2019-06-26 14:46:07 +00:00
Serial . println ( F ( " [main] Starting " ) ) ;
2019-06-13 13:33:08 +00:00
random_begin ( ) ;
2019-06-26 14:59:49 +00:00
Serial . println ( freeMemory ( ) , DEC ) ;
2019-06-26 14:46:07 +00:00
GPSLocation gps_data = gps_fetch ( ) ;
2019-06-26 14:59:49 +00:00
Serial . println ( freeMemory ( ) , DEC ) ;
2019-06-13 13:13:03 +00:00
2019-06-26 14:46:07 +00:00
Serial . print ( F ( " [main] Location " ) ) ; Serial . print ( gps_data . lat ) ; Serial . print ( F ( " , " ) ) ; Serial . println ( gps_data . lng ) ;
2019-06-12 19:18:37 +00:00
2019-06-13 13:33:08 +00:00
uint32_t id = random_get ( ) ;
2019-06-12 19:18:37 +00:00
2019-06-26 14:46:07 +00:00
Serial . print ( F ( " [main] Id " ) ) ;
2019-06-13 13:33:08 +00:00
Serial . println ( id ) ;
2019-06-12 19:18:37 +00:00
2019-06-24 12:52:33 +00:00
// Activate microSD card breakout board on the SPI bus
2019-06-26 14:59:49 +00:00
peripheral_register ( PIN_SPI_CS_RFM95 ) ;
peripheral_register ( PIN_SPI_CS_SD ) ;
2019-06-24 12:52:33 +00:00
peripheral_unsilence ( PIN_SPI_CS_SD ) ;
store_init ( ) ;
2019-06-26 15:28:35 +00:00
Serial . println ( freeMemory ( ) , DEC ) ;
2019-06-26 14:46:07 +00:00
store_reading ( id , gps_data ) ;
2019-06-26 15:28:35 +00:00
Serial . println ( freeMemory ( ) , DEC ) ;
2019-06-26 14:46:07 +00:00
# ifdef SD_DEBUG_ENABLED
store_debug ( gps_data . time , 19 ) ;
# endif
2019-06-26 15:28:35 +00:00
Serial . println ( freeMemory ( ) , DEC ) ;
2019-06-27 14:58:01 +00:00
store_end ( ) ;
2019-06-26 15:28:35 +00:00
Serial . println ( freeMemory ( ) , DEC ) ;
2019-06-20 12:56:08 +00:00
2019-06-24 12:52:33 +00:00
// ------------------------------------------------------------------------
// Activate the RFM95
2019-06-24 14:43:04 +00:00
peripheral_switch ( PIN_SPI_CS_SD , PIN_SPI_CS_RFM95 ) ;
uint8_t message [ ] = " testing " ;
2019-06-24 12:52:33 +00:00
2019-06-26 14:46:07 +00:00
// transmit_init();
// transmit_send(message, 7);
2019-06-24 12:52:33 +00:00
2019-06-20 12:56:08 +00:00
power_off ( ) ; // Doesn't return
2019-06-12 19:18:37 +00:00
}
void loop ( ) {
}