<?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>sd_ble_gap_addr_set is the correct way to change device real MAC ?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/69530/sd_ble_gap_addr_set-is-the-correct-way-to-change-device-real-mac</link><description>Hi, I try to change my MAC address, but return error code 8. 
 
 
 
 check error code 8 is : 
 
 So I try set the mac address after ble connected. and the function sd_ble_gap_addr_set retrun success, and try use sd_ble_gap_addr_get is what my last set</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 15 Dec 2020 12:25:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/69530/sd_ble_gap_addr_set-is-the-correct-way-to-change-device-real-mac" /><item><title>RE: sd_ble_gap_addr_set is the correct way to change device real MAC ?</title><link>https://devzone.nordicsemi.com/thread/285054?ContentTypeID=1</link><pubDate>Tue, 15 Dec 2020 12:25:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e7a1c0f-27b8-491f-a4f6-040c6c4deba9</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;&lt;span&gt;&lt;span&gt;Hi,&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;The address must be set with &lt;/span&gt;&lt;a title="sd_ble_gap_addr_set" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v7.2.0/group___b_l_e___g_a_p___f_u_n_c_t_i_o_n_s.html?cp=4_7_3_1_2_1_3_1#gaef69dc212534adf4b78d211edce2267b"&gt;sd_ble_gap_addr_set() &lt;/a&gt;&lt;/span&gt;&lt;span&gt;before you start start advertising or enter a connection, otherwise it will return error 8 (NRF_ERROR_INVALID_STATE) as you experienced.&lt;/span&gt;&lt;/p&gt;
[quote user=""]But after device reboot ,&amp;nbsp; MAC change back to the origin Nordic random MAC address!!![/quote]
&lt;p&gt;&amp;nbsp;This is as excepted. The Softdevice will not store the address you provide in persistent memory, so you have to call sd_ble_gap_addr_set() with your address on every reboot (unless you want to use the device&amp;#39;s random address)&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>