• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef SOFTBUS_ADAPTER_BT_COMMON_H
17 #define SOFTBUS_ADAPTER_BT_COMMON_H
18 
19 #include <stdbool.h>
20 #include <stdint.h>
21 
22 #include "softbus_type_def.h"
23 
24 #ifdef __cplusplus
25 #if __cplusplus
26 extern "C" {
27 #endif
28 #endif
29 
30 #define BT_ADDR_LEN 6
31 #define BT_UUID_LEN 16
32 
33 #define BLE_DISABLE 0
34 #define BLE_ENABLE 1
35 
36 #define MAC_FIRST_INDEX 0
37 #define MAC_ONE_INDEX 1
38 #define MAC_FIVE_INDEX 5
39 
40 typedef enum {
41     SOFTBUS_BT_STATUS_SUCCESS = 0x00,
42     SOFTBUS_BT_STATUS_FAIL,
43     SOFTBUS_BT_STATUS_NOT_READY,
44     SOFTBUS_BT_STATUS_NOMEM,
45     SOFTBUS_BT_STATUS_BUSY,
46     SOFTBUS_BT_STATUS_DONE,
47     SOFTBUS_BT_STATUS_UNSUPPORTED,
48     SOFTBUS_BT_STATUS_PARM_INVALID,
49     SOFTBUS_BT_STATUS_UNHANDLED,
50     SOFTBUS_BT_STATUS_AUTH_FAILURE,
51     SOFTBUS_BT_STATUS_RMT_DEV_DOWN,
52     SOFTBUS_BT_STATUS_AUTH_REJECTED
53 } SoftBusBtStatus;
54 
55 typedef enum {
56     SOFTBUS_BT_STATE_TURNING_ON = 0x0,
57     SOFTBUS_BT_STATE_TURN_ON,
58     SOFTBUS_BT_STATE_TURNING_OFF,
59     SOFTBUS_BT_STATE_TURN_OFF,
60     SOFTBUS_BR_STATE_TURNING_ON,
61     SOFTBUS_BR_STATE_TURN_ON,
62     SOFTBUS_BR_STATE_TURNING_OFF,
63     SOFTBUS_BR_STATE_TURN_OFF
64 } SoftBusBtStackState;
65 
66 typedef struct {
67     unsigned char addr[BT_ADDR_LEN];
68 } SoftBusBtAddr;
69 
70 typedef struct {
71     unsigned char uuidLen;
72     char *uuid;
73 } SoftBusBtUuid;
74 
75 typedef enum {
76     SOFTBUS_BT_CONNECT = 0x01,
77     SOFTBUS_BT_DISCONNECT = 0x03
78 } SoftBusBtConnectState;
79 
80 typedef struct {
81     void (*OnBtStateChanged)(int listenerId, int state);
82 } SoftBusBtStateListener;
83 
84 int SoftBusEnableBt(void);
85 
86 int SoftBusDisableBt(void);
87 
88 int SoftBusGetBtState(void);
89 
90 int SoftBusGetBtMacAddr(SoftBusBtAddr *mac);
91 
92 int SoftBusGetBtName(unsigned char *name, unsigned int *len);
93 
94 int SoftBusSetBtName(const char *name);
95 
96 int SoftBusAddBtStateListener(const SoftBusBtStateListener *listener);
97 
98 int SoftBusRemoveBtStateListener(int listenerId);
99 
100 #ifdef __cplusplus
101 #if __cplusplus
102 }
103 #endif /* __cplusplus */
104 #endif /* __cplusplus */
105 #endif