remove blocking code and optimize for sleep #66
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR removes some blocking code and optimizes for sleep
poll(): The millis() function does not return reliable time when sleeping because the SysTick is stopped during sleep. So, the poll() is skipped if you call this function after waking from sleep. So, I removed the code that would otherwise return without checking the status of the modem. Since the caller is in control of when this function is called, this seems appropriate. Second, the function returns an int now and the value is return value of modemSend().
sendRXData(): This function was added to allow for polling the module for received data. This function is used when the modem firmware is modified to not automatically send a response. This avoids missing a response when the mcu is sleeping.
modemSend(): Removed the blocking wait for an ACK for a confirmed packet. This wait time is arbitrary and the actual time it takes the module to respond can at times exceed this delay by a significant amount depending on the region and a number of other factors. A new function is provided, getCFS(), to poll the module for the status of a confirmed packet.
getCFS(): This function polls the module for the status of a confirmed packet.
getJoinStatus(): This function was moved to make it a public function.