5
5
* Author: Jack Chen <redchenjs@live.com>
6
6
*/
7
7
8
+ #include <string.h>
9
+
8
10
#include "esp_bt.h"
9
11
#include "esp_log.h"
10
12
#include "esp_bt_main.h"
11
13
#include "esp_bt_device.h"
12
14
13
15
#define TAG "bt"
14
16
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
+ }
16
42
17
43
void bt_init (void )
18
44
{
@@ -26,7 +52,13 @@ void bt_init(void)
26
52
ESP_ERROR_CHECK (esp_bluedroid_init ());
27
53
ESP_ERROR_CHECK (esp_bluedroid_enable ());
28
54
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 ));
30
62
31
63
ESP_LOGI (TAG , "initialized, bt: 1, ble: %d" ,
32
64
#ifdef CONFIG_ENABLE_BLE_CONTROL_IF
0 commit comments