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

[nRF51-ble-app-uart-static-passkey] Calling app_timer_start at BLE_GAP_EVT_CONNECTED

Using,

/**********************************************************/

Hi, I modified some codes of main.c. main_edited.c

This file can be compiled after adding ble_dis.c.

The main changes are

Change1

Change1-1

  1. Changing device name, added DIS (Device Info Service) and infinite advertising.

This timer starts after connection / disconnection. The call of the timeout handler can be observed from the LEDs.

Change2

  1. Added a timer. This timer just makes the LED 0, LED 1 to blink

Change3

  1. Edited passkey properly for SDK7.2.

Change4

  1. Enabled whitelist advertising

  2. If a NUS packet was sent from the central, it echoes back the same packet.

This is for checking the connection.

/**********************************************************/

One surprising this is that

the test_timer_timeout is not called after the BLE_GAP_EVT_CONNECTED.

I made the timer to start after connection, but I observed that RTC1_IRQHandler wasn't called.

However, the disconnection event called test_timer_timeout.

Why RTC1_IRQHandler isn't called after connection event happened?

Although I changed the timeout_ticks for app_timer_start and enabled the scheduler, the result was same.

Is there a change to be done in order to trigger RTC1_IRQHandler after connection?

-Regards, Mango

  • FormerMember
    0 FormerMember

    How long does your device stay connected before you disconnect? Does it stay connected more than 3s?

  • Yes. Maybe maximum 15 minutes I guess.

    What seems to be the problem?

  • FormerMember
    0 FormerMember

    For development, I would recommend you to use the latest version of the SDK, v10.0.0, and implement static passkey, and the timer. Adding static passkey should be fairly straight forward, and should be very similar to the github example.

    With SDK 10.0.0, the timer should be implemented the following way:

    1) Define the timer as a static variable: APP_TIMER_DEF(m_connected_timer_test_id);

    2) Initialize and create the timer in main():

    int main(void)
    {
       ...
        
        // Initialize.
        APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
        ...
    	err_code = app_timer_create(&m_connected_timer_test_id, APP_TIMER_MODE_SINGLE_SHOT, connected_timer_test_timeout_handler);
    	APP_ERROR_CHECK(err_code);
    	
        ...
        
        // Enter main loop.
        for (;;)
        {
            power_manage();
        }
    }
    

    3) Create timeout handler

    static void connected_timer_test_timeout_handler(void * p_context)
    {
        uint32_t err_code;
    		err_code = bsp_indication_set(BSP_INDICATE_ALERT_3);
        APP_ERROR_CHECK(err_code);
    }
    

    4) Start the timer where you need it, for example in BLE_GAP_EVT_CONNECTED:

    err_code = app_timer_start(m_connected_timer_test_id, timeout_ticks, NULL);  
    APP_ERROR_CHECK(err_code);
    
  • Then are you meaning that the SDK 7.2 has a bug about the timer?

    I wish to hear whether the devteam has checked the cause or reason.

    Also I wish to change the SDK. However my target device's MCU is based on revision 2

    which is not compatible with latest SDK and SoftDevice.

    I just use the PCA10001 (that has revision 3 chip) to see whether it will operate properly or not.

    In this sense, I wish to stick with SDK 7.2.

    I understand the devteam has a tight schedule.

    In sum, will it consume many time to reveal the reason of my problem?

    If so, I will close the case and try the new SDK somehow.

  • FormerMember
    0 FormerMember in reply to FormerMember

    Oeky, I see. Did you remember to increase APP_TIMER_MAX_TIMERS when adding the timer? To my knowledge it shouldn't be any problem to start a timer upon a connection. Let me know if increasing APP_TIMER_MAX_TIMER solves the problem.

Related