<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>periodic advertising and sleep mode</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/11346/periodic-advertising-and-sleep-mode</link><description>link text from this link i want to advertise for 10 second then i want to stop advertise for 20 second then again advertise for 10 second. i want this continuously. for that i have defined timer 
 static void timers1_init(void)
{
 uint32_t err_code;</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 16 Jan 2016 11:36:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/11346/periodic-advertising-and-sleep-mode" /><item><title>RE: periodic advertising and sleep mode</title><link>https://devzone.nordicsemi.com/thread/42721?ContentTypeID=1</link><pubDate>Sat, 16 Jan 2016 11:36:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:16067ff6-c0fb-4954-9651-2d30b555d5b4</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;its my finle code.here device periodically advertises but on time and off time are not equal.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: periodic advertising and sleep mode</title><link>https://devzone.nordicsemi.com/thread/42720?ContentTypeID=1</link><pubDate>Sat, 16 Jan 2016 11:35:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d1a95e5-f79c-4221-bc49-c59cbe467a83</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;/* Copyright (c) 2015 Nordic Semiconductor. All Rights Reserved.
*
* The information contained herein is property of Nordic Semiconductor ASA.
* Terms and conditions of usage are described in detail in NORDIC
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
*
* Licensees are granted free, non-transferable use of the information. NO
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
* the file.
*
*/&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/** @example examples/ble_peripheral/ble_app_blinky/main.c
 *
 * @brief Blinky Sample Application main file.
 *
 * This file contains the source code for a sample application using the LED Button service.
 */

#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;quot;nordic_common.h&amp;quot;
#include &amp;quot;nrf.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;quot;ble.h&amp;quot;
#include &amp;quot;ble_hci.h&amp;quot;
#include &amp;quot;ble_srv_common.h&amp;quot;
#include &amp;quot;ble_advdata.h&amp;quot;

#include &amp;quot;ble_advertising.h&amp;quot;
#include &amp;quot;ble_conn_params.h&amp;quot;
#include &amp;quot;softdevice_handler.h&amp;quot;
#include &amp;quot;app_timer.h&amp;quot;
#include &amp;quot;app_button.h&amp;quot;
#include &amp;quot;ble_lbs.h&amp;quot;
#include &amp;quot;bsp.h&amp;quot;
#include &amp;quot;ble_gap.h&amp;quot;


#define ADVERTISING_LED_PIN             BSP_LED_0_MASK                              /**&amp;lt; Is on when device is advertising. */
#define CONNECTED_LED_PIN               BSP_LED_1_MASK                              /**&amp;lt; Is on when device has connected. */

#define LEDBUTTON_LED_PIN               BSP_LED_0_MASK                              /**&amp;lt; LED to be toggled with the help of the LED Button Service. */
#define LEDBUTTON_BUTTON_PIN            BSP_BUTTON_0                                /**&amp;lt; Button that will trigger the notification event with the LED Button Service */

#define DEVICE_NAME                     &amp;quot;Nordic_Blinky&amp;quot;                             /**&amp;lt; Name of device. Will be included in the advertising data. */

#define APP_ADV_INTERVAL                64                                          /**&amp;lt; The advertising interval (in units of 0.625 ms; this value corresponds to 40 ms). */
#define APP_ADV_TIMEOUT_IN_SECONDS      BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED       /**&amp;lt; The advertising time-out (in units of seconds). When set to 0, we will never time out. */

#define APP_TIMER_PRESCALER             0                                           /**&amp;lt; Value of the RTC1 PRESCALER register. */
#define APP_TIMER_MAX_TIMERS            6                                           /**&amp;lt; Maximum number of simultaneously created timers. */
#define APP_TIMER_OP_QUEUE_SIZE         4                                           /**&amp;lt; Size of timer operation queues. */

#define MIN_CONN_INTERVAL               MSEC_TO_UNITS(100, UNIT_1_25_MS)            /**&amp;lt; Minimum acceptable connection interval (0.5 seconds). */
#define MAX_CONN_INTERVAL               MSEC_TO_UNITS(200, UNIT_1_25_MS)            /**&amp;lt; Maximum acceptable connection interval (1 second). */
#define SLAVE_LATENCY                   0                                           /**&amp;lt; Slave latency. */
#define CONN_SUP_TIMEOUT                MSEC_TO_UNITS(4000, UNIT_10_MS)             /**&amp;lt; Connection supervisory time-out (4 seconds). */
#define FIRST_CONN_PARAMS_UPDATE_DELAY  APP_TIMER_TICKS(20000, APP_TIMER_PRESCALER) /**&amp;lt; Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (15 seconds). */
#define NEXT_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(5000, APP_TIMER_PRESCALER)  /**&amp;lt; Time between each call to sd_ble_gap_conn_param_update after the first call (5 seconds). */
#define MAX_CONN_PARAMS_UPDATE_COUNT    3                                           /**&amp;lt; Number of attempts before giving up the connection parameter negotiation. */

#define APP_GPIOTE_MAX_USERS            1                                           /**&amp;lt; Maximum number of users of the GPIOTE handler. */
#define BUTTON_DETECTION_DELAY          APP_TIMER_TICKS(50, APP_TIMER_PRESCALER)    /**&amp;lt; Delay from a GPIOTE event until a button is reported as pushed (in number of timer ticks). */

#define DEAD_BEEF                       0xDEADBEEF                                  /**&amp;lt; Value used as error code on stack dump, can be used to identify stack location on stack unwind. */

#define INTERVAL     APP_TIMER_TICKS(4000, APP_TIMER_PRESCALER) 
#define INTERVAL1     APP_TIMER_TICKS(8000, APP_TIMER_PRESCALER) 
static uint16_t                         m_conn_handle = BLE_CONN_HANDLE_INVALID;    /**&amp;lt; Handle of the current connection. */
static ble_lbs_t                        m_lbs;                                      /**&amp;lt; LED Button Service instance. */

APP_TIMER_DEF(abc);
APP_TIMER_DEF(abc1);
/**@brief Function for assert macro callback.
 *
 * @details This function will be called in case of an assert in the SoftDevice.
 *
 * @warning This handler is an example only and does not fit a final product. You need to analyze 
 *          how your product is supposed to react in case of Assert.
 * @warning On assert from the SoftDevice, the system can only recover on reset.
 *
 * @param[in] line_num    Line number of the failing ASSERT call.
 * @param[in] p_file_name File name of the failing ASSERT call.
 */
void assert_nrf_callback(uint16_t line_num, const uint8_t * p_file_name)
{
    app_error_handler(DEAD_BEEF, line_num, p_file_name);
}
static void power_manage(void)
{
    uint32_t err_code = sd_app_evt_wait();

    APP_ERROR_CHECK(err_code);
}
static void application_timers1_start(void)
{
    uint32_t err_code;

    err_code = app_timer_start(abc1, INTERVAL1, NULL);
    APP_ERROR_CHECK(err_code);
}
static void advertising_init(void)
{
    uint32_t      err_code;
    ble_advdata_t advdata;
    ble_advdata_t scanrsp;

    ble_uuid_t adv_uuids[] = {{LBS_UUID_SERVICE, m_lbs.uuid_type}};

    // Build and set advertising data
    memset(&amp;amp;advdata, 0, sizeof(advdata));

    advdata.name_type          = BLE_ADVDATA_FULL_NAME;
    advdata.include_appearance = true;
    advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;


    memset(&amp;amp;scanrsp, 0, sizeof(scanrsp));
    scanrsp.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]);
    scanrsp.uuids_complete.p_uuids  = adv_uuids;

    err_code = ble_advdata_set(&amp;amp;advdata, &amp;amp;scanrsp);
    APP_ERROR_CHECK(err_code);
}

