This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

BLE disconnects UART

Hi,

My name is Bruno and I'm developing an Application which consists on:

Connect to a BLE device (I'm using Nina B112 from u-blox, which contains a NRF52832 SoC) through a Android Apk;

Android will send Nina data through NUS;

Nina will send data through UART to another microcontroller (MSP430);

MSP will send data back to Nina;

Nina will send MSP's data back to the Android through NUS;

The problem is that I can connect to the BLE and everything works good, but suddenly i get disconnected and can't reconnect (can't find Nina's advertising anymore)

When anything connects to Nina, it powers on the MSP so i can start the communication (I'm doing this for power consumption purposes). And when it gets disconnected, Nina turns off the MSP.

I don't know if Nina's stopped working and all pins were left 'HIGH' because MSP keeps turned on after that.

I connected to Nina B1 EVK and keep sending messages through NUS and no errors occured (it kept normally for hours). But Nina's EVK was not connected to anything so there was no UART messages received (only sent). Because of that i think that the UART might be the issue.

I couldn't track when the error occurs cause it occured after sending few messages (like 20 successfull messages sent) and lots of messages (like over 10 000). The interval between messages that android is sending is 200ms.

SPECS:

-UART: default config @19200 baudrate (flow control disabled, thinking about enabling it, i don't know if it would fix it)

-Nina: I'm using SDK v15.2, softdevice s132 that came with the SDK

-when receiving a UART message I'm using the Scheduler to proccess it, same with NUS.

-I'm using app_uart's methods

-on Android side i'm using nRF_Connect apk and an apk modified from nRF_UART

-as a try to solve the issue i implemented a routine that renews a timer each time a message arrive from NUS, and if no message arrive the timer expires and calls sd_ble_gap_disconnect using the m_connection_handle from the ble_uart_app example and BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION.

I still think the UART might be the issue, wondering if there's something related to priorities and interrupts. If any one could help me i'd be very thankfull. Is there any point i'm missing?

Thanks in advance,

Bruno

  • Forget to point that when this connection error occurs my disconnect routine does not work, msp keeps working and Nina doesn't start advertising over again

  • I also created a timer to keep track of elapsed time since the device was powered on and as debug purpose i blink a led every second. I manage to get that error again and my suspicious seems to be right: Nina looks freezed (led stopped blinking and was left on) after i lost BLE connection to the Android. Is there any way to fix this problem or any other way to use the NUS/UART (i don't know, maybe i should refresh the BLE connection or something like this) to provent this problem? After getting this error where Nina can't execute any code anymore, the only solution that comes to my mind is to use an external Watchdog and force reset it, but i'd rather fix this on software, Could anyone please help me?

  • Just tried another test. I used the Watchdog example in order to make the module reset, and it worked, now I'm able to reconnect to it. I don't know if it's the best fix i could've done, but if anyone has any clue about what is making this problem I'd be very glad to fix it in a proper way.

  • Hello,

    If you have any unexpected behavior, you should try to define DEBUG in your preprocessor defines, and monitor the log (RTT log). Make sure that NRF_LOG is enabled in sdk_config.h. What SDK version are you using?

    If you get a log entry saying that it received an error somewhere in the project, what function returned the err_code that was passed into APP_ERROR_CHECK(err_code) that the log is pointing to?

    Best regards,

    Edvin

  • Hi, 

    Thanks for the reply! I'm using SDK version 15.2. I am currently using a custom board for this application, so i don't know how to debug it with RTT since my Nina's Uart is being used for communicating with MSP. 

Related