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

sleep mode in nrf51822

from this post link text i have again doubt

i define #define APP_ADV_TIMEOUT_IN_SECONDS 10. now my advertising stops after 10 sec.but i want to restart it again then??

  • advertising stops after 10 sec.then device restart advertising after 20 second. i want to do this continuously. when advertising stops, i want nrf51822 in low power mode

  • Hi

    As pointed out in previous answer, you can start advertising with calling advertising_start(), as done in i.e. ble_app_bps in nRF51 SDK 10.0.0

    To stop advertising, you can call sd_ble_gap_adv_stop() function.

    If you want to enter System Off low power mode, you can call sleep_mode_enter, as done in the ble_app_bps example. When in System Off low power mode, you can only wake up the chip by pin interrupt (when SENSE enabled), reset, or ANADETECT signal on low power comparator. The device will reset when waking up from System Off mode.

    If you want to enter System On low power mode, you should call sd_app_evt_wait(). Any interrupt will wake up the CPU from system on low power mode. All nRF51 peripherals are enabled in System On low power mode.

    Update 13.1.2016 I have updated a modified ble_app_bps example from nRF51 SDK 10.0.0. When BLE event is either BLE_GAP_EVT_DISCONNECTED or BLE_GAP_EVT_TIMEOUT a timer is started which will expire in 10 seconds and then restart advertising. To find the code that is changed/added from the original example, look for "by Nordic" in the main file.

    ble_app_bps_with_periodic_advertising.zip

    The advertising timeout is set to 10 seconds. When advertising starts again after timeout, it will be in slow advertising mode (like the default ble_app_bps example) which shows no LED activity on the PCA10028 board. However, if you connect to the board and then disconnect, you will see the board will start advertising again and the LED starts to blink after 10 seconds.

  • Hi, just add advertising start function call on idle event. See here below:

    /* Function for handling advertising events. This function will be called for advertising events which are passed to the application */ static void on_adv_evt(ble_adv_evt_t ble_adv_evt) { ret_code_t err_code;

    switch (ble_adv_evt)
    {
        case BLE_ADV_EVT_FAST:
    	{
        	/* do nothing */
            break;
    	}
        case BLE_ADV_EVT_IDLE:
    	{
    		/* start advertising again */
    		err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
            APP_ERROR_CHECK(err_code);
            break;
    	}
        default:
            break;
    }
    

    }

    Feel free to have a look at my code repo on github for a full application example:

    github.com/.../nrf51_led_dimmer

    Regards.

  • ...

    static void on_ble_evt(ble_evt_t * p_ble_evt)
    {
        uint32_t                         err_code;
        
        switch (p_ble_evt->header.evt_id)
        {
            case BLE_GAP_EVT_CONNECTED:
                err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
                APP_ERROR_CHECK(err_code);
                m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
                break;
                
            case BLE_GAP_EVT_DISCONNECTED:
                err_code = bsp_indication_set(BSP_INDICATE_IDLE);
                APP_ERROR_CHECK(err_code);
                m_conn_handle = BLE_CONN_HANDLE_INVALID;
                break;
    
            case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
                // Pairing not supported
                err_code = sd_ble_gap_sec_params_reply(m_conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL);
                APP_ERROR_CHECK(err_code);
                break;
    
            case BLE_GATTS_EVT_SYS_ATTR_MISSING:
                // No system attributes have been stored.
                err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0, 0);
                APP_ERROR_CHECK(err_code);
                break;
    				case BLE_GAP_EVT_TIMEOUT:
    					//printf("rushin");
    				LEDS_ON(BSP_LED_1_MASK);
    				 break;
            default:
                // No implementation needed.
                break;
        }
    }
    
Related