• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-2022 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 #include "bluetooth_socket_observer_proxy.h"
17 #include "bluetooth_log.h"
18 
19 namespace OHOS {
20 namespace Bluetooth {
OnConnectionStateChanged(const BluetoothRawAddress & dev,bluetooth::Uuid uuid,int status,int result)21 void BluetoothClientSocketObserverProxy::OnConnectionStateChanged(const BluetoothRawAddress &dev, bluetooth::Uuid uuid,
22     int status, int result)
23 {
24     MessageParcel data;
25     MessageParcel reply;
26     MessageOption option(MessageOption::TF_SYNC);
27     if (!data.WriteInterfaceToken(BluetoothClientSocketObserverProxy::GetDescriptor())) {
28         HILOGE("WriteInterfaceToken error");
29         return;
30     }
31     data.WriteParcelable(&dev);
32 
33     BluetoothUuid btUuid(uuid);
34     data.WriteParcelable(&btUuid);
35     data.WriteInt32(status);
36     data.WriteInt32(result);
37     int32_t st = Remote()->SendRequest(static_cast<uint32_t>(BT_SOCKET_OBSERVER_CONNECTION_STATE_CHANGED),
38         data, reply, option);
39     if (st != ERR_NONE) {
40         HILOGE("OnConnectionStateChanged failed, error code is %{public}d", st);
41         return;
42     }
43 
44     return;
45 }
46 }  // namespace Bluetooth
47 }  // namespace OHOS