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

Fix issues in setting radio access technology #12020

Merged
merged 5 commits into from
Jan 2, 2020

Conversation

linlingao
Copy link
Contributor

@linlingao linlingao commented Dec 3, 2019

Summary of changes

Fix a missing comma when radio access technology is specified. This missing comma causes modem to return syntax error.
Add implementation for setting radio access technology for Telit ME910. Without this, RAT is set back to UNKNOWN.
Add configuration in JSON to allow PLMN fallback to auto if manual selection fails.

Impact of changes

Migration actions required

Documentation

None


Pull request type

[x] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[x] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Reviewers


@linlingao
Copy link
Contributor Author

Thanks to @marcuschangarm for spotting and identifying most of the issues addressed in this PR.

@ciarmcom ciarmcom requested review from a team December 3, 2019 22:00
@ciarmcom
Copy link
Member

ciarmcom commented Dec 3, 2019

@linlingao, thank you for your changes.
@ARMmbed/mbed-os-wan @ARMmbed/mbed-os-maintainers please review.

@@ -48,7 +48,7 @@ class FileHandle;
extern const char *OK;
extern const char *CRLF;

#define BUFF_SIZE 32
#define BUFF_SIZE 128

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reason for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some AT commands such as AT+CGDCONT have longer than 32-character responses. When AT debug is turned on, you'll see AT ERR instead of AT RX. See the trace below:

image
Increasing the buffer to 128 eliminates these errors and makes debug easier. I feel like it's a good tradeoff to show most commonly used AT commands with minimal RAM usage increase.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you check if you have made any changes in ATHandler? The ERR print should be from fill_buffer, but it prints first "AT overflow" which is missing in the log above.

BUFF_SIZE is actually needed to read just the prefix, that's +CGDCONT: in the log above, so it should be large enough to hold the longest prefix and 32 should be enough here.

Copy link
Contributor Author

