0

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

Newbie gravatar image

asked 2017-07-17 13:30:08 +0100

updated 2017-07-19 14:55:19 +0100

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 flag offensive reopen delete report spam

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

Comments

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.

Petter Myhre ( 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

Newbie ( 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?

Petter Myhre ( 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

Newbie ( 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?

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

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

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

bool flag = 0;
on_ble_evt()
{
    BLE_GAP_EVT_ADV_REPORT:
    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

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

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

p_adv_report->peer_addr.addr[4], p_adv_report->peer_addr.addr[3], p_adv_report->peer_addr.addr[2], p_adv_report->peer_addr.addr[1], p_adv_report->peer_addr.addr[0] in my function uart_loopback_test();. In my uart_loopback test there is one function to send data for example:

        for (uint32_t i = 0; i < 40; i++)
{
    tx_DATA[i] =  p_adv_report->peer_addr.addr[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,

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

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

Petter Myhre ( 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

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

You never return to main? What if you try to stop scanning when you get the advertisment you want?

Petter Myhre ( 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,

Newbie ( 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.

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

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

Thanks, Shailav

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

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

Roger Clark ( 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()?

Petter Myhre ( 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

Newbie ( 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?

Petter Myhre ( 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?

Newbie ( 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?

Petter Myhre ( 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.

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

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

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

What did the trick?

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

1 answer

Sort by ยป oldest newest most voted
1
Newbie gravatar image

answered 2017-07-20 15:59:52 +0100

Petter gravatar image

updated 2017-07-20 16:01:40 +0100

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

edit flag offensive delete publish link more

Question Tools

1 follower

Stats

Asked: 2017-07-17 13:30:08 +0100

Seen: 97 times

Last updated: juli 19