Cellular.command() AT commands with Quotation marks how to

For testing I need to make a B523/B524 run a specific network technology, in this case 2G with the Quectel specific command AT+QCFG=“nwscanmode”,1,1

I tried the doc example here: Device OS API | Reference Documentation | Particle but in setup instead of loop.

SerialLogHandler logHandler(LOG_LEVEL_TRACE);

void setup()
{
    WITH_LOCK(Cellular) {
        Cellular.command("AT+QCFG=“nwscanmode”,1,1\r\n");
    }
}
 
void loop(){
}

But it does not have any effect, and a trace show an “ERROR” response.

[connected ...]
0000041549 [system] INFO: Cloud connected
0000041550 [ncp.at] TRACE: > AT+QCFG=“nwscanmode”,1,1
0000041553 [ncp.at] TRACE: < ERROR
[... etc.]

I later tried this logging the cellular.command response, and that is = -3 meaning RESP_ERROR.

With “AT” (or AT+CPAS) it works fine:

0000004721 [system] INFO: Cloud connected
0000004722 [ncp.at] TRACE: > AT
0000004723 [ncp.at] TRACE: < OK
[... etc.]

Also tried AT commands including quotes just requesting status info such as AT+QCFG=“nwscanmode” and AT+QCFG=“nwscanseq”, that I believe should get an OK, but it is still an error response.

So I am wondering if quotation marks in AT commands are making trouble, and how to handle that in cellular.command()?

Have you tried using escaped quotes (\") in your string? I’m not familiar with AT commands but I doubt it works with “smart-quotes”.

Cellular.command("AT+QCFG=\"nwscanmode\",1,1\r\n");

Yes I tried it without success, but copying you example worked just now, in the sense that I got an OK response :+1:

I did not get the intended result out of the AT command, but that is another topic.

Ah, the reason it did not work for me at first was a classic - copying the AT command code from doc, it contained the wrong type of quotes instead of ".

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.