xref: /btstack/src/mesh/mesh_upper_transport.h (revision 77ba3d3f9fd2c90e975cda31e3c706784e95d43a)
1*77ba3d3fSMatthias Ringwald /*
2*77ba3d3fSMatthias Ringwald  * Copyright (C) 2018 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 #ifndef __MESH_TRANSPORT_H
39*77ba3d3fSMatthias Ringwald #define __MESH_TRANSPORT_H
40*77ba3d3fSMatthias Ringwald 
41*77ba3d3fSMatthias Ringwald #include <stdint.h>
42*77ba3d3fSMatthias Ringwald 
43*77ba3d3fSMatthias Ringwald #ifdef __cplusplus
44*77ba3d3fSMatthias Ringwald extern "C"
45*77ba3d3fSMatthias Ringwald {
46*77ba3d3fSMatthias Ringwald #endif
47*77ba3d3fSMatthias Ringwald 
48*77ba3d3fSMatthias Ringwald 
49*77ba3d3fSMatthias Ringwald #include <stdint.h>
50*77ba3d3fSMatthias Ringwald #include "mesh/mesh_network.h"
51*77ba3d3fSMatthias Ringwald 
52*77ba3d3fSMatthias Ringwald void mesh_transport_init();
53*77ba3d3fSMatthias Ringwald 
54*77ba3d3fSMatthias Ringwald void mesh_upper_transport_set_primary_element_address(uint16_t primary_element_address);
55*77ba3d3fSMatthias Ringwald 
56*77ba3d3fSMatthias Ringwald void mesh_upper_transport_message_processed_by_higher_layer(mesh_pdu_t * pdu);
57*77ba3d3fSMatthias Ringwald 
58*77ba3d3fSMatthias Ringwald // Control PDUs
59*77ba3d3fSMatthias Ringwald 
60*77ba3d3fSMatthias Ringwald void mesh_upper_transport_register_control_message_handler(void (*callback)(mesh_pdu_t * pdu));
61*77ba3d3fSMatthias Ringwald 
62*77ba3d3fSMatthias Ringwald uint8_t mesh_upper_transport_setup_control_pdu(mesh_pdu_t * pdu, uint16_t netkey_index,
63*77ba3d3fSMatthias Ringwald         uint8_t ttl, uint16_t src, uint16_t dest, uint8_t opcode, const uint8_t * control_pdu_data, uint16_t control_pdu_len);
64*77ba3d3fSMatthias Ringwald 
65*77ba3d3fSMatthias Ringwald void mesh_upper_transport_send_control_pdu(mesh_pdu_t * pdu);
66*77ba3d3fSMatthias Ringwald 
67*77ba3d3fSMatthias Ringwald // Access PDUs
68*77ba3d3fSMatthias Ringwald 
69*77ba3d3fSMatthias Ringwald 
70*77ba3d3fSMatthias Ringwald void mesh_upper_transport_register_access_message_handler(void (*callback)(mesh_pdu_t * pdu));
71*77ba3d3fSMatthias Ringwald 
72*77ba3d3fSMatthias Ringwald uint8_t mesh_upper_transport_setup_access_pdu_header(mesh_pdu_t * pdu, uint16_t netkey_index, uint16_t appkey_index,
73*77ba3d3fSMatthias Ringwald                                                                uint8_t ttl, uint16_t src, uint16_t dest, uint8_t szmic);
74*77ba3d3fSMatthias Ringwald 
75*77ba3d3fSMatthias Ringwald uint8_t mesh_upper_transport_setup_access_pdu(mesh_pdu_t * pdu, uint16_t netkey_index, uint16_t appkey_index,
76*77ba3d3fSMatthias Ringwald                                                           uint8_t ttl, uint16_t src, uint16_t dest, uint8_t szmic,
77*77ba3d3fSMatthias Ringwald                                                           const uint8_t * access_pdu_data, uint8_t access_pdu_len);
78*77ba3d3fSMatthias Ringwald 
79*77ba3d3fSMatthias Ringwald void mesh_upper_transport_send_access_pdu(mesh_pdu_t * pdu);
80*77ba3d3fSMatthias Ringwald 
81*77ba3d3fSMatthias Ringwald // allocator
82*77ba3d3fSMatthias Ringwald mesh_transport_pdu_t * mesh_transport_pdu_get(void);
83*77ba3d3fSMatthias Ringwald void mesh_transport_pdu_free(mesh_transport_pdu_t * transport_pdu);
84*77ba3d3fSMatthias Ringwald 
85*77ba3d3fSMatthias Ringwald #ifdef __cplusplus
86*77ba3d3fSMatthias Ringwald } /* end of extern "C" */
87*77ba3d3fSMatthias Ringwald #endif
88*77ba3d3fSMatthias Ringwald 
89*77ba3d3fSMatthias Ringwald #endif
90