xref: /btstack/src/mesh/gatt_bearer.h (revision 4662af4a88ca1e7d6d85dcfaea44271a9a60ea26)
177ba3d3fSMatthias Ringwald /*
277ba3d3fSMatthias Ringwald  * Copyright (C) 2017 BlueKitchen GmbH
377ba3d3fSMatthias Ringwald  *
477ba3d3fSMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
577ba3d3fSMatthias Ringwald  * modification, are permitted provided that the following conditions
677ba3d3fSMatthias Ringwald  * are met:
777ba3d3fSMatthias Ringwald  *
877ba3d3fSMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
977ba3d3fSMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
1077ba3d3fSMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
1177ba3d3fSMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
1277ba3d3fSMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
1377ba3d3fSMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
1477ba3d3fSMatthias Ringwald  *    contributors may be used to endorse or promote products derived
1577ba3d3fSMatthias Ringwald  *    from this software without specific prior written permission.
1677ba3d3fSMatthias Ringwald  * 4. Any redistribution, use, or modification is done solely for
1777ba3d3fSMatthias Ringwald  *    personal benefit and not for any commercial purpose or for
1877ba3d3fSMatthias Ringwald  *    monetary gain.
1977ba3d3fSMatthias Ringwald  *
2077ba3d3fSMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
2177ba3d3fSMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2277ba3d3fSMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
2377ba3d3fSMatthias Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
2477ba3d3fSMatthias Ringwald  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
2577ba3d3fSMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
2677ba3d3fSMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
2777ba3d3fSMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
2877ba3d3fSMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2977ba3d3fSMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
3077ba3d3fSMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3177ba3d3fSMatthias Ringwald  * SUCH DAMAGE.
3277ba3d3fSMatthias Ringwald  *
3377ba3d3fSMatthias Ringwald  * Please inquire about commercial licensing options at
3477ba3d3fSMatthias Ringwald  * [email protected]
3577ba3d3fSMatthias Ringwald  *
3677ba3d3fSMatthias Ringwald  */
3777ba3d3fSMatthias Ringwald 
3877ba3d3fSMatthias Ringwald 
3977ba3d3fSMatthias Ringwald #ifndef __GATT_BEARER_H
4077ba3d3fSMatthias Ringwald #define __GATT_BEARER_H
4177ba3d3fSMatthias Ringwald 
4277ba3d3fSMatthias Ringwald #include <stdint.h>
4377ba3d3fSMatthias Ringwald #include "btstack_defines.h"
4477ba3d3fSMatthias Ringwald 
4577ba3d3fSMatthias Ringwald #if defined __cplusplus
4677ba3d3fSMatthias Ringwald extern "C" {
4777ba3d3fSMatthias Ringwald #endif
4877ba3d3fSMatthias Ringwald 
4977ba3d3fSMatthias Ringwald /**
5077ba3d3fSMatthias Ringwald  * Initialize GATT Bearer
5177ba3d3fSMatthias Ringwald  */
5277ba3d3fSMatthias Ringwald void gatt_bearer_init(void);
5377ba3d3fSMatthias Ringwald 
5477ba3d3fSMatthias Ringwald /**
5577ba3d3fSMatthias Ringwald  * Register listener for particular message types: Mesh Message, Mesh Beacon, proxy configuration
5677ba3d3fSMatthias Ringwald  */
57*4662af4aSMatthias Ringwald void gatt_bearer_register_for_network_pdu(btstack_packet_handler_t packet_handler);
58*4662af4aSMatthias Ringwald void gatt_bearer_register_for_beacon(btstack_packet_handler_t packet_handler);
5977ba3d3fSMatthias Ringwald void gatt_bearer_register_for_mesh_proxy_configuration(btstack_packet_handler_t _packet_handler);
6077ba3d3fSMatthias Ringwald 
6177ba3d3fSMatthias Ringwald /**
6277ba3d3fSMatthias Ringwald  * Request can send now event for particular message type: Mesh Message, Mesh Beacon, proxy configuration
6377ba3d3fSMatthias Ringwald  */
64*4662af4aSMatthias Ringwald void gatt_bearer_request_can_send_now_for_network_pdu(void);
65*4662af4aSMatthias Ringwald void gatt_bearer_request_can_send_now_for_beacon(void);
6677ba3d3fSMatthias Ringwald void gatt_bearer_request_can_send_now_for_mesh_proxy_configuration(void);
6777ba3d3fSMatthias Ringwald 
6877ba3d3fSMatthias Ringwald /**
6977ba3d3fSMatthias Ringwald  * Send particular message type: Mesh Message, Mesh Beacon, proxy configuration
7077ba3d3fSMatthias Ringwald  * @param data to send
7177ba3d3fSMatthias Ringwald  * @param data_len max 29 bytes
7277ba3d3fSMatthias Ringwald  */
73*4662af4aSMatthias Ringwald void gatt_bearer_send_network_pdu(const uint8_t * network_pdu, uint16_t size);
74*4662af4aSMatthias Ringwald void gatt_bearer_send_beacon(const uint8_t * beacon_update, uint16_t size);
7577ba3d3fSMatthias Ringwald void gatt_bearer_send_mesh_proxy_configuration(const uint8_t * proxy_configuration, uint16_t size);
7677ba3d3fSMatthias Ringwald 
7777ba3d3fSMatthias Ringwald /* Utility functions */
7877ba3d3fSMatthias Ringwald /**
7977ba3d3fSMatthias Ringwald  * Setup Proxy Advertisement for given network id
8077ba3d3fSMatthias Ringwald  * @param buffer (20 bytes)
8177ba3d3fSMatthias Ringwald  * @param network_id (8 bytes)
8277ba3d3fSMatthias Ringwald  */
8377ba3d3fSMatthias Ringwald uint8_t gatt_bearer_setup_advertising_with_network_id(uint8_t * buffer, uint8_t * network_id);
8477ba3d3fSMatthias Ringwald 
8577ba3d3fSMatthias Ringwald #if defined __cplusplus
8677ba3d3fSMatthias Ringwald }
8777ba3d3fSMatthias Ringwald #endif
8877ba3d3fSMatthias Ringwald 
8977ba3d3fSMatthias Ringwald #endif // __GATT_BEARER_H
90