13deb3ec6SMatthias Ringwald /* 23deb3ec6SMatthias Ringwald * Copyright (C) 2014 BlueKitchen GmbH 33deb3ec6SMatthias Ringwald * 43deb3ec6SMatthias Ringwald * Redistribution and use in source and binary forms, with or without 53deb3ec6SMatthias Ringwald * modification, are permitted provided that the following conditions 63deb3ec6SMatthias Ringwald * are met: 73deb3ec6SMatthias Ringwald * 83deb3ec6SMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 93deb3ec6SMatthias Ringwald * notice, this list of conditions and the following disclaimer. 103deb3ec6SMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 113deb3ec6SMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 123deb3ec6SMatthias Ringwald * documentation and/or other materials provided with the distribution. 133deb3ec6SMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 143deb3ec6SMatthias Ringwald * contributors may be used to endorse or promote products derived 153deb3ec6SMatthias Ringwald * from this software without specific prior written permission. 163deb3ec6SMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 173deb3ec6SMatthias Ringwald * personal benefit and not for any commercial purpose or for 183deb3ec6SMatthias Ringwald * monetary gain. 193deb3ec6SMatthias Ringwald * 203deb3ec6SMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 213deb3ec6SMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 223deb3ec6SMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 232fca4dadSMilanka Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 242fca4dadSMilanka Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 253deb3ec6SMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 263deb3ec6SMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 273deb3ec6SMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 283deb3ec6SMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 293deb3ec6SMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 303deb3ec6SMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 313deb3ec6SMatthias Ringwald * SUCH DAMAGE. 323deb3ec6SMatthias Ringwald * 333deb3ec6SMatthias Ringwald * Please inquire about commercial licensing options at 343deb3ec6SMatthias Ringwald * [email protected] 353deb3ec6SMatthias Ringwald * 363deb3ec6SMatthias Ringwald */ 373deb3ec6SMatthias Ringwald 383deb3ec6SMatthias Ringwald 393deb3ec6SMatthias Ringwald /** 40fe5a6c4eSMilanka Ringwald * @title ATT Dispatch 41fe5a6c4eSMilanka Ringwald * 42fe5a6c4eSMilanka Ringwald * Dispatcher for independent implementation of ATT client and server. 43fe5a6c4eSMilanka Ringwald * 443deb3ec6SMatthias Ringwald */ 453deb3ec6SMatthias Ringwald 4680e33422SMatthias Ringwald #ifndef ATT_DISPATCH_H 4780e33422SMatthias Ringwald #define ATT_DISPATCH_H 483deb3ec6SMatthias Ringwald 49eb886013SMatthias Ringwald #include "btstack_util.h" 503deb3ec6SMatthias Ringwald 513deb3ec6SMatthias Ringwald #if defined __cplusplus 523deb3ec6SMatthias Ringwald extern "C" { 533deb3ec6SMatthias Ringwald #endif 543deb3ec6SMatthias Ringwald 553deb3ec6SMatthias Ringwald /** 567405427fSMatthias Ringwald * @brief Register packet handler for ATT Client PDUs 577405427fSMatthias Ringwald * @param packet_handler 583deb3ec6SMatthias Ringwald */ 593deb3ec6SMatthias Ringwald void att_dispatch_register_client(btstack_packet_handler_t packet_handler); 603deb3ec6SMatthias Ringwald 613deb3ec6SMatthias Ringwald /** 627405427fSMatthias Ringwald * @brief Register packet handler for ATT Server PDUs 637405427fSMatthias Ringwald * @param packet_handler 643deb3ec6SMatthias Ringwald */ 653deb3ec6SMatthias Ringwald void att_dispatch_register_server(btstack_packet_handler_t packet_handler); 663deb3ec6SMatthias Ringwald 6719448c0bSMatthias Ringwald /** 68d385c90eSMatthias Ringwald * @brief Register L2CAP ATT Service with fixed PSM 69d385c90eSMatthias Ringwald * @note requires ENABLE_GATT_OVER_CLASSIC 70d385c90eSMatthias Ringwald */ 71d385c90eSMatthias Ringwald void att_dispatch_classic_register_service(void); 72d385c90eSMatthias Ringwald 73d385c90eSMatthias Ringwald /** 74*1f4d0bc6SMatthias Ringwald * @brief Create L2CAP ATT Connection 75*1f4d0bc6SMatthias Ringwald * @note ENABLE_GATT_OVER_CLASSIC 76*1f4d0bc6SMatthias Ringwald * @param address 77*1f4d0bc6SMatthias Ringwald * @param l2cap_psm 78*1f4d0bc6SMatthias Ringwald */ 79*1f4d0bc6SMatthias Ringwald uint8_t att_dispatch_classic_connect(bd_addr_t address, uint16_t l2cap_psm, uint16_t *out_cid); 80*1f4d0bc6SMatthias Ringwald 81*1f4d0bc6SMatthias Ringwald /** 8219448c0bSMatthias Ringwald * @brief can send packet for client 83fc64f94aSMatthias Ringwald * @param con_handle 8419448c0bSMatthias Ringwald */ 854a7a258fSMatthias Ringwald bool att_dispatch_client_can_send_now(hci_con_handle_t con_handle); 8619448c0bSMatthias Ringwald 8719448c0bSMatthias Ringwald /** 8819448c0bSMatthias Ringwald * @brief can send packet for server 89fc64f94aSMatthias Ringwald * @param con_handle 9019448c0bSMatthias Ringwald */ 914a7a258fSMatthias Ringwald bool att_dispatch_server_can_send_now(hci_con_handle_t con_handle); 9219448c0bSMatthias Ringwald 930b9d7e78SMatthias Ringwald /** 940b9d7e78SMatthias Ringwald * @brief Request emission of L2CAP_EVENT_CAN_SEND_NOW as soon as possible for client 950b9d7e78SMatthias Ringwald * @note L2CAP_EVENT_CAN_SEND_NOW might be emitted during call to this function 960b9d7e78SMatthias Ringwald * so packet handler should be ready to handle it 970b9d7e78SMatthias Ringwald * @param con_handle 980b9d7e78SMatthias Ringwald */ 990b9d7e78SMatthias Ringwald void att_dispatch_client_request_can_send_now_event(hci_con_handle_t con_handle); 1000b9d7e78SMatthias Ringwald 1010b9d7e78SMatthias Ringwald /** 1020b9d7e78SMatthias Ringwald * @brief Request emission of L2CAP_EVENT_CAN_SEND_NOW as soon as possible for server 1030b9d7e78SMatthias Ringwald * @note L2CAP_EVENT_CAN_SEND_NOW might be emitted during call to this function 1040b9d7e78SMatthias Ringwald * so packet handler should be ready to handle it 1050b9d7e78SMatthias Ringwald * @param con_handle 1060b9d7e78SMatthias Ringwald */ 1070b9d7e78SMatthias Ringwald void att_dispatch_server_request_can_send_now_event(hci_con_handle_t con_handle); 10819448c0bSMatthias Ringwald 109b12646c5SJakob Krantz /** 110b12646c5SJakob Krantz * @brief Used for propogating a updated MTU from att_server to gatt_client 111b12646c5SJakob Krantz * @param con_handle 112b12646c5SJakob Krantz * @param mtu 113b12646c5SJakob Krantz */ 114b12646c5SJakob Krantz void att_dispatch_server_mtu_exchanged(hci_con_handle_t con_handle, uint16_t new_mtu); 115b12646c5SJakob Krantz 116b12646c5SJakob Krantz /** 117b12646c5SJakob Krantz * @brief Used for propogating a updated MTU from gatt_client to att_server 118b12646c5SJakob Krantz * @param con_handle 119b12646c5SJakob Krantz * @param mtu 120b12646c5SJakob Krantz */ 121b12646c5SJakob Krantz void att_dispatch_client_mtu_exchanged(hci_con_handle_t con_handle, uint16_t new_mtu); 122b12646c5SJakob Krantz 1233deb3ec6SMatthias Ringwald #if defined __cplusplus 1243deb3ec6SMatthias Ringwald } 1253deb3ec6SMatthias Ringwald #endif 1263deb3ec6SMatthias Ringwald 12780e33422SMatthias Ringwald #endif // ATT_DISPATCH_H 128