[LoRaWAN] Add simple receive methods
This commit is contained in:
parent
ab67097587
commit
0d75bfae02
2 changed files with 46 additions and 0 deletions
|
@ -1317,6 +1317,20 @@ int16_t LoRaWANNode::downlink(String& str, LoRaWANEvent_t* event) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int16_t LoRaWANNode::downlink(LoRaWANEvent_t* event) {
|
||||||
|
int16_t state = RADIOLIB_ERR_NONE;
|
||||||
|
|
||||||
|
// build a temporary buffer
|
||||||
|
// LoRaWAN downlinks can have 250 bytes at most with 1 extra byte for NULL
|
||||||
|
size_t length = 0;
|
||||||
|
uint8_t data[251];
|
||||||
|
|
||||||
|
// wait for downlink
|
||||||
|
state = this->downlink(data, &length, event);
|
||||||
|
|
||||||
|
return(state);
|
||||||
|
}
|
||||||
|
|
||||||
int16_t LoRaWANNode::downlink(uint8_t* data, size_t* len, LoRaWANEvent_t* event) {
|
int16_t LoRaWANNode::downlink(uint8_t* data, size_t* len, LoRaWANEvent_t* event) {
|
||||||
// handle Rx1 and Rx2 windows - returns RADIOLIB_ERR_NONE if a downlink is received
|
// handle Rx1 and Rx2 windows - returns RADIOLIB_ERR_NONE if a downlink is received
|
||||||
int16_t state = downlinkCommon();
|
int16_t state = downlinkCommon();
|
||||||
|
@ -1650,6 +1664,16 @@ int16_t LoRaWANNode::sendReceive(String& strUp, uint8_t port, String& strDown, b
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int16_t LoRaWANNode::sendReceive(uint8_t* dataUp, size_t lenUp, uint8_t port, bool isConfirmed, LoRaWANEvent_t* eventUp, LoRaWANEvent_t* eventDown) {
|
||||||
|
// send the uplink
|
||||||
|
int16_t state = this->uplink(dataUp, lenUp, port, isConfirmed, eventUp);
|
||||||
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
|
// wait for the downlink
|
||||||
|
state = this->downlink(eventDown);
|
||||||
|
return(state);
|
||||||
|
}
|
||||||
|
|
||||||
int16_t LoRaWANNode::sendReceive(const char* strUp, uint8_t port, uint8_t* dataDown, size_t* lenDown, bool isConfirmed, LoRaWANEvent_t* eventUp, LoRaWANEvent_t* eventDown) {
|
int16_t LoRaWANNode::sendReceive(const char* strUp, uint8_t port, uint8_t* dataDown, size_t* lenDown, bool isConfirmed, LoRaWANEvent_t* eventUp, LoRaWANEvent_t* eventDown) {
|
||||||
// send the uplink
|
// send the uplink
|
||||||
int16_t state = this->uplink(strUp, port, isConfirmed, eventUp);
|
int16_t state = this->uplink(strUp, port, isConfirmed, eventUp);
|
||||||
|
|
|
@ -533,6 +533,14 @@ class LoRaWANNode {
|
||||||
*/
|
*/
|
||||||
int16_t downlink(uint8_t* data, size_t* len, LoRaWANEvent_t* event = NULL);
|
int16_t downlink(uint8_t* data, size_t* len, LoRaWANEvent_t* event = NULL);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Wait for downlink, simplified to allow for simpler sendReceive
|
||||||
|
\param event Pointer to a structure to store extra information about the event
|
||||||
|
(port, frame counter, etc.). If set to NULL, no extra information will be passed to the user.
|
||||||
|
\returns \ref status_codes
|
||||||
|
*/
|
||||||
|
int16_t downlink(LoRaWANEvent_t* event = NULL);
|
||||||
|
|
||||||
#if defined(RADIOLIB_BUILD_ARDUINO)
|
#if defined(RADIOLIB_BUILD_ARDUINO)
|
||||||
/*!
|
/*!
|
||||||
\brief Send a message to the server and wait for a downlink during Rx1 and/or Rx2 window.
|
\brief Send a message to the server and wait for a downlink during Rx1 and/or Rx2 window.
|
||||||
|
@ -580,6 +588,20 @@ class LoRaWANNode {
|
||||||
*/
|
*/
|
||||||
int16_t sendReceive(uint8_t* dataUp, size_t lenUp, uint8_t port, uint8_t* dataDown, size_t* lenDown, bool isConfirmed = false, LoRaWANEvent_t* eventUp = NULL, LoRaWANEvent_t* eventDown = NULL);
|
int16_t sendReceive(uint8_t* dataUp, size_t lenUp, uint8_t port, uint8_t* dataDown, size_t* lenDown, bool isConfirmed = false, LoRaWANEvent_t* eventUp = NULL, LoRaWANEvent_t* eventDown = NULL);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Send a message to the server and wait for a downlink but don't bother the user with downlink contents
|
||||||
|
\param dataUp Data to send.
|
||||||
|
\param lenUp Length of the data.
|
||||||
|
\param port Port number to send the message to.
|
||||||
|
\param isConfirmed Whether to send a confirmed uplink or not.
|
||||||
|
\param eventUp Pointer to a structure to store extra information about the uplink event
|
||||||
|
(port, frame counter, etc.). If set to NULL, no extra information will be passed to the user.
|
||||||
|
\param eventDown Pointer to a structure to store extra information about the downlink event
|
||||||
|
(port, frame counter, etc.). If set to NULL, no extra information will be passed to the user.
|
||||||
|
\returns \ref status_codes
|
||||||
|
*/
|
||||||
|
int16_t sendReceive(uint8_t* dataUp, size_t lenUp, uint8_t port = 1, bool isConfirmed = false, LoRaWANEvent_t* eventUp = NULL, LoRaWANEvent_t* eventDown = NULL);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Set device status.
|
\brief Set device status.
|
||||||
\param battLevel Battery level to set. 0 for external power source, 1 for lowest battery,
|
\param battLevel Battery level to set. 0 for external power source, 1 for lowest battery,
|
||||||
|
|
Loading…
Add table
Reference in a new issue