1 /* 2 * Copyright (C) 2017 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of the copyright holders nor the names of 14 * contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * 4. Any redistribution, use, or modification is done solely for 17 * personal benefit and not for any commercial purpose or for 18 * monetary gain. 19 * 20 * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 24 * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * Please inquire about commercial licensing options at 34 * [email protected] 35 * 36 */ 37 38 39 #ifndef __ADV_BEARER_H 40 #define __ADV_BEARER_H 41 42 #include <stdint.h> 43 #include "btstack_defines.h" 44 #include "bluetooth.h" 45 46 #if defined __cplusplus 47 extern "C" { 48 #endif 49 50 typedef struct { 51 void * next; 52 uint8_t adv_length; 53 uint8_t adv_data[31]; 54 } adv_bearer_connectable_advertisement_data_item_t; 55 56 /** 57 * Initialize Advertising Bearer 58 */ 59 void adv_bearer_init(void); 60 61 // 62 // Mirror gap.h advertisement API for use with ADV Bearer 63 // 64 // Advertisements are interleaved with ADV Bearer Messages 65 66 /** 67 * Add Connectable Advertisement Data Item 68 * @param item 69 * @note item is not copied, pointer has to stay valid 70 * @note '00:00:00:00:00:00' in advertising_data will be replaced with actual bd addr 71 */ 72 void adv_bearer_advertisements_add_item(adv_bearer_connectable_advertisement_data_item_t * item); 73 74 /** 75 * Remove Connectable Advertisement Data Item 76 * @param item 77 * @note item is not copied, pointer has to stay valid 78 * @note '00:00:00:00:00:00' in advertising_data will be replaced with actual bd addr 79 */ 80 void adv_bearer_advertisements_remove_item(adv_bearer_connectable_advertisement_data_item_t * item); 81 82 /** 83 * @brief Set Advertisement Paramters 84 * @param adv_int_min 85 * @param adv_int_max 86 * @param adv_type 87 * @param direct_address_type 88 * @param direct_address 89 * @param channel_map 90 * @param filter_policy 91 * @note own_address_type is used from gap_random_address_set_mode 92 */ 93 void adv_bearer_advertisements_set_params(uint16_t adv_int_min, uint16_t adv_int_max, uint8_t adv_type, 94 uint8_t direct_address_typ, bd_addr_t direct_address, uint8_t channel_map, uint8_t filter_policy); 95 96 /** 97 * @brief Enable/Disable Advertisements. OFF by default. 98 * @param enabled 99 */ 100 void adv_bearer_advertisements_enable(int enabled); 101 102 /** 103 * Register listener for particular message types: Mesh Message, Mesh Beacon, PB-ADV 104 */ 105 void adv_bearer_register_for_network_pdu(btstack_packet_handler_t packet_handler); 106 void adv_bearer_register_for_beacon(btstack_packet_handler_t packet_handler); 107 void adv_bearer_register_for_provisioning_pdu(btstack_packet_handler_t packet_handler); 108 109 /** 110 * Request can send now event for particular message type: Mesh Message, Mesh Beacon, PB-ADV 111 */ 112 void adv_bearer_request_can_send_now_for_network_pdu(void); 113 void adv_bearer_request_can_send_now_for_beacon(void); 114 void adv_bearer_request_can_send_now_for_provisioning_pdu(void); 115 116 /** 117 * Send particular message type: Mesh Message, Mesh Beacon, PB-ADV 118 * @param data to send 119 * @param data_len max 29 bytes 120 */ 121 void adv_bearer_send_network_pdu(const uint8_t * network_pdu, uint16_t size); 122 void adv_bearer_send_beacon(const uint8_t * beacon_update, uint16_t size); 123 void adv_bearer_send_provisioning_pdu(const uint8_t * pb_adv_pdu, uint16_t size); 124 125 126 #if defined __cplusplus 127 } 128 #endif 129 130 #endif // __ADV_BEARER_H 131