21#include "AustralisConfig.h"
24#include "stm32f439xx.h"
27#include "event_groups.h"
28#include "message_buffer.h"
43static TaskHandle_t vLoRaTransmitHandle;
44static TaskHandle_t vLoRaReceiveHandle;
52void LoRa_setTransceiver(
LoRa_t *transceiver_) {
53 transceiver = transceiver_;
55LoRa_t *LoRa_getTransceiver() {
return transceiver; }
59void LoRa_setRfToggle(
GPIOpin_t *rfToggle_) {
73void vLoRaTransmit(
void *argument) {
74 const TickType_t blockTime = portMAX_DELAY;
77 vLoRaTransmitHandle = xTaskGetCurrentTaskHandle();
81 if (transceiver == NULL)
85 BaseType_t result = WAIT_COMMENT(
86 lora.public.commentInbox,
92 if (result == pdTRUE) {
96 rfToggle->reset(rfToggle);
99 transceiver->transmit(transceiver, txData.data, txData.length);
102 xTaskNotifyWaitIndexed(1, 0, 0, NULL, blockTime);
106 rfToggle->set(rfToggle);
109 transceiver->startReceive(transceiver);
125void vLoRaReceive(
void *argument) {
126 const TickType_t blockTime = portMAX_DELAY;
130 vLoRaReceiveHandle = xTaskGetCurrentTaskHandle();
134 if (transceiver == NULL)
138 xTaskNotifyWaitIndexed(1, 0, 0, NULL, blockTime);
141 rxData.length = transceiver->readReceive(transceiver, rxData.data, LORA_MSG_LENGTH);
157void pubLoraInterrupt(
void) {
158 BaseType_t xHigherPriorityTaskWoken = pdFALSE;
161 if (transceiver == NULL)
164 TaskHandle_t activeHandle = NULL;
167 if (transceiver->currentMode == LORA_MODE_TX) {
168 activeHandle = vLoRaTransmitHandle;
169 }
else if (transceiver->currentMode == LORA_MODE_RX) {
170 activeHandle = vLoRaReceiveHandle;
174 if (activeHandle == NULL)
178 xTaskNotifyIndexedFromISR(activeHandle, 1, 0, eNoAction, &xHigherPriorityTaskWoken);
179 portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
185 transceiver->clearIRQ(transceiver, 0xFF);
bool Topic_publish(PrivateTopic *topic, uint8_t *article)
Publish an "article" to all discovered subscribers of a topic.
#define CREATE_TOPIC(topic, commentInboxSize, messageSize)
Macro to define and initialize a topic instance.
Internal representation of a Topic instance.
Struct definition for a GPIO pin.
Defines the API for LoRa communication.
#define CREATE_MESSAGE(name, length_)
Macro to define, on the stack, a named message struct.
Public representation of a Topic.