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

nrf52832 optimization Level 3 result ble cannot re-advertise

I am using BLE for NUS template example to create my app , and when I Compile my code with Keil 5.23.0.0 with optimization Level 0, It behaves good with the following operations:

 1. Download app to chip, connect with APP on mobilephone

 2. disconnet the ble connection on the phone

 3. connect with APP on the mobile phone, OK

But:     

  when I compile the code with optimization Level 3 , re-do the operation 1.2.3 ,  I cannot find the device when step 3

It seems than the chip stop advertiing when I disconnect the first time!

Any one met this case?

  • Hi,

    The first thing that comes to mind is volatile variables. Could that be something? If not, can you upload your code so I can have a look at it?

  • BLE_CUBIC-testLevel3.7z Here is my project, it's Level 0 Now, You can search a ECube_XXX ble devive from your phone app, you can reconnect to the device; But if you change build setting to Level 3, you cannot reconnect

  • When I run your project on my nRF52 DK development kit I can only see the device advertising for about a second, but then it stops and LED 1 and 3 turn on. I'm not able to connect and I get all kinds of weird behaviour when debugging. Is it supposed to be possible to run this project on a simple nRF52 DK without any external circuitry etc.?

    What S132 version are you using? 

    Have you tried debugging yourself? Are you able to determine what the application is doing when it is not advertising?

    Are you able to use UART or RTT to print some logging information?

    Can you try to implement an error handler for the Advertising Library? You can do it as simple as this:

    void advertising_error_handler(uint32_t nrf_error)
    {
        // Use a debugger and/or LEDs etc. to check for errors. 
    }
    
    /**@brief Function for initializing the Advertising functionality.
     */
    static void advertising_init(void)
    {
        uint32_t               err_code;
        ble_advertising_init_t init;
        
        // Use an Advertising Library error handler
        init.error_handler = advertising_error_handler;
    
        memset(&init, 0, sizeof(init));
    
        init.advdata.name_type          = BLE_ADVDATA_FULL_NAME;
        init.advdata.include_appearance = false;
        init.advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
        
        etc...
        ....

  • 1.  LED 1 and 3 turn on is beacuse I use the IO for GPIOTE input

    2.  External device is MPU9250/6 channel GPIOTE / 6 button / 74HC595 etc .  But I think it will not stop ble advertising, I decrease the project init operation, please help me re-check it!

    3. UART / RTT / LOG module is disabled in my project

    4. the suggest code "init.error_handler = advertising_error_handler;" I have added in main.c

    5. S132 version is SDK14.1.0   s132_nrf52_5.0.0_softdevice.hex  pca10040

    6. I am sure that the code is usable to advertise for a long time, And perform well in LEVEL 0, and this code is written for a product.

    3007.BLE_CUBIC-testLevel3.7z 电路图.zip

Related