link check disabled; SendBuffer no more global (does not solve mem leak)
This commit is contained in:
parent
5fbcd0aebb
commit
d704acc3e5
@ -114,7 +114,7 @@ void refreshtheDisplay() {
|
|||||||
// update Battery status (line 2)
|
// update Battery status (line 2)
|
||||||
#ifdef HAS_BATTERY_PROBE
|
#ifdef HAS_BATTERY_PROBE
|
||||||
u8x8.setCursor(0, 2);
|
u8x8.setCursor(0, 2);
|
||||||
u8x8.printf("B:%.1fV", batt_voltage / 1000.0);
|
u8x8.printf(batt_voltage > 4000 ? "B:USB " : "B:%.1fV", batt_voltage / 1000.0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// update GPS status (line 2)
|
// update GPS status (line 2)
|
||||||
|
@ -37,6 +37,13 @@ typedef struct {
|
|||||||
char version[10]; // Firmware version
|
char version[10]; // Firmware version
|
||||||
} configData_t;
|
} configData_t;
|
||||||
|
|
||||||
|
// Struct holding payload for data send queue
|
||||||
|
typedef struct {
|
||||||
|
uint8_t MessageSize;
|
||||||
|
uint8_t MessagePort;
|
||||||
|
uint8_t Message[PAYLOAD_BUFFER_SIZE];
|
||||||
|
} MessageBuffer_t;
|
||||||
|
|
||||||
// global variables
|
// global variables
|
||||||
extern configData_t cfg; // current device configuration
|
extern configData_t cfg; // current device configuration
|
||||||
extern char display_line6[], display_line7[]; // screen buffers
|
extern char display_line6[], display_line7[]; // screen buffers
|
||||||
|
@ -172,13 +172,13 @@ void onEvent(ev_t ev) {
|
|||||||
strcpy_P(buff, PSTR("JOINED"));
|
strcpy_P(buff, PSTR("JOINED"));
|
||||||
sprintf(display_line6, " "); // clear previous lmic status
|
sprintf(display_line6, " "); // clear previous lmic status
|
||||||
|
|
||||||
// set cyclic lmic link check to off because is not supported by ttn
|
|
||||||
// (but enabled by lmic after join)
|
|
||||||
LMIC_setLinkCheckMode(0);
|
|
||||||
|
|
||||||
// set data rate adaptation according to saved setting
|
// set data rate adaptation according to saved setting
|
||||||
LMIC_setAdrMode(cfg.adrmode);
|
LMIC_setAdrMode(cfg.adrmode);
|
||||||
|
|
||||||
|
// set cyclic lmic link check to off if no ADR because is not supported by
|
||||||
|
// ttn (but enabled by lmic after join)
|
||||||
|
LMIC_setLinkCheckMode(cfg.adrmode);
|
||||||
|
|
||||||
// Set data rate and transmit power (note: txpower seems to be ignored by
|
// Set data rate and transmit power (note: txpower seems to be ignored by
|
||||||
// the library)
|
// the library)
|
||||||
switch_lora(cfg.lorasf, cfg.txpower);
|
switch_lora(cfg.lorasf, cfg.txpower);
|
||||||
|
@ -109,8 +109,6 @@ void setup() {
|
|||||||
|
|
||||||
// initialize send queues for transmit channels
|
// initialize send queues for transmit channels
|
||||||
#ifdef HAS_LORA
|
#ifdef HAS_LORA
|
||||||
//--> LoraSendQueue = xQueueCreate(SEND_QUEUE_SIZE, sizeof(struct SendBuffer
|
|
||||||
//*));
|
|
||||||
LoraSendQueue = xQueueCreate(SEND_QUEUE_SIZE, sizeof(MessageBuffer_t));
|
LoraSendQueue = xQueueCreate(SEND_QUEUE_SIZE, sizeof(MessageBuffer_t));
|
||||||
if (LoraSendQueue == 0) {
|
if (LoraSendQueue == 0) {
|
||||||
ESP_LOGE(TAG, "Could not create LORA send queue. Aborting.");
|
ESP_LOGE(TAG, "Could not create LORA send queue. Aborting.");
|
||||||
@ -120,8 +118,6 @@ void setup() {
|
|||||||
SEND_QUEUE_SIZE * PAYLOAD_BUFFER_SIZE);
|
SEND_QUEUE_SIZE * PAYLOAD_BUFFER_SIZE);
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAS_SPI
|
#ifdef HAS_SPI
|
||||||
//--> SPISendQueue = xQueueCreate(SEND_QUEUE_SIZE, sizeof(struct SendBuffer
|
|
||||||
//*));
|
|
||||||
SPISendQueue = xQueueCreate(SEND_QUEUE_SIZE, sizeof(MessageBuffer_t));
|
SPISendQueue = xQueueCreate(SEND_QUEUE_SIZE, sizeof(MessageBuffer_t));
|
||||||
if (SPISendQueue == 0) {
|
if (SPISendQueue == 0) {
|
||||||
ESP_LOGE(TAG, "Could not create SPI send queue. Aborting.");
|
ESP_LOGE(TAG, "Could not create SPI send queue. Aborting.");
|
||||||
|
@ -1,26 +1,31 @@
|
|||||||
// Basic Config
|
// Basic Config
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
MessageBuffer_t SendBuffer;
|
|
||||||
|
|
||||||
// put data to send in RTos Queues used for transmit over channels Lora and SPI
|
// put data to send in RTos Queues used for transmit over channels Lora and SPI
|
||||||
void SendData(uint8_t port) {
|
void SendData(uint8_t port) {
|
||||||
|
|
||||||
|
int m1 = 0, m2 = 0;
|
||||||
|
m1 = ESP.getFreeHeap();
|
||||||
|
|
||||||
|
MessageBuffer_t SendBuffer;
|
||||||
|
|
||||||
SendBuffer.MessageSize = payload.getSize();
|
SendBuffer.MessageSize = payload.getSize();
|
||||||
SendBuffer.MessagePort = PAYLOAD_ENCODER <= 2
|
SendBuffer.MessagePort = PAYLOAD_ENCODER <= 2
|
||||||
? port
|
? port
|
||||||
: (PAYLOAD_ENCODER == 4 ? LPP2PORT : LPP1PORT);
|
: (PAYLOAD_ENCODER == 4 ? LPP2PORT : LPP1PORT);
|
||||||
memcpy(SendBuffer.Message, payload.getBuffer(), payload.getSize());
|
memcpy(SendBuffer.Message, payload.getBuffer(), payload.getSize());
|
||||||
|
|
||||||
// enqueue message in LoRa send queue
|
// enqueue message in LoRa send queue
|
||||||
#ifdef HAS_LORA
|
#ifdef HAS_LORA
|
||||||
if (xQueueSendToBack(LoraSendQueue, (void *)&SendBuffer, (TickType_t)0) == pdTRUE)
|
if (xQueueSendToBack(LoraSendQueue, (void *)&SendBuffer, (TickType_t)0) ==
|
||||||
|
pdTRUE)
|
||||||
ESP_LOGI(TAG, "%d bytes enqueued to send on LoRa", payload.getSize());
|
ESP_LOGI(TAG, "%d bytes enqueued to send on LoRa", payload.getSize());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// enqueue message in SPI send queue
|
// enqueue message in SPI send queue
|
||||||
#ifdef HAS_SPI
|
#ifdef HAS_SPI
|
||||||
if (xQueueSendToBack(SPISendQueue, (void *)&SendBuffer, (TickType_t)0) == pdTRUE)
|
if (xQueueSendToBack(SPISendQueue, (void *)&SendBuffer, (TickType_t)0) ==
|
||||||
|
pdTRUE)
|
||||||
ESP_LOGI(TAG, "%d bytes enqueued to send on SPI", payload.getSize());
|
ESP_LOGI(TAG, "%d bytes enqueued to send on SPI", payload.getSize());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -31,10 +36,17 @@ void SendData(uint8_t port) {
|
|||||||
ESP_LOGI(TAG, "Counter cleared");
|
ESP_LOGI(TAG, "Counter cleared");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m2 = ESP.getFreeHeap();
|
||||||
|
if (m2 - m1)
|
||||||
|
ESP_LOGI(TAG, "SendData %d bytes", m2 - m1);
|
||||||
|
|
||||||
} // SendData
|
} // SendData
|
||||||
|
|
||||||
// cyclic called function to prepare payload to send
|
// cyclic called function to prepare payload to send
|
||||||
void sendPayload() {
|
void sendPayload() {
|
||||||
|
|
||||||
|
int m1 = 0, m2 = 0;
|
||||||
|
m1 = ESP.getFreeHeap();
|
||||||
if (SendCycleTimerIRQ) {
|
if (SendCycleTimerIRQ) {
|
||||||
portENTER_CRITICAL(&timerMux);
|
portENTER_CRITICAL(&timerMux);
|
||||||
SendCycleTimerIRQ = 0;
|
SendCycleTimerIRQ = 0;
|
||||||
@ -65,6 +77,11 @@ void sendPayload() {
|
|||||||
#endif
|
#endif
|
||||||
SendData(COUNTERPORT);
|
SendData(COUNTERPORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m2 = ESP.getFreeHeap();
|
||||||
|
if (m2 - m1)
|
||||||
|
ESP_LOGI(TAG, "sendpayload %d bytes", m2 - m1);
|
||||||
|
|
||||||
} // sendpayload()
|
} // sendpayload()
|
||||||
|
|
||||||
// interrupt handler used for payload send cycle timer
|
// interrupt handler used for payload send cycle timer
|
||||||
@ -77,27 +94,36 @@ void IRAM_ATTR SendCycleIRQ() {
|
|||||||
// cyclic called function to eat data from RTos send queues and transmit it
|
// cyclic called function to eat data from RTos send queues and transmit it
|
||||||
void processSendBuffer() {
|
void processSendBuffer() {
|
||||||
|
|
||||||
|
int m1 = 0, m2 = 0;
|
||||||
|
m1 = ESP.getFreeHeap();
|
||||||
|
|
||||||
|
MessageBuffer_t SendBuffer;
|
||||||
|
|
||||||
#ifdef HAS_LORA
|
#ifdef HAS_LORA
|
||||||
// Check if there is a pending TX/RX job running
|
// Check if there is a pending TX/RX job running
|
||||||
if ((LMIC.opmode & (OP_JOINING | OP_REJOIN | OP_TXDATA | OP_POLL)) != 0) {
|
if ((LMIC.opmode & (OP_JOINING | OP_REJOIN | OP_TXDATA | OP_POLL)) != 0) {
|
||||||
// LoRa Busy -> don't eat data from queue, since it cannot be sent
|
// LoRa Busy -> don't eat data from queue, since it cannot be sent
|
||||||
} else {
|
} else {
|
||||||
if (xQueueReceive(LoraSendQueue, &(SendBuffer), (TickType_t)0) == pdTRUE) {
|
if (xQueueReceive(LoraSendQueue, &SendBuffer, (TickType_t)0) == pdTRUE) {
|
||||||
// SendBuffer gets struct MessageBuffer with next payload from queue
|
// SendBuffer gets struct MessageBuffer with next payload from queue
|
||||||
LMIC_setTxData2(SendBuffer.MessagePort, SendBuffer.Message,
|
LMIC_setTxData2(SendBuffer.MessagePort, SendBuffer.Message,
|
||||||
SendBuffer.MessageSize, (cfg.countermode & 0x02));
|
SendBuffer.MessageSize, (cfg.countermode & 0x02));
|
||||||
ESP_LOGI(TAG, "%d bytes sent to LORA", SendBuffer.MessageSize);
|
ESP_LOGI(TAG, "%d bytes sent to LoRa", SendBuffer.MessageSize);
|
||||||
sprintf(display_line7, "PACKET QUEUED");
|
sprintf(display_line7, "PACKET QUEUED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAS_SPI
|
#ifdef HAS_SPI
|
||||||
if (xQueueReceive(SPISendQueue, &(SendBuffer), (TickType_t)0) == pdTRUE) {
|
if (xQueueReceive(SPISendQueue, &SendBuffer, (TickType_t)0) == pdTRUE) {
|
||||||
ESP_LOGI(TAG, "%d bytes sent to SPI", SendBuffer.MessageSize);
|
ESP_LOGI(TAG, "%d bytes sent to SPI", SendBuffer.MessageSize);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
m2 = ESP.getFreeHeap();
|
||||||
|
if (m2 - m1)
|
||||||
|
ESP_LOGI(TAG, "processSendBuffer %d bytes", m2 - m1);
|
||||||
|
|
||||||
} // processSendBuffer
|
} // processSendBuffer
|
||||||
|
|
||||||
void flushQueues() {
|
void flushQueues() {
|
||||||
|
@ -1,13 +1,6 @@
|
|||||||
#ifndef _SENDDATA_H
|
#ifndef _SENDDATA_H
|
||||||
#define _SENDDATA_H
|
#define _SENDDATA_H
|
||||||
|
|
||||||
// Struct holding payload for data send queue
|
|
||||||
typedef struct {
|
|
||||||
uint8_t MessageSize;
|
|
||||||
uint8_t MessagePort;
|
|
||||||
uint8_t Message[PAYLOAD_BUFFER_SIZE];
|
|
||||||
} MessageBuffer_t;
|
|
||||||
|
|
||||||
void SendData(uint8_t port);
|
void SendData(uint8_t port);
|
||||||
void sendPayload(void);
|
void sendPayload(void);
|
||||||
void SendCycleIRQ(void);
|
void SendCycleIRQ(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user