how to get the local bd address?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

  i want to get the local bd address, and i use the library function (void wiced_bt_dev_read_local_addr(wiced_bt_device_address_t bd_addr)).

I print the bd_addr ,but it is an array of two bytes which are not equal to six in the sample code. I want to know the reason and if i can use the function

to get local bd address.

Jane.Xia

1 Solution
BoonT_56
Employee
Employee
500 likes received 250 likes received 100 likes received

I inserted the api into the hello sensor app so that you can view the read-back of the bd address in the 1s-timer loop via teraterm.

void hello_sensor_timeout( uint32_t count )

{

   

    wiced_bt_device_address_t bda = { 0 };

    hello_sensor_state.timer_count++;

    WICED_BT_TRACE("hello_sensor_timeout: %d\n", hello_sensor_state.timer_count);

    wiced_bt_dev_read_local_addr(bda);

    WICED_BT_TRACE("Local Bluetooth Address: [%B]\n", bda);

   

}

View solution in original post

6 Replies
BoonT_56
Employee
Employee
500 likes received 250 likes received 100 likes received

You can check the implementation under the apps/demo/hci_serial_gatt_service/hci_control.c

void hci_control_handle_read_local_bda( void )

{

    wiced_bt_device_address_t bda = { 0 };

    wiced_bt_dev_read_local_addr(bda);

    WICED_BT_TRACE("Local Bluetooth Address: [%B]\n", bda);

    wiced_transport_send_data( HCI_CONTROL_EVENT_READ_LOCAL_BDA, (uint8_t*)bda , 6 );

}

0 Likes
BoonT_56
Employee
Employee
500 likes received 250 likes received 100 likes received

I inserted the api into the hello sensor app so that you can view the read-back of the bd address in the 1s-timer loop via teraterm.

void hello_sensor_timeout( uint32_t count )

{

   

    wiced_bt_device_address_t bda = { 0 };

    hello_sensor_state.timer_count++;

    WICED_BT_TRACE("hello_sensor_timeout: %d\n", hello_sensor_state.timer_count);

    wiced_bt_dev_read_local_addr(bda);

    WICED_BT_TRACE("Local Bluetooth Address: [%B]\n", bda);

   

}

Anonymous
Not applicable

Hi,

I do this as follows.

pastedImage_0.png

And i get the results like this:

pastedImage_1.png

Can you help me analyse the two results? Thanks.

Jane.Xia

0 Likes

I'm not too sure what you are asking me to analyse. You have got it right in your bd addr callback although you did not turn on the code as shown above. Anyhow, use the api as you deemed appropriate in your development.

0 Likes
Anonymous
Not applicable

I think you are worried about the "OK+LELADD: pj ". Since you are copying a uint8 string into a character string and printing the character string, the values are being displayed as ASCII when you are printing.

20 = Space

70=p

6a=j

20=space

fb and a8 not defined in the ASCII table.

Anonymous
Not applicable

I think you are right, and thank you for solving the puzzle.

0 Likes