How to manually instantiate a new cellular connectivity?

In the official example , all settings like pin, apn, username and password are configured via mbed_app.json, then the instance is get by calling:

ec25 = CellularContext::get_default_instance();

This works, but has the downside are: 1) sensitive information like username and password are included in source which is typically not a good practice; 2) those settings cannot be changed on the fly.

So my question is, can we instantiate a cellular connectivity like we do with ethernet or Wifi/ESP8266? Something like the following lines of code. If yes, we will have a lot more flexibility.

ESP8266Interface wifi(WIFI_RADIO_TX, WIFI_RADIO_RX, false, WIFI_RADIO_RTS, WIFI_RADIO_CTS, WIFI_RADIO_RST);
// or
EthernetInterface eth;

Thanks in advance.

you can change APN on the fly with

ec25->set_credentials();

as well as PIN

ec25->set_sim_pin()

I made a template while ago, you can get inspired GitHub - pilotak/mbed-cellular-boilerplate: Mbed uBlox cellular basic with reconnect

I briefly went through source code of EC25, it seems setting up pins on the fly is not possible as of now.

What is the point setting up the pins on the fly? modem is/should be hard wired on the board

Not necessarily a moot. 1) If the same PCB are used in two models of product, once with EC25 and the other one without. Then starting UART TX as input can be used as a mechanism to detect if a module is installed. 2) I generally try to avoid changes/configurations in the json file. Whenever any minor changes happen there , it means minutes of compilation time.