LoRaWAN-Signal-Mapping/iot/main/main.ino

67 lines
1.6 KiB
Arduino
Raw Normal View History

#include "settings.h"
#include <Arduino.h>
#include <TinyGPS++.h>
#include <SD.h>
#include <MemoryFree.h>
#include "random.h"
// 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"
#include "gps.h"
#include "peripheral.h"
2019-06-24 13:31:33 +00:00
#include "storage.h"
#include "power.h"
#include "transmission.h"
void setup() {
Serial.begin(BAUD_PC);
Serial.println(F("[main] Starting"));
random_begin();
Serial.println(freeMemory(), DEC);
GPSLocation gps_data = gps_fetch();
Serial.println(freeMemory(), DEC);
Serial.print(F("[main] Location ")); Serial.print(gps_data.lat); Serial.print(F(", ")); Serial.println(gps_data.lng);
uint32_t id = random_get();
Serial.print(F("[main] Id "));
Serial.println(id);
// Activate microSD card breakout board on the SPI bus
peripheral_register(PIN_SPI_CS_RFM95);
peripheral_register(PIN_SPI_CS_SD);
peripheral_unsilence(PIN_SPI_CS_SD);
store_init();
Serial.println(freeMemory(), DEC); // 6
store_reading(id, gps_data);
#ifdef SD_DEBUG_ENABLED
store_debug(gps_data.time, 19);
#endif
store_close();
Serial.println(freeMemory(), DEC); // 7
// ------------------------------------------------------------------------
// Activate the RFM95
peripheral_switch(PIN_SPI_CS_SD, PIN_SPI_CS_RFM95);
uint8_t message[] = "testing";
// transmit_init();
// transmit_send(message, 7);
power_off(); // Doesn't return
}
void loop() {
}