• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 # Copyright (C) 2024 HiHope Open Source Organization .
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 OHOS_SLE_CONNECTION_MANAGER_H
16 #define OHOS_SLE_CONNECTION_MANAGER_H
17 
18 
19 #include "sle_connection_manager.h"
20 #include "ohos_sle_errcode.h"
21 #include "ohos_sle_common.h"
22 
23 typedef struct {
24     uint16_t connId;             /*!< @if Eng connection ID
25                                        @else   连接ID @endif */
26     uint16_t intervalMin;        /*!< @if Eng minimum interval
27                                        @else   链路调度最小间隔,单位slot @endif */
28     uint16_t intervalMax;        /*!< @if Eng maximum interval
29                                        @else   链路调度最大间隔,单位slot @endif */
30     uint16_t maxLatency;         /*!< @if Eng maximum latency
31                                        @else   延迟周期,单位slot @endif */
32     uint16_t supervisionTimeout; /*!< @if Eng timeout
33                                        @else   超时时间,单位10ms @endif */
34 } SleConnectionParamUpdate;
35 
36 typedef struct {
37     uint16_t interval;              /*!< @if Eng interval
38                                          @else   链路调度间隔,单位slot @endif */
39     uint16_t latency;               /*!< @if Eng latency
40                                          @else   延迟周期,单位slot @endif */
41     uint16_t supervision;           /*!< @if Eng timeout
42                                          @else   超时时间,单位10ms @endif */
43 } SleConnectionParamUpdateEvt;
44 
45 
46 ErrCodeType SleGetPairedDevicesNum(uint16_t *number);
47 
48 ErrCodeType SleGetPairedDevices(SleAddr *addr, uint16_t *number);
49 
50 ErrCodeType SleGetPairState(const SleAddr *addr, uint8_t *state);
51 
52 ErrCodeType SleRemovePairedRemoteDevice(const SleAddr *addr);
53 
54 ErrCodeType SleRemoveAllPairs(void);
55 
56 ErrCodeType SleReadRemoteDeviceRssi(uint16_t connId);
57 
58 ErrCodeType SleUpdateConnectParam(SleConnectionParamUpdate *params);
59 
60 ErrCodeType SleConnectRemoteDevice(const SleAddr *addr);
61 
62 ErrCodeType SleDisconnectRemoteDevice(const SleAddr *addr);
63 
64 ErrCodeType SlePairRemoteDevice(const SleAddr *addr);
65 
66 
67 
68 
69 typedef void (*SleConnectStateChangedCallback)(uint16_t connId, const SleAddr *addr, SleAcbStateType connState,
70  SlePairStateType pairState, SleDiscReasonType discReason);
71 
72 typedef void (*SlePairCompleteCallback)(uint16_t connId, const SleAddr *addr, ErrCodeType status);
73 
74 typedef void (*SleReadRssiCallback)(uint16_t connId, int8_t rssi, ErrCodeType status);
75 
76 typedef void (*SleConnectParamUpdateCallback)(uint16_t connId, ErrCodeType status, const SleConnectionParamUpdateEvt *param);
77 
78 typedef void (*SleConnectParamUpdateReqCallback)(uint16_t conn_id, errcode_t status,const sle_connection_param_update_req_t *param);
79 
80 typedef void (*SleAuthCompleteCallback)(uint16_t conn_id, const SleAddr *addr, errcode_t status,const sle_auth_info_evt_t* evt);
81 
82 typedef struct {
83    SleConnectStateChangedCallback connectStateChangedCb; /*!< @if Eng Connect state changed callback.
84                                                                           @else   连接状态改变回调函数。 @endif */
85    SleConnectParamUpdateReqCallback connectParamUpdateReqCb;   /*!< @if Eng Connect param updated callback.
86                                                                           @else   连接参数更新回调函数。 @endif */
87    SleConnectParamUpdateCallback connectParamUpdateCb;           /*!< @if Eng Connect param updated callback.
88                                                                             @else   连接参数更新回调函数。 @endif */
89     SleAuthCompleteCallback authCompleteCb;                         /*!< @if Eng Authentication complete callback.
90                                                                             @else   认证完成回调函数。 @endif */
91     SlePairCompleteCallback pairCompleteCb;                         /*!< @if Eng Pairing complete callback.
92                                                                             @else   配对完成回调函数。 @endif */
93     SleReadRssiCallback readRssiCb;                                 /*!< @if Eng Read rssi callback.
94                                                                             @else   读取rssi回调函数。 @endif */
95 } SleConnectionCallbacks;
96 
97 
98 ErrCodeType SleConnectionRegisterCallbacks(SleConnectionCallbacks *func);
99 
100 #endif
101