<?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>change device name on button press</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/23321/change-device-name-on-button-press</link><description>Hi. 
 I havent found answer for - in my opinion - common question - how to temporarily change name of ble device on button press. As long as button isnt pressed - advertise NOBUTTON name and if i press it - advertise BUTTON name, or any other. 
 i am</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 10 Jul 2017 10:52:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/23321/change-device-name-on-button-press" /><item><title>RE: change device name on button press</title><link>https://devzone.nordicsemi.com/thread/91685?ContentTypeID=1</link><pubDate>Mon, 10 Jul 2017 10:52:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b63f1365-1061-484d-aa87-c062a75f22b7</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The nRF5x DK boards is marked with PCA100xx number, where PCA10028 is nRF51 DK and PCA10040 is nRF52 DK. You can also see this from the chip markings, where nRF51422 is nRF51 DK, and nRF52832 is nRF52 DK.&lt;/p&gt;
&lt;p&gt;It should be possible to change the advertised name in mbed. Note that you have to stop advertising, initiate the advertising with the new data, and start advertising again.&lt;/p&gt;
&lt;p&gt;In your code, you most likely have a function initializing the advertising, which put the device name in the advertising packet using &lt;a href="https://docs.mbed.com/docs/ble-api/en/master/api/classBLE.html#a5cf4219d040276dddc7c8e9169e049e1"&gt;&lt;code&gt;accumulateAdvertisingPayload()&lt;/code&gt;&lt;/a&gt;. Something like this should work:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;const static char     DEVICE_NAME1[] = &amp;quot;NAME1&amp;quot;;
const static char     DEVICE_NAME2[] = &amp;quot;NAME2&amp;quot;;

bool buttonPressed = false;

void changeAdvertisingName(void)
{
	BLE &amp;amp;ble = BLE::Instance();
	
	ble.gap().stopAdvertising();
	if(buttonPressed)
	{
		ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME1, sizeof(DEVICE_NAME1));
	}
	else
	{
		ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME2, sizeof(DEVICE_NAME2));
	}
    ble.gap().startAdvertising();
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Button presses can be handled using the mbed &lt;a href="https://developer.mbed.org/handbook/InterruptIn"&gt;InterruptIn library&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change device name on button press</title><link>https://devzone.nordicsemi.com/thread/91684?ContentTypeID=1</link><pubDate>Sat, 08 Jul 2017 09:46:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d1f2ace-a0b6-41c7-906d-a6f77e376186</guid><dc:creator>kalreg</dc:creator><description>&lt;p&gt;Thanks for suggestions. I&amp;#39;ve read tutorials however they are quite cloudy for noob. I use mbed and not sure if i have 51DK or 52DK - they both look the same to me, and no name is on the board - it has n51422 chip onboard.
I want to programm nrf51822 via DK board to manage buttons through gpio buttons on nrf 51822 to advertise different device name if i press button. Is that even possible?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change device name on button press</title><link>https://devzone.nordicsemi.com/thread/91683?ContentTypeID=1</link><pubDate>Fri, 07 Jul 2017 08:51:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c66c996-82c6-4706-9279-323ed439c79e</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Are you using nRF51 or nRF52? mbed or our SDK? We have a &lt;a href="https://devzone.nordicsemi.com/tutorials/"&gt;tutorial section&lt;/a&gt; here on DevZone, which should help you get started with our SDK. You can take a look at the &lt;a href="https://devzone.nordicsemi.com/tutorials/13"&gt;BSP tutotial&lt;/a&gt; if you want to configure buttons.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>