Skip to content

Update M5_LoRaWAN.cpp #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions src/M5_LoRaWAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,18 @@ bool M5_LoRaWAN::checkJoinStatus() {
* @param time Waiting time (milliseconds)
* @return Received messages */
String M5_LoRaWAN::waitMsg(unsigned long time) {
String restr;
unsigned long start = millis();
while (1) {
if (_serial->available() || (millis() - start) < time) {
String str = _serial->readString();
restr += str;
} else {
break;
}
unsigned long start = millis();
String str;
while (1) {
if ((millis() - start) > time) {
start = millis();
String cmd = "AT+DRX=?\r\n";
writeCMD(cmd);
str = _serial->readString();
break;
}
return restr;
}
return str;
}

/*! @brief Send an AT command
Expand Down Expand Up @@ -170,4 +171,4 @@ String M5_LoRaWAN::decodeMsg(String hexEncoded) {
} else {
return hexEncoded;
}
}
}