Skip to content

Commit

Permalink
Merge branch 'feature/btdm_common_api' into 'master'
Browse files Browse the repository at this point in the history
component/bt : add bt device api

1. add get bd_addr function

later, will add other functions reference with bluetooth device.

See merge request !380
  • Loading branch information
jack0c committed Jan 9, 2017
2 parents 37fbe9e + 9c630b7 commit 0106fee
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 0 deletions.
22 changes: 22 additions & 0 deletions components/bt/bluedroid/api/esp_bt_device.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.


#include "esp_bt_device.h"
#include "controller.h"

const uint8_t *esp_bt_dev_get_address(void)
{
return controller_get_interface()->get_address()->address;
}
3 changes: 3 additions & 0 deletions components/bt/bluedroid/api/include/esp_bt_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ typedef enum {
/// Maximum of the application id
#define ESP_APP_ID_MAX 0x7fff

#define ESP_BD_ADDR_STR "%02x:%02x:%02x:%02x:%02x:%02x"
#define ESP_BD_ADDR_HEX(addr) addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]

#ifdef __cplusplus
}
#endif
Expand Down
38 changes: 38 additions & 0 deletions components/bt/bluedroid/api/include/esp_bt_device.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef __ESP_BT_DEVICE_H__
#define __ESP_BT_DEVICE_H__

#include <stdint.h>
#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
*
* @brief Get bluetooth device address. Must use after "esp_bluedroid_enable".
*
* @return bluetooth device address (six bytes)
*/
const uint8_t *esp_bt_dev_get_address(void);

#ifdef __cplusplus
}
#endif


#endif /* __ESP_BT_DEVICE_H__ */
1 change: 1 addition & 0 deletions docs/api/bt_common.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ BT COMMON

Bluetooth DEFINE <esp_bt_defs>
Bluetooth MAIN <esp_bt_main>
Bluetooth DEVICE <esp_bt_device>
48 changes: 48 additions & 0 deletions docs/api/esp_bt_device.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
BT DEVICE APIs
===============

Overview
--------

Bluetooth device reference APIs.

`Instructions`_

Application Example
-------------------

`Instructions`_

.. _Instructions: template.html


API Reference
-------------

Header Files
^^^^^^^^^^^^

* `bt/bluedroid/api/include/esp_bt_device.h <https://github.com/espressif/esp-idf/blob/master/components/bt/bluedroid/api/include/esp_bt_device.h>`_


Macros
^^^^^^


Type Definitions
^^^^^^^^^^^^^^^^


Enumerations
^^^^^^^^^^^^


Structures
^^^^^^^^^^


Functions
^^^^^^^^^

.. doxygenfunction:: esp_bt_dev_get_address

3 changes: 3 additions & 0 deletions examples/12_blufi/main/blufi_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "esp_bt_defs.h"
#include "esp_gap_ble_api.h"
#include "esp_bt_main.h"
#include "esp_bt_device.h"
#include "blufi_demo.h"

static void blufi_event_callback(esp_blufi_cb_event_t event, esp_blufi_cb_param_t *param);
Expand Down Expand Up @@ -328,6 +329,8 @@ void app_main()
return;
}

BLUFI_INFO("BD ADDR: "ESP_BD_ADDR_STR"\n", ESP_BD_ADDR_HEX(esp_bt_dev_get_address()));

BLUFI_INFO("BLUFI VERSION %04x\n", esp_blufi_get_version());

blufi_security_init();
Expand Down

0 comments on commit 0106fee

Please sign in to comment.