Skip to content

Major refactoring: changing Network inheritance from CellularNetwork to new class CellularContext #8579

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 14 commits into from
Nov 14, 2018

Conversation

jarvte
Copy link
Contributor

@jarvte jarvte commented Oct 30, 2018

Description

Major refactoring: changing NetworkInterface inheritance from CellularNetwork to new class CellularContext

  • this was done to support multiple APN/PDP Contexts
  • big PR but big part of changes are moving methods from (AT_)CellularNetwork to (AT_)CellularContext
    and also moving overridden methods in target folder
  • CellularDevice owns new CellularStateMachine class which is based on old CellularConnectionFSM which was deleted as it's now obsolete. This was done so that we don't have to expose state machine as an API as it's logic and states might change
  • state machine now runs device to attached state (previous was to connect), CellularContext class does context activation and connection
  • changing inheritance affects many classes so it was quite impossible to a smaller PR (also UNIT tests needed to be modified for PR to pass)
  • after this change main API's for user application is CellularDevice and CellularContext
  • tested with MTS_DRAGONFLY, ADV_WISE_1570, UBLOX_C027, GEMALTO_CINTERION and QUECTEL_BG96
    @AriParkkila @mirelachirica please review

Pull request type

[ ] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[X] Breaking change

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 30, 2018

after this change main API's for user application is CellularDevice and CellularContext

How to migrate from 5.10 to 5.11 (if it includes this one) ? Is there a way to make this backward compatible or only one way forward (migration guide needed) ?

@0xc0170 0xc0170 requested review from bulislaw and a team October 30, 2018 09:15
@jarvte
Copy link
Contributor Author

jarvte commented Oct 30, 2018

after this change main API's for user application is CellularDevice and CellularContext

How to migrate from 5.10 to 5.11 (if it includes this one) ? Is there a way to make this backward compatible or only one way forward (migration guide needed) ?

https://github.com/ARMmbed/mbed-os-example-cellular will still work. It uses CellularBase interface and new class CellularContext is derived from CellulalBase. We also have an internal ticket to update handbook documentation.

using namespace mbed;

AT_CellularContext::AT_CellularContext(ATHandler &at, CellularDevice *device, const char *apn, nsapi_ip_stack_t stack) :
AT_CellularBase(at), _ip_stack_type_requested(DEFAULT_STACK), _is_connected(false), _is_blocking(true),
Copy link
Contributor

Choose a reason for hiding this comment

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

_ip_stack_type_requested(DEFAULT_STACK) -> _ip_stack_type_requested(stack) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

true, will fix

Choose a reason for hiding this comment

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

Can we really make API to prefer some IP version? Could just use a flag to prefer non-IP and/or control plane?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed with the team that we will remove nsapi_ip_stack_t stack from the constructor.

@bulislaw
Copy link
Member

Are all the APIs mentioned here stay the same and all the example still work? https://os.mbed.com/docs/v5.10/apis/cellular-api.html

@jarvte jarvte force-pushed the cellular_context branch 4 times, most recently from 02fbf22 to b7b077e Compare November 2, 2018 11:42
@jarvte
Copy link
Contributor Author

jarvte commented Nov 2, 2018

@bulislaw

Are all the APIs mentioned here stay the same and all the example still work? https://os.mbed.com/docs/v5.10/apis/cellular-api.html

Yes, example still works as now new class CellularContext is derived from CellularBase.

"default-cellular-apn": null,
"default-cellular-username": null,
"default-cellular-password": null,
"default-cellular-plmn": 0,

Choose a reason for hiding this comment

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

Remove from here, can be changed via Device API.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

CellularContext::AuthenticationType type) {
}

