Skip to content

Commit

Permalink
[LoRaWAN] Add datarate into event structure (#885)
Browse files Browse the repository at this point in the history
* [LoRaWAN] Move TX power logic to function

* Update keywords

* [LoRaWAN] Add datarate into event structure
  • Loading branch information
StevenCellist authored Nov 27, 2023
1 parent b2b73ab commit b6f6718
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ void loop() {
Serial.println(event.confirmed);
Serial.print(F("[LoRaWAN] Confirming:\t"));
Serial.println(event.confirming);
Serial.print(F("[LoRaWAN] Datarate:\t"));
Serial.print(event.datarate);
Serial.print(F("[LoRaWAN] Frequency:\t"));
Serial.print(event.freq, 3);
Serial.println(F(" MHz"));
Expand Down
2 changes: 2 additions & 0 deletions src/protocols/LoRaWAN/LoRaWAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,7 @@ int16_t LoRaWANNode::uplink(uint8_t* data, size_t len, uint8_t port, bool isConf
event->dir = RADIOLIB_LORAWAN_CHANNEL_DIR_UPLINK;
event->confirmed = isConfirmed;
event->confirming = isConfirmingDown;
event->datarate = this->dataRates[RADIOLIB_LORAWAN_CHANNEL_DIR_UPLINK];
event->freq = currentChannels[event->dir].freq;
event->power = this->txPwrCur;
event->fcnt = this->fcntUp;
Expand Down Expand Up @@ -1262,6 +1263,7 @@ int16_t LoRaWANNode::downlink(uint8_t* data, size_t* len, LoRaWANEvent_t* event)
event->dir = RADIOLIB_LORAWAN_CHANNEL_DIR_DOWNLINK;
event->confirmed = isConfirmedDown;
event->confirming = isConfirmingUp;
event->datarate = this->dataRates[RADIOLIB_LORAWAN_CHANNEL_DIR_DOWNLINK];
event->freq = currentChannels[event->dir].freq;
event->power = this->txPwrCur;
event->fcnt = isAppDownlink ? this->aFcntDown : this->nFcntDown;
Expand Down
3 changes: 3 additions & 0 deletions src/protocols/LoRaWAN/LoRaWAN.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ struct LoRaWANEvent_t {
/*! \brief Whether the event is confirming a previous request
(e.g., server downlink reply to confirmed uplink sent by user application)*/
bool confirming;

/*! \brief Datarate */
uint8_t datarate;

/*! \brief Frequency in MHz */
float freq;
Expand Down

0 comments on commit b6f6718

Please sign in to comment.