Send AT commands to activate QuecLocator in cellular example of NuMaker IoT M487 board

Hi everyone,

My case

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.

nsapi_error_t do_connect()
    nsapi_error_t retcode = NSAPI_ERROR_OK;
    uint8_t retry_counter = 0;

    while (iface->get_connection_status() != NSAPI_STATUS_GLOBAL_UP) {
        retcode = iface->connect();
        if (retcode == NSAPI_ERROR_AUTH_FAILURE) {
            print_function("\n\nAuthentication Failure. Exiting application\n");
        } else if (retcode == NSAPI_ERROR_OK) {
            print_function("\n\nConnection Established.\n");
        } else if (retry_counter > RETRY_COUNT) {
            print_function("\n\nFatal connection failure: %d\n", retcode);
        } else {
            print_function("\n\nCouldn't connect: %d, will retry\n", retcode);
    return retcode;

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.

  1. Is it possible to add a new function of iface to send the AT commands I would like to?
  2. 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 :slight_smile:. So basically CellularDevice::get_default_instance()->get_at_handler() should give you the ATHandler you are looking for.

Hi @boraozgen ,

Thank you for your support.

The following is the way I establish cellular connection.

NetworkInterface *NetworkInterface_Object;
NetworkInterface_Object = CellularContext::get_default_instance();
nsapi_error_t retcode = NSAPI_ERROR_NO_CONNECTION;
retcode = NetworkInterface_Object->connect()

NetworkInterface_Object->get_device()->get_at_handler() didn’t work.
But the following statements works.

ATHandler *_at_handler;
_at_handler = CellularContext::get_default_instance()->get_device()->get_at_handler();

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.

I just want to make sure I got the correct AT handler.
Like you said, I would ask questions regarding QuecLocator on their forum or support email.

I can’t imagine how much time it would take to solve this question without your help.
Much appreciated for your support!

1 Like