ARMmbed / mbed-os

Arm Mbed OS is a platform operating system designed for the internet of things
https://mbed.com
Other
4.66k stars 2.97k forks source link

CellularNetwork instance not accessible #13395

Closed boraozgen closed 4 years ago

boraozgen commented 4 years ago

Description of defect

I am using an external cellular modem (Quectel BG96/95) and NetworkInterface API to connect to the internet. I would like to use the cellular registration information for diagnosis purposes in my application. I noticed that these information are conveniently read and saved in the CellularNetwork class, which is used by the CellularContext class, which however does not expose the used instance. I wonder if this is a design decision or was just overlooked in the API. Shouldn't the CellularNetwork instance be exposed to the application? I think the registration information, such as signal quality and cell information could be useful to any application using cellular connections.

Target(s) affected by this defect ?

Custom board.

Toolchain(s) (name and version) displaying this defect ?

API issue, not relevant.

What version of Mbed-os are you using (tag or sha) ?

mbed-os-6.2.0

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

API issue, not relevant.

How is this defect reproduced ?

API issue, not relevant.

ciarmcom commented 4 years ago

Thank you for raising this detailed GitHub issue. I am now notifying our internal issue triagers. Internal Jira reference: https://jira.arm.com/browse/MBOTRIAGE-2779

kivaisan commented 4 years ago

@boraozgen You can get handle to CellularNetwork via CellularContext and CellularDevice:

For example:

NetworkInterface *iface = NetworkInterface::get_default_instance(); // "target.network-default-interface-type": "CELLULAR"
CellularContext *ctx = (CellularContext *)iface;
CellularDevice *dev = ctx->get_device();
CellularNetwork *nw = dev->open_network();
boraozgen commented 4 years ago

I see, the name of the method is confusing though. I guess it does not create a new network instance if it already exists?

If that is the case, this issue could be a suggestion to clarify the method name.

kivaisan commented 4 years ago

Yes, it will create a new instance only if not created already earlier. Otherwise it will just return the handle to the existing one.

This is a public API function so name is frozen.

boraozgen commented 4 years ago

This solution works for me, closing the issue. Nevertheless I still think the API is unclear and something like get_network() would be much better. Thanks for the support.