1bc2ed2b3Sopenharmony_ci/*
2bc2ed2b3Sopenharmony_ci * Copyright (C) 2022 Huawei Device Co., Ltd.
3bc2ed2b3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4bc2ed2b3Sopenharmony_ci * you may not use this file except in compliance with the License.
5bc2ed2b3Sopenharmony_ci * You may obtain a copy of the License at
6bc2ed2b3Sopenharmony_ci *
7bc2ed2b3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8bc2ed2b3Sopenharmony_ci *
9bc2ed2b3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10bc2ed2b3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11bc2ed2b3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12bc2ed2b3Sopenharmony_ci * See the License for the specific language governing permissions and
13bc2ed2b3Sopenharmony_ci * limitations under the License.
14bc2ed2b3Sopenharmony_ci */
15bc2ed2b3Sopenharmony_ci#include "nfc_basic_proxy.h"
16bc2ed2b3Sopenharmony_ci
17bc2ed2b3Sopenharmony_ci#include "loghelper.h"
18bc2ed2b3Sopenharmony_ci
19bc2ed2b3Sopenharmony_cinamespace OHOS {
20bc2ed2b3Sopenharmony_cinamespace NFC {
21bc2ed2b3Sopenharmony_ciint NfcBasicProxy::SendRequestExpectReplyStringAndStatusCode(uint32_t cmd,
22bc2ed2b3Sopenharmony_ci    MessageParcel& data, MessageParcel& reply, MessageOption& option, std::string& result)
23bc2ed2b3Sopenharmony_ci{
24bc2ed2b3Sopenharmony_ci    int ret = remoteObj_->SendRequest(cmd, data, reply, option);
25bc2ed2b3Sopenharmony_ci    if (ret == ERR_NONE) {
26bc2ed2b3Sopenharmony_ci        result = reply.ReadString();
27bc2ed2b3Sopenharmony_ci    }
28bc2ed2b3Sopenharmony_ci    InfoLog("SendRequestExpectReplyStringAndStatusCode, cmd %{public}d, ret %{public}d", cmd, ret);
29bc2ed2b3Sopenharmony_ci    return ret;
30bc2ed2b3Sopenharmony_ci}
31bc2ed2b3Sopenharmony_ci
32bc2ed2b3Sopenharmony_ciint NfcBasicProxy::SendRequestExpectReplyIntAndStatusCode(uint32_t cmd,
33bc2ed2b3Sopenharmony_ci    MessageParcel& data, MessageParcel& reply, MessageOption& option, int& result)
34bc2ed2b3Sopenharmony_ci{
35bc2ed2b3Sopenharmony_ci    int ret = remoteObj_->SendRequest(cmd, data, reply, option);
36bc2ed2b3Sopenharmony_ci    if (ret == ERR_NONE) {
37bc2ed2b3Sopenharmony_ci        result = reply.ReadInt32();
38bc2ed2b3Sopenharmony_ci    }
39bc2ed2b3Sopenharmony_ci    InfoLog("SendRequestExpectReplyIntAndStatusCode, cmd %{public}d, ret %{public}d, result %{public}d",
40bc2ed2b3Sopenharmony_ci        cmd, ret, result);
41bc2ed2b3Sopenharmony_ci    return ret;
42bc2ed2b3Sopenharmony_ci}
43bc2ed2b3Sopenharmony_ci
44bc2ed2b3Sopenharmony_ciint NfcBasicProxy::SendRequestExpectReplyBoolAndStatusCode(uint32_t cmd,
45bc2ed2b3Sopenharmony_ci    MessageParcel& data, MessageParcel& reply, MessageOption& option, bool& result)
46bc2ed2b3Sopenharmony_ci{
47bc2ed2b3Sopenharmony_ci    int32_t ret = remoteObj_->SendRequest(cmd, data, reply, option);
48bc2ed2b3Sopenharmony_ci    if (ret == ERR_NONE) {
49bc2ed2b3Sopenharmony_ci        result = reply.ReadBool();
50bc2ed2b3Sopenharmony_ci    }
51bc2ed2b3Sopenharmony_ci    InfoLog("SendRequestExpectReplyBoolAndStatusCode, cmd %{public}d, ret %{public}d, result %{public}d",
52bc2ed2b3Sopenharmony_ci        cmd, ret, result);
53bc2ed2b3Sopenharmony_ci    return ret;
54bc2ed2b3Sopenharmony_ci}
55bc2ed2b3Sopenharmony_ci
56bc2ed2b3Sopenharmony_ciint NfcBasicProxy::SendRequestExpectReplyNoneAndStatusCode(uint32_t cmd,
57bc2ed2b3Sopenharmony_ci    MessageParcel& data, MessageParcel& reply, MessageOption& option)
58bc2ed2b3Sopenharmony_ci{
59bc2ed2b3Sopenharmony_ci    int32_t ret = remoteObj_->SendRequest(cmd, data, reply, option);
60bc2ed2b3Sopenharmony_ci    InfoLog("SendRequestExpectReplyNoneAndStatusCode, cmd %{public}d, ret %{public}d", cmd, ret);
61bc2ed2b3Sopenharmony_ci    return ret;
62bc2ed2b3Sopenharmony_ci}
63bc2ed2b3Sopenharmony_ci
64bc2ed2b3Sopenharmony_ciint NfcBasicProxy::SendRequestExpectReplyInt(uint32_t cmd, MessageParcel& data, MessageOption& option, int& result)
65bc2ed2b3Sopenharmony_ci{
66bc2ed2b3Sopenharmony_ci    MessageParcel reply;
67bc2ed2b3Sopenharmony_ci    int ret = remoteObj_->SendRequest(cmd, data, reply, option);
68bc2ed2b3Sopenharmony_ci    if (ret == ERR_NONE) {
69bc2ed2b3Sopenharmony_ci        result = reply.ReadInt32();
70bc2ed2b3Sopenharmony_ci    }
71bc2ed2b3Sopenharmony_ci    InfoLog("SendRequestExpectReplyInt, cmd %{public}d, ret %{public}d, reply %{public}d", cmd, ret, result);
72bc2ed2b3Sopenharmony_ci    return ret;
73bc2ed2b3Sopenharmony_ci}
74bc2ed2b3Sopenharmony_ci
75bc2ed2b3Sopenharmony_ciint NfcBasicProxy::SendRequestExpectReplyBool(uint32_t cmd, MessageParcel& data, MessageOption& option, bool& result)
76bc2ed2b3Sopenharmony_ci{
77bc2ed2b3Sopenharmony_ci    MessageParcel reply;
78bc2ed2b3Sopenharmony_ci    int32_t ret = remoteObj_->SendRequest(cmd, data, reply, option);
79bc2ed2b3Sopenharmony_ci    if (ret == ERR_NONE) {
80bc2ed2b3Sopenharmony_ci        result = reply.ReadBool();
81bc2ed2b3Sopenharmony_ci    }
82bc2ed2b3Sopenharmony_ci    InfoLog("SendRequestExpectReplyBool, cmd %{public}d, ret %{public}d, reply %{public}d", cmd, ret, result);
83bc2ed2b3Sopenharmony_ci    return ret;
84bc2ed2b3Sopenharmony_ci}
85bc2ed2b3Sopenharmony_ci
86bc2ed2b3Sopenharmony_ciint NfcBasicProxy::SendRequestExpectReplyNone(uint32_t cmd, MessageParcel& data, MessageOption& option)
87bc2ed2b3Sopenharmony_ci{
88bc2ed2b3Sopenharmony_ci    MessageParcel reply;
89bc2ed2b3Sopenharmony_ci    int32_t ret = remoteObj_->SendRequest(cmd, data, reply, option);
90bc2ed2b3Sopenharmony_ci    InfoLog("SendRequestExpectReplyNone, cmd %{public}d, ret %{public}d", cmd, ret);
91bc2ed2b3Sopenharmony_ci    return ret;
92bc2ed2b3Sopenharmony_ci}
93bc2ed2b3Sopenharmony_ci}  // namespace NFC
94bc2ed2b3Sopenharmony_ci}  // namespace OHOS
95