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 CGI for Quectel modems #2019
Conversation
e1f4e2f
to
82486ff
Compare
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.
Great job solving this so fast!
Codacy, does not like the I will make a CH story and annotate the code with //TODO: Use correct data types to parse URC
//[ch46994](https://app.clubhouse.io/particle/story/46994/fix-scanf-input-formatting-for-at-creg-et-al)
//Warning: %x in format string (no. 3) requires 'unsigned int *' but the argument type is 'signed int *'. |
I’m also kind of wondering why the extra %*x is there now as well. 6 Params and 5 params instead of the spec’d 5 and 4.
… On Feb 10, 2020, at 11:19 PM, keer ***@***.***> wrote:
@keeramis approved this pull request.
In hal/src/b5som/network/quectel_ncp_client.cpp:
> return SYSTEM_ERROR_NONE;
},
this));
CHECK(parser_.addUrcHandler("+CGREG",
[](AtResponseReader* reader, const char* prefix, void* data) -> int {
const auto self = (QuectelNcpClient*)data;
- int val[2];
- int r = CHECK_PARSER_URC(reader->scanf("+CGREG: %d,%d", &val[0], &val[1]));
- CHECK_TRUE(r >= 1, SYSTEM_ERROR_UNKNOWN);
+ int val[4] = {-1,-1,-1,-1};
+ char atResponse[64] = {0};
+ // Take a copy of AT response for multi-pass scanning
+ CHECK_PARSER_URC(reader->readLine(atResponse, sizeof(atResponse)));
+ // Parse response ignoring mode (replicate URC response)
+ int r = ::sscanf(atResponse, "+CGREG: %*d,%d,\"%x\",\"%x\",%d,\"%*x\"", &val[0], &val[1], &val[2], &val[3]);
+ // Reparse URC as direct response
CGREG AT command gives responses like this:
If we query, the response format is this - we will have 5 values in the response string -
+CGREG: n,stat[,lac,ci[,Act]]
If it's a URC, the response format is - we will have 4 values in the response string -
+CGREG: stat[,lac,ci[,Act]]
In hal/src/b5som/network/quectel_ncp_client.cpp:
> return SYSTEM_ERROR_NONE;
},
this));
CHECK(parser_.addUrcHandler("+CGREG",
[](AtResponseReader* reader, const char* prefix, void* data) -> int {
const auto self = (QuectelNcpClient*)data;
- int val[2];
- int r = CHECK_PARSER_URC(reader->scanf("+CGREG: %d,%d", &val[0], &val[1]));
- CHECK_TRUE(r >= 1, SYSTEM_ERROR_UNKNOWN);
+ int val[4] = {-1,-1,-1,-1};
+ char atResponse[64] = {0};
+ // Take a copy of AT response for multi-pass scanning
+ CHECK_PARSER_URC(reader->readLine(atResponse, sizeof(atResponse)));
+ // Parse response ignoring mode (replicate URC response)
+ int r = ::sscanf(atResponse, "+CGREG: %*d,%d,\"%x\",\"%x\",%d,\"%*x\"", &val[0], &val[1], &val[2], &val[3]);
+ // Reparse URC as direct response
+ if (0 >= r) {
+ r = CHECK_PARSER_URC(
+ ::sscanf(atResponse, "+CGREG: %d,\"%x\",\"%x\",%d,\"%*x\"", &val[0], &val[1], &val[2], &val[3]));
Nit: Why 5 parameters here, while this line (https://github.com/particle-iot/device-os/blob/82486ffdf7811904faa3dbc1ecad2e52377ecc49/hal/src/b5som/network/quectel_ncp_client.cpp#L223) has only 4 ?
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
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 agree with the points raised by other reviewers.
This code was copied over from sara_ncp_client.cpp
and for ublox modems the responses may contain additional parameters like <rac> One byte routing area in hexadecimal format
and others. These handlers also take care of both the read responses and URCs, so should take care of any format expected due to CH28408, however the format is still different between the modems, so let's make sure we tailor the parsing to Quectel AT commands manual.
2a73035
to
c09f327
Compare
c09f327
to
d1ff7b7
Compare
d1ff7b7
to
c289c5a
Compare
c289c5a
to
bce49b0
Compare
bce49b0
to
b321aae
Compare
b321aae
to
305d6da
Compare
submission notes
Problem
Quectel modems do not correctly report CGI data.
quectel_ncp_client.cpp
appears to have been copied before CGI data was finished.This results in not setting the flags TWO_DIGIT_MNC flag value, and the lac and ci are reported from uninitialized values.
Solution
Copy the latest Gen3 implementation from
sara_ncp_client.cpp
.Steps to Test
Create a sample application on new b5som hardware
Example App
References
ch46950
Completeness