1b12ad867SMatthias Ringwald /* 2b12ad867SMatthias Ringwald * Copyright (C) 2014 BlueKitchen GmbH 3b12ad867SMatthias Ringwald * 4b12ad867SMatthias Ringwald * Redistribution and use in source and binary forms, with or without 5b12ad867SMatthias Ringwald * modification, are permitted provided that the following conditions 6b12ad867SMatthias Ringwald * are met: 7b12ad867SMatthias Ringwald * 8b12ad867SMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 9b12ad867SMatthias Ringwald * notice, this list of conditions and the following disclaimer. 10b12ad867SMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 11b12ad867SMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 12b12ad867SMatthias Ringwald * documentation and/or other materials provided with the distribution. 13b12ad867SMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 14b12ad867SMatthias Ringwald * contributors may be used to endorse or promote products derived 15b12ad867SMatthias Ringwald * from this software without specific prior written permission. 16b12ad867SMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 17b12ad867SMatthias Ringwald * personal benefit and not for any commercial purpose or for 18b12ad867SMatthias Ringwald * monetary gain. 19b12ad867SMatthias Ringwald * 20b12ad867SMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21b12ad867SMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22b12ad867SMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23b12ad867SMatthias Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 24b12ad867SMatthias Ringwald * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25b12ad867SMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26b12ad867SMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27b12ad867SMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28b12ad867SMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29b12ad867SMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30b12ad867SMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31b12ad867SMatthias Ringwald * SUCH DAMAGE. 32b12ad867SMatthias Ringwald * 33b12ad867SMatthias Ringwald * Please inquire about commercial licensing options at 34b12ad867SMatthias Ringwald * [email protected] 35b12ad867SMatthias Ringwald * 36b12ad867SMatthias Ringwald */ 37b12ad867SMatthias Ringwald 38b12ad867SMatthias Ringwald // ***************************************************************************** 39b12ad867SMatthias Ringwald // 40b12ad867SMatthias Ringwald // Advertising Data Parser 41b12ad867SMatthias Ringwald // 42b12ad867SMatthias Ringwald // ***************************************************************************** 43b12ad867SMatthias Ringwald 44*80e33422SMatthias Ringwald #ifndef AD_PARSER_H 45*80e33422SMatthias Ringwald #define AD_PARSER_H 46b12ad867SMatthias Ringwald 47b12ad867SMatthias Ringwald #include "btstack_config.h" 4891a08b11SMatthias Ringwald #include <stdint.h> 49b12ad867SMatthias Ringwald 50b12ad867SMatthias Ringwald #if defined __cplusplus 51b12ad867SMatthias Ringwald extern "C" { 52b12ad867SMatthias Ringwald #endif 53b12ad867SMatthias Ringwald 54b12ad867SMatthias Ringwald /* API_START */ 55b12ad867SMatthias Ringwald 56b12ad867SMatthias Ringwald typedef struct ad_context { 57b12ad867SMatthias Ringwald const uint8_t * data; 58b12ad867SMatthias Ringwald uint8_t offset; 59b12ad867SMatthias Ringwald uint8_t length; 60b12ad867SMatthias Ringwald } ad_context_t; 61b12ad867SMatthias Ringwald 62b12ad867SMatthias Ringwald // Advertising or Scan Response data iterator 63b12ad867SMatthias Ringwald void ad_iterator_init(ad_context_t *context, uint8_t ad_len, const uint8_t * ad_data); 64b12ad867SMatthias Ringwald int ad_iterator_has_more(const ad_context_t * context); 65b12ad867SMatthias Ringwald void ad_iterator_next(ad_context_t * context); 66b12ad867SMatthias Ringwald 67b12ad867SMatthias Ringwald // Access functions 68b12ad867SMatthias Ringwald uint8_t ad_iterator_get_data_type(const ad_context_t * context); 69b12ad867SMatthias Ringwald uint8_t ad_iterator_get_data_len(const ad_context_t * context); 70b12ad867SMatthias Ringwald const uint8_t * ad_iterator_get_data(const ad_context_t * context); 71b12ad867SMatthias Ringwald 72b12ad867SMatthias Ringwald // convenience function on complete advertisements 73b12ad867SMatthias Ringwald int ad_data_contains_uuid16(uint8_t ad_len, const uint8_t * ad_data, uint16_t uuid); 74b12ad867SMatthias Ringwald int ad_data_contains_uuid128(uint8_t ad_len, const uint8_t * ad_data, const uint8_t * uuid128); 75b12ad867SMatthias Ringwald 76b12ad867SMatthias Ringwald /* API_END */ 77b12ad867SMatthias Ringwald 78b12ad867SMatthias Ringwald #if defined __cplusplus 79b12ad867SMatthias Ringwald } 80b12ad867SMatthias Ringwald #endif 81*80e33422SMatthias Ringwald #endif // AD_PARSER_H 82