Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Not working modified multilink central by merged uart code in sdk 15.0.

Hi,

I have already working code in nordic sdk 13.1 with eclipse. But we are move to latest sdk v 15.0 for example of central and peripheral. Now every thing i have modified related to sensor and data sending using nus_c is working fine. 

But in central device i have merged uart  example for interfaced external wifi module work on AT command set.

This already i have done in old sdk v 13.1 and in that able to sent data to server.

I want to do same in new sdk 15.0, not get any error but uart_event_handle code is not work. This is my uart event code for reading and sending AT command to wifi module:

void uart_event_handle(app_uart_evt_t * p_event)
{
    static uint8_t ch;
    uint32_t err_code;
    switch (p_event->evt_type)
    	{
          case APP_UART_DATA_READY:
        	  err_code = app_uart_get(&ch);
        	  if (err_code == NRF_SUCCESS)
        	  {
        		  if(flag2== -2 && ch =='>') {
        			  flag2 = 1;
                                  START_SENDING = true;
        		  }
                          if(flag2 == -5 && ch =='>') {
                            flag2 = -3;
                            START_SENDING = true;
                            sendToWiFi();
                          }
        		  if(ch=='\n') {
        			  data[dataCounter++] = '\0';
                                  NRF_LOG_INFO("RESP: %s",(uint32_t)data);
        			  dataCounter = 0;
        		  }else 
                            if(ch !='\r')
                            {
                             data[dataCounter++] = ch;
        		    }

        	  }else if(err_code == NRF_ERROR_NOT_FOUND)
        	  {
        		  break;
        	  }

           break;
            case APP_UART_TX_EMPTY:
            sendToWiFi();
                break;
             case APP_UART_COMMUNICATION_ERROR:
             NRF_LOG_INFO("APP_UART_COMMUNICATION_ERROR");
             break;
        default:
            break;
    	}
}
 

console log in SES is 

Why first charter in response in overwritten by next response see in connect and no ip.

As per new sdk 15.0 is it any configuration for NRF_LOG_INFO in sdk_config.h file, if yes please let me know. I thing this logging issue because same uart event logic is working fine in old sdk.

Please let me  know..!!

Thanks,,,

Parents
  • Have you tried to follow the migration guide in the infocenter? This migration guide could also be helpful. I would start there & make sure you have followed all the correct steps first. This devzone case might also be helpful.

  • I read migration guide as per you suggested me. My multilink central and ble peripheral is working fine and able communicate each of them with uart central service. 

    But problem only in central device for communicate external wifi module via UART. i checked this same uart event handle logic is working in ble_app_uart same sdk 15.0. But why it is not working in central with uart.

    Have you check my above uart_event_handle code is it fine. Because when i put this same in sdk 15.0 ble_app_uart it is working fine. all logs of AT command is not repeated and not overwritten first character.

    Thanks.  

  • I have taken a look at your uart_event_handle() code & it looks ok to me. In general, I would make sure that the line indentation & spacing is a bit more organized to make it easier to understand the code. This might have occurred when you copied & pasted your code into devzone. I have compared your code with the sdk 15 ble_app_uart_c uart_event_handle() code & I noticed that instead of the ble_nus_c_string_send(&m_ble_nus_c, data_array, index) function, you are calling a sendToWifi() function.

    Where is this sendToWifi() function defined?

    Does it do the same as ble_nus_c_string_send() inside ble_nus_c.c of the ble_app_uart_c example? 

    Also, why do you call the sendToWifi() function when you have an APP_UART_TX_EMPTY event?

  • I have modified uart_event_handle() function for just solving this error, please see the attached updated uart_event_handle(). This same function i tested in my multilink central example and in sdk 15.0 ble peripheral ---> ble_app_uart example replaced existing uart_event_handle() by this.

    void uart_event_handle(app_uart_evt_t * p_event)
    {
        static uint8_t ch;
        uint32_t err_code;
        switch (p_event->evt_type)
        	{
              case APP_UART_DATA_READY:
            	  err_code = app_uart_get(&ch);
            	  if (err_code == NRF_SUCCESS)
            	  {
                        if(ch =='\n') {
                                data[dataCounter++] = '\0';
                                NRF_LOG_INFO("RESP: %s",(uint32_t)data);
                                dataCounter = 0;
                        }else 
                          if(ch !='\r')
                          {
                            data[dataCounter++] = ch;
    //                        NRF_LOG_INFO("else r call: %d", dataCounter);
                          }
    
            	  }else if(err_code == NRF_ERROR_NOT_FOUND)
            	  {
            		  break;
            	  }
    
               break;
                case APP_UART_TX_EMPTY:
    //            sendToWiFi();
                    break;
                 case APP_UART_COMMUNICATION_ERROR:
                 NRF_LOG_INFO("APP_UART_COMMUNICATION_ERROR");
                 break;
            default:
                break;
        	}
    }

    see the following log result both of in SES:

    Multilink central error log

    Working log image in ble_app_uart:

    The same uart_event function i have run in two examples. In my multilink central why it get overwritten first char as see like OT but this is not getting in other example. I want to do same like this in other example when i sent AT it should be return OK.

    I have debugging more time my multilink link example but until not find issue why it so getting "OT".

    Once this issue solve then my whole wifi code is working as sendTowifi(). Temporary i comment this function due this issue is not depent on that. 

    In central device i don't want to send to ble app using ble_nus_c_string_send(&m_ble_nus_c, data_array, index) function so i have remove this function. 

    Once  APP_UART_TX_EMPTY event come means that now uart buffer is empty then we have send next data. Because more data not able to send in one buffer so we are sending sequentially.

    I have compare both example but not get any difference for uart communication. Still stuck in finding this issue why wifi AT command response repeated in multilink. Please help me..!!  

    Thanks..!!

