<?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>How to switch between beacon modes without buttons?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/3935/how-to-switch-between-beacon-modes-without-buttons</link><description>Hi, 
 I&amp;#39;m using nRF51822 Bluetooth Smart Beacon Kit. Is it possible to to switch between
beacon mode and configuration mode without the need to press SW2 button e.g.: by sending some instructions, or from beacon mode to DFU mode?
Any ideas are very</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 29 Sep 2014 20:55:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/3935/how-to-switch-between-beacon-modes-without-buttons" /><item><title>RE: How to switch between beacon modes without buttons?</title><link>https://devzone.nordicsemi.com/thread/14158?ContentTypeID=1</link><pubDate>Mon, 29 Sep 2014 20:55:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2920f158-43ed-4396-a3f0-3761a0b62732</guid><dc:creator>Paolo A.</dc:creator><description>&lt;p&gt;Hi Adam
I also interesting about this application, so I modified the Beacon Source code to obtain the same result without press SW2 button.
For the other point, entry in DFU without press SW1, I&amp;#39;m still working but I didn&amp;#39;t found any solution. Below you can find a snippet code for the first step:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;in the main.c you must put:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;if (mode == beacon_mode_config)
{
uint32_t      err_code;
ble_advdata_t advdata;
ble_advdata_t scanrsp;
ble_advdata_manuf_data_t manuf_specific_data;
uint8_t       flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;		  manuf_specific_data.company_identifier = APP_COMPANY_IDENTIFIER;
    manuf_specific_data.data.p_data        = (uint8_t *) clbeacon_info;
    manuf_specific_data.data.size          = APP_BEACON_INFO_LENGTH;
		
    ble_uuid_t adv_uuids[] = {{BCS_UUID_SERVICE, m_bcs.uuid_type}};

    // Build and set advertising data
    memset(&amp;amp;advdata, 0, sizeof(advdata));
    //advdata.name_type               = BLE_ADVDATA_FULL_NAME;
    advdata.include_appearance      = false;
    advdata.flags.size              = sizeof(flags);
    advdata.flags.p_data            = &amp;amp;flags;
			advdata.p_manuf_specific_data   = &amp;amp;manuf_specific_data;
    
    memset(&amp;amp;scanrsp, 0, sizeof(scanrsp));
			scanrsp.name_type                = BLE_ADVDATA_FULL_NAME;
    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);
    
    // Initialize advertising parameters (used when starting advertising).
    memset(&amp;amp;m_adv_params, 0, sizeof(m_adv_params));
    
    m_adv_params.type        = BLE_GAP_ADV_TYPE_ADV_IND;
    m_adv_params.p_peer_addr = NULL;
    m_adv_params.fp          = BLE_GAP_ADV_FP_ANY;
    m_adv_params.interval    = APP_ADV_INTERVAL;
    m_adv_params.timeout     = APP_ADV_TIMEOUT_IN_SECONDS;           
}
else
{
    APP_ERROR_CHECK_BOOL(false);
} 
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;comment the lines:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;//err_code = app_button_is_pushed(CONFIG_MODE_BUTTON_PIN, &amp;amp;config_mode);
//APP_ERROR_CHECK(err_code);&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;finally you must remember to put:
bool config_mode = true;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this mode the beacon is always connectable.&lt;/p&gt;
&lt;p&gt;If anyone have suggestion to entry in bootloader mode without press SW1, please reply in this thread, thank you.
I read the question in &lt;a href="https://devzone.nordicsemi.com/question/2227/firmware-update-without-button-press/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt; but I can not understand the operation of the function:&lt;/p&gt;
&lt;p&gt;static void on_write(ble_evt_t * p_ble_evt)
{ ble_gatts_evt_write_t * p_evt_write = &amp;amp;p_ble_evt-&amp;gt;evt.gatts_evt.params.write;
if (p_evt_write-&amp;gt;handle == 3) // device name handle
{ NRF_POWER-&amp;gt;GPREGRET = 1; sd_nvic_SystemReset(); }
}&lt;/p&gt;
&lt;p&gt;What is the device name handle? And in which source code I must to put this function?&lt;/p&gt;
&lt;p&gt;I&amp;#39;m waiting for an answer, thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>