xref: /btstack/src/ad_parser.h (revision 2fca4dad957cd7b88f4657ed51e89c12615dda72)
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
23*2fca4dadSMilanka Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN
24*2fca4dadSMilanka Ringwald  * GMBH 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 
38fe5a6c4eSMilanka Ringwald /**
3990f75057SMilanka Ringwald  * @title AD Data Parser
40fe5a6c4eSMilanka Ringwald  *
4190f75057SMilanka Ringwald  * AD Data (Advertisements and EIR) Parser
42fe5a6c4eSMilanka Ringwald  */
43b12ad867SMatthias Ringwald 
4480e33422SMatthias Ringwald #ifndef AD_PARSER_H
4580e33422SMatthias Ringwald #define AD_PARSER_H
46b12ad867SMatthias Ringwald 
47b12ad867SMatthias Ringwald #include "btstack_config.h"
482baf01d2SMatthias Ringwald #include "btstack_bool.h"
492baf01d2SMatthias Ringwald 
5091a08b11SMatthias Ringwald #include <stdint.h>
51b12ad867SMatthias Ringwald 
52b12ad867SMatthias Ringwald #if defined __cplusplus
53b12ad867SMatthias Ringwald extern "C" {
54b12ad867SMatthias Ringwald #endif
55b12ad867SMatthias Ringwald 
56b12ad867SMatthias Ringwald /* API_START */
57b12ad867SMatthias Ringwald 
58b12ad867SMatthias Ringwald typedef struct ad_context {
59b12ad867SMatthias Ringwald      const uint8_t * data;
60b12ad867SMatthias Ringwald      uint8_t   offset;
61b12ad867SMatthias Ringwald      uint8_t   length;
62b12ad867SMatthias Ringwald } ad_context_t;
63b12ad867SMatthias Ringwald 
64b12ad867SMatthias Ringwald // Advertising or Scan Response data iterator
65b12ad867SMatthias Ringwald void ad_iterator_init(ad_context_t *context, uint8_t ad_len, const uint8_t * ad_data);
662baf01d2SMatthias Ringwald bool ad_iterator_has_more(const ad_context_t * context);
67b12ad867SMatthias Ringwald void ad_iterator_next(ad_context_t * context);
68b12ad867SMatthias Ringwald 
69b12ad867SMatthias Ringwald // Access functions
70b12ad867SMatthias Ringwald uint8_t         ad_iterator_get_data_type(const ad_context_t * context);
71b12ad867SMatthias Ringwald uint8_t         ad_iterator_get_data_len(const ad_context_t * context);
72b12ad867SMatthias Ringwald const uint8_t * ad_iterator_get_data(const ad_context_t * context);
73b12ad867SMatthias Ringwald 
74b12ad867SMatthias Ringwald // convenience function on complete advertisements
759c2810d0SMatthias Ringwald bool ad_data_contains_uuid16(uint8_t ad_len, const uint8_t * ad_data, uint16_t uuid16);
762baf01d2SMatthias Ringwald bool ad_data_contains_uuid128(uint8_t ad_len, const uint8_t * ad_data, const uint8_t * uuid128);
77b12ad867SMatthias Ringwald 
78b12ad867SMatthias Ringwald /* API_END */
79b12ad867SMatthias Ringwald 
80b12ad867SMatthias Ringwald #if defined __cplusplus
81b12ad867SMatthias Ringwald }
82b12ad867SMatthias Ringwald #endif
8380e33422SMatthias Ringwald #endif // AD_PARSER_H
84