diff --git a/src/LoRaWan.cpp b/src/LoRaWan.cpp index e5940721..409dabf2 100644 --- a/src/LoRaWan.cpp +++ b/src/LoRaWan.cpp @@ -416,6 +416,25 @@ bool LoRaWanClass::transferPacketWithConfirmed(unsigned char *buffer, unsigned c return false; } +bool LoRaWanClass::transferPacketLinkCheckReq(unsigned char timeout) +{ + while(SerialLoRa.available())SerialLoRa.read(); + + sendCommand("AT+MSG\r\n"); + + memset(_buffer, 0, BEFFER_LENGTH_MAX); + readBuffer(_buffer, BEFFER_LENGTH_MAX, timeout); +#if _DEBUG_SERIAL_ + SerialUSB.print(_buffer); +#endif + dutycycle = false; + if(strstr(_buffer, "+MSG: No band")){ + dutycycle = true; + } + if(strstr(_buffer, "+MSG: Done"))return true; + return false; +} + short LoRaWanClass::receivePacket(char *buffer, short length, short *rssi) { char *ptr; @@ -1042,4 +1061,4 @@ short LoRaWanClass::sendCommandAndWaitForResponse(char* command, char *response, } -LoRaWanClass lora; \ No newline at end of file +LoRaWanClass lora; diff --git a/src/LoRaWan.h b/src/LoRaWan.h index fa492ab4..8dc6182d 100644 --- a/src/LoRaWan.h +++ b/src/LoRaWan.h @@ -271,7 +271,12 @@ class LoRaWanClass * \return Return bool. Ture : Confirmed ACK, false : Confirmed NOT ACK */ bool transferPacketWithConfirmed(unsigned char *buffer, unsigned char length, unsigned char timeout = DEFAULT_TIMEOUT); - + /** + * \brief Perform a LinkCheck request + * + * \return Return bool. True : Confirmed ACK, false : Confirmed NOT ACK + */ + bool transferPacketLinkCheckReq(unsigned char timeout = DEFAULT_TIMEOUT); /** * \brief Receive the data * @@ -498,4 +503,4 @@ class LoRaWanClass extern LoRaWanClass lora; -#endif \ No newline at end of file +#endif