1 /*
2  * Copyright (C) 2021 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 "rfcomm_defs.h"
17 
RfcommRecvChannelSecurityResult(uint16_t result,GapServiceSecurityInfo serviceInfo,void * context)18 void RfcommRecvChannelSecurityResult(uint16_t result, GapServiceSecurityInfo serviceInfo, void *context)
19 {
20     LOG_INFO("%{public}s result:%hu", __func__, result);
21 
22     bool isChannelValid = RfcommIsChannelValid((RfcommChannelInfo *)context);
23     if (!isChannelValid) {
24         LOG_ERROR("%{public}s:DLC is closed.", __func__);
25         return;
26     }
27 
28     RfcommChannelEvtFsm((RfcommChannelInfo *)context, EV_CHANNEL_RECV_SECURITY_RESULT, (void *)&result);
29 }
30 
RfcommRecvSessionSecurityResult(uint16_t result,GapServiceSecurityInfo serviceInfo,void * context)31 void RfcommRecvSessionSecurityResult(uint16_t result, GapServiceSecurityInfo serviceInfo, void *context)
32 {
33     LOG_INFO("%{public}s result:%hu, direction:%{public}d.", __func__, result, serviceInfo.direction);
34 
35     RfcommSessionSecurityRslt securityRslt;
36     securityRslt.result = result;
37     securityRslt.direction = serviceInfo.direction;
38 
39     bool isSessionValid = RfcommIsSessionValid((RfcommSessionInfo *)context);
40     if (!isSessionValid) {
41         LOG_ERROR("%{public}s:Session is closed.", __func__);
42         return;
43     }
44 
45     RfcommSessionEvtFsm((RfcommSessionInfo *)context, EV_SESSION_RECV_SECURITY_RESULT, (void *)&securityRslt);
46 }