<?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 change the device name?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/9963/how-to-change-the-device-name</link><description>Hi all, 
 I&amp;#39;m using the PCA10028 and S130 based on SDK9.0。Now I have save the device name(such as &amp;quot;My device&amp;quot;) in the flash,so the 51822 can read the device name and update the name when powered up or reset everytime.I have use sd_ble_gap_device_name_set</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 29 Oct 2015 10:13:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/9963/how-to-change-the-device-name" /><item><title>RE: How to change the device name?</title><link>https://devzone.nordicsemi.com/thread/36967?ContentTypeID=1</link><pubDate>Thu, 29 Oct 2015 10:13:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc45c43a-cd2a-4fe8-909b-43eb89f53cf1</guid><dc:creator>John</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Yes,I&amp;#39;m sure.Now I have founf the problem.It is my fault that I have not write the length of device name to the flash,so DeviceNameLen is zero when the chip is powered up or reset.Thank you all the same.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to change the device name?</title><link>https://devzone.nordicsemi.com/thread/36965?ContentTypeID=1</link><pubDate>Thu, 29 Oct 2015 08:41:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:40dbb17a-a2a2-4b84-a95c-aaf1cd6cb8df</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;So this line prints the correct device name:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;printf(&amp;quot;change device name: %s&amp;quot;,(uint8_t *)&amp;amp;at_com_data.device_name[1]);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;?&lt;/p&gt;
&lt;p&gt;And you are 100% sure that the first character in the device name is &amp;#39;N&amp;#39;?&lt;/p&gt;
&lt;p&gt;Also in the else-statement you don&amp;#39;t call ble_advdata_set() so you will not be able to set the name to DEVICE_NAME.&lt;/p&gt;
&lt;p&gt;Could you post your complete main.c file?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to change the device name?</title><link>https://devzone.nordicsemi.com/thread/36966?ContentTypeID=1</link><pubDate>Thu, 29 Oct 2015 08:23:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22e31b46-4b24-4ad0-95c2-fba7337cb2bf</guid><dc:creator>John</dc:creator><description>&lt;p&gt;Hi.Thank you for your hellp.May be you have not understood what I mean.I mean the device name(eg My_Device) has been save in the flash.When the chip is powered up or done reset,the code will run to the gap_params_init() function.In the function,I have done some modification.I will check whether there is a name saved in the flash,or it will use the default name defined in the Macro DEVICE_NAME.&lt;/p&gt;
&lt;p&gt;The code as below:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;        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);
        
    		if(at_com_data.device_name[0]==&amp;#39;N&amp;#39;)				// Device name has been saved in the flash.
    		{
    //			printf(&amp;quot;change device name: &amp;quot;);
    			printf(&amp;quot;change device name: %s&amp;quot;,(uint8_t *)&amp;amp;at_com_data.device_name[1]);
    			printf(&amp;quot;\r\n&amp;quot;);
    
    			err_code = sd_ble_gap_device_name_set(&amp;amp;sec_mode,
                                              (const uint8_t *)&amp;amp;at_com_data.device_name[1],
                                              DeviceNameLen);	
APP_ERROR_CHECK(err_code);
    			memset(&amp;amp;advdata, 0, sizeof(advdata));
    			advdata.name_type          = BLE_ADVDATA_FULL_NAME;
    			advdata.include_appearance = false;
    			advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;

    			err_code = ble_advdata_set(&amp;amp;advdata, NULL);
    			APP_ERROR_CHECK(err_code);	
    //			printf(&amp;quot;err_code=0x%08x\r\n&amp;quot;,err_code);
    		}	
    		else
// Device name isn&amp;#39;t in the flash.
    		{
    			printf(&amp;quot;defaule name\r\n&amp;quot;);
    			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);
    		}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since the chip has been powered up or reset,and can read the device name from the flash successfully,why cann&amp;#39;t change the device name?What I use is SDK9.0,S130 V1.0,PCA10028 where there is nRF51422 on the board.&lt;/p&gt;
&lt;p&gt;I also refer to your demo code and use a timer to change the name of a device every 10 second,most of time it is success.If the time less than 5 second,the device name canm&amp;#39;t be changed mostly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to change the device name?</title><link>https://devzone.nordicsemi.com/thread/36964?ContentTypeID=1</link><pubDate>Wed, 28 Oct 2015 11:50:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:89377929-7334-4354-8772-2bbaf9187206</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi. You will need to call ble_advdata_set() after you have changed the name with sd_ble_gap_device_name_set(). See &lt;a href="https://devzone.nordicsemi.com/question/2334/is-it-possible-to-change-the-device-name-handle-value-manually/"&gt;this thread&lt;/a&gt; for more info.&lt;/p&gt;
&lt;p&gt;I have attached an example that uses a timer to change the name of a device every other second. It uses SDK V9 and Softdevice S110 V8. Search for // NORDIC in the example for comments.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/change_2D00_device_2D00_name.zip"&gt;Example&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>