• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
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  * Description: SLE Service Access Protocol SERVER module.
15  */
16 
17 /**
18  * @defgroup sle_ssap_server Service Access Protocol SERVER API
19  * @ingroup  SLE
20  * @{
21  */
22 
23 #ifndef SLE_SSAP_SERVER_H
24 #define SLE_SSAP_SERVER_H
25 
26 #include <stdbool.h>
27 #include <stdint.h>
28 #include "errcode.h"
29 #include "sle_common.h"
30 #include "sle_ssap_stru.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /**
37  * @if Eng
38  * @brief Struct of add property information.
39  * @else
40  * @brief 添加特征信息。
41  * @endif
42  */
43 typedef struct {
44     sle_uuid_t uuid;             /*!< @if Eng UUID of SSAP property.
45                                       @else   SSAP 特征 UUID。 @endif */
46     uint16_t permissions;        /*!< @if Eng Properity permissions. { @ref ssap_permission_t }
47                                       @else   特征权限。{ @ref ssap_permission_t }。 @endif */
48     uint32_t operate_indication; /*!< @if Eng Operate Indication. { @ref ssap_operate_indication_t }
49                                       @else   操作指示 { @ref ssap_operate_indication_t } @endif */
50     uint16_t value_len;          /*!< @if Eng Length of reponse data.
51                                       @else   响应的数据长度。 @endif */
52     uint8_t *value;              /*!< @if Eng Reponse data.
53                                       @else   响应的数据。 @endif */
54 } ssaps_property_info_t;
55 
56 /**
57  * @if Eng
58  * @brief Struct of add property descriptor information.
59  * @else
60  * @brief 添加特征描述符信息。
61  * @endif
62  */
63 typedef struct {
64     sle_uuid_t uuid;             /*!< @if Eng UUID of SSAP descriptor.
65                                       @else   SSAP 描述符 UUID。 @endif */
66     uint16_t permissions;        /*!< @if Eng descriptor permissions. { @ref ssap_permission_t }.
67                                       @else   特征权限。 { @ref ssap_permission_t } @endif */
68     uint32_t operate_indication; /*!< @if Eng operate Indication. { @ref ssap_operate_indication_t }
69                                       @else   操作指示 { @ref ssap_operate_indication_t } @endif */
70     uint8_t type;                /*!< @if Eng descriptor type. { @ref ssap_property_type_t }.
71                                       @else   描述符类型。 { @ref ssap_property_type_t } @endif */
72     uint16_t value_len;          /*!< @if Eng data length.
73                                       @else   数据长度。 @endif */
74     uint8_t *value;              /*!< @if Eng data.
75                                       @else   数据。 @endif */
76 } ssaps_desc_info_t;
77 
78 /**
79  * @if Eng
80  * @brief Struct of read request information.
81  * @else
82  * @brief 读请求信息。
83  * @endif
84  */
85 typedef struct {
86     uint16_t request_id;  /*!< @if Eng Request id.
87                                @else   请求id。 @endif */
88     uint16_t handle;      /*!< @if Eng Properity handle of the read request.
89                                @else   请求读的属性句柄。 @endif */
90     uint8_t type;         /*!< @if Eng property type { @ref ssap_property_type_t }.
91                                @else   属性类型。 @endif  { @ref ssap_property_type_t } */
92     bool need_rsp;        /*!< @if Eng Whether response is needed.
93                                @else   是否需要发送响应。 @endif */
94     bool need_authorize;  /*!< @if Eng Whether authorize is needed.
95                                @else   是否授权。 @endif */
96 } ssaps_req_read_cb_t;
97 
98 /**
99  * @if Eng
100  * @brief Struct of write request information.
101  * @else
102  * @brief 写请求信息。
103  * @endif
104  */
105 typedef struct {
106     uint16_t request_id;  /*!< @if Eng Request id.
107                                @else   请求id。 @endif */
108     uint16_t handle;      /*!< @if Eng Properity handle of the write request.
109                                @else   请求写的属性句柄。 @endif */
110     uint8_t type;         /*!< @if Eng property type { @ref ssap_property_type_t }.
111                                @else   属性类型。 @endif  { @ref ssap_property_type_t } */
112     bool need_rsp;        /*!< @if Eng Whether response is needed.
113                                @else   是否需要发送响应。 @endif */
114     bool need_authorize;  /*!< @if Eng Whether authorize is needed.
115                                @else   是否授权。 @endif */
116     uint16_t length;      /*!< @if Eng Length of write request data.
117                                @else   请求写的数据长度。 @endif */
118     uint8_t *value;       /*!< @if Eng Write request data.
119                                @else   请求写的数据。 @endif */
120 } ssaps_req_write_cb_t;
121 
122 /**
123  * @if Eng
124  * @brief Struct of send response information.
125  * @else
126  * @brief 发送响应信息。
127  * @endif
128  */
129 typedef struct {
130     uint16_t request_id; /*!< @if Eng Request ID.
131                               @else   请求 ID。 @endif */
132     uint8_t status;      /*!< @if Eng Status code of read/write. Success:
133                                       ERRCODE_SLE_SUCCESS. For details about the exception { @ref errcode_sle_ssap_t }
134                               @else   读写结果的状态, 成功ERRCODE_SLE_SUCCESS
135                                       异常参考{ @ref errcode_sle_ssap_t } @endif */
136     uint16_t value_len;  /*!< @if Eng Length of reponse data.
137                               @else   响应的数据长度。 @endif */
138     uint8_t *value;      /*!< @if Eng Reponse data.
139                               @else   响应的数据。 @endif */
140 } ssaps_send_rsp_t;
141 
142 /**
143  * @if Eng
144  * @brief Struct of send notification/indication information.
145  * @else
146  * @brief 发送通知/指示信息。
147  * @endif
148  */
149 typedef struct {
150     uint16_t handle;      /*!< @if Eng Properity handle.
151                                @else   属性句柄。 @endif */
152     uint8_t type;         /*!< @if Eng property type { @ref ssap_property_type_t }.
153                                @else   属性类型 { @ref ssap_property_type_t }。 @endif */
154     uint16_t value_len;   /*!< @if Eng Length of notification/indication data.
155                                @else   通知/指示数据长度。 @endif */
156     uint8_t *value;       /*!< @if Eng Notification/indication data.
157                                @else   发送的通知/指示数据。 @endif */
158 } ssaps_ntf_ind_t;
159 
160 /**
161  * @if Eng
162  * @brief Struct of send notification/indication by uuid information.
163  * @else
164  * @brief 通过uuid发送通知/指示信息。
165  * @endif
166  */
167 typedef struct {
168     sle_uuid_t uuid;       /*!< @if Eng Properity UUID.
169                                 @else   特征UUID。 @endif */
170     uint16_t start_handle; /*!< @if Eng start handle.
171                                 @else   起始句柄。 @endif */
172     uint16_t end_handle;   /*!< @if Eng end handle.
173                                 @else   结束句柄。 @endif */
174     uint8_t type;          /*!< @if Eng property type { @ref ssap_property_type_t }.
175                                 @else   属性类型。 @endif { @ref ssap_property_type_t } */
176     uint16_t value_len;    /*!< @if Eng Length of notification/indication data.
177                                 @else   通知/指示数据长度。 @endif */
178     uint8_t *value;        /*!< @if Eng Notification/indication data.
179                                 @else   发送的通知/指示数据。 @endif */
180 } ssaps_ntf_ind_by_uuid_t;
181 
182 /**
183  * @if Eng
184  * @brief Callback invoked when service add.
185  * @par Callback invoked when service add.
186  * @attention 1.This function is called in SLE service context,should not be blocked or do long time waiting.
187  * @attention 2. The memories of pointer are requested and freed by the SLE service automatically.
188  * @param  [in]  server_id server ID.
189  * @param  [in]  uuid      service uuid.
190  * @param  [in]  handle    service attribute handle.
191  * @param  [in]  status    error code.
192  * @par Dependency:
193  * @li  sle_ssap_stru.h
194  * @see sle_ssaps_callbacks_t
195  * @else
196  * @brief  服务注册的回调函数。
197  * @par    服务注册的回调函数。
198  * @attention  1. 该回调函数运行于SLE service线程,不能阻塞或长时间等待。
199  * @attention  2. pointer由SLE service申请内存,也由SLE service释放,回调中不应释放。
200  * @param  [in]  server_id 服务端 ID。
201  * @param  [in]  uuid      服务uuid。
202  * @param  [in]  handle    服务属性句柄。
203  * @param  [in]  status    执行结果错误码。
204  * @par 依赖:
205  * @li  sle_ssap_stru.h
206  * @see sle_ssaps_callbacks_t
207  * @endif
208  */
209 typedef void (*ssaps_add_service_callback)(uint8_t server_id, sle_uuid_t *uuid, uint16_t handle, errcode_t status);
210 
211 /**
212  * @if Eng
213  * @brief Callback invoked when property add.
214  * @par Callback invoked when property add.
215  * @attention 1.This function is called in SLE service context,should not be blocked or do long time waiting.
216  * @attention 2. The memories of pointer are requested and freed by the SLE service automatically.
217  * @param  [in]  server_id      server ID.
218  * @param  [in]  uuid           property uuid.
219  * @param  [in]  service_handle service attribute handle.
220  * @param  [in]  handle         character attribute handle.
221  * @param  [in]  status         error code.
222  * @par Dependency:
223  * @li  sle_ssap_stru.h
224  * @see sle_ssaps_callbacks_t
225  * @else
226  * @brief  特征注册的回调函数。
227  * @par    特征注册的回调函数。
228  * @attention  1. 该回调函数运行于SLE service线程,不能阻塞或长时间等待。
229  * @attention  2. pointer由SLE service申请内存,也由SLE service释放,回调中不应释放。
230  * @param  [in]  server_id      服务端 ID。
231  * @param  [in]  uuid           特征 uuid。
232  * @param  [in]  service_handle 服务属性句柄。
233  * @param  [in]  handle         特征属性句柄。
234  * @param  [in]  status         执行结果错误码。
235  * @par 依赖:
236  * @li  sle_ssap_stru.h
237  * @see sle_ssaps_callbacks_t
238  * @endif
239  */
240 typedef void (*ssaps_add_property_callback)(uint8_t server_id, sle_uuid_t *uuid, uint16_t service_handle,
241     uint16_t handle, errcode_t status);
242 
243 /**
244  * @if Eng
245  * @brief Callback invoked when property descriptor add.
246  * @par Callback invoked when property descriptor add.
247  * @attention 1.This function is called in SLE service context,should not be blocked or do long time waiting.
248  * @attention 2. The memories of pointer are requested and freed by the SLE service automatically.
249  * @param  [in]  server_id       server ID.
250  * @param  [in]  uuid            property uuid.
251  * @param  [in]  service_handle  service attribute handle.
252  * @param  [in]  property_handle character descriptor attribute handle.
253  * @param  [in]  status          error code.
254  * @par Dependency:
255  * @li  sle_ssap_stru.h
256  * @see sle_ssaps_callbacks_t
257  * @else
258  * @brief  特征描述符注册的回调函数。
259  * @par    特征描述符注册的回调函数。
260  * @attention  1. 该回调函数运行于SLE service线程,不能阻塞或长时间等待。
261  * @attention  2. pointer由SLE service申请内存,也由SLE service释放,回调中不应释放。
262  * @param  [in]  server_id       服务端 ID。
263  * @param  [in]  uuid            特征 uuid。
264  * @param  [in]  service_handle  服务属性句柄。
265  * @param  [in]  property_handle 特征描述符属性句柄。
266  * @param  [in]  status          执行结果错误码。
267  * @par 依赖:
268  * @li  sle_ssap_stru.h
269  * @see sle_ssaps_callbacks_t
270  * @endif
271  */
272 typedef void (*ssaps_add_descriptor_callback)(uint8_t server_id, sle_uuid_t *uuid, uint16_t service_handle,
273     uint16_t property_handle, errcode_t status);
274 
275 /**
276  * @if Eng
277  * @brief Callback invoked when service started.
278  * @par Callback invoked when service started.
279  * @attention 1.This function is called in SLE service context,should not be blocked or do long time waiting.
280  * @attention 2. The memories of pointer are requested and freed by the SLE service automatically.
281  * @param  [in]  server_id server ID.
282  * @param  [in]  handle    service attribute handle.
283  * @param  [in]  status    error code.
284  * @par Dependency:
285  * @li  sle_ssap_stru.h
286  * @see sle_ssaps_callbacks_t
287  * @else
288  * @brief  开始服务的回调函数。
289  * @par    开始服务的回调函数。
290  * @attention  1. 该回调函数运行于SLE service线程,不能阻塞或长时间等待。
291  * @attention  2. pointer由SLE service申请内存,也由SLE service释放,回调中不应释放。
292  * @param  [in]  server_id 服务端 ID。
293  * @param  [in]  handle    服务属性句柄。
294  * @param  [in]  status    执行结果错误码。
295  * @par 依赖:
296  * @li  sle_ssap_stru.h
297  * @see sle_ssaps_callbacks_t
298  * @endif
299  */
300 typedef void (*ssaps_start_service_callback)(uint8_t server_id, uint16_t handle, errcode_t status);
301 
302 /**
303  * @if Eng
304  * @brief Callback invoked when all services deleted.
305  * @par Callback invoked when all services deleted.
306  * @attention 1.This function is called in bts context,should not be blocked or do long time waiting.
307  * @attention 2. The memories of devices are requested and freed by the bts automatically.
308  * @param  [in]  server_id server ID.
309  * @param  [in]  status    error code.
310  * @par Dependency:
311  * @li  sle_ssap_stru.h
312  * @see sle_ssaps_callbacks_t
313  * @else
314  * @brief  删除全部服务的回调函数。
315  * @par    删除全部服务的回调函数。
316  * @attention  1. 该回调函数运行于bts线程,不能阻塞或长时间等待。
317  * @attention  2. devices由bts申请内存,也由bts释放,回调中不应释放。
318  * @param  [in]  server_id 服务端 ID。
319  * @param  [in]  status    执行结果错误码。
320  * @par 依赖:
321  * @li  sle_ssap_stru.h
322  * @see sle_ssaps_callbacks_t
323  * @endif
324  */
325 typedef void (*ssaps_delete_all_service_callback)(uint8_t server_id, errcode_t status);
326 
327 /**
328  * @if Eng
329  * @brief Callback invoked when receive read request.
330  * @par Callback invoked when  receive read request.
331  * @attention 1.This function is called in SLE service context,should not be blocked or do long time waiting.
332  * @attention 2. The memories of pointer are requested and freed by the SLE service automatically.
333  * @param  [in]  server_id    server ID.
334  * @param  [in]  conn_id      connection ID.
335  * @param  [in]  read_cb_para read request parameter.
336  * @param  [in]  status       error code.
337  * @par Dependency:
338  * @li  sle_ssap_stru.h
339  * @see sle_ssaps_callbacks_t
340  * @else
341  * @brief  收到读请求的回调函数。
342  * @par    收到读请求的回调函数。
343  * @attention  1. 该回调函数运行于SLE service线程,不能阻塞或长时间等待。
344  * @attention  2. pointer由SLE service申请内存,也由SLE service释放,回调中不应释放。
345  * @param  [in]  server_id    服务端 ID。
346  * @param  [in]  conn_id      连接 ID。
347  * @param  [in]  read_cb_para 读请求参数。
348  * @param  [in]  status       执行结果错误码。
349  * @par 依赖:
350  * @li  sle_ssap_stru.h
351  * @see sle_ssaps_callbacks_t
352  * @endif
353  */
354 typedef void (*ssaps_read_request_callback)(uint8_t server_id, uint16_t conn_id, ssaps_req_read_cb_t *read_cb_para,
355     errcode_t status);
356 
357 /**
358  * @if Eng
359  * @brief Callback invoked when receive write request.
360  * @par Callback invoked when  receive write request.
361  * @attention 1.This function is called in SLE service context,should not be blocked or do long time waiting.
362  * @attention 2. The memories of pointer are requested and freed by the SLE service automatically.
363  * @param  [in]  server_id     server ID.
364  * @param  [in]  conn_id       connection ID.
365  * @param  [in]  write_cb_para write request parameter.
366  * @param  [in]  status        error code.
367  * @par Dependency:
368  * @li  sle_ssap_stru.h
369  * @see sle_ssaps_callbacks_t
370  * @else
371  * @brief  收到写请求的回调函数。
372  * @par    收到写请求的回调函数。
373  * @attention  1. 该回调函数运行于SLE service线程,不能阻塞或长时间等待。
374  * @attention  2. pointer由SLE service申请内存,也由SLE service释放,回调中不应释放。
375  * @param  [in]  server_id     服务端 ID。
376  * @param  [in]  conn_id       连接 ID。
377  * @param  [in]  write_cb_para 写请求参数。
378  * @param  [in]  status        执行结果错误码。
379  * @par 依赖:
380  * @li  sle_ssap_stru.h
381  * @see sle_ssaps_callbacks_t
382  * @endif
383  */
384 typedef void (*ssaps_write_request_callback)(uint8_t server_id, uint16_t conn_id, ssaps_req_write_cb_t *write_cb_para,
385     errcode_t status);
386 
387 /**
388  * @if Eng
389  * @brief Callback invoked when mtu size changed.
390  * @par Callback invoked when mtu size changed.
391  * @attention 1.This function is called in SLE service context,should not be blocked or do long time waiting.
392  * @attention 2. The memories of pointer are requested and freed by the SLE service automatically.
393  * @param  [in]  server_id server ID.
394  * @param  [in]  conn_id   connection ID.
395  * @param  [in]  mtu_size  mtu size.
396  * @param  [in]  status    error code.
397  * @par Dependency:
398  * @li  sle_ssap_stru.h
399  * @see sle_ssaps_callbacks_t
400  * @else
401  * @brief  mtu大小改变的回调函数。
402  * @par    mtu大小改变的回调函数。
403  * @attention  1. 该回调函数运行于SLE service线程,不能阻塞或长时间等待。
404  * @attention  2. pointer由SLE service申请内存,也由SLE service释放,回调中不应释放。
405  * @param  [in]  server_id 服务端 ID。
406  * @param  [in]  conn_id   连接 ID。
407  * @param  [in]  mtu_size  mtu 大小。
408  * @param  [in]  status    执行结果错误码。
409  * @par 依赖:
410  * @li  sle_ssap_stru.h
411  * @see sle_ssaps_callbacks_t
412  * @endif
413  */
414 typedef void (*ssaps_mtu_changed_callback)(uint8_t server_id, uint16_t conn_id,
415     ssap_exchange_info_t *info, errcode_t status);
416 
417 /**
418  * @if Eng
419  * @brief Struct of SSAP server callback function.
420  * @else
421  * @brief SSAP server回调函数接口定义。
422  * @endif
423  */
424 typedef struct {
425     ssaps_add_service_callback add_service_cb;               /*!< @if Eng Service added callback.
426                                                                   @else   添加服务回调函数。 @endif */
427     ssaps_add_property_callback add_property_cb;             /*!< @if Eng Characteristc added callback.
428                                                                   @else   添加特征回调函数。 @endif */
429     ssaps_add_descriptor_callback add_descriptor_cb;         /*!< @if Eng Descriptor added callback.
430                                                                   @else   添加描述符回调函数。 @endif */
431     ssaps_start_service_callback start_service_cb;           /*!< @if Eng Service started callback.
432                                                                   @else   启动服务回调函数。 @endif */
433     ssaps_delete_all_service_callback delete_all_service_cb; /*!< @if Eng Service deleted callback.
434                                                                   @else   删除服务回调函数。 @endif */
435     ssaps_read_request_callback read_request_cb;             /*!< @if Eng Read request received callback.
436                                                                   @else   收到远端读请求回调函数。 @endif */
437     ssaps_write_request_callback write_request_cb;           /*!< @if Eng Write request received callback.
438                                                                   @else   收到远端写请求回调函数。 @endif */
439     ssaps_mtu_changed_callback mtu_changed_cb;               /*!< @if Eng Mtu changed callback.
440                                                                   @else   mtu 大小更新回调函数。 @endif */
441 } ssaps_callbacks_t;
442 
443 /**
444  * @if Eng
445  * @brief  Register ssap server.
446  * @par Description: Register ssap server.
447  * @param  [in]  app_uuid  App uuid
448  * @param  [out] server_id Server ID
449  * @retval ERRCODE_SUCC Success.
450  * @retval Other        Failure. For details, see @ref errcode_t
451  * @par Depends:
452  * @li sle_ssap_stru.h
453  * @else
454  * @brief  注册ssap服务端。
455  * @par Description: 注册ssap服务端。
456  * @param  [in]  app_uuid  上层应用uuid
457  * @param  [out] server_id 服务端ID
458  * @retval ERRCODE_SUCC 成功。
459  * @retval Other        失败。参考 @ref errcode_t
460  * @par 依赖:
461  * @li sle_ssap_stru.h
462  * @endif
463  */
464 errcode_t ssaps_register_server(sle_uuid_t *app_uuid, uint8_t *server_id);
465 
466 /**
467  * @if Eng
468  * @brief  Unregister ssap server.
469  * @par Description: Unregister ssap server.
470  * @param  [in] server_id Server ID
471  * @retval ERRCODE_SUCC Success.
472  * @retval Other        Failure. For details, see @ref errcode_t
473  * @par Depends:
474  * @li sle_ssap_stru.h
475  * @else
476  * @brief  注销ssap服务端。
477  * @par Description: 注销ssap服务端。
478  * @param  [in] server_id 服务端ID
479  * @retval ERRCODE_SUCC 成功。
480  * @retval Other        失败。参考 @ref errcode_t
481  * @par 依赖:
482  * @li sle_ssap_stru.h
483  * @endif
484  */
485 errcode_t ssaps_unregister_server(uint8_t server_id);
486 
487 /**
488  * @if Eng
489  * @brief  asynchronously add an SSAP service. The registered service handle is returned in add_service_cb.
490  * @par Description: Add a ssap service.
491  * @param  [in] server_id Server ID.
492  * @param  [in] service_uuid Service uuid.
493  * @param  [in] is_primary is primary service or not.
494  * @retval error code, the service handle will be returned in { @ref ssaps_add_service_callback }.
495  * @par Depends:
496  * @li sle_ssap_stru.h
497  * @else
498  * @brief  异步添加一个ssap服务,注册service handle在add_service_cb中返回。
499  * @par Description: 添加一个ssap服务。
500  * @param  [in] server_id 服务端 ID。
501  * @param  [in] service_uuid 服务uuid。
502  * @param  [in] is_primary 是否是首要服务。
503  * @retval 执行结果错误码,服务句柄将在 { @ref ssaps_add_service_callback }中返回。
504  * @par 依赖:
505  * @li sle_ssap_stru.h
506  * @endif
507  */
508 errcode_t ssaps_add_service(uint8_t server_id, sle_uuid_t *service_uuid, bool is_primary);
509 
510 /**
511  * @if Eng
512  * @brief  Add an ssap attribute asynchronously. The register attribute handle is returned in add_property_cb.
513  * @par Description: Add a ssap property.
514  * @param  [in] server_id Server ID.
515  * @param  [in] service_handle Service handle.
516  * @param  [in] property SSAP Properity.
517  * @retval error code, the character handle will be returned in { @ref ssaps_add_property_callback }.
518  * @par Depends:
519  * @li sle_ssap_stru.h
520  * @else
521  * @brief  异步添加一个ssap属性,注册属性 handle在add_property_cb中返回
522  * @par Description: 添加一个ssap特征。
523  * @param  [in] server_id 服务端 ID。
524  * @param  [in] service_handle 服务句柄。
525  * @param  [in] property SSAP 特征。
526  * @retval 执行结果错误码,特征句柄将在 { @ref ssaps_add_property_callback }中返回。
527  * @par 依赖:
528  * @li sle_ssap_stru.h
529  * @endif
530  */
531 errcode_t ssaps_add_property(uint8_t server_id, uint16_t service_handle, ssaps_property_info_t *property);
532 
533 /**
534  * @if Eng
535  * @brief  An SSAP description is added asynchronously. The registration result is returned in add_descriptor_cb.
536  * @par Description: Add a ssap property descriptor.
537  * @param  [in] server_id       Server ID.
538  * @param  [in] service_handle  Service handle.
539  * @param  [in] property_handle Property handle.
540  * @param  [in] descriptor      Properity descriptor.
541  * @retval error code, the descriptor handle will be returned in { @ref ssaps_add_descriptor_callback }.
542  * @par Depends:
543  * @li sle_ssap_stru.h
544  * @else
545  * @brief  异步添加一个ssap描述,注册描述结果在add_descriptor_cb中返回
546  * @par Description: 添加一个ssap特征描述符。
547  * @param  [in] server_id       服务端 ID。
548  * @param  [in] service_handle  服务句柄。
549  * @param  [in] property_handle 特征句柄。
550  * @param  [in] descriptor      SSAP 特征描述符。
551  * @retval 执行结果错误码,特征句柄将在 { @ref ssaps_add_descriptor_callback } 中返回。
552  * @par 依赖:
553  * @li sle_ssap_stru.h
554  * @endif
555  */
556 errcode_t ssaps_add_descriptor(uint8_t server_id, uint16_t service_handle, uint16_t property_handle,
557     ssaps_desc_info_t *descriptor);
558 
559 /**
560  * @if Eng
561  * @brief  Add a ssap service.
562  * @par Description: Add a ssap service.
563  * @param  [in]  server_id Server ID.
564  * @param  [in]  service_uuid Service uuid.
565  * @param  [in]  is_primary is primary service or not.
566  * @param  [out] handle service handle.
567  * @retval ERRCODE_SUCC Success.
568  * @retval Other        Failure. For details, see @ref errcode_t
569  * @par Depends:
570  * @li sle_ssap_stru.h
571  * @else
572  * @brief  添加一个ssap服务。
573  * @par Description: 添加一个ssap服务。
574  * @param  [in]  server_id    服务端 ID。
575  * @param  [in]  service_uuid 服务uuid。
576  * @param  [in]  is_primary   是否是首要服务。
577  * @param  [out] handle       服务句柄.
578  * @retval ERRCODE_SUCC 成功。
579  * @retval Other        失败。参考 @ref errcode_t
580  * @par 依赖:
581  * @li sle_ssap_stru.h
582  * @endif
583  */
584 errcode_t ssaps_add_service_sync(uint8_t server_id, sle_uuid_t *service_uuid, bool is_primary, uint16_t *handle);
585 
586 /**
587  * @if Eng
588  * @brief  Add a ssap property.
589  * @par Description: Add a ssap property.
590  * @param  [in]  server_id      Server ID.
591  * @param  [in]  service_handle Service handle.
592  * @param  [in]  property      SSAP Properity Info.
593  * @param  [out] handle         Properity handle.
594  * @retval ERRCODE_SUCC Success.
595  * @retval Other        Failure. For details, see @ref errcode_t
596  * @par Depends:
597  * @li sle_ssap_stru.h
598  * @else
599  * @brief  添加一个ssap特征。
600  * @par Description: 添加一个ssap特征。
601  * @param  [in]  server_id      服务端 ID。
602  * @param  [in]  service_handle 服务句柄。
603  * @param  [in]  property      SSAP 特征信息。
604  * @param  [out] handle         特征句柄
605  * @retval ERRCODE_SUCC 成功。
606  * @retval Other        失败。参考 @ref errcode_t
607  * @par 依赖:
608  * @li sle_ssap_stru.h
609  * @endif
610  */
611 errcode_t ssaps_add_property_sync(uint8_t server_id, uint16_t service_handle, ssaps_property_info_t *property,
612     uint16_t *handle);
613 
614 /**
615  * @if Eng
616  * @brief  Add a ssap property descriptor.
617  * @par Description: Add a ssap property descriptor.
618  * @param  [in]  server_id       Server ID.
619  * @param  [in]  service_handle  Service handle.
620  * @param  [in]  property_handle Properity handle corresponding to the descriptor.
621  * @param  [in]  descriptor      Properity descriptor.
622  * @retval ERRCODE_SUCC Success.
623  * @retval Other        Failure. For details, see @ref errcode_t
624  * @par Depends:
625  * @li sle_ssap_stru.h
626  * @else
627  * @brief  添加一个ssap特征描述符。
628  * @par Description: 添加一个ssap特征描述符。
629  * @param  [in]  server_id       服务端 ID。
630  * @param  [in]  service_handle  服务句柄。
631  * @param  [in]  property_handle 描述符所在得特征句柄。
632  * @param  [in]  descriptor      特征描述符。
633  * @retval ERRCODE_SUCC 成功。
634  * @retval Other        失败。参考 @ref errcode_t
635  * @par 依赖:
636  * @li sle_ssap_stru.h
637  * @endif
638  */
639 errcode_t ssaps_add_descriptor_sync(uint8_t server_id, uint16_t service_handle, uint16_t property_handle,
640     ssaps_desc_info_t *descriptor);
641 
642 /**
643  * @if Eng
644  * @brief  Start a SSAP service.
645  * @par Description: Start a SSAP service.
646  * @param  [in] server_id      server ID.
647  * @param  [in] service_handle service handle.
648  * @retval error code, the service start result will be returned at { @ref ssaps_start_service_callback }.
649  * @par Depends:
650  * @li sle_ssap_stru.h
651  * @else
652  * @brief  开始一个SSAP服务。
653  * @par Description: 开始一个SSAP服务。
654  * @param  [in] server_id      服务端 ID。
655  * @param  [in] service_handle 服务句柄。
656  * @retval 执行结果错误码,服务开启结果将在 { @ref ssaps_start_service_callback }中返回。
657  * @par 依赖:
658  * @li sle_ssap_stru.h
659  * @endif
660  */
661 errcode_t ssaps_start_service(uint8_t server_id, uint16_t service_handle);
662 
663 /**
664  * @if Eng
665  * @brief  Delete all SSAP service.
666  * @par Description: Delete all SSAP service.
667  * @param  [in] server_id      server ID.
668  * @retval ERRCODE_SUCC Success.
669  * @retval Other        Failure. For details, see @ref errcode_t
670  * @par Depends:
671  * @li sle_ssap_stru.h
672  * @else
673  * @brief  删除所有SSAP服务。
674  * @par Description: 删除所有SSAP服务。
675  * @param  [in] server_id      服务端 ID。
676  * @retval ERRCODE_SUCC 成功。
677  * @retval Other        失败。参考 @ref errcode_t
678  * @par 依赖:
679  * @li sle_ssap_stru.h
680  * @endif
681  */
682 errcode_t ssaps_delete_all_services(uint8_t server_id);
683 
684 /**
685  * @if Eng
686  * @brief  Send response when receive the request need to response by user.
687  * @par Description: Send response when receive the request need to response by user
688                      { @ref ssaps_read_request_callback } { @ref ssaps_write_request_callback }.
689  * @param  [in] server_id server ID.
690  * @param  [in] conn_id   connection ID.
691  * @param  [in] param     response parameter.
692  * @retval ERRCODE_SUCC Success.
693  * @retval Other        Failure. For details, see @ref errcode_t
694  * @par Depends:
695  * @li sle_ssap_stru.h
696  * @else
697  * @brief  当收到需要用户回复响应的请求时发送响应。
698  * @par Description: 当收到需要用户回复响应的请求时发送响应
699                      { @ref ssaps_read_request_callback } { @ref ssaps_write_request_callback }。
700  * @param  [in] server_id 服务端 ID.
701  * @param  [in] conn_id   连接ID。
702  * @param  [in] param     响应参数.
703  * @retval ERRCODE_SUCC 成功。
704  * @retval Other        失败。参考 @ref errcode_t
705  * @par 依赖:
706  * @li sle_ssap_stru.h
707  * @endif
708  */
709 errcode_t ssaps_send_response(uint8_t server_id, uint16_t conn_id, ssaps_send_rsp_t *param);
710 
711 /**
712  * @if Eng
713  * @brief  Send indication or notification to remote device.
714  * @par Description: Send indication or notification to remote device,
715                      send status depend on character descriptor: client property configuration.
716                      value = 0x0000: notification and indication not allowed
717                      value = 0x0001: notification allowed
718                      value = 0x0002: indication allowed
719  * @param  [in] server_id server ID.
720  * @param  [in] conn_id   connection ID,To send packets to all peer ends, enter conn_id = 0xffff.
721  * @param  [in] param     notify/indicate parameter.
722  * @retval ERRCODE_SUCC Success.
723  * @retval Other        Failure. For details, see @ref errcode_t
724  * @par Depends:
725  * @li sle_ssap_stru.h
726  * @else
727  * @brief  向对端发送通知或指示。
728  * @par Description: 向对端发送通知或指示,具体发送状态取决于特征描述符:客户端特征配置
729                      value = 0x0000:不允许通知和指示
730                      value = 0x0001:允许通知
731                      value = 0x0002:允许指示
732  * @param  [in] server_id 服务端 ID。
733  * @param  [in] conn_id   连接ID,如果向全部对端发送则输入conn_id = 0xffff;
734  * @param  [in] param     通知或指示参数。
735  * @retval ERRCODE_SUCC 成功。
736  * @retval Other        失败。参考 @ref errcode_t
737  * @par 依赖:
738  * @li sle_ssap_stru.h
739  * @endif
740  */
741 errcode_t ssaps_notify_indicate(uint8_t server_id, uint16_t conn_id, ssaps_ntf_ind_t *param);
742 
743 /**
744  * @if Eng
745  * @brief  Send indication or notification to remote device by uuid.
746  * @par Description: Send indication or notification to remote device by uuid,
747                      send status depend on client property configuration descriptor value,
748                      value = 0x0000: notification and indication not allowed
749                      value = 0x0001: notification allowed
750                      value = 0x0002: indication allowed
751  * @param  [in] server_id server ID.
752  * @param  [in] conn_id   connection ID,To send packets to all peer ends, enter conn_id = 0xffff.
753  * @param  [in] param     notify/indicate parameter.
754  * @retval ERRCODE_SUCC Success.
755  * @retval Other        Failure. For details, see @ref errcode_t
756  * @par Depends:
757  * @li sle_ssap_stru.h
758  * @else
759  * @brief  通过uuid向对端发送通知或指示。
760  * @par Description: 通过uuid向对端发送通知或指示,具体发送状态取决于客户端特征配置描述符值,
761                      value = 0x0000:不允许通知和指示
762                      value = 0x0001:允许通知
763                      value = 0x0002:允许指示
764  * @param  [in] server_id 服务端 ID。
765  * @param  [in] conn_id   连接ID,如果向全部对端发送则输入conn_id = 0xffff;
766  * @param  [in] param     通知或指示参数。
767  * @retval ERRCODE_SUCC 成功。
768  * @retval Other        失败。参考 @ref errcode_t
769  * @par 依赖:
770  * @li sle_ssap_stru.h
771  * @endif
772  */
773 errcode_t ssaps_notify_indicate_by_uuid(uint8_t server_id, uint16_t conn_id, ssaps_ntf_ind_by_uuid_t *param);
774 
775 
776 /**
777  * @if Eng
778  * @brief  Set server info before connected.
779  * @par Description: Set server info before connected.
780  * @param  [in] server_id server ID.
781  * @param  [in] info      server info.
782  * @retval ERRCODE_SUCC Success.
783  * @retval Other        Failure. For details, see @ref errcode_t
784  * @par Depends:
785  * @li bts_def.h
786  * @else
787  * @brief  在连接之前设置服务端info。
788  * @par Description: 在连接之前设置服务端info。
789  * @param  [in] server_id 服务端ID。
790  * @param  [in] info      服务端info。
791  * @retval ERRCODE_SUCC 成功。
792  * @retval Other        失败。参考 @ref errcode_t
793  * @par 依赖:
794  * @li bts_def.h
795  * @endif
796  */
797 errcode_t ssaps_set_info(uint8_t server_id, ssap_exchange_info_t *info);
798 
799 /**
800  * @if Eng
801  * @brief  Register SSAP server callbacks.
802  * @par Description: Register SSAP server callbacks.
803  * @param  [in] func callback function.
804  * @retval ERRCODE_SUCC Success.
805  * @retval Other        Failure. For details, see @ref errcode_t
806  * @par Depends:
807  * @li sle_ssap_stru.h
808  * @else
809  * @brief  注册 SSAP server 回调函数。
810  * @par Description: 注册回调函数。
811  * @param  [in] func 回调函数
812  * @retval ERRCODE_SUCC 成功。
813  * @retval Other        失败。参考 @ref errcode_t
814  * @par 依赖:
815  * @li sle_ssap_stru.h
816  * @endif
817  */
818 errcode_t ssaps_register_callbacks(ssaps_callbacks_t *func);
819 
820 #ifdef __cplusplus
821 }
822 #endif
823 #endif
824 /** @} */
825 
826