I am using NuMaker IoT M487 board and Quectel EG25-G, and there are no question to connect with the cellular network if following the example correctly.
The question is how to use the same instance to send the AT commands.
The followings are the codes in the example to establish connection by NetworkInterface.
The iface has the connect() to establish the cellular connection.
I would like to use the iface to send the AT commands which are used to activate QuecLocater, but I can’t find the proper way to do this.
I had gone through many files such as CellularInterface, NetworkInterface, AT_CellularContext, Semaphore and CellularDevice (both of header files and cpp files).
However, I can’t even find where it send the AT commands for connecting, let alone add a new function.
Questions
Is it possible to add a new function of iface to send the AT commands I would like to?
Is it possible to inherit the instance of iface, and use it to send the AT commands?
Really appreciate if any information or references
The cellular stack is pretty complex and poorly documented. I spent a lot of time figuring out how the modules interact with the each other.
Basically you need the underlying ATHandler to send custom AT commands. This class is pretty well documented.
To access the ATHandler, you need to call get_at_handler() of the CellularDevice. And to access that, you must cast the NetworkInterface to a CellularContext, which is actually what you get when you call NetworkInterface::get_default_instance() on a cellular board. If you want to avoid unsafe casting, you can get the CellularContext instance directly with CellularContext::get_default_instance(). Afterwards, you can use CellularContext::get_device() to access the underlying device.
Edit: Apparently you can obtain the CellularDevice instance with CellularDevice::get_default_instance() directly. Every time I open the cellular sources, I learn something new . So basically CellularDevice::get_default_instance()->get_at_handler() should give you the ATHandler you are looking for.
Now I can send the AT commands with _at_handler, but how should I ensure that this is the same instance as the one I used to connect cellular network?
(Because QuecLocator still doesn’t work and return “HTTP(S) network open failed” to me)
There is only one instance of AT handler per modem.
I haven’t used QuecLocator before. If you have managed to communicate with the modem using AT commands, try to get support from Quectel forums regarding QuecLocator.