2019-04-30 18:17:07 +00:00
|
|
|
#include <timer.h>
|
2019-04-25 06:17:02 +00:00
|
|
|
#include "WiFi.h"
|
|
|
|
#include "loraprs.h"
|
|
|
|
|
2019-04-30 18:17:07 +00:00
|
|
|
#define LED_BUILTIN 2
|
|
|
|
#define LED_TOGGLE_PERIOD 1000
|
|
|
|
|
2019-04-25 06:17:02 +00:00
|
|
|
#define LORAPRS_CLIENT
|
|
|
|
|
|
|
|
#define LORAPRS_FREQ 432.5E6
|
|
|
|
|
|
|
|
#ifdef LORAPRS_CLIENT
|
|
|
|
#define LORAPRS_BT_NAME "loraprs_client"
|
|
|
|
#define LORAPRS_WIFI_SSID ""
|
|
|
|
#define LORAPRS_WIFI_KEY ""
|
|
|
|
#define LORAPRS_LOGIN "NOCALL-0"
|
|
|
|
#define LORAPRS_PASS "00000"
|
|
|
|
#else
|
2019-04-30 17:31:04 +00:00
|
|
|
#define LORAPRS_BT_NAME ""
|
2019-04-25 06:17:02 +00:00
|
|
|
#define LORAPRS_WIFI_SSID "<mywifi>"
|
|
|
|
#define LORAPRS_WIFI_KEY "<key>"
|
|
|
|
#define LORAPRS_LOGIN "NOCALL-0"
|
|
|
|
#define LORAPRS_PASS "00000"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
LoraPrs loraPrs(
|
|
|
|
LORAPRS_FREQ,
|
|
|
|
LORAPRS_BT_NAME,
|
|
|
|
LORAPRS_WIFI_SSID,
|
|
|
|
LORAPRS_WIFI_KEY,
|
|
|
|
LORAPRS_LOGIN,
|
|
|
|
LORAPRS_PASS);
|
|
|
|
|
2019-04-30 18:17:07 +00:00
|
|
|
auto watchdogLedTimer = timer_create_default();
|
|
|
|
|
2019-04-25 06:17:02 +00:00
|
|
|
void setup() {
|
2019-04-30 18:17:07 +00:00
|
|
|
pinMode(LED_BUILTIN, OUTPUT);
|
|
|
|
digitalWrite(LED_BUILTIN, 1);
|
|
|
|
|
2019-04-25 06:17:02 +00:00
|
|
|
Serial.begin(115200);
|
|
|
|
while (!Serial);
|
|
|
|
|
|
|
|
loraPrs.setup();
|
2019-04-30 18:17:07 +00:00
|
|
|
|
|
|
|
watchdogLedTimer.every(LED_TOGGLE_PERIOD, toggleWatchdogLed);
|
2019-04-25 06:17:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop() {
|
|
|
|
loraPrs.loop();
|
2019-04-30 18:17:07 +00:00
|
|
|
watchdogLedTimer.tick();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool toggleWatchdogLed(void *) {
|
|
|
|
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
|
|
|
return true;
|
2019-04-25 06:17:02 +00:00
|
|
|
}
|