119e95205Sopenharmony_ci/* 219e95205Sopenharmony_ci * Copyright (C) 2021 Huawei Device Co., Ltd. 319e95205Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 419e95205Sopenharmony_ci * you may not use this file except in compliance with the License. 519e95205Sopenharmony_ci * You may obtain a copy of the License at 619e95205Sopenharmony_ci * 719e95205Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 819e95205Sopenharmony_ci * 919e95205Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1019e95205Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1119e95205Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1219e95205Sopenharmony_ci * See the License for the specific language governing permissions and 1319e95205Sopenharmony_ci * limitations under the License. 1419e95205Sopenharmony_ci */ 1519e95205Sopenharmony_ci 1619e95205Sopenharmony_ci/** 1719e95205Sopenharmony_ci * @file l2cap_if.h 1819e95205Sopenharmony_ci * 1919e95205Sopenharmony_ci * @brief Interface of bluetooth l2cap protocol BR/EDR part 2019e95205Sopenharmony_ci * 2119e95205Sopenharmony_ci */ 2219e95205Sopenharmony_ci 2319e95205Sopenharmony_ci#ifndef L2CAP_IF_H 2419e95205Sopenharmony_ci#define L2CAP_IF_H 2519e95205Sopenharmony_ci 2619e95205Sopenharmony_ci#include "l2cap_def.h" 2719e95205Sopenharmony_ci 2819e95205Sopenharmony_ci#ifdef __cplusplus 2919e95205Sopenharmony_ciextern "C" { 3019e95205Sopenharmony_ci#endif // __cplusplus 3119e95205Sopenharmony_ci 3219e95205Sopenharmony_ci/** 3319e95205Sopenharmony_ci * @brief Initialize l2cap for BR/EDR 3419e95205Sopenharmony_ci * 3519e95205Sopenharmony_ci * @param traceLevel debug log level. 3619e95205Sopenharmony_ci */ 3719e95205Sopenharmony_civoid BTSTACK_API L2CIF_Initialize(int traceLevel); 3819e95205Sopenharmony_ci 3919e95205Sopenharmony_ci/** 4019e95205Sopenharmony_ci * @brief Finalize l2cap for BR/EDR 4119e95205Sopenharmony_ci * 4219e95205Sopenharmony_ci */ 4319e95205Sopenharmony_civoid BTSTACK_API L2CIF_Finalize(); 4419e95205Sopenharmony_ci 4519e95205Sopenharmony_ci/** 4619e95205Sopenharmony_ci * @brief Register l2cap psm 4719e95205Sopenharmony_ci * 4819e95205Sopenharmony_ci * @param psm protocol psm 4919e95205Sopenharmony_ci * @param svc callback for protocol psm 5019e95205Sopenharmony_ci * @param context context for protocol psm 5119e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails. 5219e95205Sopenharmony_ci */ 5319e95205Sopenharmony_ciint BTSTACK_API L2CIF_RegisterService( 5419e95205Sopenharmony_ci uint16_t lpsm, const L2capService *svc, void *context, void (*cb)(uint16_t lpsm, int result)); 5519e95205Sopenharmony_ci 5619e95205Sopenharmony_ci/** 5719e95205Sopenharmony_ci * @brief Deregister l2cap psm 5819e95205Sopenharmony_ci * 5919e95205Sopenharmony_ci * @param psm protocol psm 6019e95205Sopenharmony_ci */ 6119e95205Sopenharmony_civoid BTSTACK_API L2CIF_DeregisterService(uint16_t lpsm, void (*cb)(uint16_t lpsm, int result)); 6219e95205Sopenharmony_ci 6319e95205Sopenharmony_ci/** 6419e95205Sopenharmony_ci * @brief Send Connection Request packets 6519e95205Sopenharmony_ci * 6619e95205Sopenharmony_ci * @param addr remote bluetooth address 6719e95205Sopenharmony_ci * @param lpsm local protocol psm 6819e95205Sopenharmony_ci * @param rpsm remote protocol psm 6919e95205Sopenharmony_ci * @param lcid OUT parameter, local channel id 7019e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails. 7119e95205Sopenharmony_ci */ 7219e95205Sopenharmony_ciint BTSTACK_API L2CIF_ConnectReq(const BtAddr *addr, uint16_t lpsm, uint16_t rpsm, void *context, 7319e95205Sopenharmony_ci void (*cb)(const BtAddr *addr, uint16_t lcid, int result, void *context)); 7419e95205Sopenharmony_ci 7519e95205Sopenharmony_ci/** 7619e95205Sopenharmony_ci * @brief Send Connection Response packet 7719e95205Sopenharmony_ci * 7819e95205Sopenharmony_ci * @param lcid local channel id 7919e95205Sopenharmony_ci * @param id identifier of l2cap command 8019e95205Sopenharmony_ci * @param result indicates the outcome of the connection request 8119e95205Sopenharmony_ci * @param status indicates the status of the connection 8219e95205Sopenharmony_ci */ 8319e95205Sopenharmony_civoid BTSTACK_API L2CIF_ConnectRsp( 8419e95205Sopenharmony_ci uint16_t lcid, uint8_t id, uint16_t result, uint16_t status, void (*cb)(uint16_t lcid, int result)); 8519e95205Sopenharmony_ci 8619e95205Sopenharmony_ci/** 8719e95205Sopenharmony_ci * @brief Send Configuration Request packet 8819e95205Sopenharmony_ci * 8919e95205Sopenharmony_ci * @param lcid local channel id 9019e95205Sopenharmony_ci * @param cfg config parameter 9119e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails. 9219e95205Sopenharmony_ci */ 9319e95205Sopenharmony_ciint BTSTACK_API L2CIF_ConfigReq(uint16_t lcid, const L2capConfigInfo *cfg, void (*cb)(uint16_t lcid, int result)); 9419e95205Sopenharmony_ci 9519e95205Sopenharmony_ci/** 9619e95205Sopenharmony_ci * @brief Send Configuration Response packet 9719e95205Sopenharmony_ci * 9819e95205Sopenharmony_ci * @param lcid local channel id 9919e95205Sopenharmony_ci * @param id identifier of l2cap command 10019e95205Sopenharmony_ci * @param cfg config parameter 10119e95205Sopenharmony_ci * @param result config result 10219e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails. 10319e95205Sopenharmony_ci */ 10419e95205Sopenharmony_ciint BTSTACK_API L2CIF_ConfigRsp( 10519e95205Sopenharmony_ci uint16_t lcid, uint8_t id, const L2capConfigInfo *cfg, uint16_t result, void (*cb)(uint16_t lcid, int result)); 10619e95205Sopenharmony_ci 10719e95205Sopenharmony_ci/** 10819e95205Sopenharmony_ci * @brief Send Disconnection Request packet 10919e95205Sopenharmony_ci * 11019e95205Sopenharmony_ci * @param lcid local channel id 11119e95205Sopenharmony_ci */ 11219e95205Sopenharmony_civoid BTSTACK_API L2CIF_DisconnectionReq(uint16_t lcid, void (*cb)(uint16_t lcid, int result)); 11319e95205Sopenharmony_ci 11419e95205Sopenharmony_ci/** 11519e95205Sopenharmony_ci * @brief Send Disconnection Response packet 11619e95205Sopenharmony_ci * 11719e95205Sopenharmony_ci * @param lcid local channel id 11819e95205Sopenharmony_ci * @param id identifier of l2cap command 11919e95205Sopenharmony_ci */ 12019e95205Sopenharmony_civoid BTSTACK_API L2CIF_DisconnectionRsp(uint16_t lcid, uint8_t id, void (*cb)(uint16_t lcid, int result)); 12119e95205Sopenharmony_ci 12219e95205Sopenharmony_ci/** 12319e95205Sopenharmony_ci * @brief In Enhanced Retransmission mode, send RNR to information remote to stop sending data 12419e95205Sopenharmony_ci * 12519e95205Sopenharmony_ci * @param lcid local channel id 12619e95205Sopenharmony_ci * @param isBusy flag to indicate busy state, 0 -- non busy, 1 -- busy 12719e95205Sopenharmony_ci */ 12819e95205Sopenharmony_civoid BTSTACK_API L2CIF_LocalBusy(uint16_t lcid, uint8_t isBusy, void (*cb)(uint16_t lcid, int result)); 12919e95205Sopenharmony_ci 13019e95205Sopenharmony_ci/** 13119e95205Sopenharmony_ci * @brief Send l2cap data packet 13219e95205Sopenharmony_ci * 13319e95205Sopenharmony_ci * @param lcid local channel id 13419e95205Sopenharmony_ci * @param pkt packet of data 13519e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails. 13619e95205Sopenharmony_ci */ 13719e95205Sopenharmony_ciint BTSTACK_API L2CIF_SendData(uint16_t lcid, const Packet *pkt, void (*cb)(uint16_t lcid, int result)); 13819e95205Sopenharmony_ci 13919e95205Sopenharmony_ci/** 14019e95205Sopenharmony_ci * @brief Register Echo callback 14119e95205Sopenharmony_ci * 14219e95205Sopenharmony_ci * @param echoCallback callback of echo 14319e95205Sopenharmony_ci * @param context context of caller 14419e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails. 14519e95205Sopenharmony_ci */ 14619e95205Sopenharmony_ciint BTSTACK_API L2CIF_RegisterEcho(const L2capEcho *echoCallback, void *context); 14719e95205Sopenharmony_ci 14819e95205Sopenharmony_ci/** 14919e95205Sopenharmony_ci * @brief Deregister Echo callback 15019e95205Sopenharmony_ci * 15119e95205Sopenharmony_ci */ 15219e95205Sopenharmony_civoid BTSTACK_API L2CIF_DeregisterEcho(); 15319e95205Sopenharmony_ci 15419e95205Sopenharmony_ci/** 15519e95205Sopenharmony_ci * @brief Send Echo Request packet 15619e95205Sopenharmony_ci * 15719e95205Sopenharmony_ci * @param aclHandle ACL Handle 15819e95205Sopenharmony_ci * @param data data of echo 15919e95205Sopenharmony_ci * @param dataLen length of data 16019e95205Sopenharmony_ci */ 16119e95205Sopenharmony_civoid BTSTACK_API L2CIF_EchoReq( 16219e95205Sopenharmony_ci uint16_t aclHandle, const uint8_t *data, uint16_t dataLen, void (*cb)(uint16_t aclHandle, int result)); 16319e95205Sopenharmony_ci 16419e95205Sopenharmony_ci/** 16519e95205Sopenharmony_ci * @brief Send Echo Response packet received 16619e95205Sopenharmony_ci * 16719e95205Sopenharmony_ci * @param aclHandle ACL Handle 16819e95205Sopenharmony_ci * @param id identifier of l2cap command 16919e95205Sopenharmony_ci * @param data data of echo 17019e95205Sopenharmony_ci * @param dataLen length of data 17119e95205Sopenharmony_ci */ 17219e95205Sopenharmony_civoid BTSTACK_API L2CIF_EchoRsp( 17319e95205Sopenharmony_ci uint16_t aclHandle, uint8_t id, const uint8_t *data, uint16_t dataLen, void (*cb)(uint16_t aclHandle, int result)); 17419e95205Sopenharmony_ci 17519e95205Sopenharmony_ci#ifdef __cplusplus 17619e95205Sopenharmony_ci} 17719e95205Sopenharmony_ci#endif // __cplusplus 17819e95205Sopenharmony_ci 17919e95205Sopenharmony_ci#endif // L2CAP_IF_H