# Using RTT viewer and Uart to send ESP8266 AT commands [closed]

Hello , I am using sdk12.2 and pca10028. I have implemented rtt viewer so that I dont need uart to debug or to print something. I am using uart to send AT commands to esp8266. I have tested individually and my uart code can send AT commands and I am getting response back. Now I am combining this code with ble_app_uart_c(central ) for scanning nearby ble devices.

scan function - New Text Document (3).txt.

Uart_loopback_test - New Text Document (3).txt

Uart_terminal - uart_terminal.PNG

RTT_Terminal - rtt_terminal.PNG

main.c - New Text Document (3).txt

Thanks, Shailav

edit retag reopen delete

### Closed as "the question is answered, right answer was accepted" by Newbie at 2017-07-21 07:36:57 +0100

Have you tried to debug to figure out why your scanning stops? Do you get an error somewhere that resets the device? This might give some insight.

( 2017-07-18 10:56:57 +0100 )editconvert to answer

Hi Peter, I figured out the challenge. I am actually trying to scan the nearby ble devices using the code ble_app_uart_c . Now I want to send this data through esp8266 using at commands. Now unfortunately nrf51822 has only 1 uart so I am using rtt viewer to see the data of scan devices. So the left uart I am using now to send AT commands to esp8266. Now my challenge is when I am using the function of uart in function of scan response is attached in question above. I am not getting output as expected. Although I am successful in sending data through uart to Esp8266 wifi module. For your reference I am attaching the uart code for esp8266 above in question. Please suggest me changes. Thanks, Shailav

( 2017-07-18 12:23:07 +0100 )editconvert to answer

Ok. So what do you get? Have you tried to debug? Have you checked if you get any errors?

( 2017-07-18 13:39:09 +0100 )editconvert to answer

Hi, I am not getting errors. I am attaching screenshot of the function and output from uart as well as rtt viewer above in question. My function call uart_loopback_test() is not getting executed when I am calling this in case BLE_GAP_EVT_ADV_REPORT: I want to send the mac address, rssi and UUId via esp8266 to server. Thanks, Shailav

( 2017-07-19 10:24:57 +0100 )editconvert to answer

Maybe this is happening because you are calling it from interrupt context? Does it work if you set a flag when you get the BLE_GAPEVT_ADV_REPORT and call uart_loopback_test() from main instead? Or you could try to increase the interrupt priority of the uart?

( 2017-07-19 10:28:47 +0100 )editconvert to answer

Hi, Can you please show me code snippet to implement your suggestions? Thanks, Shailav

( 2017-07-19 10:32:30 +0100 )editconvert to answer

bool flag = 0;
on_ble_evt()
{
flag = 1;
}

main()
{
for
{
if(flag==1)
{
flag = 0;
uart_loopback_test();
}
power_manage();
}
}


The interrupt priority can be changed in sdk_config.h, try setting UART_DEFAULT_CONFIG_IRQ_PRIORITY 1

( 2017-07-19 12:36:58 +0100 )editconvert to answer

Hi, My main challenge is I want to pass the parameters like

        for (uint32_t i = 0; i < 40; i++)
{
while (app_uart_put(tx_DATA[i]) != NRF_SUCCESS);
}
nrf_delay_ms(10000);


So how should I implement this? Thats why I was trying to call uart_loopback_test in BLE_GAP_EVT_ADV_REPORT. Thanks,

( 2017-07-19 13:46:56 +0100 )editconvert to answer

Can't you just copy the address to a global array?

( 2017-07-19 14:06:25 +0100 )editconvert to answer

Hi, I can copy that.I have 2 functions in my main loop: uart_loopback_test(); scan_start(); So when the scan_start(); my code starts scanning nearby devices and it never returns to main function again. So I was trying to call uart_loopback_test(); in BLE_GAPEVT_ADV_REPORT. But unfortunately my uart_loopback_test is not working in BLE_GAPEVT_ADV_REPORT function. I am attaching my main file in question above. Please suggest me changes. Thanks

