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 CallbackParam & callbackParam)21 void BluetoothClientSocketObserverProxy::OnConnectionStateChanged(const CallbackParam &callbackParam)
22 {
23 MessageParcel data;
24 MessageParcel reply;
25 MessageOption option(MessageOption::TF_SYNC);
26 if (!data.WriteInterfaceToken(BluetoothClientSocketObserverProxy::GetDescriptor())) {
27 HILOGE("WriteInterfaceToken error");
28 return;
29 }
30 data.WriteParcelable(&callbackParam.dev);
31
32 BluetoothUuid btUuid(callbackParam.uuid);
33 data.WriteParcelable(&btUuid);
34 data.WriteInt32(callbackParam.status);
35 data.WriteInt32(callbackParam.result);
36 data.WriteInt32(callbackParam.type);
37 data.WriteInt32(callbackParam.psm);
38 int32_t st = Remote()->SendRequest(static_cast<uint32_t>(BT_SOCKET_OBSERVER_CONNECTION_STATE_CHANGED),
39 data, reply, option);
40 if (st != ERR_NONE) {
41 HILOGE("OnConnectionStateChanged failed, error code is %{public}d", st);
42 return;
43 }
44
45 return;
46 }
47 } // namespace Bluetooth
48 } // namespace OHOS