static void timeout_handler(void * p_context)
{
    UNUSED_PARAMETER(p_context);
	sd_ble_gap_adv_stop ();
		application_timers1_start();

    
}

static void timers1_init(void)
{
    uint32_t err_code;

    // Initialize timer module.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);

    // Create timers.
    err_code = app_timer_create(&amp;amp;abc,
                                APP_TIMER_MODE_SINGLE_SHOT,
                                timeout_handler);

    APP_ERROR_CHECK(err_code);
}
static void application_timers_start(void)
{
    uint32_t err_code;

    // Start application timers.
    err_code = app_timer_start(abc, INTERVAL, NULL);
    APP_ERROR_CHECK(err_code);
}

static void advertising_start(void)
{
    uint32_t             err_code;
    ble_gap_adv_params_t adv_params;

    // Start advertising
    memset(&amp;amp;adv_params, 0, sizeof(adv_params));

    adv_params.type        = BLE_GAP_ADV_TYPE_ADV_IND;
    adv_params.p_peer_addr = NULL;
    adv_params.fp          = BLE_GAP_ADV_FP_ANY;
    adv_params.interval    = APP_ADV_INTERVAL;
    adv_params.timeout     = APP_ADV_TIMEOUT_IN_SECONDS;

    err_code = sd_ble_gap_adv_start(&amp;amp;adv_params);


    APP_ERROR_CHECK(err_code);
    LEDS_ON(ADVERTISING_LED_PIN);
	//
}
static void timeout_handler1(void * p_context)
{
	uint32_t err_code;
    UNUSED_PARAMETER(p_context);
	application_timers_start();
	advertising_start();

}
static void timers2_init(void)
{
    uint32_t err_code;

    // Initialize timer module.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);

    // Create timers.
    err_code = app_timer_create(&amp;amp;abc1,
                               APP_TIMER_MODE_SINGLE_SHOT,
                                timeout_handler1);


    APP_ERROR_CHECK(err_code);
}