( 2017-07-19 14:47:26 +0100 )editconvert to answer

( 2017-07-19 15:26:30 +0100 )editconvert to answer

Hi, I want to scan 1 device UUID and want to send that to Webserver using Esp8266. Then again I want scan other device UUID and want to send that data to webserver. So Scanning should be continuous to detect new devices. Thanks,

( 2017-07-19 15:31:19 +0100 )editconvert to answer

I'm not suggesting this to be your final product, I'm trying to suggest something that will solve the problem you are having. To figure out why it is not working. Can you please try stop scanning and see if you are able to return to main(), and then call uart_loopback_test() from there? Or try to increase the UART priority to 1? Or try to disable the uart interrupt so that it will poll the register instead? Or you can upload your complete project so I can test it here.

( 2017-07-19 15:53:28 +0100 )editconvert to answer

Hi, I have set priority to 1. I am attaching my project.

Thanks, Shailav

( 2017-07-19 16:10:31 +0100 )editconvert to answer

Why not just use an ESP32 for both Wifi and BLE ?

( 2017-07-20 09:47:18 +0100 )editconvert to answer
1

What if you change APP_IRQ_PRIORITY_LOWEST to APP_IRQ_PRIORITY_HIGHEST when you call APP_UART_FIFO_INIT inside uart_init()?

( 2017-07-20 11:24:37 +0100 )editconvert to answer

Hi Petter, I changed to APP_IRQ_PRIORITY_HIGHEST. But I can see something working. I will try the code again and will let you know. Thanks, Shailav

( 2017-07-20 12:17:46 +0100 )editconvert to answer

I have tried. It works here. It is sending data over the UART. Can I ask why you have those 10 second delays in your code?

( 2017-07-20 12:33:54 +0100 )editconvert to answer

Its a random delay I kept so that I can properly get the response from back from ESP8266. Is that effecting my code? Should I remove?

( 2017-07-20 12:36:27 +0100 )editconvert to answer

I don't see how random delay would help? And it isn't random is it?

( 2017-07-20 12:47:50 +0100 )editconvert to answer

Yeah it is not helping. I will remove the delay. I will let you know about the progress.

( 2017-07-20 12:59:40 +0100 )editconvert to answer

Hi Peter, Its working now. Thanks for all the support.

( 2017-07-20 14:59:46 +0100 )editconvert to answer

What did the trick?

( 2017-07-20 15:49:24 +0100 )editconvert to answer

Sort by » oldest newest most voted

Changing APP_IRQ_PRIORITY_HIGHEST worked for me and the rest was working fine. Thanks, Shailav

more

## Recent blog posts

• ### Job Offer: nRF / Embedded Developer in Stuttgart, Germany

Posted 2017-11-20 11:46:20 by Marius Heil
• ### Estudando Projetos do SDK 10 para nRF5x com Eclipse Oxygen (Portuguese)

Posted 2017-11-12 00:08:55 by Carlos Delfino
• ### Configurando o Eclipse Oxygen para Desenvolvimento com nRF5x (Portuguese)

Posted 2017-11-10 21:15:47 by Carlos Delfino
• ### How to use Git for embedded software development

Posted 2017-11-06 13:21:55 by Yaniv Nis
• ### Thingy:52 based Weather Station

Posted 2017-10-29 22:31:15 by Krzysztof Szewczyk

## Recent questions

• ### nRF51-Dongle can never display in ANTware II

Posted 2017-11-22 04:19:43 by iBaBei
• ### HID Keyboard + Consumer control settings no working

Posted 2017-11-22 04:01:25 by Hung Alan
• ### APP_UART_COMMUNICATION_ERROR

Posted 2017-11-22 03:10:28 by muyang
• ### pm_conn_sec_status_get bug?

Posted 2017-11-22 02:48:46 by Elias Simon
• ### multiple connect ,discover service multiple ,why?

Posted 2017-11-22 02:07:13 by strengthstrong