xref: /btstack/src/mesh/gatt_bearer.h (revision 77ba3d3f9fd2c90e975cda31e3c706784e95d43a)
1*77ba3d3fSMatthias Ringwald /*
2*77ba3d3fSMatthias Ringwald  * Copyright (C) 2017 BlueKitchen GmbH
3*77ba3d3fSMatthias Ringwald  *
4*77ba3d3fSMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
5*77ba3d3fSMatthias Ringwald  * modification, are permitted provided that the following conditions
6*77ba3d3fSMatthias Ringwald  * are met:
7*77ba3d3fSMatthias Ringwald  *
8*77ba3d3fSMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
9*77ba3d3fSMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
10*77ba3d3fSMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
11*77ba3d3fSMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
12*77ba3d3fSMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
13*77ba3d3fSMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
14*77ba3d3fSMatthias Ringwald  *    contributors may be used to endorse or promote products derived
15*77ba3d3fSMatthias Ringwald  *    from this software without specific prior written permission.
16*77ba3d3fSMatthias Ringwald  * 4. Any redistribution, use, or modification is done solely for
17*77ba3d3fSMatthias Ringwald  *    personal benefit and not for any commercial purpose or for
18*77ba3d3fSMatthias Ringwald  *    monetary gain.
19*77ba3d3fSMatthias Ringwald  *
20*77ba3d3fSMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21*77ba3d3fSMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22*77ba3d3fSMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23*77ba3d3fSMatthias Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
24*77ba3d3fSMatthias Ringwald  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25*77ba3d3fSMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26*77ba3d3fSMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27*77ba3d3fSMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28*77ba3d3fSMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29*77ba3d3fSMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30*77ba3d3fSMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31*77ba3d3fSMatthias Ringwald  * SUCH DAMAGE.
32*77ba3d3fSMatthias Ringwald  *
33*77ba3d3fSMatthias Ringwald  * Please inquire about commercial licensing options at
34*77ba3d3fSMatthias Ringwald  * [email protected]
35*77ba3d3fSMatthias Ringwald  *
36*77ba3d3fSMatthias Ringwald  */
37*77ba3d3fSMatthias Ringwald 
38*77ba3d3fSMatthias Ringwald 
39*77ba3d3fSMatthias Ringwald #ifndef __GATT_BEARER_H
40*77ba3d3fSMatthias Ringwald #define __GATT_BEARER_H
41*77ba3d3fSMatthias Ringwald 
42*77ba3d3fSMatthias Ringwald #include <stdint.h>
43*77ba3d3fSMatthias Ringwald #include "btstack_defines.h"
44*77ba3d3fSMatthias Ringwald 
45*77ba3d3fSMatthias Ringwald #if defined __cplusplus
46*77ba3d3fSMatthias Ringwald extern "C" {
47*77ba3d3fSMatthias Ringwald #endif
48*77ba3d3fSMatthias Ringwald 
49*77ba3d3fSMatthias Ringwald /**
50*77ba3d3fSMatthias Ringwald  * Initialize GATT Bearer
51*77ba3d3fSMatthias Ringwald  */
52*77ba3d3fSMatthias Ringwald void gatt_bearer_init(void);
53*77ba3d3fSMatthias Ringwald 
54*77ba3d3fSMatthias Ringwald /**
55*77ba3d3fSMatthias Ringwald  * Register listener for particular message types: Mesh Message, Mesh Beacon, proxy configuration
56*77ba3d3fSMatthias Ringwald  */
57*77ba3d3fSMatthias Ringwald void gatt_bearer_register_for_mesh_network_pdu(btstack_packet_handler_t packet_handler);
58*77ba3d3fSMatthias Ringwald void gatt_bearer_register_for_mesh_beacon(btstack_packet_handler_t packet_handler);
59*77ba3d3fSMatthias Ringwald void gatt_bearer_register_for_mesh_proxy_configuration(btstack_packet_handler_t _packet_handler);
60*77ba3d3fSMatthias Ringwald 
61*77ba3d3fSMatthias Ringwald /**
62*77ba3d3fSMatthias Ringwald  * Request can send now event for particular message type: Mesh Message, Mesh Beacon, proxy configuration
63*77ba3d3fSMatthias Ringwald  */
64*77ba3d3fSMatthias Ringwald void gatt_bearer_request_can_send_now_for_mesh_network_pdu(void);
65*77ba3d3fSMatthias Ringwald void gatt_bearer_request_can_send_now_for_mesh_beacon(void);
66*77ba3d3fSMatthias Ringwald void gatt_bearer_request_can_send_now_for_mesh_proxy_configuration(void);
67*77ba3d3fSMatthias Ringwald 
68*77ba3d3fSMatthias Ringwald /**
69*77ba3d3fSMatthias Ringwald  * Send particular message type: Mesh Message, Mesh Beacon, proxy configuration
70*77ba3d3fSMatthias Ringwald  * @param data to send
71*77ba3d3fSMatthias Ringwald  * @param data_len max 29 bytes
72*77ba3d3fSMatthias Ringwald  */
73*77ba3d3fSMatthias Ringwald void gatt_bearer_send_mesh_network_pdu(const uint8_t * network_pdu, uint16_t size);
74*77ba3d3fSMatthias Ringwald void gatt_bearer_send_mesh_beacon(const uint8_t * beacon_update, uint16_t size);
75*77ba3d3fSMatthias Ringwald void gatt_bearer_send_mesh_proxy_configuration(const uint8_t * proxy_configuration, uint16_t size);
76*77ba3d3fSMatthias Ringwald 
77*77ba3d3fSMatthias Ringwald /* Utility functions */
78*77ba3d3fSMatthias Ringwald /**
79*77ba3d3fSMatthias Ringwald  * Setup Proxy Advertisement for given network id
80*77ba3d3fSMatthias Ringwald  * @param buffer (20 bytes)
81*77ba3d3fSMatthias Ringwald  * @param network_id (8 bytes)
82*77ba3d3fSMatthias Ringwald  */
83*77ba3d3fSMatthias Ringwald uint8_t gatt_bearer_setup_advertising_with_network_id(uint8_t * buffer, uint8_t * network_id);
84*77ba3d3fSMatthias Ringwald 
85*77ba3d3fSMatthias Ringwald #if defined __cplusplus
86*77ba3d3fSMatthias Ringwald }
87*77ba3d3fSMatthias Ringwald #endif
88*77ba3d3fSMatthias Ringwald 
89*77ba3d3fSMatthias Ringwald #endif // __GATT_BEARER_H
90