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

ble_app_gzll example

Hello

I am trying to run the dual mode BLE/Gazell application example ble_app_gzll. I adapted it slightly such that the stacks are switched automatically in main() as follows:

// Enter main loop.
for (;;)
{
  power_manage();
  //if (running_mode != previous_mode)
  //{
  //    previous_mode = running_mode;
    if (running_mode == GAZELL)
    {
      nrf_gpio_pin_set(GZLL_DEBUG_PIN);
  
      // Stop all heart rate functionality before disabling the SoftDevice.
      ble_hrs_app_stop();
  		
      // Disable the S110 stack.
      ble_stack_stop();
      nrf_gpio_pin_clear(ADVERTISING_LED_PIN_NO);
      nrf_gpio_pin_clear(CONNECTED_LED_PIN_NO  );
  		
      // Enable Gazell.
      gzll_app_start();
      timers_init();
      gpiote_init();
      buttons_init();
  
      running_mode = BLE;
      nrf_gpio_pin_clear(GZLL_DEBUG_PIN);
    }
    else if (running_mode == BLE)
    {
      nrf_gpio_pin_set(BLE_DEBUG_PIN);
  
      // Disable Gazell.
      gzll_app_stop();
      nrf_gpio_pin_clear(GZLL_TX_SUCCESS_LED_PIN_NO);
      nrf_gpio_pin_clear(GZLL_TX_FAIL_LED_PIN_NO   );
  		
      // Re-enable the S110 stack.
      ble_stack_start();
      timers_init();
      gpiote_init();
      buttons_init();
      ble_hrs_app_start();
  
      running_mode = GAZELL;
      nrf_gpio_pin_clear(BLE_DEBUG_PIN);
    }
  //}
}

However, the program crashes every time it reaches advertising_start(); and ends in the app_error_handler with a NRF_ERROR_INVALID_STATE error.

Moreover, in the very first execution a NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED error occurs during initialization upon calling ble_stack_start(); and resets the device.

Any ideas what I am doing wrong here? The s110_nrf51822_5.2.1_softdevice.hex SoftDevice is flashed on my nRF51822. Does the Gazell protocoll need something like a pre-flashed "SoftDevice" too?

Thanks for your advice!

BR, christof

Parents
  • Hi Christof,

    I am not quite sure I understand why you want to immediately switch between gazell and BLE right after you enable them.

    The issue you have most likely caused because of you enable BLE stack when it already enabled or calling advertising_start() twice. Please make sure you didn't start with BLE (before the for() loop) and then run into running_mode =BLE again. Function power_manage would also need to be modified to match with the state.

    My suggestion is if you don't want to use a button to switch between BLE and Gazell, you can use an app timer (let's say 1 second interval) to switch instead of immediately switching.

  • my application is just a test to measure the time needed to switch the stacks. Anyway, thank you for your answer, I will try it out tomorrow! BR, chris

Reply Children
No Data
Related