177ba3d3fSMatthias Ringwald /* 277ba3d3fSMatthias Ringwald * Copyright (C) 2017 BlueKitchen GmbH 377ba3d3fSMatthias Ringwald * 477ba3d3fSMatthias Ringwald * Redistribution and use in source and binary forms, with or without 577ba3d3fSMatthias Ringwald * modification, are permitted provided that the following conditions 677ba3d3fSMatthias Ringwald * are met: 777ba3d3fSMatthias Ringwald * 877ba3d3fSMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 977ba3d3fSMatthias Ringwald * notice, this list of conditions and the following disclaimer. 1077ba3d3fSMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 1177ba3d3fSMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 1277ba3d3fSMatthias Ringwald * documentation and/or other materials provided with the distribution. 1377ba3d3fSMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 1477ba3d3fSMatthias Ringwald * contributors may be used to endorse or promote products derived 1577ba3d3fSMatthias Ringwald * from this software without specific prior written permission. 1677ba3d3fSMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 1777ba3d3fSMatthias Ringwald * personal benefit and not for any commercial purpose or for 1877ba3d3fSMatthias Ringwald * monetary gain. 1977ba3d3fSMatthias Ringwald * 2077ba3d3fSMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 2177ba3d3fSMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2277ba3d3fSMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 232fca4dadSMilanka Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 242fca4dadSMilanka Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 2577ba3d3fSMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 2677ba3d3fSMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 2777ba3d3fSMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 2877ba3d3fSMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 2977ba3d3fSMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 3077ba3d3fSMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3177ba3d3fSMatthias Ringwald * SUCH DAMAGE. 3277ba3d3fSMatthias Ringwald * 3377ba3d3fSMatthias Ringwald * Please inquire about commercial licensing options at 3477ba3d3fSMatthias Ringwald * [email protected] 3577ba3d3fSMatthias Ringwald * 3677ba3d3fSMatthias Ringwald */ 3777ba3d3fSMatthias Ringwald 3877ba3d3fSMatthias Ringwald 39*bc6a318fSMatthias Ringwald #ifndef ADV_BEARER_H 40*bc6a318fSMatthias Ringwald #define ADV_BEARER_H 4177ba3d3fSMatthias Ringwald 4277ba3d3fSMatthias Ringwald #include <stdint.h> 43f4854a5eSMatthias Ringwald 4477ba3d3fSMatthias Ringwald #include "btstack_defines.h" 4577ba3d3fSMatthias Ringwald #include "bluetooth.h" 4677ba3d3fSMatthias Ringwald 4777ba3d3fSMatthias Ringwald #if defined __cplusplus 4877ba3d3fSMatthias Ringwald extern "C" { 4977ba3d3fSMatthias Ringwald #endif 5077ba3d3fSMatthias Ringwald 5177ba3d3fSMatthias Ringwald typedef struct { 5277ba3d3fSMatthias Ringwald void * next; 5377ba3d3fSMatthias Ringwald uint8_t adv_length; 5477ba3d3fSMatthias Ringwald uint8_t adv_data[31]; 5577ba3d3fSMatthias Ringwald } adv_bearer_connectable_advertisement_data_item_t; 5677ba3d3fSMatthias Ringwald 5777ba3d3fSMatthias Ringwald /** 5877ba3d3fSMatthias Ringwald * Initialize Advertising Bearer 5977ba3d3fSMatthias Ringwald */ 6077ba3d3fSMatthias Ringwald void adv_bearer_init(void); 6177ba3d3fSMatthias Ringwald 6277ba3d3fSMatthias Ringwald // 6377ba3d3fSMatthias Ringwald // Mirror gap.h advertisement API for use with ADV Bearer 6477ba3d3fSMatthias Ringwald // 6577ba3d3fSMatthias Ringwald // Advertisements are interleaved with ADV Bearer Messages 6677ba3d3fSMatthias Ringwald 6777ba3d3fSMatthias Ringwald /** 6877ba3d3fSMatthias Ringwald * Add Connectable Advertisement Data Item 6977ba3d3fSMatthias Ringwald * @param item 7077ba3d3fSMatthias Ringwald * @note item is not copied, pointer has to stay valid 7177ba3d3fSMatthias Ringwald * @note '00:00:00:00:00:00' in advertising_data will be replaced with actual bd addr 7277ba3d3fSMatthias Ringwald */ 7377ba3d3fSMatthias Ringwald void adv_bearer_advertisements_add_item(adv_bearer_connectable_advertisement_data_item_t * item); 7477ba3d3fSMatthias Ringwald 7577ba3d3fSMatthias Ringwald /** 7677ba3d3fSMatthias Ringwald * Remove Connectable Advertisement Data Item 7777ba3d3fSMatthias Ringwald * @param item 7877ba3d3fSMatthias Ringwald * @note item is not copied, pointer has to stay valid 7977ba3d3fSMatthias Ringwald * @note '00:00:00:00:00:00' in advertising_data will be replaced with actual bd addr 8077ba3d3fSMatthias Ringwald */ 8177ba3d3fSMatthias Ringwald void adv_bearer_advertisements_remove_item(adv_bearer_connectable_advertisement_data_item_t * item); 8277ba3d3fSMatthias Ringwald 8377ba3d3fSMatthias Ringwald /** 8477ba3d3fSMatthias Ringwald * @brief Set Advertisement Paramters 8577ba3d3fSMatthias Ringwald * @param adv_int_min 8677ba3d3fSMatthias Ringwald * @param adv_int_max 8777ba3d3fSMatthias Ringwald * @param adv_type 8877ba3d3fSMatthias Ringwald * @param direct_address_type 8977ba3d3fSMatthias Ringwald * @param direct_address 9077ba3d3fSMatthias Ringwald * @param channel_map 9177ba3d3fSMatthias Ringwald * @param filter_policy 9277ba3d3fSMatthias Ringwald * @note own_address_type is used from gap_random_address_set_mode 9377ba3d3fSMatthias Ringwald */ 9477ba3d3fSMatthias Ringwald void adv_bearer_advertisements_set_params(uint16_t adv_int_min, uint16_t adv_int_max, uint8_t adv_type, 9577ba3d3fSMatthias Ringwald uint8_t direct_address_typ, bd_addr_t direct_address, uint8_t channel_map, uint8_t filter_policy); 9677ba3d3fSMatthias Ringwald 9777ba3d3fSMatthias Ringwald /** 9877ba3d3fSMatthias Ringwald * @brief Enable/Disable Advertisements. OFF by default. 9977ba3d3fSMatthias Ringwald * @param enabled 10077ba3d3fSMatthias Ringwald */ 10177ba3d3fSMatthias Ringwald void adv_bearer_advertisements_enable(int enabled); 10277ba3d3fSMatthias Ringwald 10377ba3d3fSMatthias Ringwald /** 10477ba3d3fSMatthias Ringwald * Register listener for particular message types: Mesh Message, Mesh Beacon, PB-ADV 10577ba3d3fSMatthias Ringwald */ 1064662af4aSMatthias Ringwald void adv_bearer_register_for_network_pdu(btstack_packet_handler_t packet_handler); 1074662af4aSMatthias Ringwald void adv_bearer_register_for_beacon(btstack_packet_handler_t packet_handler); 1084662af4aSMatthias Ringwald void adv_bearer_register_for_provisioning_pdu(btstack_packet_handler_t packet_handler); 10977ba3d3fSMatthias Ringwald 11077ba3d3fSMatthias Ringwald /** 11177ba3d3fSMatthias Ringwald * Request can send now event for particular message type: Mesh Message, Mesh Beacon, PB-ADV 11277ba3d3fSMatthias Ringwald */ 1134662af4aSMatthias Ringwald void adv_bearer_request_can_send_now_for_network_pdu(void); 1144662af4aSMatthias Ringwald void adv_bearer_request_can_send_now_for_beacon(void); 1154662af4aSMatthias Ringwald void adv_bearer_request_can_send_now_for_provisioning_pdu(void); 11677ba3d3fSMatthias Ringwald 11777ba3d3fSMatthias Ringwald /** 1183bf10e3aSMatthias Ringwald * Send Mesh Message 1193bf10e3aSMatthias Ringwald * @param data to send 1203bf10e3aSMatthias Ringwald * @param data_len max 29 bytes 1213bf10e3aSMatthias Ringwald * @param count number of transmissions 1223bf10e3aSMatthias Ringwald * @param interval between transmission 1233bf10e3aSMatthias Ringwald */ 1243bf10e3aSMatthias Ringwald void adv_bearer_send_network_pdu(const uint8_t * network_pdu, uint16_t size, uint8_t count, uint16_t interval); 1253bf10e3aSMatthias Ringwald 1263bf10e3aSMatthias Ringwald /** 1273bf10e3aSMatthias Ringwald * Send particular message type:Mesh Beacon, PB-ADV 12877ba3d3fSMatthias Ringwald * @param data to send 12977ba3d3fSMatthias Ringwald * @param data_len max 29 bytes 13077ba3d3fSMatthias Ringwald */ 1314662af4aSMatthias Ringwald void adv_bearer_send_beacon(const uint8_t * beacon_update, uint16_t size); 1324662af4aSMatthias Ringwald void adv_bearer_send_provisioning_pdu(const uint8_t * pb_adv_pdu, uint16_t size); 13377ba3d3fSMatthias Ringwald 13477ba3d3fSMatthias Ringwald 13577ba3d3fSMatthias Ringwald #if defined __cplusplus 13677ba3d3fSMatthias Ringwald } 13777ba3d3fSMatthias Ringwald #endif 13877ba3d3fSMatthias Ringwald 13977ba3d3fSMatthias Ringwald #endif // __ADV_BEARER_H 140