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_CONNECTION_FFI_H
17 #define BLUETOOTH_CONNECTION_FFI_H
18 
19 #include "cj_common_ffi.h"
20 #include "native/ffi_remote_data.h"
21 
22 #include <cstdint>
23 
24 extern "C" {
25 typedef struct {
26     int majorClass;
27     int majorMinorClass;
28     int classOfDevice;
29 } DeviceClass;
30 
31 typedef struct {
32     char *deviceId;
33     char *pinCode;
34 } CPinRequiredParam;
35 
36 typedef struct {
37     char *deviceId;
38     int32_t state;
39     int32_t cause;
40 } CBondStateParam;
41 
42 typedef struct {
43     int batteryLevel;
44     int leftEarBatteryLevel;
45     int leftEarChargeState;
46     int rightEarBatteryLevel;
47     int rightEarChargeState;
48     int boxBatteryLevel;
49     int boxChargeState;
50 } CBatteryInfo;
51 
52 const int32_t REGISTER_BATTERY_CHANGE_TYPE = 0;
53 const int32_t REGISTER_DEVICE_FIND_TYPE = 1;
54 const int32_t REGISTER_BOND_STATE_TYPE = 2;
55 const int32_t REGISTER_PIN_REQUEST_TYPE = 3;
56 
57 FFI_EXPORT void FfiBluetoothConPairDevice(const char* deviceId, int32_t* errCode);
58 FFI_EXPORT char* FfiBluetoothConGetRemoteDeviceName(const char* deviceId, int32_t* errCode);
59 FFI_EXPORT DeviceClass FfiBluetoothConGetRemoteDeviceClass(const char* deviceId, int32_t* errCode);
60 FFI_EXPORT CArrString FfiBluetoothConGetRemoteProfileUuids(const char* deviceId, int32_t* errCode);
61 FFI_EXPORT char* FfiBluetoothConGetLocalName(int32_t* errCode);
62 FFI_EXPORT CArrString FfiBluetoothConGetPairedDevices(int32_t* errCode);
63 FFI_EXPORT int32_t FfiBluetoothConGetPairState(const char* deviceId, int32_t* errCode);
64 FFI_EXPORT int32_t FfiBluetoothConGetProfileConnectionState(int32_t profileId, int32_t* errCode);
65 FFI_EXPORT void FfiBluetoothConSetDevicePairingConfirmation(const char* deviceId, bool accept, int32_t* errCode);
66 FFI_EXPORT void FfiBluetoothConSetDevicePinCode(const char* deviceId, const char* code, int32_t* errCode);
67 FFI_EXPORT void FfiBluetoothConSetLocalName(const char* localName, int32_t* errCode);
68 FFI_EXPORT void FfiBluetoothConSetBluetoothScanMode(int32_t mode, int32_t duration, int32_t* errCode);
69 FFI_EXPORT int32_t FfiBluetoothConGetBluetoothScanMode(int32_t* errCode);
70 FFI_EXPORT void FfiBluetoothConStartBluetoothDiscovery(int32_t* errCode);
71 FFI_EXPORT void FfiBluetoothConStopBluetoothDiscovery(int32_t* errCode);
72 FFI_EXPORT bool FfiBluetoothConIsBluetoothDiscovering(int32_t* errCode);
73 FFI_EXPORT void FfiBluetoothConSetRemoteDeviceName(const char* deviceId, const char* name, int32_t* errCode);
74 FFI_EXPORT CBatteryInfo FfiBluetoothConGetRemoteDeviceBatteryInfo(const char* deviceId, int32_t* errCode);
75 FFI_EXPORT void FfiBluetoothConOn(int32_t callbackType, void (*callback)(), int32_t* errCode);
76 }
77 
78 #endif // BLUETOOTH_CONNECTION_FFI_H