-
-
Notifications
You must be signed in to change notification settings - Fork 648
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
non blocking functions added #62
Conversation
@universam1 thanks for submitting! Have you seen these API's in any other packet based Arduino libraries? Just wondering if there's existing API's we can leverage. |
Well, I would say it is actually more of a standard then exceptional to support non blocking calls (http://bfy.tw/FAaI) So out of my head lets mention Don't get me wrong, I consider your library is great, but non blocking functions are mandatory for me and turn a great library to professional. |
Would like to get this moving and reach an agreement if you @sandeepmistry and @morganrallen are happy with this implementation or rather overload the existing function with an async parameter? |
I'd like to take a look at how other existing Stream based Arduino libraries handle async. The links from #62 (comment) are not necessarily Stream based. Maybe nothing exists yet? |
I agree a streaming support might be desirable at the long run! Though this would be a bigger step. |
Some API ideas:
|
8806e51
to
7efaf8c
Compare
@sandeepmistry Implemented:
Please review if that is fine, thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@universam1 Good progress!
I think this is good to merge after my two comments are addressed and the code style (mainly brackets) matches the existing code base. The API docs will also have to be updated.
while (!Serial) | ||
; | ||
|
||
Serial.println("LoRa Sender"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe adding "non-blocking" to the title here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fine with me
src/LoRa.h
Outdated
@@ -22,7 +22,8 @@ class LoRaClass : public Stream { | |||
void end(); | |||
|
|||
int beginPacket(int implicitHeader = false); | |||
int endPacket(); | |||
int endPacket(bool async = false); | |||
bool isTransmitting(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer if this API was private for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sandeepmistry Does this mean, leave int endPacket()
in public and move int endPacket(bool async = false)
private? Don't know C++ classes well enough to understand what this will accomplish.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@morganrallen I was thinking isTransmitting()
should be private for now.
With the current PRbeginPacket(...)
, fails if there is a transmission in progress.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@morganrallen any thoughts on the above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, thanks makes sense, missed this comment last week.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved into private
I've checked this PR out and it appears to work so I'm inclined to merge it as it's an important feature. I'll address the comments and merge this evening if there are no objections. |
fine with me 👍 |
API.md also needs to be updated accordingly for the new supported values. |
@morganrallen @sandeepmistry updated the PR accordingly, LGTM |
API.md
Outdated
@@ -103,6 +103,34 @@ LoRa.endPacket() | |||
|
|||
Returns `1` on success, `0` on failure. | |||
|
|||
## Sending data - non blocking |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should have a totally new section for non-blocking, rather modify the existing sending section, since there is really just a new parameter to endPacket
and beginPacket
has another reason to fail.
@morganrallen any thoughts on this?
74d1a50
to
d386218
Compare
@sandeepmistry @morganrallen I've changed the API accordingly and removed the additional part merging now. |
all requests fullfilled, if no further objections @sandeepmistry I understand it's fine to merge |
the
endPacket()
is a blocking function that can take over 6 seconds depending on the radio settings. Here is a non blocking version added, tested successfully on ESP8266. Note the grace time required for the radio to properly update the registers.