AT commands for Loop

0 votes

I am trying to execute AT commands from a Nordic NRF52. I am using the Nordic UART modulewith a built-in function called app_uart_put(uint8_t byte) to put AT commands on the UART. The node that receiving the AT commands is a EE-NBIoT module and it triggers on a postfix \r\n. When I run the following code, I get OK.

while (app_uart_put('A') != NRF_SUCCESS);
while (app_uart_put('T') != NRF_SUCCESS);
while (app_uart_put('+') != NRF_SUCCESS);
while (app_uart_put('C') != NRF_SUCCESS);
while (app_uart_put('F') != NRF_SUCCESS);
while (app_uart_put('U') != NRF_SUCCESS);
while (app_uart_put('N') != NRF_SUCCESS);
while (app_uart_put('=') != NRF_SUCCESS);
while (app_uart_put('1') != NRF_SUCCESS);
while (app_uart_put('\r') != NRF_SUCCESS);
while (app_uart_put('\n') != NRF_SUCCESS);

But I want to make a more reusable code, so I wrote the following writeCommand function.

void writeCommand(char cmd[])
{   
 while (app_uart_put('A') != NRF_SUCCESS);
 while (app_uart_put('T') != NRF_SUCCESS);
 while (app_uart_put('+') != NRF_SUCCESS);

 uint8_t i;
 for(i = 0; cmd[i] != '\0'; i++){
     while (app_uart_put(cmd[i]) != NRF_SUCCESS);
 }

 while (app_uart_put('\r') != NRF_SUCCESS);
 while (app_uart_put('\n') != NRF_SUCCESS);
 nrf_delay_ms(100);
}

When I run this function as shown below, I get ERROR.

char cmd[] = "CFUN=1";
nrf_delay_ms(1000);
writeCommand(cmd);

Why does not this work? When I look at the outgoing commands, they are equal.

Nov 22, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
958 views

1 answer to this question.

0 votes

I had a brief look at the AT command documentation for U-Blox Sara N210, and it seems decent although a bit brief on the introduction part. I suggest reading the V.250 specification first because that is much more thorough. So after writing your 1000 sentences, read this answer, first following the instructions regarding V.250, and then implement something along the given code structure of how to properly handle AT command, command/response text.

answered Nov 22, 2018 by Shubham
• 13,490 points

Related Questions In IoT (Internet of Things)

0 votes
1 answer

Disk Management Commands in PowerShell for Windows IoT device

All libraries of the full .Net framework ...READ MORE

answered Nov 26, 2018 in IoT (Internet of Things) by nirvana
• 3,130 points
1,047 views
0 votes
1 answer

What is the maximum message length for a MQTT broker?

It's not entirely clear what you're asking ...READ MORE

answered Jul 17, 2018 in IoT (Internet of Things) by anonymous2
• 4,280 points
9,390 views
0 votes
1 answer

Node-RED, IOT Foundation Out Node Not Sending Commands

A simple test to check if the ...READ MORE

answered Jul 19, 2018 in IoT (Internet of Things) by TejaswiniUL
• 140 points
990 views
0 votes
1 answer

Connect Android Things based Raspberry Pi 3 to wifi network for the first time!

Hey, I think its alright!  Your Raspberry Pi ...READ MORE

answered Jul 19, 2018 in IoT (Internet of Things) by nirvana
• 3,130 points
1,092 views
0 votes
1 answer
0 votes
1 answer

Sending more than 8 byte through UART on Raspberry Pi using Android Things!

So, you can send 234212441325454543595674859764 in ASCII, ...READ MORE

answered Aug 25, 2018 in IoT (Internet of Things) by nirvana
• 3,130 points
1,222 views
0 votes
1 answer

Pair and connect new devices using Bluez5 DBUS API with C++

Although high-level APIs like Qt5, which also ...READ MORE

answered Oct 8, 2018 in IoT (Internet of Things) by nirvana
• 3,130 points
5,822 views
0 votes
1 answer

What AT commands are required to register an IoT modem on Verizon?

In the PLMN scan result, there is ...READ MORE

answered Nov 19, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,921 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP