2019-04-25 06:17:02 +00:00
|
|
|
#ifndef LORAPRS_H
|
|
|
|
#define LORAPRS_H
|
|
|
|
|
|
|
|
#include <Arduino.h>
|
|
|
|
#include <SPI.h>
|
|
|
|
#include <LoRa.h>
|
|
|
|
#include <WiFi.h>
|
|
|
|
|
|
|
|
#include "BluetoothSerial.h"
|
|
|
|
|
|
|
|
class LoraPrs
|
|
|
|
{
|
|
|
|
public:
|
2019-05-09 16:13:08 +00:00
|
|
|
LoraPrs(int loraFreq, const String & btName, const String & wifiName,
|
|
|
|
const String & wifiKey, const String & aprsLoginCallsign, const String & aprsPass);
|
|
|
|
|
|
|
|
void setup();
|
|
|
|
void loop();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void setupWifi(const String & wifiName, const String & wifiKey);
|
|
|
|
void setupLora(int loraFreq);
|
|
|
|
void setupBt(const String & btName);
|
|
|
|
|
|
|
|
void reconnectWifi();
|
|
|
|
|
|
|
|
void onLoraReceived(int packetSize);
|
|
|
|
void onBtReceived();
|
|
|
|
void onAprsReceived(const String & aprsMessage);
|
2020-02-11 09:00:39 +00:00
|
|
|
|
|
|
|
void kissResetState();
|
2019-05-09 16:13:08 +00:00
|
|
|
|
|
|
|
String convertAX25ToAprs(byte *rxPayload, int payloadLength, const String & signalReport);
|
|
|
|
String decodeCall(byte *rxPtr);
|
|
|
|
|
|
|
|
private:
|
|
|
|
enum KissMarker {
|
|
|
|
Fend = 0xc0,
|
|
|
|
Fesc = 0xdb,
|
|
|
|
Tfend = 0xdc,
|
|
|
|
Tfesc = 0xdd
|
|
|
|
};
|
|
|
|
|
|
|
|
enum KissState {
|
|
|
|
Void = 0,
|
|
|
|
GetCmd,
|
|
|
|
GetData,
|
|
|
|
Escape
|
|
|
|
};
|
|
|
|
|
|
|
|
enum KissCmd {
|
|
|
|
Data = 0x00,
|
|
|
|
NoCmd = 0x80
|
|
|
|
};
|
|
|
|
|
|
|
|
enum AX25Ctrl {
|
|
|
|
UI = 0x03
|
|
|
|
};
|
|
|
|
|
|
|
|
enum AX25Pid {
|
|
|
|
NoLayer3 = 0xf0
|
|
|
|
};
|
|
|
|
|
2019-04-25 06:17:02 +00:00
|
|
|
const String CfgLoraprsVersion = "LoRAPRS 0.1";
|
|
|
|
|
|
|
|
const byte CfgPinSs = 5;
|
|
|
|
const byte CfgPinRst = 26;
|
|
|
|
const byte CfgPinDio0 = 14;
|
|
|
|
|
2020-02-10 16:26:51 +00:00
|
|
|
const int CfgBw = 125e3;
|
2020-02-10 17:20:07 +00:00
|
|
|
const byte CfgSpread = 12;
|
2019-04-26 07:07:01 +00:00
|
|
|
const byte CfgCodingRate = 7;
|
2019-04-25 06:17:02 +00:00
|
|
|
const byte CfgSync = 0xf3;
|
|
|
|
const byte CfgPower = 20;
|
|
|
|
|
|
|
|
const int CfgAprsPort = 14580;
|
|
|
|
const String CfgAprsHost = "rotate.aprs2.net";
|
|
|
|
|
|
|
|
private:
|
|
|
|
int loraFreq_;
|
|
|
|
String btName_;
|
|
|
|
String wifiName_;
|
|
|
|
String wifiKey_;
|
|
|
|
String aprsLogin_;
|
2019-05-09 16:13:08 +00:00
|
|
|
|
|
|
|
KissCmd kissCmd_;
|
|
|
|
KissState kissState_;
|
|
|
|
|
|
|
|
BluetoothSerial serialBt_;
|
2019-04-25 06:17:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // LORAPRS_H
|