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