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

BLE Uart example hangs

Hi,

I tried the BLE Uart example on my own nRF51 board, but after a few minutes the application hangs in the softdevice.

The board is one we developed, an FTDI cable connects the uart (incl. RTS/CTS) to a PC and an RGB LED is used to monitor the status. I can communicate between my tablet running the Master Control Panel and the PC okay. But when not connected, the nRF hangs after a few minutes (the LED stops blinking).

I tested this with SDK version 6.0.0 and S110 7.1.0 and here the code always stops with the PC at 0x06B0. Since this is an old setup I decided to try the SDK 10.0.0 with S110 version 8.0.0 Same result but with the PC at 0x06B2

What happens? I only changed the defines for the LED pins to use the RGB LED, nothing else has been changed by me.

And yes, the board is working OK. I've been running multiple examples and my own applcations without any problems.

Rob

  • Win7 / uVision 5 / Segger J-Link / custom board
  • I'm pretty sure I found the answer on this.

    In on_ble_evt() I found a switch with the following case:

     case BLE_GAP_EVT_TIMEOUT:
            if (p_ble_evt->evt.gap_evt.params.timeout.src  == BLE_GAP_TIMEOUT_SRC_ADVERTISEMENT)
            { 
                nrf_gpio_pin_clear(ADVERTISING_LED_PIN_NO);
    
                // Configure buttons with sense level low as wakeup source.
                nrf_gpio_cfg_sense_input(WAKEUP_BUTTON_PIN,
                                         BUTTON_PULL,
                                         NRF_GPIO_PIN_SENSE_LOW);
                
                // Go to system-off mode (this function will not return; wakeup will cause a reset)
                err_code = sd_power_system_off();    
                APP_ERROR_CHECK(err_code);
            }
            break;
    

    and the timeout is set to 180s, which is indeed the time at which the application hangs and waits for the button to be pushed. Setting this timeout to BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED fixes my problem. The application now runs forever.

    I found it a bit strange to set this 180s timeout in this type of a demo application but for low energy purposes it kind of does make sense.

  • I am no expert, but isn't 180s the default advertisement timeout for the example? After that nRF51 goes to deep sleep and starts advertising again when you wake it up (on the DevKit one button is assigned as WAKEUP). Without this timeout the battery would drain fairly quickly.

  • But where to change BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED ?

  • The BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED define is not meant to be changed. It is defined in ble_gap.h:

    #define BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED  0 /**< Unlimited advertising in general discoverable mode. */

    If you don't want your advertiser to time out you set the advertising timeout to zero. 

Related