/**@brief Function for the LEDs initialization.
 *
 * @details Initializes all LEDs used by the application.
 */
static void leds_init(void)
{
    LEDS_CONFIGURE(ADVERTISING_LED_PIN | CONNECTED_LED_PIN);
    LEDS_OFF(ADVERTISING_LED_PIN | CONNECTED_LED_PIN);
}


/**@brief Function for the Timer initialization.
 *
 * @details Initializes the timer module.
 */
static void timers_init(void)
{
    // Initialize timer module, making it use the scheduler
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
}


/**@brief Function for the GAP initialization.
 *
 * @details This function sets up all the necessary GAP (Generic Access Profile) parameters of the
 *          device including the device name, appearance, and the preferred connection parameters.
 */
static void gap_params_init(void)
{
    uint32_t                err_code;
    ble_gap_conn_params_t   gap_conn_params;
    ble_gap_conn_sec_mode_t sec_mode;

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;sec_mode);

    err_code = sd_ble_gap_device_name_set(&amp;amp;sec_mode,
                                          (const uint8_t *)DEVICE_NAME,
                                          strlen(DEVICE_NAME));
    APP_ERROR_CHECK(err_code);

    memset(&amp;amp;gap_conn_params, 0, sizeof(gap_conn_params));

    gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
    gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
    gap_conn_params.slave_latency     = SLAVE_LATENCY;
    gap_conn_params.conn_sup_timeout  = CONN_SUP_TIMEOUT;

    err_code = sd_ble_gap_ppcp_set(&amp;amp;gap_conn_params);
    APP_ERROR_CHECK(err_code);
}


/**@brief Function for initializing the Advertising functionality.
 *
 * @details Encodes the required advertising data and passes it to the stack.
 *          Also builds a structure to be passed to the stack when starting advertising.
 */



/**@brief Function for handling write events to the LED characteristic.
 *
 * @param[in] p_lbs     Instance of LED Button Service to which the write applies.
 * @param[in] led_state Written/desired state of the LED.
 */
static void led_write_handler(ble_lbs_t * p_lbs, uint8_t led_state)
{
    if (led_state)
    {
        LEDS_ON(LEDBUTTON_LED_PIN);
    }
    else
    {
        LEDS_OFF(LEDBUTTON_LED_PIN);
    }
}


/**@brief Function for initializing services that will be used by the application.
 */
static void services_init(void)
{
    uint32_t       err_code;
    ble_lbs_init_t init;

    init.led_write_handler = led_write_handler;

    err_code = ble_lbs_init(&amp;amp;m_lbs, &amp;amp;init);
    APP_ERROR_CHECK(err_code);
}


/**@brief Function for handling the Connection Parameters Module.
 *
 * @details This function will be called for all events in the Connection Parameters Module that
 *          are passed to the application.
 *
 * @note All this function does is to disconnect. This could have been done by simply
 *       setting the disconnect_on_fail config parameter, but instead we use the event
 *       handler mechanism to demonstrate its use.
 *
 * @param[in] p_evt  Event received from the Connection Parameters Module.
 */
static void on_conn_params_evt(ble_conn_params_evt_t * p_evt)
{
    uint32_t err_code;

    if (p_evt-&amp;gt;evt_type == BLE_CONN_PARAMS_EVT_FAILED)
    {
        err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_CONN_INTERVAL_UNACCEPTABLE);
        APP_ERROR_CHECK(err_code);
    }
}


/**@brief Function for handling a Connection Parameters error.
 *
 * @param[in] nrf_error  Error code containing information about what went wrong.
 */
