NETWORK_TNC test
This commit is contained in:
parent
df6a468e21
commit
316d8cb711
|
|
@ -6,8 +6,11 @@
|
||||||
#include "BluetoothSerial.h"
|
#include "BluetoothSerial.h"
|
||||||
extern BluetoothSerial SerialBT;
|
extern BluetoothSerial SerialBT;
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(ENABLE_WIFI)
|
||||||
|
#include "taskWebServer.h"
|
||||||
|
#endif
|
||||||
extern QueueHandle_t tncToSendQueue;
|
extern QueueHandle_t tncToSendQueue;
|
||||||
extern QueueHandle_t tncReceivedQueue;
|
extern QueueHandle_t tncReceivedQueue;
|
||||||
|
|
||||||
void taskTNC(void *parameter);
|
[[noreturn]] void taskTNC(void *parameter);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,16 @@
|
||||||
#include <ESPmDNS.h>
|
#include <ESPmDNS.h>
|
||||||
#include <Preferences.h>
|
#include <Preferences.h>
|
||||||
|
|
||||||
|
#ifndef TASK_WEBSERVER
|
||||||
|
#define TASK_WEBSERVER
|
||||||
|
|
||||||
|
|
||||||
#define ENABLE_PREFERENCES
|
#define ENABLE_PREFERENCES
|
||||||
|
|
||||||
extern Preferences preferences;
|
extern Preferences preferences;
|
||||||
|
#ifdef KISS_PROTOCOL
|
||||||
|
extern WiFiServer tncServer;
|
||||||
|
#endif
|
||||||
// MAX 15 chars for preferenece key!!!
|
// MAX 15 chars for preferenece key!!!
|
||||||
static const char *const PREF_APRS_CALLSIGN = "aprs_callsign";
|
static const char *const PREF_APRS_CALLSIGN = "aprs_callsign";
|
||||||
static const char *const PREF_APRS_RELAY_PATH = "aprs_relay_path";
|
static const char *const PREF_APRS_RELAY_PATH = "aprs_relay_path";
|
||||||
|
|
@ -33,4 +40,5 @@ typedef struct {
|
||||||
String callsign;
|
String callsign;
|
||||||
} tWebServerCfg;
|
} tWebServerCfg;
|
||||||
|
|
||||||
[[noreturn]] void taskWebServer(void *parameter);
|
[[noreturn]] void taskWebServer(void *parameter);
|
||||||
|
#endif
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
#define T_BEAM_V1_0 // if enabled t-beam v1.0 disabled t-beam V.0.7
|
#define T_BEAM_V1_0 // if enabled t-beam v1.0 disabled t-beam V.0.7
|
||||||
//#define KISS_DEBUG
|
//#define KISS_DEBUG
|
||||||
#define ENABLE_WIFI
|
#define ENABLE_WIFI
|
||||||
|
#define NETWORK_TNC_PORT 8001
|
||||||
|
|
||||||
#define MAX_TIME_TO_NEXT_TX 360000L // TRANSMIT INTERVAL set here MAXIMUM time in ms(!) for smart beaconing - minimum time is always 1 min = 60 secs = 60000L !!!
|
#define MAX_TIME_TO_NEXT_TX 360000L // TRANSMIT INTERVAL set here MAXIMUM time in ms(!) for smart beaconing - minimum time is always 1 min = 60 secs = 60000L !!!
|
||||||
#define FIX_BEACON_INTERVAL 1800000L // Fixed beacon interwal (when GPS is disabled and FIXED_BEACON_EN is enabled) 30min default
|
#define FIX_BEACON_INTERVAL 1800000L // Fixed beacon interwal (when GPS is disabled and FIXED_BEACON_EN is enabled) 30min default
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
String inTNCData = "";
|
String inTNCData = "";
|
||||||
QueueHandle_t tncToSendQueue = nullptr;
|
QueueHandle_t tncToSendQueue = nullptr;
|
||||||
QueueHandle_t tncReceivedQueue = nullptr;
|
QueueHandle_t tncReceivedQueue = nullptr;
|
||||||
|
WiFiClient client;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle incoming TNC KISS data character
|
* Handle incoming TNC KISS data character
|
||||||
|
|
@ -23,6 +24,12 @@ void handleKISSData(char character) {
|
||||||
SerialBT.print(inTNCData);
|
SerialBT.print(inTNCData);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ENABLE_WIFI
|
||||||
|
if (client.connected()){
|
||||||
|
client.print(inTNCData);
|
||||||
|
client.flush();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
auto *buffer = new String();
|
auto *buffer = new String();
|
||||||
buffer->concat(TNC2DataFrame);
|
buffer->concat(TNC2DataFrame);
|
||||||
|
|
@ -34,31 +41,50 @@ void handleKISSData(char character) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void taskTNC(void *parameter) {
|
[[noreturn]] void taskTNC(void *parameter) {
|
||||||
tncToSendQueue = xQueueCreate(4,sizeof(String *));
|
tncToSendQueue = xQueueCreate(4,sizeof(String *));
|
||||||
tncReceivedQueue = xQueueCreate(4,sizeof(String *));
|
tncReceivedQueue = xQueueCreate(4,sizeof(String *));
|
||||||
String *loraReceivedFrameString = nullptr;
|
String *loraReceivedFrameString = nullptr;
|
||||||
|
client = tncServer.available();
|
||||||
while (true) {
|
while (true) {
|
||||||
while (Serial.available() > 0) {
|
while (Serial.available() > 0) {
|
||||||
char character = Serial.read();
|
char character = Serial.read();
|
||||||
handleKISSData(character);
|
handleKISSData(character);
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_BLUETOOTH
|
#ifdef ENABLE_BLUETOOTH
|
||||||
if (SerialBT.hasClient()) {
|
if (SerialBT.hasClient()) {
|
||||||
while (SerialBT.available() > 0) {
|
while (SerialBT.available() > 0) {
|
||||||
char character = SerialBT.read();
|
char character = SerialBT.read();
|
||||||
handleKISSData(character);
|
handleKISSData(character);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_WIFI
|
||||||
|
if (!client.connected()){
|
||||||
|
client = tncServer.available();
|
||||||
|
}
|
||||||
|
if (client.connected()){
|
||||||
|
while (client.available() > 0) {
|
||||||
|
char character = client.read();
|
||||||
|
handleKISSData(character);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
if (xQueueReceive(tncReceivedQueue, &loraReceivedFrameString, (1 / portTICK_PERIOD_MS)) == pdPASS) {
|
if (xQueueReceive(tncReceivedQueue, &loraReceivedFrameString, (1 / portTICK_PERIOD_MS)) == pdPASS) {
|
||||||
Serial.print(encode_kiss(*loraReceivedFrameString));
|
const String &kissEncoded = encode_kiss(*loraReceivedFrameString);
|
||||||
|
Serial.print(kissEncoded);
|
||||||
#ifdef ENABLE_BLUETOOTH
|
#ifdef ENABLE_BLUETOOTH
|
||||||
if (SerialBT.hasClient()){
|
if (SerialBT.hasClient()){
|
||||||
SerialBT.print(encode_kiss(*loraReceivedFrameString));
|
SerialBT.print(kissEncoded);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ENABLE_WIFI
|
||||||
|
if (client.connected()){
|
||||||
|
client.print(kissEncoded);
|
||||||
|
client.flush();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
delete loraReceivedFrameString;
|
delete loraReceivedFrameString;
|
||||||
}
|
}
|
||||||
vTaskDelay(50 / portTICK_PERIOD_MS);
|
vTaskDelay(50 / portTICK_PERIOD_MS);
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,9 @@ String apSSID = "";
|
||||||
String apPassword = "xxxxxxxxxx";
|
String apPassword = "xxxxxxxxxx";
|
||||||
WebServer server(80);
|
WebServer server(80);
|
||||||
Preferences preferences;
|
Preferences preferences;
|
||||||
|
#ifdef KISS_PROTOCOL
|
||||||
|
WiFiServer tncServer(NETWORK_TNC_PORT);
|
||||||
|
#endif
|
||||||
|
|
||||||
void sendCacheHeader() { server.sendHeader("Cache-Control", "max-age=3600"); }
|
void sendCacheHeader() { server.sendHeader("Cache-Control", "max-age=3600"); }
|
||||||
void sendGzipHeader() { server.sendHeader("Content-Encoding", "gzip"); }
|
void sendGzipHeader() { server.sendHeader("Content-Encoding", "gzip"); }
|
||||||
|
|
@ -181,8 +184,14 @@ void handle_SaveAPRSCfg() {
|
||||||
}
|
}
|
||||||
|
|
||||||
server.begin();
|
server.begin();
|
||||||
|
#ifdef KISS_PROTOCOL
|
||||||
|
tncServer.begin();
|
||||||
|
#endif
|
||||||
if (MDNS.begin(webServerCfg->callsign.c_str())) {
|
if (MDNS.begin(webServerCfg->callsign.c_str())) {
|
||||||
MDNS.addService("http", "tcp", 80);
|
MDNS.addService("http", "tcp", 80);
|
||||||
|
#ifdef KISS_PROTOCOL
|
||||||
|
MDNS.addService("kiss-tnc", "tcp", NETWORK_TNC_PORT);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true){
|
while (true){
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue