-
Notifications
You must be signed in to change notification settings - Fork 3k
cellular: ATHandler send delay #6572
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
#ifdef MBED_CONF_RTOS_PRESENT | ||
#include "rtos/Thread.h" | ||
#endif | ||
#include "Kernel.h" | ||
|
||
using namespace mbed; | ||
using namespace events; | ||
|
@@ -58,7 +59,7 @@ static const uint8_t map_3gpp_errors[][2] = { | |
{ 146, 46 }, { 178, 65 }, { 179, 66 }, { 180, 48 }, { 181, 83 }, { 171, 49 }, | ||
}; | ||
|
||
ATHandler::ATHandler(FileHandle *fh, EventQueue &queue, int timeout, const char *output_delimiter) : | ||
ATHandler::ATHandler(FileHandle *fh, EventQueue &queue, int timeout, const char *output_delimiter, uint16_t send_delay) : | ||
_nextATHandler(0), | ||
_fileHandle(fh), | ||
_queue(queue), | ||
|
@@ -68,6 +69,8 @@ ATHandler::ATHandler(FileHandle *fh, EventQueue &queue, int timeout, const char | |
_oobs(NULL), | ||
_at_timeout(timeout), | ||
_previous_at_timeout(timeout), | ||
_at_send_delay(send_delay), | ||
_last_response_stop(0), | ||
_fh_sigio_set(false), | ||
_processing(false), | ||
_ref_count(1), | ||
|
@@ -893,6 +896,8 @@ void ATHandler::resp_stop() | |
set_tag(&_resp_stop, OK); | ||
// Reset info resp prefix | ||
memset(_info_resp_prefix, 0, sizeof(_info_resp_prefix)); | ||
|
||
_last_response_stop = rtos::Kernel::get_ms_count(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be 0 to avoid redundant initial waiting. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Set 0 in the constructor |
||
} | ||
|
||
void ATHandler::information_response_stop() | ||
|
@@ -936,8 +941,21 @@ const char* ATHandler::mem_str(const char* dest, size_t dest_len, const char* sr | |
|
||
void ATHandler::cmd_start(const char* cmd) | ||
{ | ||
|
||
if (_at_send_delay) { | ||
uint64_t current_time = rtos::Kernel::get_ms_count(); | ||
uint64_t time_difference = current_time - _last_response_stop; | ||
|
||
if (time_difference < (uint64_t)_at_send_delay) { | ||
wait_ms((uint64_t)_at_send_delay - time_difference); | ||
tr_debug("AT wait %llu %llu", current_time, _last_response_stop); | ||
} | ||
} | ||
|
||
tr_debug("AT> %s", cmd); | ||
|
||
|
||
|
||
if (_last_err != NSAPI_ERROR_OK) { | ||
return; | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
uint16_t send_delay
- why uint16_t was chosen? vsint timeout
(3rd parameter)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.
the delay is always positive, and 16 bits is enough for it for practical cases
Uh oh!
There was an error while loading. Please reload this page.
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.
OK. I was just asking as basic types should be sufficient , if there was a specific reason to use uint16_t (why then timeout is plain
int
). If I add a new method here, I would be confused which one to use