bugfix message queuing to LMIC while LMIC is busy

This commit is contained in:
Verkehrsrot committed 2019-08-28 10:48:39 +02:00
1 parent bbca15a76e
commit 829ab0ea05
6 files changed
+27 -25

No files matched your search

+13 -16
View File
@@ -391,21 +391,16 @@ void switch_lora(uint8_t sf, uint8_t tx) {
void lora_send(osjob_t *job) {
MessageBuffer_t SendBuffer;
// Check if there is a pending TX/RX job running, if yes don't eat data
// since it cannot be sent right now
if ((LMIC.opmode & (OP_JOINING | OP_REJOIN | OP_TXDATA | OP_POLL)) != 0) {
// waiting for LoRa getting ready
} else {
if (xQueueReceive(LoraSendQueue, &SendBuffer, (TickType_t)0) == pdTRUE) {
// SendBuffer now filled with next payload from queue
if (!LMIC_setTxData2(SendBuffer.MessagePort, SendBuffer.Message,
SendBuffer.MessageSize, (cfg.countermode & 0x02))) {
ESP_LOGI(TAG, "%d byte(s) sent to LoRa", SendBuffer.MessageSize);
} else {
ESP_LOGE(TAG, "could not send %d byte(s) to LoRa",
SendBuffer.MessageSize);
}
// sprintf(display_line7, "PACKET QUEUED");
if (xQueueReceive(LoraSendQueue, &SendBuffer, (TickType_t)0) == pdTRUE) {
// SendBuffer now filled with next payload from queue
if (LMIC_setTxData2(SendBuffer.MessagePort, SendBuffer.Message,
SendBuffer.MessageSize,
(cfg.countermode & 0x02)) == 0) {
ESP_LOGI(TAG, "%d byte(s) sent to LoRa", SendBuffer.MessageSize);
} else {
lora_enqueuedata(&SendBuffer);
// ESP_LOGE(TAG, "could not send %d byte(s) to LoRa, rescheduled",
// SendBuffer.MessageSize);
}
}
// reschedule job every 0,5 - 1 sec. including a bit of random to prevent
@@ -441,10 +436,12 @@ esp_err_t lora_stack_init() {
return ESP_OK; // continue main program
}
void lora_enqueuedata(MessageBuffer_t *message, sendprio_t prio) {
void lora_enqueuedata(MessageBuffer_t *message) {
// enqueue message in LORA send queue
BaseType_t ret;
MessageBuffer_t DummyBuffer;
sendprio_t prio = message->MessagePrio;
switch (prio) {
case prio_high:
// clear space in queue if full, then fallthrough to normal
+5 -3
View File
@@ -10,9 +10,11 @@ void sendcycle() {
// put data to send in RTos Queues used for transmit over channels Lora and SPI
void SendPayload(uint8_t port, sendprio_t prio) {
MessageBuffer_t SendBuffer; // contains MessageSize, MessagePort, Message[]
MessageBuffer_t SendBuffer; // contains MessageSize, MessagePort, MessagePrio, Message[]
SendBuffer.MessageSize = payload.getSize();
SendBuffer.MessagePrio = prio;
switch (PAYLOAD_ENCODER) {
case 1: // plain -> no mapping
case 2: // packed -> no mapping
@@ -42,10 +44,10 @@ void SendPayload(uint8_t port, sendprio_t prio) {
// enqueue message in device's send queues
#if (HAS_LORA)
lora_enqueuedata(&SendBuffer, prio);
lora_enqueuedata(&SendBuffer);
#endif
#ifdef HAS_SPI
spi_enqueuedata(&SendBuffer, prio);
spi_enqueuedata(&SendBuffer);
#endif
} // SendPayload
+3 -1
View File
@@ -147,10 +147,12 @@ esp_err_t spi_init() {
return ret;
}
void spi_enqueuedata(MessageBuffer_t *message, sendprio_t prio) {
void spi_enqueuedata(MessageBuffer_t *message) {
// enqueue message in SPI send queue
BaseType_t ret;
MessageBuffer_t DummyBuffer;
sendprio_t prio = message->MessagePrio;
switch (prio) {
case prio_high:
// clear space in queue if full, then fallthrough to normal