static void conn_params_error_handler(uint32_t nrf_error)
{
    APP_ERROR_HANDLER(nrf_error);
}


/**@brief Function for initializing the Connection Parameters module.
 */
static void conn_params_init(void)
{
    uint32_t               err_code;
    ble_conn_params_init_t cp_init;

    memset(&amp;amp;cp_init, 0, sizeof(cp_init));

    cp_init.p_conn_params                  = NULL;
    cp_init.first_conn_params_update_delay = FIRST_CONN_PARAMS_UPDATE_DELAY;
    cp_init.next_conn_params_update_delay  = NEXT_CONN_PARAMS_UPDATE_DELAY;
    cp_init.max_conn_params_update_count   = MAX_CONN_PARAMS_UPDATE_COUNT;
    cp_init.start_on_notify_cccd_handle    = BLE_GATT_HANDLE_INVALID;
    cp_init.disconnect_on_fail             = false;
    cp_init.evt_handler                    = on_conn_params_evt;
    cp_init.error_handler                  = conn_params_error_handler;

    err_code = ble_conn_params_init(&amp;amp;cp_init);
    APP_ERROR_CHECK(err_code);
}


/**@brief Function for starting advertising.
 */



/**@brief Function for handling the Application&amp;#39;s BLE stack events.
 *
 * @param[in] p_ble_evt  Bluetooth stack event.
 */
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
    uint32_t err_code;

    switch (p_ble_evt-&amp;gt;header.evt_id)
    {
        case BLE_GAP_EVT_CONNECTED:
            LEDS_ON(CONNECTED_LED_PIN);
            LEDS_OFF(ADVERTISING_LED_PIN);
            m_conn_handle = p_ble_evt-&amp;gt;evt.gap_evt.conn_handle;

            err_code = app_button_enable();
            APP_ERROR_CHECK(err_code);
            break;

        case BLE_GAP_EVT_DISCONNECTED:
            LEDS_OFF(CONNECTED_LED_PIN);
            m_conn_handle = BLE_CONN_HANDLE_INVALID;

            err_code = app_button_disable();
            APP_ERROR_CHECK(err_code);

            advertising_start();
            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;

        default:
            // No implementation needed.
            break;
    }
}


/**@brief Function for dispatching a BLE stack event to all modules with a BLE stack event handler.
 *
 * @details This function is called from the scheduler in the main loop after a BLE stack
 *          event has been received.
 *
 * @param[in] p_ble_evt  Bluetooth stack event.
 */
static void ble_evt_dispatch(ble_evt_t * p_ble_evt)
{
    on_ble_evt(p_ble_evt);
    ble_conn_params_on_ble_evt(p_ble_evt);
    ble_lbs_on_ble_evt(&amp;amp;m_lbs, p_ble_evt);
}


/**@brief Function for initializing the BLE stack.
 *
 * @details Initializes the SoftDevice and the BLE event interrupt.
 */
static void ble_stack_init(void)
{
    uint32_t err_code;

    // Initialize the SoftDevice handler module.
    SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, false);

    // Enable BLE stack 
    ble_enable_params_t ble_enable_params;
    memset(&amp;amp;ble_enable_params, 0, sizeof(ble_enable_params));
    err_code = sd_ble_enable(&amp;amp;ble_enable_params);
    APP_ERROR_CHECK(err_code);

    ble_gap_addr_t addr;

    err_code = sd_ble_gap_address_get(&amp;amp;addr);
    APP_ERROR_CHECK(err_code);
    err_code = sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_NONE, &amp;amp;addr);
    APP_ERROR_CHECK(err_code);

    // Subscribe for BLE events.
    err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
    APP_ERROR_CHECK(err_code);
}


/**@brief Function for handling events from the button handler module.
 *
 * @param[in] pin_no        The pin that the event applies to.
 * @param[in] button_action The button action (press/release).
 */
static void button_event_handler(uint8_t pin_no, uint8_t button_action)
{
    uint32_t err_code;

    switch (pin_no)
    {
        case LEDBUTTON_BUTTON_PIN:
            err_code = ble_lbs_on_button_change(&amp;amp;m_lbs, button_action);
            if (err_code != NRF_SUCCESS &amp;amp;&amp;amp;
                err_code != BLE_ERROR_INVALID_CONN_HANDLE &amp;amp;&amp;amp;
                err_code != NRF_ERROR_INVALID_STATE)
            {
                APP_ERROR_CHECK(err_code);
            }
            break;

        default:
            APP_ERROR_HANDLER(pin_no);
            break;
    }
}