void AT_CellularContext::set_apn_credentials(const char* apn, const char *uname, const char *pwd,

Choose a reason for hiding this comment

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

Remove this, two times almost the same function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed both set_apn_xxx methods as we changed to derive from CellularBase


uint32_t AT_CellularContext::get_timeout_for_operation(ContextOperation op) const
{
uint32_t timeout = 10 * 60 * 1000; // default timeout is 10 minutes as registration and attach may take time

Choose a reason for hiding this comment

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

This should be more than 10 minutes, probably something like 30 minutes. Maybe could be defined as NETWORK_TIMEOUT.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

} else {
MBED_ASSERT(_cid >= 0 && _cid <= 99);
char cmd_buf[sizeof("ATD*99***xx#")];
std::sprintf(cmd_buf, "ATD*99***%d#", _cid);

Choose a reason for hiding this comment

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

This is missing one commit from master.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added the missing fix


bool GEMALTO_CINTERION_CellularContext::stack_type_supported(nsapi_ip_stack_t requested_stack)
{
#if NSAPI_PPP_AVAILABLE

Choose a reason for hiding this comment

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

Missing one commit, this function should be:

if (GEMALTO_CINTERION_Module::get_model() == GEMALTO_CINTERION_Module::ModelBGS2) {
    return (requested_stack == IPV4_STACK);
}
return (requested_stack == IPV4_STACK || requested_stack == IPV6_STACK);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed


bool TELIT_HE910_CellularContext::stack_type_supported(nsapi_ip_stack_t requested_stack)
{
return requested_stack == IPV4_STACK || requested_stack == IPV6_STACK;

Choose a reason for hiding this comment

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

This is missing the same commit as in Gemalto drivers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed as in master

@jarvte jarvte force-pushed the cellular_context branch 2 times, most recently from d902716 to b46a66e Compare November 5, 2018 08:08
*
* @return pointer to interface, if any.
*/
static CellularBase *get_default_instance();
Copy link
Contributor

Choose a reason for hiding this comment

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

This is CellularBase too.

Copy link
Contributor Author

@jarvte jarvte Nov 5, 2018

Choose a reason for hiding this comment

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

true, moved under CellularBase

nsapi_error_t check_operation(nsapi_error_t err, ContextOperation op);

private:
nsapi_ip_stack_t _ip_stack_type_requested;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since there is no more requested stack type(removed from constructor) it means this is not relevant anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, but we agreed that we are not remove this in this PR as it will change getting the context logic which will change anyway after this PR.

* CellularContext (might be many) and CellularStateMachine if available.
*
*/
void cellular_callback(nsapi_event_t ev, intptr_t ptr);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be rephrased more clear? It is not clear who is actually calling it and to which case PPP reffers to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

@bulislaw
Copy link
Member

bulislaw commented Nov 5, 2018

As long as the backward compatibility is not broken I'm ok with that. The code review will need to be performed by Cllular team.

CC: @kjbracey-arm

@jarvte jarvte force-pushed the cellular_context branch 4 times, most recently from a093041 to c0858b9 Compare November 7, 2018 07:12
@cmonr
Copy link
Contributor

cmonr commented Nov 12, 2018

@jarvte Thanks for the heads up. Will start when able.

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 12, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Nov 12, 2018

Build : FAILURE

Build number : 3605
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/8579/

@jarvte jarvte force-pushed the cellular_context branch 2 times, most recently from 33dd456 to 132e94b Compare November 13, 2018 10:08
@0xc0170
Copy link
Contributor

0xc0170 commented Nov 13, 2018

travis-ci/astyle — Passed, 61 files (+12 files)

Please clean up these 12 files

@jarvte
Copy link
Contributor Author

jarvte commented Nov 13, 2018

travis-ci/astyle — Passed, 61 files (+12 files)

Please clean up these 12 files

@0xc0170 @cmonr Astyle and other fixes done

@NirSonnenschein
Copy link
Contributor

/morph build

@mbed-ci
Copy link

mbed-ci commented Nov 14, 2018

Build : SUCCESS

Build number : 3616
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/8579/

Triggering tests

/morph test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Nov 14, 2018

@mbed-ci
Copy link

mbed-ci commented Nov 14, 2018

@maclobdell
Copy link
Contributor

maclobdell commented Nov 30, 2018

Has this been tested with MTS_DRAGONFLY_L471QG (the new Dragonfly Nano)? There is hardware in Oulu.

@jarvte
Copy link
Contributor Author

jarvte commented Nov 30, 2018

Has this been tested with MTS_DRAGONFLY_L471QG (the new Dragonfly Nano)? There is hardware in Oulu.

No I don't think we tested with that. I didn't know that we have that here.

@jarvte jarvte deleted the cellular_context branch December 3, 2018 07:04
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.