Compare commits
No commits in common. "65d51f13aab640ec3e636968bc1677856ed4db82" and "0363b1eebc6f14c5610ddc14b8fbca318ef21829" have entirely different histories.
65d51f13aa
...
0363b1eebc
Binary file not shown.
Before Width: | Height: | Size: 53 KiB |
@ -2,16 +2,10 @@
|
|||||||
#define _LORA_NET_H_
|
#define _LORA_NET_H_
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#ifdef LORA_FEATURE_ENABLED
|
|
||||||
#include <LoRa_E220.h>
|
#include <LoRa_E220.h>
|
||||||
#elif defined(FEATURE_ENABLE_UARTLORA)
|
|
||||||
#include <SoftwareSerial.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// local includes
|
// local includes
|
||||||
#include "lora_messages.h"
|
#include "lora_messages.h"
|
||||||
#include "debugger.h"
|
|
||||||
#include "defaults.h"
|
#include "defaults.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
@ -14,9 +14,6 @@
|
|||||||
#error "You must define an WIFI_AP_PASSWORD for Standalone AP-Mode"
|
#error "You must define an WIFI_AP_PASSWORD for Standalone AP-Mode"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(FEATURE_ENABLE_UARTLORA) && defined(FEATURE_ENABLE_LORA)
|
|
||||||
#error "You cannot enable LoRa and UART-Protocol at the same time!"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef FEATURE_ENABLE_WIFI_CLIENT
|
#ifdef FEATURE_ENABLE_WIFI_CLIENT
|
||||||
#ifndef WIFI_CLIENT_PASSWORD
|
#ifndef WIFI_CLIENT_PASSWORD
|
||||||
|
@ -22,7 +22,7 @@ upload_speed = 921600
|
|||||||
;upload_port = 10.0.1.48
|
;upload_port = 10.0.1.48
|
||||||
;upload_protocol = espota
|
;upload_protocol = espota
|
||||||
;upload_flags =
|
;upload_flags =
|
||||||
; --auth=${wifi_cred.ota_password}
|
; --auth=${wifi_cred.admin_password}
|
||||||
|
|
||||||
build_flags=
|
build_flags=
|
||||||
!python git_rev_macro.py
|
!python git_rev_macro.py
|
||||||
@ -30,9 +30,8 @@ build_flags=
|
|||||||
;-DFEATURE_ENABLE_WIFI_CLIENT
|
;-DFEATURE_ENABLE_WIFI_CLIENT
|
||||||
;-DFEATURE_ENABLE_LORA
|
;-DFEATURE_ENABLE_LORA
|
||||||
;-DCAPTIVE
|
;-DCAPTIVE
|
||||||
-DFEATURE_ENABLE_UARTLORA
|
|
||||||
-DWIFI_AP_IP_GW=10,0,0,1
|
-DWIFI_AP_IP_GW=10,0,0,1
|
||||||
-DADMIN_PASSWORD=${wifi_cred.ota_password}
|
-DADMIN_PASSWORD=${wifi_cred.admin_password}
|
||||||
-DWIFI_CLIENT_SSID=${wifi_cred.wifi_client_ssid}
|
-DWIFI_CLIENT_SSID=${wifi_cred.wifi_client_ssid}
|
||||||
-DWIFI_CLIENT_PASSWORD=${wifi_cred.wifi_client_password}
|
-DWIFI_CLIENT_PASSWORD=${wifi_cred.wifi_client_password}
|
||||||
-DWIFI_AP_SSID=${wifi_cred.wifi_ap_ssid}
|
-DWIFI_AP_SSID=${wifi_cred.wifi_ap_ssid}
|
||||||
|
@ -1,19 +1,13 @@
|
|||||||
#include "lora_net.h"
|
#include "lora_net.h"
|
||||||
|
|
||||||
#ifdef FEATURE_ENABLE_LORA
|
|
||||||
LoRa_E220 e220ttl(GPIO_LORA_TX, GPIO_LORA_RX, GPIO_LORA_AUX, 3, 4); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
LoRa_E220 e220ttl(GPIO_LORA_TX, GPIO_LORA_RX, GPIO_LORA_AUX, 3, 4); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||||
|
|
||||||
void printParameters(struct Configuration configuration);
|
void printParameters(struct Configuration configuration);
|
||||||
void printModuleInformation(struct ModuleInformation moduleInformation);
|
void printModuleInformation(struct ModuleInformation moduleInformation);
|
||||||
#elif defined(FEATURE_ENABLE_UARTLORA)
|
|
||||||
SoftwareSerial SerialLoRa(GPIO_LORA_RX, GPIO_LORA_TX); // RX, TX
|
|
||||||
void Parse_LoRa_UartCommand(char input[], int size);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool InitLoRa(void (*MPinHelper)(int, int))
|
bool InitLoRa(void (*MPinHelper)(int, int))
|
||||||
{
|
{
|
||||||
bool returnval = false;
|
bool returnval;
|
||||||
|
|
||||||
#ifdef FEATURE_ENABLE_LORA
|
|
||||||
|
|
||||||
e220ttl.setMPins = MPinHelper;
|
e220ttl.setMPins = MPinHelper;
|
||||||
returnval = e220ttl.begin();
|
returnval = e220ttl.begin();
|
||||||
@ -66,15 +60,11 @@ bool InitLoRa(void (*MPinHelper)(int, int))
|
|||||||
{
|
{
|
||||||
MaintainDTC(DTC_NO_LORA_FOUND, DTC_WARN, true);
|
MaintainDTC(DTC_NO_LORA_FOUND, DTC_WARN, true);
|
||||||
}
|
}
|
||||||
#elif defined(FEATURE_ENABLE_UARTLORA)
|
|
||||||
// LORA UART Stuff here
|
|
||||||
#endif
|
|
||||||
return returnval;
|
return returnval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoRa_Process()
|
void LoRa_Process()
|
||||||
{
|
{
|
||||||
#ifdef FEATURE_ENABLE_LORA
|
|
||||||
if (e220ttl.available() > 1)
|
if (e220ttl.available() > 1)
|
||||||
{
|
{
|
||||||
ResponseContainer rc = e220ttl.receiveMessageRSSI();
|
ResponseContainer rc = e220ttl.receiveMessageRSSI();
|
||||||
@ -92,50 +82,10 @@ void LoRa_Process()
|
|||||||
Serial.println(rc.rssi, DEC);
|
Serial.println(rc.rssi, DEC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined(FEATURE_ENABLE_UARTLORA)
|
|
||||||
|
|
||||||
char packageInput[16];
|
|
||||||
bool packageRecieved = false;
|
|
||||||
unsigned int bufferPtr = 0;
|
|
||||||
|
|
||||||
if (SerialLoRa.available() && packageRecieved == false)
|
|
||||||
{
|
|
||||||
while (bufferPtr < sizeof(packageInput))
|
|
||||||
{
|
|
||||||
packageInput[bufferPtr] = SerialLoRa.read();
|
|
||||||
if (packageInput[bufferPtr] == '\n')
|
|
||||||
{
|
|
||||||
packageInput[bufferPtr] = 0; // terminate String
|
|
||||||
packageRecieved = true;
|
|
||||||
Debug_pushMessage("Got LoRa UART: %s\n", packageInput);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if ((packageInput[bufferPtr] >= 0x30) || (packageInput[bufferPtr] <= 0x5A)) // only accept Numbers, UpperCase-Letters and some special chars
|
|
||||||
{
|
|
||||||
if (bufferPtr < sizeof(packageInput) - 1)
|
|
||||||
{
|
|
||||||
bufferPtr++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
packageInput[bufferPtr] = 0; // terminate String, bc Buffer is full (package to long)
|
|
||||||
packageRecieved = true; // send it anyway to the parser
|
|
||||||
Debug_pushMessage("Got LoRa UART: %s\n", packageInput);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (packageRecieved)
|
|
||||||
Parse_LoRa_UartCommand(packageInput, bufferPtr);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendStatus_LoRa()
|
void sendStatus_LoRa()
|
||||||
{
|
{
|
||||||
#ifdef FEATURE_ENABLE_LORA
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
MessageType_t type = "STATUS";
|
MessageType_t type = "STATUS";
|
||||||
@ -151,13 +101,8 @@ void sendStatus_LoRa()
|
|||||||
|
|
||||||
ResponseStatus rs = e220ttl.sendFixedMessage(0xFF, 0xFF, 23, (byte *)&sendStatus, sizeof(sendStatus));
|
ResponseStatus rs = e220ttl.sendFixedMessage(0xFF, 0xFF, 23, (byte *)&sendStatus, sizeof(sendStatus));
|
||||||
Serial.println(rs.getResponseDescription());
|
Serial.println(rs.getResponseDescription());
|
||||||
#elif defined(FEATURE_ENABLE_UARTLORA)
|
|
||||||
// LORA UART SEND STUFF HERE
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FEATURE_ENABLE_LORA
|
|
||||||
|
|
||||||
void printParameters(struct Configuration configuration)
|
void printParameters(struct Configuration configuration)
|
||||||
{
|
{
|
||||||
Serial.println("----------------------------------------");
|
Serial.println("----------------------------------------");
|
||||||
@ -223,27 +168,4 @@ void printParameters(struct Configuration configuration)
|
|||||||
Serial.println(configuration.TRANSMISSION_MODE.getFixedTransmissionDescription());
|
Serial.println(configuration.TRANSMISSION_MODE.getFixedTransmissionDescription());
|
||||||
|
|
||||||
Serial.println("----------------------------------------");
|
Serial.println("----------------------------------------");
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef FEATURE_ENABLE_UARTLORA
|
|
||||||
void Parse_LoRa_UartCommand(char input[], int size)
|
|
||||||
{
|
|
||||||
|
|
||||||
char delimiter[] = ";";
|
|
||||||
char *ptr;
|
|
||||||
char command[8];
|
|
||||||
char value[8];
|
|
||||||
|
|
||||||
ptr = strtok(input, delimiter);
|
|
||||||
|
|
||||||
while (ptr != NULL)
|
|
||||||
{
|
|
||||||
strncpy(command, ptr, sizeof(command));
|
|
||||||
ptr = strtok(NULL, delimiter);
|
|
||||||
strncpy(value, ptr, sizeof(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
Debug_pushMessage("Parsed LoRa UART Command: %s Value: %s\n", command, value);
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -19,7 +19,7 @@
|
|||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "dtc.h"
|
#include "dtc.h"
|
||||||
#include "debugger.h"
|
#include "debugger.h"
|
||||||
#if defined(FEATURE_ENABLE_LORA) || defined(FEATURE_ENABLE_UARTLORA)
|
#ifdef FEATURE_ENABLE_LORA
|
||||||
#include "lora_net.h"
|
#include "lora_net.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ void OverrideDisplay(uint32_t time, const char *message1, const char *message2,
|
|||||||
void initGlobals();
|
void initGlobals();
|
||||||
void maintainSysStat();
|
void maintainSysStat();
|
||||||
|
|
||||||
#if defined(FEATURE_ENABLE_UARTLORA) || defined(FEATURE_ENABLE_LORA)
|
#ifdef FEATURE_ENABLE_LORA
|
||||||
void setMPins_Helper(int pin, int status);
|
void setMPins_Helper(int pin, int status);
|
||||||
void tmrCallback_StatusSender();
|
void tmrCallback_StatusSender();
|
||||||
Ticker tmrStatusSender(tmrCallback_StatusSender, 30000, 0, MILLIS);
|
Ticker tmrStatusSender(tmrCallback_StatusSender, 30000, 0, MILLIS);
|
||||||
@ -72,7 +72,7 @@ Ticker tmrWiFiMaintainConnection(tmrCallback_WiFiMaintainConnection, 1000, 0, MI
|
|||||||
uint32_t DisplayOverrideFlag = 0;
|
uint32_t DisplayOverrideFlag = 0;
|
||||||
char DisplayOverrideValue[3][5] = {0};
|
char DisplayOverrideValue[3][5] = {0};
|
||||||
|
|
||||||
#if defined(FEATURE_ENABLE_UARTLORA) || defined(FEATURE_ENABLE_LORA)
|
#ifdef FEATURE_ENABLE_LORA
|
||||||
void setMPins_Helper(int pin, int status)
|
void setMPins_Helper(int pin, int status)
|
||||||
{
|
{
|
||||||
i2c_io.write(pin, status);
|
i2c_io.write(pin, status);
|
||||||
@ -119,7 +119,7 @@ void setup()
|
|||||||
Serial.print("INA219 not Initialized\n");
|
Serial.print("INA219 not Initialized\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(FEATURE_ENABLE_UARTLORA) || defined(FEATURE_ENABLE_LORA)
|
#ifdef FEATURE_ENABLE_LORA
|
||||||
if (InitLoRa(&setMPins_Helper))
|
if (InitLoRa(&setMPins_Helper))
|
||||||
{
|
{
|
||||||
Serial.print("Initialized LoRa_Transceiver\n");
|
Serial.print("Initialized LoRa_Transceiver\n");
|
||||||
@ -229,9 +229,9 @@ void loop()
|
|||||||
DTC_Process();
|
DTC_Process();
|
||||||
Debug_Process();
|
Debug_Process();
|
||||||
|
|
||||||
#if defined(FEATURE_ENABLE_LORA) || defined(FEATURE_ENABLE_UARTLORA)
|
#ifdef FEATURE_ENABLE_LORA
|
||||||
LoRa_Process();
|
|
||||||
tmrStatusSender.update();
|
tmrStatusSender.update();
|
||||||
|
LoRa_Process();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CAPTIVE
|
#ifdef CAPTIVE
|
||||||
@ -380,7 +380,7 @@ void tmrCallback_InputGetter()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(FEATURE_ENABLE_LORA) || defined(FEATURE_ENABLE_UARTLORA)
|
#ifdef FEATURE_ENABLE_LORA
|
||||||
void tmrCallback_StatusSender()
|
void tmrCallback_StatusSender()
|
||||||
{
|
{
|
||||||
sendStatus_LoRa();
|
sendStatus_LoRa();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[wifi_cred]
|
[wifi_cred]
|
||||||
wifi_ap_ssid = wifi-ap-ssid
|
wifi_ap_ssid = wifi-ap-ssid
|
||||||
wifi_ap_password = wifiappass
|
wifi_ap_password = wifiappass
|
||||||
wifi_client_ssid = wifi-ssid
|
wifi_ssid = wifi-ssid
|
||||||
wifi_client_password = wifi-pass
|
wifi_password = wifi-pass
|
||||||
ota_password = ota-password
|
admin_password = ota-password
|
Loading…
x
Reference in New Issue
Block a user