/**@brief Function for initializing the button handler module.
 */
static void buttons_init(void)
{
    uint32_t err_code;

    //The array must be static because a pointer to it will be saved in the button handler module.
    static app_button_cfg_t buttons[] =
    {
        {LEDBUTTON_BUTTON_PIN, false, BUTTON_PULL, button_event_handler}
    };

    err_code = app_button_init(buttons, sizeof(buttons) / sizeof(buttons[0]),
                               BUTTON_DETECTION_DELAY);
    APP_ERROR_CHECK(err_code);
}


/**@brief Function for the Power Manager.
 */



/**@brief Function for application main entry.
 */
int main(void)
{
    // Initialize.
    leds_init();
    timers_init();
    buttons_init();
    ble_stack_init();
    gap_params_init();
    services_init();
    advertising_init();
	timers1_init();
timers2_init();
    conn_params_init();

    // Start execution.
    advertising_start();
application_timers_start();
	//application_timers1_start();

    // Enter main loop.
    for (;;)
    {
       // power_manage();
    }
}


/**
 * @}
 */
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: periodic advertising and sleep mode</title><link>https://devzone.nordicsemi.com/thread/42719?ContentTypeID=1</link><pubDate>Sat, 16 Jan 2016 10:48:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25afc9c5-c87f-492b-862f-c7ce1dc89ba6</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;here i know that power_manage() function is used for entering low power mode. then this time out handler will stop advertising??&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: periodic advertising and sleep mode</title><link>https://devzone.nordicsemi.com/thread/42718?ContentTypeID=1</link><pubDate>Sat, 16 Jan 2016 10:46:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:42cc5ef4-619e-4cc4-ac2b-72978443ea3d</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;one more question is if i write timeout handler as below&lt;/p&gt;
&lt;p&gt;static void timeout_handler(void * p_context)
{
UNUSED_PARAMETER(p_context);&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;power_manage();  
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: periodic advertising and sleep mode</title><link>https://devzone.nordicsemi.com/thread/42717?ContentTypeID=1</link><pubDate>Sat, 16 Jan 2016 10:42:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4660c336-c8af-4c8a-9955-8cc3c774867f</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;after i run this code on nrf51 dk. my nrf51 advertising for 10 s. then it off for 10 s. then it continuously advertising. you gave me solution in last comment. but i can&amp;#39;t understand it. can you tell me how to do it??&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: periodic advertising and sleep mode</title><link>https://devzone.nordicsemi.com/thread/42716?ContentTypeID=1</link><pubDate>Sat, 16 Jan 2016 10:39:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:910a4f32-f0a2-4624-ab52-3cd7b0302d6e</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;static void advertising_init(void)
{
uint32_t      err_code;
ble_advdata_t advdata;
ble_advdata_t scanrsp;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    ble_uuid_t adv_uuids[] = {{LBS_UUID_SERVICE, m_lbs.uuid_type}};

    // Build and set advertising data
    memset(&amp;amp;advdata, 0, sizeof(advdata));

    advdata.name_type          = BLE_ADVDATA_FULL_NAME;
    advdata.include_appearance = true;
    advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;


    memset(&amp;amp;scanrsp, 0, sizeof(scanrsp));
    scanrsp.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]);
    scanrsp.uuids_complete.p_uuids  = adv_uuids;

    err_code = ble_advdata_set(&amp;amp;advdata, &amp;amp;scanrsp);
    APP_ERROR_CHECK(err_code);
}
static void advertising_start(void)
{
    uint32_t             err_code;
    ble_gap_adv_params_t adv_params;

    // Start advertising
    memset(&amp;amp;adv_params, 0, sizeof(adv_params));

    adv_params.type        = BLE_GAP_ADV_TYPE_ADV_IND;
    adv_params.p_peer_addr = NULL;
    adv_params.fp          = BLE_GAP_ADV_FP_ANY;
    adv_params.interval    = APP_ADV_INTERVAL;
    adv_params.timeout     = APP_ADV_TIMEOUT_IN_SECONDS;

    err_code = sd_ble_gap_adv_start(&amp;amp;adv_params);
    APP_ERROR_CHECK(err_code);
    LEDS_ON(ADVERTISING_LED_PIN);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;these are my advertising function&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: periodic advertising and sleep mode</title><link>https://devzone.nordicsemi.com/thread/42715?ContentTypeID=1</link><pubDate>Sat, 16 Jan 2016 10:38:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f06543d4-a684-440c-bbaf-86c670901a9a</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;i called these two timers in main code.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;int main(void)
{
    // Initialize.
    leds_init();
    timers_init();
    buttons_init();
    ble_stack_init();
    gap_params_init();
    services_init();
    advertising_init();
	timers1_init();
	timers2_init();
    conn_params_init();

    // Start execution.
    advertising_start();
	application_timers_start();
	application_timers1_start();
//advertising_start();
    // Enter main loop.
    for (;;)
    {
       // power_manage();
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: periodic advertising and sleep mode</title><link>https://devzone.nordicsemi.com/thread/42714?ContentTypeID=1</link><pubDate>Sat, 16 Jan 2016 10:37:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41527c24-ecfa-45ef-8986-538e8804acff</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;static void timers2_init(void)
{
uint32_t err_code;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    // Initialize timer module.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);

    // Create timers.
    err_code = app_timer_create(&amp;amp;abc1,
                               APP_TIMER_MODE_SINGLE_SHOT,
                                timeout_handler1);

//APP_TIMER_MODE_SINGLE_SHOT-The timer will expire only once.
//APP_TIMER_MODE_REPEATED-The timer will restart each time it expires.

    APP_ERROR_CHECK(err_code);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;static void application_timers1_start(void)
{
uint32_t err_code;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// Start application timers.
err_code = app_timer_start(abc1, INTERVAL1, NULL);
APP_ERROR_CHECK(err_code);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: periodic advertising and sleep mode</title><link>https://devzone.nordicsemi.com/thread/42713?ContentTypeID=1</link><pubDate>Sat, 16 Jan 2016 10:36:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41be24f2-4820-43e8-a64b-660e826a0685</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;i have edited code for first timer i define period for two timers&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define INTERVAL     APP_TIMER_TICKS(10000, APP_TIMER_PRESCALER) 
#define INTERVAL1     APP_TIMER_TICKS(20000, APP_TIMER_PRESCALER)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;created second timer&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;APP_TIMER_DEF(abc1);

static void timeout_handler1(void * p_context)
{
	uint32_t err_code;
    UNUSED_PARAMETER(p_context);
	advertising_start();
	//err_code=sd_ble_gap_adv_start(BLE_ADV_MODE_FAST);
//	 err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
	//power_manage();
    
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: periodic advertising and sleep mode</title><link>https://devzone.nordicsemi.com/thread/42712?ContentTypeID=1</link><pubDate>Sat, 16 Jan 2016 10:22:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d831f20-52d0-4cf5-9232-a015c7ee6a63</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;each time the first timer times out, you enable the other one, then it times out and you enable the first one, then it times out and you enable the other one then it times out and you enable the first one then it times out and you enable the other one then it times out and you enable the first one then it times out and you enable the other one then it times out ..&lt;/p&gt;
&lt;p&gt;repeat&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: periodic advertising and sleep mode</title><link>https://devzone.nordicsemi.com/thread/42711?ContentTypeID=1</link><pubDate>Sat, 16 Jan 2016 10:19:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e976bc92-c052-4b6c-b434-daf7f34ac6f6</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;i understand one-shot timer. so now my advertising off. another timer turn on advertising. now how this action will repeat??&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: periodic advertising and sleep mode</title><link>https://devzone.nordicsemi.com/thread/42710?ContentTypeID=1</link><pubDate>Sat, 16 Jan 2016 10:11:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f790a77-0fc2-42bf-886b-79b86cfa4313</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;can you tell me how to do it??&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: periodic advertising and sleep mode</title><link>https://devzone.nordicsemi.com/thread/42709?ContentTypeID=1</link><pubDate>Sat, 16 Jan 2016 09:58:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9eb2916a-69f7-40bb-b2b5-7a1376b395cf</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;what? instead of a repeating off timer, make a one-shot timer which turns advertising off and another one which turns it on again, in each handler start the other timer as well as turning advertising off or on.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: periodic advertising and sleep mode</title><link>https://devzone.nordicsemi.com/thread/42708?ContentTypeID=1</link><pubDate>Sat, 16 Jan 2016 09:53:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:354b8e47-4165-4ca9-8df0-881031fcc167</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;here advertise stops after 10 second. but how to restart and stop after it??&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>