|
|
|
|
@ -37,9 +37,12 @@
@@ -37,9 +37,12 @@
|
|
|
|
|
#include <lmic.h> |
|
|
|
|
#include <hal/hal.h> |
|
|
|
|
#include <SPI.h> |
|
|
|
|
#include <Wire.h> |
|
|
|
|
#include <RTCZero.h> |
|
|
|
|
#include "hseSensorProtocol.h" |
|
|
|
|
#include "MessenSensoren.h" |
|
|
|
|
#include "ArduinoLowPower.h" |
|
|
|
|
|
|
|
|
|
RTCZero rtc; |
|
|
|
|
|
|
|
|
|
// This EUI must be in little-endian format, so least-significant-byte
|
|
|
|
|
// first. When copying an EUI from ttnctl output, this means to reverse
|
|
|
|
|
@ -228,20 +231,27 @@ void onEvent(ev_t ev) {
@@ -228,20 +231,27 @@ void onEvent(ev_t ev) {
|
|
|
|
|
} |
|
|
|
|
Serial1.println(F("")); |
|
|
|
|
} |
|
|
|
|
// Schedule next transmission
|
|
|
|
|
os_setTimedCallback(&sendjob, os_getTime() + sec2osticks(TX_INTERVAL), do_send); |
|
|
|
|
Serial1.print(F("WasTustDu=")); |
|
|
|
|
Serial1.println(WasTustDu); |
|
|
|
|
WasTustDu++; |
|
|
|
|
PrintTimeDate(); |
|
|
|
|
|
|
|
|
|
//Serial1.println(F("vor sleep"));
|
|
|
|
|
//Serial1.flush();
|
|
|
|
|
Serial1.flush(); |
|
|
|
|
|
|
|
|
|
// Sleep for a period of TX_INTERVAL using single shot alarm
|
|
|
|
|
rtc.setAlarmEpoch(rtc.getEpoch() + TX_INTERVAL); |
|
|
|
|
rtc.enableAlarm(rtc.MATCH_YYMMDDHHMMSS); |
|
|
|
|
rtc.attachInterrupt(alarmMatch); |
|
|
|
|
|
|
|
|
|
//LowPower.sleep((uint32_t) (TX_INTERVAL-10)*1000); // bis kurz vor dem Ereignis schlafen
|
|
|
|
|
//LowPower.sleep(1000); // ich will wissen wie häufig er hier vorbei kommt
|
|
|
|
|
|
|
|
|
|
PowerDown(); |
|
|
|
|
// Enter sleep mode
|
|
|
|
|
rtc.standbyMode(); |
|
|
|
|
|
|
|
|
|
//Serial1.println(F("wieder aufgewacht")); // => er wacht nicht wieder auf
|
|
|
|
|
PowerUp(); |
|
|
|
|
|
|
|
|
|
// Schedule next transmission to be immediately after this
|
|
|
|
|
os_setTimedCallback(&sendjob, os_getTime() + sec2osticks(1), do_send); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
case EV_LOST_TSYNC: |
|
|
|
|
@ -297,9 +307,13 @@ void setup() {
@@ -297,9 +307,13 @@ void setup() {
|
|
|
|
|
USBDevice.detach(); |
|
|
|
|
|
|
|
|
|
Serial1.begin(19200); |
|
|
|
|
Serial1.println(F("Starting 1.04")); |
|
|
|
|
Serial1.println(F("Starting 1.05")); |
|
|
|
|
Serial1.println(F(__FILE__)); |
|
|
|
|
Serial1.println(F(__DATE__)); |
|
|
|
|
// Initialize RTC
|
|
|
|
|
rtc.begin(); |
|
|
|
|
// Use RTC as a second timer instead of calendar
|
|
|
|
|
rtc.setEpoch(0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __SAMD21G18A__ |
|
|
|
|
@ -323,7 +337,7 @@ void setup() {
@@ -323,7 +337,7 @@ void setup() {
|
|
|
|
|
os_init(); |
|
|
|
|
// Reset the MAC state. Session and pending data transfers will be discarded.
|
|
|
|
|
LMIC_reset(); |
|
|
|
|
|
|
|
|
|
LMIC_setClockError(MAX_CLOCK_ERROR * 1 / 100); |
|
|
|
|
LMIC_setLinkCheckMode(0); |
|
|
|
|
LMIC_setDrTxpow(DR_SF7, 6); |
|
|
|
|
//LMIC_selectSubBand(1);
|
|
|
|
|
@ -338,4 +352,8 @@ void loop() {
@@ -338,4 +352,8 @@ void loop() {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void alarmMatch() |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|