• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright 2014 Google, Inc.
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 #pragma once
20 
21 #include <stdbool.h>
22 #include <stdint.h>
23 
24 // Provides Class Of Device primitive as specified in the bluetooth spec.
25 // [Class Of Device]
26 // (https://www.bluetooth.org/en-us/specification/assigned-numbers/baseband)
27 
28 // Device class may be defined in other structures.
29 // Only use defined methods to manipulate internals.
30 typedef struct bt_device_class_t {
31   uint8_t _[3];  // Do not access directly; use methods below.
32 } bt_device_class_t;
33 
34 // Copies the |data| class of device stream into device class |dc|.  |dc|
35 // and |data| must not be NULL.
36 void device_class_from_stream(bt_device_class_t* dc, const uint8_t* data);
37 
38 // Serializes the device class |dc| to pointer argument |data| in big endian
39 // format.  |len| must contain the buffer size of |data|.  Returns the actual
40 // number of bytes copied into |data|.  |dc| and |data| must not be NULL.
41 int device_class_to_stream(const bt_device_class_t* dc, uint8_t* data,
42                            size_t len);
43 
44 // Copies the |data| class of device integer into device class |dc|.  |dc|
45 // must not be NULL.
46 void device_class_from_int(bt_device_class_t* dc, int data);
47 
48 // Returns the device class |dc| in integer format.  |dc| must not be NULL.
49 int device_class_to_int(const bt_device_class_t* dc);
50 
51 // Compares and returns |true| if two device classes |p1| and |p2| are equal.
52 // False otherwise.
53 bool device_class_equals(const bt_device_class_t* p1,
54                          const bt_device_class_t* p2);
55 
56 // Copies and returns |true| if the device class was successfully copied from
57 //  |p2| into |p1|.  False otherwise.
58 bool device_class_copy(bt_device_class_t* dest, const bt_device_class_t* src);
59 
60 // Query, getters and setters for the major device class.  |dc| must not be
61 // NULL.
62 int device_class_get_major_device(const bt_device_class_t* dc);
63 void device_class_set_major_device(bt_device_class_t* dc, int val);
64 
65 // Query, getters and setters for the minor device class. |dc| must not be NULL.
66 int device_class_get_minor_device(const bt_device_class_t* dc);
67 void device_class_set_minor_device(bt_device_class_t* dc, int val);
68 
69 // Query, getters and setters for the various major service class features.
70 // |dc| must not be NULL.
71 bool device_class_get_limited(const bt_device_class_t* dc);
72 void device_class_set_limited(bt_device_class_t* dc, bool set);
73 
74 bool device_class_get_positioning(const bt_device_class_t* dc);
75 void device_class_set_positioning(bt_device_class_t* dc, bool set);
76 
77 bool device_class_get_networking(const bt_device_class_t* dc);
78 void device_class_set_networking(bt_device_class_t* dc, bool set);
79 
80 bool device_class_get_rendering(const bt_device_class_t* dc);
81 void device_class_set_rendering(bt_device_class_t* dc, bool set);
82 
83 bool device_class_get_capturing(const bt_device_class_t* dc);
84 void device_class_set_capturing(bt_device_class_t* dc, bool set);
85 
86 bool device_class_get_object_transfer(const bt_device_class_t* dc);
87 void device_class_set_object_transfer(bt_device_class_t* dc, bool set);
88 
89 bool device_class_get_audio(const bt_device_class_t* dc);
90 void device_class_set_audio(bt_device_class_t* dc, bool set);
91 
92 bool device_class_get_telephony(const bt_device_class_t* dc);
93 void device_class_set_telephony(bt_device_class_t* dc, bool set);
94 
95 bool device_class_get_information(const bt_device_class_t* dc);
96 void device_class_set_information(bt_device_class_t* dc, bool set);
97