55 * Author: Jack Chen <redchenjs@live.com>
66 */
77
8+ #include <string.h>
9+
810#include "esp_bt.h"
911#include "esp_log.h"
1012#include "esp_bt_main.h"
1113#include "esp_bt_device.h"
1214
1315#define TAG "bt"
1416
15- const char * bt_dev_address = NULL ;
17+ static char bt_mac_string [18 ] = {0 };
18+ static char ble_mac_string [18 ] = {0 };
19+
20+ static uint8_t bt_mac_address [6 ] = {0 };
21+ static uint8_t ble_mac_address [6 ] = {0 };
22+
23+ char * bt_get_mac_string (void )
24+ {
25+ return bt_mac_string ;
26+ }
27+
28+ char * ble_get_mac_string (void )
29+ {
30+ return ble_mac_string ;
31+ }
32+
33+ uint8_t * bt_get_mac_address (void )
34+ {
35+ return bt_mac_address ;
36+ }
37+
38+ uint8_t * ble_get_mac_address (void )
39+ {
40+ return ble_mac_address ;
41+ }
1642
1743void bt_init (void )
1844{
@@ -26,7 +52,13 @@ void bt_init(void)
2652 ESP_ERROR_CHECK (esp_bluedroid_init ());
2753 ESP_ERROR_CHECK (esp_bluedroid_enable ());
2854
29- bt_dev_address = (const char * )esp_bt_dev_get_address ();
55+ memcpy (bt_mac_address , esp_bt_dev_get_address (), sizeof (bt_mac_address ));
56+ memcpy (ble_mac_address , esp_bt_dev_get_address (), sizeof (ble_mac_address ));
57+
58+ ble_mac_address [0 ] |= 0xC0 ;
59+
60+ snprintf (bt_mac_string , sizeof (bt_mac_string ), MACSTR , MAC2STR (bt_mac_address ));
61+ snprintf (ble_mac_string , sizeof (ble_mac_string ), MACSTR , MAC2STR (ble_mac_address ));
3062
3163 ESP_LOGI (TAG , "initialized, bt: 1, ble: %d" ,
3264#ifdef CONFIG_ENABLE_BLE_CONTROL_IF
0 commit comments