Skip to content
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

remove blocking code and optimize for sleep #66

Closed

Conversation

sslupsky
Copy link
Contributor

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.

@sslupsky
Copy link
Contributor Author

A question was asked in issue #64

I am posting a response to so as to not clutter that issue.

modemSend() is unreliable for determining if an ACK is received for a confirmed uplink. The ACK can sometimes take longer than the "default" timeout specified in the existing modemSend(). Furthermore, modemSend() blocks until the timeout expires or the ACK is received.

getCFS() will return 1 if the module received an ACK from the network server after the module sent a confirmed uplink (the last AT_SEND) otherwise it returns 0. I believe the underlying Semtech stack tracks multiple uplinks and ACK's. However, this function doesn't allow for determining which ACK was received, it relates to the last AT_SEND. Use the modified modemSend() included with this PR (this version does not block), to transmit an uplink and then poll the module using getCFS() to check the status of the ACK.

@sslupsky sslupsky closed this Sep 8, 2020
@sslupsky sslupsky deleted the remove-blocking-code branch September 8, 2020 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant