xref: /btstack/platform/lwip/bnep_lwip.h (revision abb61bc22a5228e9b178c541f7c9a87dcafdb1f0)
197dc5e69SMatthias Ringwald /*
297dc5e69SMatthias Ringwald  * Copyright (C) 2019 BlueKitchen GmbH
397dc5e69SMatthias Ringwald  *
497dc5e69SMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
597dc5e69SMatthias Ringwald  * modification, are permitted provided that the following conditions
697dc5e69SMatthias Ringwald  * are met:
797dc5e69SMatthias Ringwald  *
897dc5e69SMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
997dc5e69SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
1097dc5e69SMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
1197dc5e69SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
1297dc5e69SMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
1397dc5e69SMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
1497dc5e69SMatthias Ringwald  *    contributors may be used to endorse or promote products derived
1597dc5e69SMatthias Ringwald  *    from this software without specific prior written permission.
1697dc5e69SMatthias Ringwald  * 4. Any redistribution, use, or modification is done solely for
1797dc5e69SMatthias Ringwald  *    personal benefit and not for any commercial purpose or for
1897dc5e69SMatthias Ringwald  *    monetary gain.
1997dc5e69SMatthias Ringwald  *
2097dc5e69SMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
2197dc5e69SMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2297dc5e69SMatthias 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,
2597dc5e69SMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
2697dc5e69SMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
2797dc5e69SMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
2897dc5e69SMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2997dc5e69SMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
3097dc5e69SMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3197dc5e69SMatthias Ringwald  * SUCH DAMAGE.
3297dc5e69SMatthias Ringwald  *
3397dc5e69SMatthias Ringwald  * Please inquire about commercial licensing options at
3497dc5e69SMatthias Ringwald  * [email protected]
3597dc5e69SMatthias Ringwald  *
3697dc5e69SMatthias Ringwald  */
3797dc5e69SMatthias Ringwald 
3897dc5e69SMatthias Ringwald /*
3997dc5e69SMatthias Ringwald  *  bnep_lwip.h
4097dc5e69SMatthias Ringwald  *  BNEP adapter for lwIP TCP/IP Network Stack
4197dc5e69SMatthias Ringwald  *
4297dc5e69SMatthias Ringwald  *  Adapter handles all BNEP events and forwards Ethernet frames between an active BNEP connection and the lwIP network stack
4397dc5e69SMatthias Ringwald  */
4497dc5e69SMatthias Ringwald 
4597dc5e69SMatthias Ringwald #ifndef BNEP_LWIP_H
4697dc5e69SMatthias Ringwald #define BNEP_LWIP_H
4797dc5e69SMatthias Ringwald 
4897dc5e69SMatthias Ringwald #include <stdint.h>
4997dc5e69SMatthias Ringwald #include "bluetooth.h"
5097dc5e69SMatthias Ringwald #include "btstack_defines.h"
5197dc5e69SMatthias Ringwald 
52*abb61bc2SPeter Harper #include "lwip/netif.h"
53*abb61bc2SPeter Harper 
5497dc5e69SMatthias Ringwald #if defined __cplusplus
5597dc5e69SMatthias Ringwald extern "C" {
5697dc5e69SMatthias Ringwald #endif
5797dc5e69SMatthias Ringwald 
5897dc5e69SMatthias Ringwald /**
5997dc5e69SMatthias Ringwald  * @brief Initialize BNEP Adapter
6097dc5e69SMatthias Ringwald  */
6197dc5e69SMatthias Ringwald void bnep_lwip_init(void);
6297dc5e69SMatthias Ringwald 
6397dc5e69SMatthias Ringwald /**
6497dc5e69SMatthias Ringwald  * @brief Register packet handler for BNEP events
6597dc5e69SMatthias Ringwald  */
6697dc5e69SMatthias Ringwald void bnep_lwip_register_packet_handler(btstack_packet_handler_t handler);
6797dc5e69SMatthias Ringwald 
6897dc5e69SMatthias Ringwald /**
6997dc5e69SMatthias Ringwald  * @brief Register BNEP service
7097dc5e69SMatthias Ringwald  * @brief Same as benp_register_service, but bnep lwip adapter handles all events
7197dc5e69SMatthias Ringwald  * @param service_uuid
7297dc5e69SMatthias Ringwald  * @Param max_frame_size
7397dc5e69SMatthias Ringwald  */
7497dc5e69SMatthias Ringwald uint8_t bnep_lwip_register_service(uint16_t service_uuid, uint16_t max_frame_size);
7597dc5e69SMatthias Ringwald 
769c30c50aSMatthias Ringwald /**
779c30c50aSMatthias Ringwald  * @brief Creates BNEP connection (channel) to a given server on a remote device with baseband address. A new baseband connection will be initiated if necessary.
789c30c50aSMatthias Ringwald  * @param addr
799c30c50aSMatthias Ringwald  * @param l2cap_psm
809c30c50aSMatthias Ringwald  * @param uuid_src
819c30c50aSMatthias Ringwald  * @param uuid_dest
829c30c50aSMatthias Ringwald  */
839c30c50aSMatthias Ringwald uint8_t bnep_lwip_connect(bd_addr_t addr, uint16_t l2cap_psm, uint16_t uuid_src, uint16_t uuid_dest);
8497dc5e69SMatthias Ringwald 
85*abb61bc2SPeter Harper /**
86*abb61bc2SPeter Harper  * @brief Get the Bluetooth lwIP network interface
87*abb61bc2SPeter Harper  */
88*abb61bc2SPeter Harper struct netif *bnep_lwip_get_interface(void);
89*abb61bc2SPeter Harper 
9097dc5e69SMatthias Ringwald #if defined __cplusplus
9197dc5e69SMatthias Ringwald }
9297dc5e69SMatthias Ringwald #endif
9397dc5e69SMatthias Ringwald 
9497dc5e69SMatthias Ringwald #endif
95