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

Cellular: CellularContext must provide access to CellularDevice #10210

Merged
merged 1 commit into from Mar 28, 2019

Conversation

jarvte
Copy link
Contributor

@jarvte jarvte commented Mar 25, 2019

Description

When using NetworkInterface::get_default_instance() application gets handle
to CellularInterface which is actually CellularContext derived from CellularInterface.
Application needs also handle to CellularDevice to open other interfaces.

Pull request type

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

Reviewers

@AnttiKauppila @kivaisan

Release Notes

When using NetworkInterface::get_default_instance() application gets handle
to CellularInterface which is actually CellularContext derived from CellularInterface.
Application needs also handle to CellularDevice to open other interfaces.

@ciarmcom ciarmcom requested review from AnttiKauppila, kivaisan and a team March 25, 2019 08:00
@ciarmcom
Copy link
Member

@jarvte, thank you for your changes.
@AnttiKauppila @kivaisan @ARMmbed/mbed-os-ipcore @ARMmbed/mbed-os-wan @ARMmbed/mbed-os-maintainers please review.

@jarvte jarvte force-pushed the cellulardevice_from_context branch from ebb65ed to c0151b1 Compare March 25, 2019 13:33
@jarvte
Copy link
Contributor Author

jarvte commented Mar 25, 2019

Force pushed review fixes:

  • removed virtual from Cellularcontext
  • removed inherited methods from AT_CellularContext

@trowbridgec
Copy link

This is a great feature to add! Whenever working with the cell infrastructure, I always find it cumbersome to work between CellularContext and CellularDevice.

When using NetworkInterface::get_default_instance() application gets handle
to CellularInterface which is actually CellularContext derived from CellularInterface.
Application needs also handle to CellularDevice to open other interfaces.
@jarvte jarvte force-pushed the cellulardevice_from_context branch from c0151b1 to b0ee22c Compare March 26, 2019 05:29
@jarvte
Copy link
Contributor Author

jarvte commented Mar 26, 2019

pushed AT-specific device getter to AT_CellularContext as @kjbracey-arm suggested.

@AriParkkila
Copy link

Should getter be virtual so that an application doesn't need to know exact type?

@kjbracey
Copy link
Contributor

kjbracey commented Mar 27, 2019

Should getter be virtual so that an application doesn't need to know exact type?

(I don't think I'm talking nonsense here, but it's possible...)

The application doesn't need to know the type - if it is using CellularContext as its local static type, it will non-virtually call CellularContext::get_device and get a CellularDevice *.

If it's using AT_CellularContext as its local static type, it will non-virtually call AT_CellularContext::get_device and get an AT_CellularDevice *.

So we're just using whatever static type information we have at the call-site, and maintaining that static type information in the output.

The actual dynamic type we don't know, and can't determine anyway as RTTI is turned off, and either way you're getting a pointer to the same object - the two implementations do the same thing, so it doesn't matter which one you call.

An application using CellularContext * doesn't need to polymorphically invoke AT_CellularContext::get_device to get the correct result.

It's just a bit like the overloads:

  • const char *strstr(const char *str, const char *target) and
  • char *strstr(char *str, const char *target).

Both do the same thing, so it doesn't really matter which you call, but the static type of the output depends on the static type of the input.

@cmonr
Copy link
Contributor

cmonr commented Mar 27, 2019

CI started

@mbed-ci
Copy link

mbed-ci commented Mar 28, 2019

Test run: SUCCESS

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

cmonr pushed a commit to cmonr/mbed-os that referenced this pull request Mar 28, 2019
Cellular: CellularContext must provide access to CellularDevice
@cmonr cmonr merged commit 4af3c38 into ARMmbed:master Mar 28, 2019
@jarvte jarvte deleted the cellulardevice_from_context branch March 29, 2019 05:27
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.

None yet

10 participants