xref: /btstack/src/mesh/pb_adv.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 __PB_ADV_H
40*77ba3d3fSMatthias Ringwald #define __PB_ADV_H
41*77ba3d3fSMatthias Ringwald 
42*77ba3d3fSMatthias Ringwald #include <stdint.h>
43*77ba3d3fSMatthias Ringwald #include "btstack_defines.h"
44*77ba3d3fSMatthias Ringwald #include "btstack_config.h"
45*77ba3d3fSMatthias Ringwald 
46*77ba3d3fSMatthias Ringwald #if defined __cplusplus
47*77ba3d3fSMatthias Ringwald extern "C" {
48*77ba3d3fSMatthias Ringwald #endif
49*77ba3d3fSMatthias Ringwald 
50*77ba3d3fSMatthias Ringwald /**
51*77ba3d3fSMatthias Ringwald  * Initialize Provisioning Bearer using Advertisement Bearer
52*77ba3d3fSMatthias Ringwald  * @param DeviceUUID
53*77ba3d3fSMatthias Ringwald  */
54*77ba3d3fSMatthias Ringwald void pb_adv_init(const uint8_t * device_uuid);
55*77ba3d3fSMatthias Ringwald 
56*77ba3d3fSMatthias Ringwald /**
57*77ba3d3fSMatthias Ringwald  * Register listener for Provisioning PDUs and MESH_PBV_ADV_SEND_COMPLETE
58*77ba3d3fSMatthias Ringwald  */
59*77ba3d3fSMatthias Ringwald void pb_adv_register_packet_handler(btstack_packet_handler_t packet_handler);
60*77ba3d3fSMatthias Ringwald 
61*77ba3d3fSMatthias Ringwald /**
62*77ba3d3fSMatthias Ringwald  * Send Provisioning PDU
63*77ba3d3fSMatthias Ringwald  * @param pb_adv_cid
64*77ba3d3fSMatthias Ringwald  * @param pdu
65*77ba3d3fSMatthias Ringwald  * @param pb_adv_cid
66*77ba3d3fSMatthias Ringwald  */
67*77ba3d3fSMatthias Ringwald void pb_adv_send_pdu(uint16_t pb_adv_cid, const uint8_t * pdu, uint16_t pdu_size);
68*77ba3d3fSMatthias Ringwald 
69*77ba3d3fSMatthias Ringwald /**
70*77ba3d3fSMatthias Ringwald  * Close Link
71*77ba3d3fSMatthias Ringwald  * @param pb_adv_cid
72*77ba3d3fSMatthias Ringwald  * @param reason 0 = success, 1 = timeout, 2 = fail
73*77ba3d3fSMatthias Ringwald  */
74*77ba3d3fSMatthias Ringwald void pb_adv_close_link(uint16_t pb_adv_cid, uint8_t reason);
75*77ba3d3fSMatthias Ringwald 
76*77ba3d3fSMatthias Ringwald #ifdef ENABLE_MESH_PROVISIONER
77*77ba3d3fSMatthias Ringwald /**
78*77ba3d3fSMatthias Ringwald  * Setup Link with unprovisioned device
79*77ba3d3fSMatthias Ringwald  * @param DeviceUUID
80*77ba3d3fSMatthias Ringwald  * @returns pb_adv_cid or 0
81*77ba3d3fSMatthias Ringwald  */
82*77ba3d3fSMatthias Ringwald uint16_t pb_adv_create_link(const uint8_t * device_uuid);
83*77ba3d3fSMatthias Ringwald #endif
84*77ba3d3fSMatthias Ringwald 
85*77ba3d3fSMatthias Ringwald #if defined __cplusplus
86*77ba3d3fSMatthias Ringwald }
87*77ba3d3fSMatthias Ringwald #endif
88*77ba3d3fSMatthias Ringwald 
89*77ba3d3fSMatthias Ringwald #endif // __PB_ADV_H
90