@linlingao linlingao Dec 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't make other changes. With the increased BUFF_SIZE, the AT ERR goes away.
BUFF_SIZE is used in ATHandler::read_int()
int32_t ATHandler::read_int()
{
if (!ok_to_proceed() || !_stop_tag || _stop_tag->found) {
return -1;
}

char buff[BUFF_SIZE];
if (read_string(buff, sizeof(buff)) == 0) {
    return -1;
}

which is called by ATHandler::at_cmd_int() while reading response.

resp = read_int();
resp_stop();
return unlock_return_error();

The code above indicates BUFF_SIZE is also used in reading response.
If you look at AT_CellularContext::get_context(), _at.read_int() is called in response to AT+CGDCONT?. This explains why the increase of BUFF_SIZE eliminates AT ERR.
I do see BUFF_SIZE is used for prefix as well as you said.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@linlingao Can you share the code how you are reading the CGDCONT response, that might be missing something like while (_at.info_resp())?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@linlingao The reason I want clean logs just with the codes from master to see if the modem response is missing <cr><ln>, which would explain buffer overflows. Those can be seen in your log but not in the log above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you convinced this fix is good? Is there anything else you'd like me to investigate pertaining to this fix?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@linlingao I'd still like to understand the root cause, otherwise it's possible that increasing BUFF_SIZE does not fix the problem but it just hides the ERR prints.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AriParkkila Would you like me to revert this change (other than the errors seen in the trace, there doesn't seem to be significant issues) while you continue to investigate? I'd like to get the other more important fixes in.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@linlingao That sounds good since BUFF_SIZE is not directly related to this PR. If you can repeat the BUFF_SIZEproblem and get the AT logs at DEBUG level with master codes (without any changes) we should be able to reproduce the problem to study it further.

} else {
return _at.at_cmd_discard("+COPS", "=1,2", "%s", plmn);
return _at.at_cmd_discard("+COPS", "=4,2,", "%s", plmn);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes network selection to be first manual and then automatic (mode=4). Do you have some specific reason for this change? Currently, if PLMN is defined only that PLMN is allowed for to avoid any unexpected costs, e.g. due to roaming.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of having the auto fallback is to increase the chance of connecting to a network. I also noticed this is the setting used in AT command tester from M2Msupport. I wasn't aware that roaming cost was a factor. I can change it back to 1 if you think cost outweighs connectivity.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think COPS mode could be a configuration option in mbed_lib.json?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all modems support COPS mode 4, so that should also be defined for each modem as CellularProperty.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add a config in mbed_lib.json to COPS mode. There're only two modes to select from:manual and manual then automatic. Do you have preference on the name of the config?
Yes, I can add COPS mode 4 to CellularProperty. Let me know if you have preference on the name of the enum.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a config in mbed_lib.json for choosing either manual or manual then automatic.
WRT adding a property in CellularProperty, I checked all the modems supported in our stack except RiotMicro RM1000 (I can't find their AT commands online), they all support mode 4. Do you still want me to add a property?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BC95 supports just COPS =0, =1 and =2. That may have changed in some of the latest release?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most likely. According to their spec, 4 is supported.
https://www.quectel.com/UploadImage/Downlad/Quectel_BC95_AT_Commands_Manual_V1.9.pdf

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, there is still a note that Only =0, =1 and =2 are supported. on the page 33.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed the note. They shouldn't have listed 3 and 4 in parameters if they're not supported. Good catch.

@adbridge
Copy link
Contributor

@linlingao please address the comments, also a rebase will be needed by the looks of it.

@linlingao
Copy link
Contributor Author

I have incorporated review comments and rebased.

@kjbracey
Copy link
Contributor

Needs another rebase, I'm afraid. @AriParkkila, can you review changes?

@AriParkkila
Copy link

@linlingao Can you remove BUFF_SIZE from here and open another issue for it, also SARA4_PPP.cpp and GENERIC_AT3GPP.cpp are missing PROPERTY_AT_COPS_FALLBACK_AUTO.

@linlingao
Copy link
Contributor Author

Incorporated new comments and rebased again.

@adbridge
Copy link
Contributor

CI started

@mbed-ci
Copy link

mbed-ci commented Dec 24, 2019

Test run: FAILED

Summary: 1 of 4 test jobs failed
Build number : 1
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_build-IAR

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 2, 2020

CI restarted

@mbed-ci
Copy link

mbed-ci commented Jan 2, 2020

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 2
Build artifacts

@0xc0170 0xc0170 added release-version: 6.0.0-alpha-1 First pre-release version of 6.0.0 and removed needs: CI labels Jan 2, 2020
@0xc0170 0xc0170 merged commit 6baa5e4 into ARMmbed:master Jan 2, 2020
@adbridge
Copy link
Contributor

@linlingao we missed this at the time, but is this adding an internal only implementation or is this new API exposed to the user ? In which case it should be a feature updated not a patch....

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 17, 2020

@linlingao we missed this at the time, but is this adding an internal only implementation or is this new API exposed to the user ? In which case it should be a feature updated not a patch....

It added a new config value to targets config. Please @linlingao confirm.

@linlingao
Copy link
Contributor Author

@adbridge @0xc0170 No new API was added in this PR. I updated the code to handle radio access technology more cleanly.

@adbridge
Copy link
Contributor

adbridge commented Mar 3, 2020

@linlingao yes but does this change anything in the way the user needs to configure things?

@linlingao
Copy link
Contributor Author

@adbridge This PR doesn't "change" anything in the way the user configures RAT. I added "plmn-fallback-auto" in json to allow the user to fine tune RAT. Prior to this PR, when manual is selected via json, network search would be limited to the specified network only. If the user wishes to limit to the specified network but this network doesn't work, now the user has a way to fall back to automatic selection. Do we consider addition to JSON an API change or new API? If so, we can mark this "feature update". This PR also fixes a bug, should I mark both "feature update" and "patch update"?

@adbridge
Copy link
Contributor

adbridge commented Mar 4, 2020

@linlingao For future reference it isn't good practice to add bug fixes and additional changes in the same PR. Anything that changes the user experience or means they need or can do anything different to what they did before is not just a 'bug fix' (unless the change is a direct result of something that was known to be wrong already according to technical spec or the documentation). Even changes to JSON files could be considered as a functionality change (in some instances). In this case you are adding additional configuration which can be used so I would suggest this counts as functionality change - so PR type should be changed accordingly. I don't think any additional documentation is required though. Impact of changes and migration is only mandatory for major changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-version: 6.0.0-alpha-1 First pre-release version of 6.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants