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

Catch advertising timeout in main

Hi,

I would like to catch in main.c the nobody connect after advertising event via ADV_SET_TERMINATED. 

I can see with breakpoint program jump into  ble_advertising_on_ble_evt inble_advertising.c but once traeted, it doesn't call the same function in main.c.


I have added the case case BLE_GAP_EVT_ADV_SET_TERMINATED in ble_evt_handler in mains.c. But this timeout event doesn' reach the ble_evt_handler function of may main.c.

I saw another topics where Joakim Jakobsen proposed a good solution, that should solve the problem, but it dosn't work for me. My code is based on ble_app_buttonless_dfu_pca10100.

devzone.nordicsemi.com/.../142407

static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
    uint32_t err_code = NRF_SUCCESS;

    switch (p_ble_evt->header.evt_id)
    {
    
            case BLE_GAP_EVT_ADV_SET_TERMINATED:
               // AdvertisingTimeout, nobody connect after 1 minutes
               etat = EVENT_TIMEOUT;
            break;

Thanks a lot !

Parents Reply Children
  • ... Sorry Vidar ... you are right it was the problem ... I was so focused on it that i didn't see this obvious mistake !

    Now next let's go to the next feature to implement: wake up the system each two days with a timer to measure a sensor , log into ram ( that is always on because of my power management mode), and go back to sleep. So i should be able to wake my system on gpio OR eache two days with a timer.

  • No worries. For wakeup I would suggest you set up a repeated app timer instance like most of our BLE examples do.

  • Yes tha's exactly what i did and it works fine. After handler function is finished, does the systeme goes automatically to sleep ? I also have a proble with my jlink connexion now , i don't know why, I have tried several boards always the same issue. I can connect with jlink commander but impossible with nordic tool like nrf Connect or SES. What is strange is taht i didn't get error in the past.

    C:\Users\flo>nrfjprog --version
    nrfjprog version: 10.8.0
    JLinkARM.dll version: 6.82c

    J-Link>connect
    Please specify device / core. <Default>: CORTEX-M4
    Type '?' for selection dialog
    Device>?
    Please specify target interface:
      J) JTAG (Default)
      S) SWD
      T) cJTAG
    TIF>S
    Specify target interface speed [kHz]. <Default>: 4000 kHz
    Speed>
    Device "NRF52833_XXAA" selected.
    
    
    Connecting to target via SWD
    InitTarget() start
    InitTarget() end
    Found SW-DP with ID 0x2BA01477
    SWD speed too high. Reduced from 4000 kHz to 853 kHz for stability
    Failed to power up DAP
    InitTarget() start
    InitTarget() end
    InitTarget() start
    InitTarget() end
    InitTarget() start
    InitTarget() end
    Cannot connect to target.
    J-Link>

  • Olfox said:
    does the systeme goes automatically to sleep ?

     You still have to call idle_state_handle() again after when the program execution returns back to your main loop.

    Olfox said:
    . I can connect with jlink commander

    Jlink commander is too failing to connect to the target based on the log you posted. Can you describe the programming setup you use (connections, voltage, etc)?

  • I'm using a jlink programmer like this : 

    it is connected to my nrf52833 via a custom production board. But recently i mak etwo times a short to gnd by accident because of a gnd debug wire that touch some voltage on the board so i wonder about something broken. This short has shutdown my laptop because of impact on USB i guess... 

    I already ordered a new segeer programmer . For the moment i will come back on the developpement board i think ... Disappointed

    But i'm surprised because i was able to debug two or three times this morning but then, impossible.

    The led of the jlink programme blink one time each second , with green color. Its seems to indicate according to documentation

    GREEN, switched off for 10ms once per second J-Link heart beat. Will be activated after the emulator has been in idle mode for at least 7 seconds.

Related