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