Skip to content

Cellular: Telit ME910 driver #10484

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 9 commits into from
Jun 19, 2019
Merged

Conversation

trowbridgec
Copy link

Description

Add support for the Telit ME910 CAT-M1 cellular module.

See #8666 for more history on this issue.

Pull request type

[ ] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change
[x] Enhancement

Reviewers

@hasnainvirk @AriParkkila @maclobdell @ARMmbed/mbed-os-wan

Release Notes

@trowbridgec trowbridgec changed the title Telit me910 driver Telit ME910 driver Apr 25, 2019
@trowbridgec
Copy link
Author

@loverdeg-ep

@ciarmcom ciarmcom requested review from AriParkkila, hasnainvirk, maclobdell and a team April 25, 2019 19:00
@ciarmcom
Copy link
Member

@trowbridgec, thank you for your changes.
@AriParkkila @maclobdell @hasnainvirk @ARMmbed/mbed-os-wan @ARMmbed/mbed-os-maintainers please review.

protected: // AT_CellularDevice
virtual uint16_t get_send_delay() const;
virtual nsapi_error_t init();
virtual nsapi_error_t hard_power_on();

Choose a reason for hiding this comment

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

Need to be implemented if defined, or if don't have the default power implementation the declaration of power-functions should be removed.

Copy link
Author

Choose a reason for hiding this comment

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

@AriParkkila I added the default power implementation for the ME910. I was toying around with this since we have a separate, board-specific power enable pin that I had to accommodate, but that functionality doesn't make sense here (should be in our application/BSP code), so now I just have the necessary power on sequences as suggested in the ME910 manual.

Copy link
Author

Choose a reason for hiding this comment

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

@AriParkkila I see that a couple of the CI jobs are failing because my power implementation references the MDMPWRON pin:

[Error] TELIT_ME910.cpp@95,29: 'MDMPWRON' was not declared in this scope
[Error] TELIT_ME910.cpp@109,29: 'MDMPWRON' was not declared in this scope

Is there a recommended way to handle this? Use a #if check for the MDMPWRON pin? Use a #if check for MODEM_ON_BOARD?

Is it better to just use the default power implementation here in the driver and leave it up to the end user to implement this in an onboard_modem_api.c file?

Choose a reason for hiding this comment

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

@trowbridgec can you follow the implementation from EC2X.

Choose a reason for hiding this comment

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

@trowbridgec You should declare the pins as class variables, e.g. TELIT_ME910.h:

    bool _active_high;
    DigitalOut _pwr;
    DigitalOut _rst;

And then use the variables instead of compile-time defines, e.g. TELIT_ME910.cpp:

nsapi_error_t TELIT_ME910::hard_power_on()
{
    if (_pwr.is_connected()) {
        _pwr = _active_high;

In addition, the pins need to be provided in the class constructor.

@0Grit
Copy link

0Grit commented May 2, 2019

@AriParkkila Any further recommendations to get this merge-able?

@trowbridgec trowbridgec changed the title Telit ME910 driver Cellular: Telit ME910 driver May 2, 2019
@adbridge
Copy link
Contributor

@AriParkkila could you re-review this please?

@AriParkkila
Copy link

@trowbridgec the pins should be defined similar to that in EC2X, see how the class constructor takes pins and power functions use those as member variables.

@trowbridgec
Copy link
Author

@AriParkkila Thanks for your help on this!

I implemented the changes you asked for; please review!


_at.resp_stop();
if (_cid == -1) { // no suitable context was found so create a new one
if (!set_new_context(1)) {

Choose a reason for hiding this comment

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

This function could probably be removed? This line seems to be the only diff to parent implementation, and this is likely incorrect, this should use _cid after the last in use, see parent implementation.

Copy link
Author

Choose a reason for hiding this comment

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

Being able to write a custom version of the get_context() function for this driver was the motivation for PR #10442. This function has 2 slight modifications from what's in AT_CellularContext.cpp:

  1. The modified if statement in the comment above.
  2. If we can't find a good APN candidate, the logic that seems to work best for this module is to just use context 1 instead of creating a 7th (which is not allowed).

// +CGREG:<stat>[,[<lac>],[<ci>],[<AcT>],[<rac>][,,[,[<ActiveTime>],[<PeriodicRAU>],[<GPRSREADYtimer>]]]]
// Current setting: enable the network registration unsolicited result code, and selects the
// short format
_at->cmd_start("AT+CGREG=1");

Choose a reason for hiding this comment

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

Could this be removed, as it will be overridden by cellular_properties.

Copy link
Author

Choose a reason for hiding this comment

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

Will do.

@AriParkkila
Copy link

@ARMmbed/mbed-os-maintainers Any guidance you can provide with the copyright texts.

if (pdp_type_len > 0) {
apn_len = _at.read_string(apn, sizeof(apn) - 1);
if (apn_len >= 0) {
if (_apn && apn_len > 0 && (strcmp(apn, _apn) != 0)) {
Copy link
Author

Choose a reason for hiding this comment

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

This modified version of the get_context() function adds a check here to only skip over (i.e. continue) a candidate APN if it's string length is greater than 0 (i.e. it's not an empty string).

Original:

if (_apn && (strcmp(apn, _apn) != 0)) {
    continue;
}

Modified:

if (_apn && apn_len > 0 && (strcmp(apn, _apn) != 0)) {
    continue;
}

Copy link
Contributor

@jarvte jarvte Jun 12, 2019

Choose a reason for hiding this comment

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

So even if _apn has been defined you wan't to accept an pdp context with empty apn if context matches by pdp type?

Copy link
Author

Choose a reason for hiding this comment

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

@jarvte The initial motivation for this change was a scenario that I saw with this module where 6 contexts were already defined (based on the return value from the AT+CGDCONT? command), but all 6 had an empty-string APN. The logic of the current function would reject all 6 of the contexts (because it doesn't exactly match the target APN), and would therefore try to create a new, 7th context which would be denied by the module (it only supports 6 contexts).

I proposed changing the logic of the get_context() function to NOT skip over a context with an empty-string APN (i.e. ONLY skip over a context if it has a non-empty-string APN that DOESN'T match the target APN).

Sorry if I'm explaining this poorly; see PR #10442 for more info.

@trowbridgec
Copy link
Author

Bump

@maclobdell @adbridge

@adbridge
Copy link
Contributor

CI started

@mbed-ci
Copy link

mbed-ci commented Jun 19, 2019

Test run: SUCCESS

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

@adbridge adbridge merged commit 2fd7f80 into ARMmbed:master Jun 19, 2019
@trowbridgec trowbridgec deleted the telit-me910-driver branch June 19, 2019 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants