liyujie
2025-08-28 b3810562527858a3b3d98ffa6e9c9c5b0f4a9a8e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/******************************************************************************
 *
 *  Copyright 2014 Google, Inc.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 ******************************************************************************/
 
#pragma once
 
#include <bluetooth/uuid.h>
#include <hardware/bluetooth.h>
#include <stdint.h>
#include <stdlib.h>
 
#include "btcore/include/device_class.h"
 
// Copies an array of consecutive properties of |count| to a newly
// allocated array. |properties| must not be NULL.
bt_property_t* property_copy_array(const bt_property_t* properties,
                                   size_t count);
 
// Copies |src| to |dest|. Returns the value of |dest|.
// |src| and |dest| must not be NULL.
bt_property_t* property_copy(bt_property_t* dest, const bt_property_t* src);
 
// Returns true if the value of the two properties |p1| and |p2| are equal.
// |p1| and |p2| must not be NULL.
bool property_equals(const bt_property_t* p1, const bt_property_t* p2);
 
// Property resource allocations. Caller is expected to free |property|
// using |property_free| or |property_free_array|.
// Parameter must not be NULL. A copy of the parameter is made and
// stored in the property.
bt_property_t* property_new_addr(const RawAddress* addr);
bt_property_t* property_new_device_class(const bt_device_class_t* dc);
bt_property_t* property_new_device_type(bt_device_type_t device_type);
bt_property_t* property_new_discovery_timeout(const uint32_t timeout);
bt_property_t* property_new_name(const char* name);
bt_property_t* property_new_rssi(const int8_t rssi);
bt_property_t* property_new_scan_mode(bt_scan_mode_t scan_mode);
bt_property_t* property_new_uuids(const bluetooth::Uuid* uuid, size_t count);
 
// Property resource frees both property and value.
void property_free(bt_property_t* property);
void property_free_array(bt_property_t* properties, size_t count);
 
// Value check convenience methods. The contents of the property are
// checked for the respective validity and returns true, false otherwise.
// |property| must not be NULL.
bool property_is_addr(const bt_property_t* property);
bool property_is_device_class(const bt_property_t* property);
bool property_is_device_type(const bt_property_t* property);
bool property_is_discovery_timeout(const bt_property_t* property);
bool property_is_name(const bt_property_t* property);
bool property_is_rssi(const bt_property_t* property);
bool property_is_scan_mode(const bt_property_t* property);
bool property_is_uuids(const bt_property_t* property);
 
// Value conversion convenience methods. The contents of the property are
// properly typed and returned to the caller. |property| must not be NULL.
const RawAddress* property_as_addr(const bt_property_t* property);
const bt_device_class_t* property_as_device_class(
    const bt_property_t* property);
bt_device_type_t property_as_device_type(const bt_property_t* property);
uint32_t property_as_discovery_timeout(const bt_property_t* property);
const bt_bdname_t* property_as_name(const bt_property_t* property);
int8_t property_as_rssi(const bt_property_t* property);
bt_scan_mode_t property_as_scan_mode(const bt_property_t* property);
const bluetooth::Uuid* property_as_uuids(const bt_property_t* property,
                                         size_t* count);