• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 BLUETOOTH_BLE_COMMON_H
17 #define BLUETOOTH_BLE_COMMON_H
18 
19 #include "bluetooth_ble_ffi.h"
20 #include "bluetooth_gatt_service.h"
21 #include "cj_common_ffi.h"
22 
23 namespace OHOS {
24 namespace CJSystemapi {
25 namespace CJBluetoothBle {
26 using Bluetooth::GattCharacteristic;
27 using Bluetooth::GattDescriptor;
28 using Bluetooth::GattService;
29 
30 enum ProfileConnectionState {
31     STATE_DISCONNECTED = 0, // the current profile is disconnected
32     STATE_CONNECTING = 1,   // the current profile is being connected
33     STATE_CONNECTED = 2,    // the current profile is connected
34     STATE_DISCONNECTING = 3 // the current profile is being disconnected
35 };
36 
37 char *MallocCString(const std::string &origin);
38 CArrString Convert2CArrString(std::vector<std::string> &tids);
39 CArrUI8 Convert2CArrUI8(std::vector<uint8_t> vec);
40 std::string GetGattClientDeviceId();
41 CArrBLECharacteristic Convert2CArrBLECharacteristic(std::vector<GattCharacteristic> characteristics);
42 CArrGattService Convert2CArrGattService(std::vector<GattService> services);
43 CArrBLEDescriptor Convert2CArrBLEDescriptor(std::vector<GattDescriptor> &descriptors);
44 NativeGattProperties ConvertGattPropertiesToCJ(int properties);
45 NativeBLECharacteristic ConvertBLECharacteristicToCJ(GattCharacteristic &characteristic);
46 NativeGattService ConvertGattServiceToCJ(GattService service);
47 NativeBLEDescriptor ConvertBLEDescriptorToCJ(GattDescriptor &descriptor);
48 uint16_t ConvertGattPermissions(const NativeGattPermission &nativePermissions);
49 uint16_t ConvertGattProperties(const NativeGattProperties &nativeProperties);
50 int GetProfileConnectionState(int state);
51 void FreeNativeBLECharacteristic(NativeBLECharacteristic characteristic);
52 void FreeNativeBLEDescriptor(NativeBLEDescriptor descriptor);
53 } // namespace CJBluetoothBle
54 } // namespace CJSystemapi
55 } // namespace OHOS
56 
57 #endif // BLUETOOTH_BLE_COMMON_H