• 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 WRAPPER_BR_INTERFACE_H
17 #define WRAPPER_BR_INTERFACE_H
18 
19 #include <stdbool.h>
20 #include <stdint.h>
21 
22 #include "softbus_adapter_bt_common.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #define BR_NAME_LEN 16
29 #define BT_ADDR_LEN 6
30 #define BT_UUID_LEN 16
31 
32 typedef uint8_t BT_UUIDL[BT_UUID_LEN];
33 typedef uint8_t BT_ADDR[BT_ADDR_LEN];
34 
35 #define BR_READ_SOCKET_CLOSED 0
36 #define BR_READ_FAILED (-1)
37 
38 typedef struct {
39     BT_UUIDL uuid;
40     BT_ADDR mac;
41     char name[BR_NAME_LEN];
42 } BluetoothRemoteDevice;
43 
44 typedef struct tagSppSocketDriver {
45     void (*Init)(const struct tagSppSocketDriver* this_p);
46     int32_t (*OpenSppServer)(const char *name, int32_t nameLen, const char *uuid, int32_t isSecure);
47     void (*CloseSppServer)(int32_t serverFd);
48     int32_t (*Connect)(const char *uuid, const BT_ADDR mac);
49     int32_t (*DisConnect)(int32_t clientFd);
50     bool (*IsConnected)(int32_t clientFd);
51     int32_t (*Accept)(int32_t serverFd);
52     int32_t (*Write)(int32_t clientFd, const char* buf, const int32_t length);
53     int32_t (*Read)(int32_t clientFd, char* buf, const int32_t length);
54     int32_t (*GetRemoteDeviceInfo)(int32_t clientFd, const BluetoothRemoteDevice* device);
55 } SppSocketDriver;
56 
57 SppSocketDriver* InitSppSocketDriver();
58 int32_t SppGattsRegisterHalCallback(const SoftBusBtStateListener *lister);
59 
60 #ifdef __cplusplus
61 }
62 #endif
63 #endif /* WRAPPER_BR_INTERFACE_H */