Reply
  • I have modified uart_event_handle() function for just solving this error, please see the attached updated uart_event_handle(). This same function i tested in my multilink central example and in sdk 15.0 ble peripheral ---> ble_app_uart example replaced existing uart_event_handle() by this.

    void uart_event_handle(app_uart_evt_t * p_event)
    {
        static uint8_t ch;
        uint32_t err_code;
        switch (p_event->evt_type)
        	{
              case APP_UART_DATA_READY:
            	  err_code = app_uart_get(&ch);
            	  if (err_code == NRF_SUCCESS)
            	  {
                        if(ch =='\n') {
                                data[dataCounter++] = '\0';
                                NRF_LOG_INFO("RESP: %s",(uint32_t)data);
                                dataCounter = 0;
                        }else 
                          if(ch !='\r')
                          {
                            data[dataCounter++] = ch;
    //                        NRF_LOG_INFO("else r call: %d", dataCounter);
                          }
    
            	  }else if(err_code == NRF_ERROR_NOT_FOUND)
            	  {
            		  break;
            	  }
    
               break;
                case APP_UART_TX_EMPTY:
    //            sendToWiFi();
                    break;
                 case APP_UART_COMMUNICATION_ERROR:
                 NRF_LOG_INFO("APP_UART_COMMUNICATION_ERROR");
                 break;
            default:
                break;
        	}
    }

    see the following log result both of in SES:

    Multilink central error log

    Working log image in ble_app_uart:

    The same uart_event function i have run in two examples. In my multilink central why it get overwritten first char as see like OT but this is not getting in other example. I want to do same like this in other example when i sent AT it should be return OK.

    I have debugging more time my multilink link example but until not find issue why it so getting "OT".

    Once this issue solve then my whole wifi code is working as sendTowifi(). Temporary i comment this function due this issue is not depent on that. 

    In central device i don't want to send to ble app using ble_nus_c_string_send(&m_ble_nus_c, data_array, index) function so i have remove this function. 

    Once  APP_UART_TX_EMPTY event come means that now uart buffer is empty then we have send next data. Because more data not able to send in one buffer so we are sending sequentially.

    I have compare both example but not get any difference for uart communication. Still stuck in finding this issue why wifi AT command response repeated in multilink. Please help me..!!  

    Thanks..!!

Children
  • From what I understand, it seems what is happening is that after the first AT response you get on the multilink central example from the WiFi module, the WiFi module then sends the O character. Even if you have sent OK, it seems the second response you get overwrites the A in AT with the O, leaving you with OT. Then, the third response overwrites the T with K, leaving you with OK. 

    I am not sure this will help, but I would try this code snippet instead of: data[dataCounter++] = ch;

    data[dataCounter+1] = ch;

    dataCounter++;

    I am guessing you have already logged the dataCounter variables in: NRF_LOG_INFO("else r call: %d", dataCounter);

    Is there any suspicious behavior there?

  • Hi,

    I have fixed this issue self by changing only build configuration setting Debug to Release in SES. Now everything is working fine. When i compare both example with SES setting then i found this but not understand why this not work when i select debug. 

    Thanks for your help and great support...!!! 

Related