<?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 send mac address as characteristic value?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/10684/how-to-send-mac-address-as-characteristic-value</link><description>hello! i want to send mac address of my bluetooth device. i have written function 
 uint32_t get_address(void)
{
 uint32_t err_code;
 ble_gap_addr_t ble_gap_addr;
 memset(&amp;amp;ble_gap_addr, 0, sizeof(ble_gap_addr));
 ble_gap_addr.addr_type= BLE_GAP_ADDR_TYPE_PUBLIC;</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 13 Dec 2015 05:52:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/10684/how-to-send-mac-address-as-characteristic-value" /><item><title>RE: how to send mac address as characteristic value?</title><link>https://devzone.nordicsemi.com/thread/39890?ContentTypeID=1</link><pubDate>Sun, 13 Dec 2015 05:52:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2deb7ccb-860f-4a63-a710-2ad9f19bfb32</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;thanks for your help. its working&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to send mac address as characteristic value?</title><link>https://devzone.nordicsemi.com/thread/39885?ContentTypeID=1</link><pubDate>Tue, 08 Dec 2015 11:22:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0f11b7c-eb3d-4097-9cdb-4ae9fa3cb043</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;The device you connect to can read your address when you send it BLE packets.
I do not know why you want to send it as a characteristic, but this would in most cases be unnecessary.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to send mac address as characteristic value?</title><link>https://devzone.nordicsemi.com/thread/39889?ContentTypeID=1</link><pubDate>Mon, 07 Dec 2015 14:50:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c93a0c61-66a6-4aef-980a-55f25f22918f</guid><dc:creator>monpetit</dc:creator><description>&lt;p&gt;like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ble_gap_addr_t ble_gap_addr;

uint32_t get_address(void)
{
    return sd_ble_gap_address_get(&amp;amp;ble_gap_addr);
}

int main(void)
{
    ......

    while (1) {
        uint32_t err_code;
        err_code = get_address();
        APP_ERROR_CHECK(err_code);
        err_code = custom_service_update_data(m_conn_handle, ble_gap_addr.addr);
        APP_ERROR_CHECK(err_code);
        app_sched_execute();
        power_manage(); 
    } 
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to send mac address as characteristic value?</title><link>https://devzone.nordicsemi.com/thread/39888?ContentTypeID=1</link><pubDate>Mon, 07 Dec 2015 14:20:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:00f75942-ae24-420f-a0c1-eac9f50ed5ea</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;then what should i return value?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to send mac address as characteristic value?</title><link>https://devzone.nordicsemi.com/thread/39887?ContentTypeID=1</link><pubDate>Mon, 07 Dec 2015 14:13:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b45584bf-dc7d-4d7c-85e8-1715f9ff85fe</guid><dc:creator>monpetit</dc:creator><description>&lt;p&gt;The return value of your function get_address() is not mac address but the error code of nRF51 SDK. The value is NRF_SUCCESS or NRF_ERROR_INVALID_ADDR.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to send mac address as characteristic value?</title><link>https://devzone.nordicsemi.com/thread/39886?ContentTypeID=1</link><pubDate>Mon, 07 Dec 2015 13:19:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cf91afbc-3686-4a0a-8abb-1e257b0d5d14</guid><dc:creator>rushin</dc:creator><description>&lt;p&gt;hello i declared ble_gap_addr outside function and write function as below&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint8_t get_address(void)
{
    uint8_t err_code;
    memset(&amp;amp;ble_gap_addr, 0, sizeof(ble_gap_addr));
    ble_gap_addr.addr_type= BLE_GAP_ADDR_TYPE_RANDOM_STATIC;//BLE_GAP_ADDR_TYPE_PUBLIC;
    err_code = sd_ble_gap_address_get(&amp;amp;ble_gap_addr);
    return(err_code);
} 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and then
i write main code as below&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;int main(void)
{ 
    uint32_t err_code;
    uint8_t		char2_data[CHARACTERISTIC_SIZE];
    uint8_t i=0;
    // Initialize
    timers_init();
    ble_stack_init();
    scheduler_init();
    gap_params_init();
    advertising_init();
    conn_params_init();
    sec_params_init();

    // Start execution
    advertising_start();
    get_address();
    services_init();

 while(1)
 {
        char2_data[8] = get_address();//{0x10,0x20,};
        err_code = custom_service_update_data(m_conn_handle,char2_data);
        APP_ERROR_CHECK(err_code);
        app_sched_execute();
        power_manage();
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;but in master control panel i am getting like this&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;AttributeHandleschanged Value:BD-9D-01-00-A8-2C-00-20-00-00-00-00-ED-84-01
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;can you tell me what should i return?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to send mac address as characteristic value?</title><link>https://devzone.nordicsemi.com/thread/39891?ContentTypeID=1</link><pubDate>Sun, 06 Dec 2015 13:38:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:04f71bd9-3d6d-4d4e-8c5e-4689c4713342</guid><dc:creator>Ulrich Myhre</dc:creator><description>&lt;p&gt;The address is stored in the &lt;em&gt;ble_gap_addr&lt;/em&gt; variable, which goes out of scope once you leave the function. You need to either declare the variable outside of this function, or make the function take a &lt;em&gt;ble_gap_addr_t&lt;/em&gt;-pointer which you then use in the &lt;strong&gt;sd_ble_gap_address_get()&lt;/strong&gt; call.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>