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 __ADV_BEARER_H 40*77ba3d3fSMatthias Ringwald #define __ADV_BEARER_H 41*77ba3d3fSMatthias Ringwald 42*77ba3d3fSMatthias Ringwald #include <stdint.h> 43*77ba3d3fSMatthias Ringwald #include "btstack_defines.h" 44*77ba3d3fSMatthias Ringwald #include "bluetooth.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 typedef struct { 51*77ba3d3fSMatthias Ringwald void * next; 52*77ba3d3fSMatthias Ringwald uint8_t adv_length; 53*77ba3d3fSMatthias Ringwald uint8_t adv_data[31]; 54*77ba3d3fSMatthias Ringwald } adv_bearer_connectable_advertisement_data_item_t; 55*77ba3d3fSMatthias Ringwald 56*77ba3d3fSMatthias Ringwald /** 57*77ba3d3fSMatthias Ringwald * Initialize Advertising Bearer 58*77ba3d3fSMatthias Ringwald */ 59*77ba3d3fSMatthias Ringwald void adv_bearer_init(void); 60*77ba3d3fSMatthias Ringwald 61*77ba3d3fSMatthias Ringwald // 62*77ba3d3fSMatthias Ringwald // Mirror gap.h advertisement API for use with ADV Bearer 63*77ba3d3fSMatthias Ringwald // 64*77ba3d3fSMatthias Ringwald // Advertisements are interleaved with ADV Bearer Messages 65*77ba3d3fSMatthias Ringwald 66*77ba3d3fSMatthias Ringwald /** 67*77ba3d3fSMatthias Ringwald * Add Connectable Advertisement Data Item 68*77ba3d3fSMatthias Ringwald * @param item 69*77ba3d3fSMatthias Ringwald * @note item is not copied, pointer has to stay valid 70*77ba3d3fSMatthias Ringwald * @note '00:00:00:00:00:00' in advertising_data will be replaced with actual bd addr 71*77ba3d3fSMatthias Ringwald */ 72*77ba3d3fSMatthias Ringwald void adv_bearer_advertisements_add_item(adv_bearer_connectable_advertisement_data_item_t * item); 73*77ba3d3fSMatthias Ringwald 74*77ba3d3fSMatthias Ringwald /** 75*77ba3d3fSMatthias Ringwald * Remove Connectable Advertisement Data Item 76*77ba3d3fSMatthias Ringwald * @param item 77*77ba3d3fSMatthias Ringwald * @note item is not copied, pointer has to stay valid 78*77ba3d3fSMatthias Ringwald * @note '00:00:00:00:00:00' in advertising_data will be replaced with actual bd addr 79*77ba3d3fSMatthias Ringwald */ 80*77ba3d3fSMatthias Ringwald void adv_bearer_advertisements_remove_item(adv_bearer_connectable_advertisement_data_item_t * item); 81*77ba3d3fSMatthias Ringwald 82*77ba3d3fSMatthias Ringwald /** 83*77ba3d3fSMatthias Ringwald * @brief Set Advertisement Paramters 84*77ba3d3fSMatthias Ringwald * @param adv_int_min 85*77ba3d3fSMatthias Ringwald * @param adv_int_max 86*77ba3d3fSMatthias Ringwald * @param adv_type 87*77ba3d3fSMatthias Ringwald * @param direct_address_type 88*77ba3d3fSMatthias Ringwald * @param direct_address 89*77ba3d3fSMatthias Ringwald * @param channel_map 90*77ba3d3fSMatthias Ringwald * @param filter_policy 91*77ba3d3fSMatthias Ringwald * @note own_address_type is used from gap_random_address_set_mode 92*77ba3d3fSMatthias Ringwald */ 93*77ba3d3fSMatthias Ringwald void adv_bearer_advertisements_set_params(uint16_t adv_int_min, uint16_t adv_int_max, uint8_t adv_type, 94*77ba3d3fSMatthias Ringwald uint8_t direct_address_typ, bd_addr_t direct_address, uint8_t channel_map, uint8_t filter_policy); 95*77ba3d3fSMatthias Ringwald 96*77ba3d3fSMatthias Ringwald /** 97*77ba3d3fSMatthias Ringwald * @brief Enable/Disable Advertisements. OFF by default. 98*77ba3d3fSMatthias Ringwald * @param enabled 99*77ba3d3fSMatthias Ringwald */ 100*77ba3d3fSMatthias Ringwald void adv_bearer_advertisements_enable(int enabled); 101*77ba3d3fSMatthias Ringwald 102*77ba3d3fSMatthias Ringwald /** 103*77ba3d3fSMatthias Ringwald * Register listener for particular message types: Mesh Message, Mesh Beacon, PB-ADV 104*77ba3d3fSMatthias Ringwald */ 105*77ba3d3fSMatthias Ringwald void adv_bearer_register_for_mesh_message(btstack_packet_handler_t packet_handler); 106*77ba3d3fSMatthias Ringwald void adv_bearer_register_for_mesh_beacon(btstack_packet_handler_t packet_handler); 107*77ba3d3fSMatthias Ringwald void adv_bearer_register_for_pb_adv(btstack_packet_handler_t packet_handler); 108*77ba3d3fSMatthias Ringwald 109*77ba3d3fSMatthias Ringwald /** 110*77ba3d3fSMatthias Ringwald * Request can send now event for particular message type: Mesh Message, Mesh Beacon, PB-ADV 111*77ba3d3fSMatthias Ringwald */ 112*77ba3d3fSMatthias Ringwald void adv_bearer_request_can_send_now_for_mesh_message(void); 113*77ba3d3fSMatthias Ringwald void adv_bearer_request_can_send_now_for_mesh_beacon(void); 114*77ba3d3fSMatthias Ringwald void adv_bearer_request_can_send_now_for_pb_adv(void); 115*77ba3d3fSMatthias Ringwald 116*77ba3d3fSMatthias Ringwald /** 117*77ba3d3fSMatthias Ringwald * Send particular message type: Mesh Message, Mesh Beacon, PB-ADV 118*77ba3d3fSMatthias Ringwald * @param data to send 119*77ba3d3fSMatthias Ringwald * @param data_len max 29 bytes 120*77ba3d3fSMatthias Ringwald */ 121*77ba3d3fSMatthias Ringwald void adv_bearer_send_mesh_message(const uint8_t * network_pdu, uint16_t size); 122*77ba3d3fSMatthias Ringwald void adv_bearer_send_mesh_beacon(const uint8_t * beacon_update, uint16_t size); 123*77ba3d3fSMatthias Ringwald void adv_bearer_send_pb_adv(const uint8_t * pb_adv_pdu, uint16_t size); 124*77ba3d3fSMatthias Ringwald 125*77ba3d3fSMatthias Ringwald 126*77ba3d3fSMatthias Ringwald #if defined __cplusplus 127*77ba3d3fSMatthias Ringwald } 128*77ba3d3fSMatthias Ringwald #endif 129*77ba3d3fSMatthias Ringwald 130*77ba3d3fSMatthias Ringwald #endif // __ADV_BEARER_H 131