• 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 #ifndef LOG_TAG
16 #define LOG_TAG "bt_cj_connection_ffi"
17 #endif
18 
19 #include "bluetooth_connection_ffi.h"
20 
21 #include "bluetooth_connection_impl.h"
22 #include "bluetooth_log.h"
23 
24 using namespace OHOS::FFI;
25 
26 namespace OHOS {
27 namespace CJSystemapi {
28 namespace CJBluetoothConnection {
29 
30 extern "C" {
FfiBluetoothConPairDevice(const char * deviceId,int32_t * errCode)31 void FfiBluetoothConPairDevice(const char* deviceId, int32_t* errCode)
32 {
33     return ConnectionImpl::PairDevice(deviceId, errCode);
34 }
35 
FfiBluetoothConGetRemoteDeviceName(const char * deviceId,int32_t * errCode)36 char* FfiBluetoothConGetRemoteDeviceName(const char* deviceId, int32_t* errCode)
37 {
38     return ConnectionImpl::GetRemoteDeviceName(deviceId, errCode);
39 }
40 
FfiBluetoothConGetRemoteDeviceClass(const char * deviceId,int32_t * errCode)41 DeviceClass FfiBluetoothConGetRemoteDeviceClass(const char* deviceId, int32_t* errCode)
42 {
43     return ConnectionImpl::GetRemoteDeviceClass(deviceId, errCode);
44 }
45 
FfiBluetoothConGetRemoteProfileUuids(const char * deviceId,int32_t * errCode)46 CArrString FfiBluetoothConGetRemoteProfileUuids(const char* deviceId, int32_t* errCode)
47 {
48     return ConnectionImpl::GetRemoteProfileUuids(deviceId, errCode);
49 }
50 
FfiBluetoothConGetLocalName(int32_t * errCode)51 char* FfiBluetoothConGetLocalName(int32_t* errCode)
52 {
53     return ConnectionImpl::GetLocalName(errCode);
54 }
55 
FfiBluetoothConGetPairedDevices(int32_t * errCode)56 CArrString FfiBluetoothConGetPairedDevices(int32_t* errCode)
57 {
58     return ConnectionImpl::GetPairedDevices(errCode);
59 }
60 
FfiBluetoothConGetPairState(const char * deviceId,int32_t * errCode)61 int32_t FfiBluetoothConGetPairState(const char* deviceId, int32_t* errCode)
62 {
63     return ConnectionImpl::GetPairState(deviceId, errCode);
64 }
65 
FfiBluetoothConGetProfileConnectionState(int32_t profileId,int32_t * errCode)66 int32_t FfiBluetoothConGetProfileConnectionState(int32_t profileId, int32_t* errCode)
67 {
68     return ConnectionImpl::GetProfileConnectionState(profileId, errCode);
69 }
70 
FfiBluetoothConSetDevicePairingConfirmation(const char * deviceId,bool accept,int32_t * errCode)71 void FfiBluetoothConSetDevicePairingConfirmation(const char* deviceId, bool accept, int32_t* errCode)
72 {
73     return ConnectionImpl::SetDevicePairingConfirmation(deviceId, accept, errCode);
74 }
75 
FfiBluetoothConSetDevicePinCode(const char * deviceId,const char * code,int32_t * errCode)76 void FfiBluetoothConSetDevicePinCode(const char* deviceId, const char* code, int32_t* errCode)
77 {
78     return ConnectionImpl::SetDevicePinCode(deviceId, code, errCode);
79 }
80 
FfiBluetoothConSetLocalName(const char * localName,int32_t * errCode)81 void FfiBluetoothConSetLocalName(const char* localName, int32_t* errCode)
82 {
83     return ConnectionImpl::SetLocalName(localName, errCode);
84 }
85 
FfiBluetoothConSetBluetoothScanMode(int32_t mode,int32_t duration,int32_t * errCode)86 void FfiBluetoothConSetBluetoothScanMode(int32_t mode, int32_t duration, int32_t* errCode)
87 {
88     return ConnectionImpl::SetBluetoothScanMode(mode, duration, errCode);
89 }
90 
FfiBluetoothConGetBluetoothScanMode(int32_t * errCode)91 int32_t FfiBluetoothConGetBluetoothScanMode(int32_t* errCode)
92 {
93     return ConnectionImpl::GetBluetoothScanMode(errCode);
94 }
95 
FfiBluetoothConStartBluetoothDiscovery(int32_t * errCode)96 void FfiBluetoothConStartBluetoothDiscovery(int32_t* errCode)
97 {
98     return ConnectionImpl::StartBluetoothDiscovery(errCode);
99 }
100 
FfiBluetoothConStopBluetoothDiscovery(int32_t * errCode)101 void FfiBluetoothConStopBluetoothDiscovery(int32_t* errCode)
102 {
103     return ConnectionImpl::StopBluetoothDiscovery(errCode);
104 }
105 
FfiBluetoothConIsBluetoothDiscovering(int32_t * errCode)106 bool FfiBluetoothConIsBluetoothDiscovering(int32_t* errCode)
107 {
108     return ConnectionImpl::IsBluetoothDiscovering(errCode);
109 }
110 
FfiBluetoothConSetRemoteDeviceName(const char * deviceId,const char * name,int32_t * errCode)111 void FfiBluetoothConSetRemoteDeviceName(const char* deviceId, const char* name, int32_t* errCode)
112 {
113     return ConnectionImpl::SetRemoteDeviceName(deviceId, name, errCode);
114 }
115 
FfiBluetoothConGetRemoteDeviceBatteryInfo(const char * deviceId,int32_t * errCode)116 CBatteryInfo FfiBluetoothConGetRemoteDeviceBatteryInfo(const char* deviceId, int32_t* errCode)
117 {
118     return ConnectionImpl::GetRemoteDeviceBatteryInfo(deviceId, errCode);
119 }
120 
FfiBluetoothConOn(int32_t callbackType,void (* callback)(),int32_t * errCode)121 void FfiBluetoothConOn(int32_t callbackType, void (*callback)(), int32_t* errCode)
122 {
123     return ConnectionImpl::RegisterConnectionObserver(callbackType, callback, errCode);
124 }
125 }
126 } // namespace CJBluetoothConnection
127 } // namespace CJSystemapi
128 } // namespace OHOS