1 /****************************************************************************** 2 * 3 * Copyright (C) 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](https://www.bluetooth.org/en-us/specification/assigned-numbers/baseband) 26 27 // Device class may be defined in other structures. 28 // Only use defined methods to manipulate internals. 29 typedef struct bt_device_class_t { 30 uint8_t _[3]; // Do not access directly; use methods below. 31 } bt_device_class_t; 32 33 // Copies the |data| class of device stream into device class |dc|. |dc| 34 // and |data| must not be NULL. 35 void device_class_from_stream(bt_device_class_t *dc, const uint8_t *data); 36 37 // Serializes the device class |dc| to pointer argument |data| in big endian 38 // format. |len| must contain the buffer size of |data|. Returns the actual 39 // number of bytes copied into |data|. |dc| and |data| must not be NULL. 40 int device_class_to_stream(const bt_device_class_t *dc, uint8_t *data, size_t len); 41 42 // Copies the |data| class of device integer into device class |dc|. |dc| 43 // must not be NULL. 44 void device_class_from_int(bt_device_class_t *dc, int data); 45 46 // Returns the device class |dc| in integer format. |dc| must not be NULL. 47 int device_class_to_int(const bt_device_class_t *dc); 48 49 // Compares and returns |true| if two device classes |p1| and |p2| are equal. 50 // False otherwise. 51 bool device_class_equals(const bt_device_class_t *p1, const bt_device_class_t *p2); 52 53 // Copies and returns |true| if the device class was successfully copied from 54 // |p2| into |p1|. False otherwise. 55 bool device_class_copy(bt_device_class_t *dest, const bt_device_class_t *src); 56 57 // Query, getters and setters for the major device class. |dc| must not be NULL. 58 int device_class_get_major_device(const bt_device_class_t *dc); 59 void device_class_set_major_device(bt_device_class_t *dc, int val); 60 61 // Query, getters and setters for the minor device class. |dc| must not be NULL. 62 int device_class_get_minor_device(const bt_device_class_t *dc); 63 void device_class_set_minor_device(bt_device_class_t *dc, int val); 64 65 // Query, getters and setters for the various major service class features. 66 // |dc| must not be NULL. 67 bool device_class_get_limited(const bt_device_class_t *dc); 68 void device_class_set_limited(bt_device_class_t *dc, bool set); 69 70 bool device_class_get_positioning(const bt_device_class_t *dc); 71 void device_class_set_positioning(bt_device_class_t *dc, bool set); 72 73 bool device_class_get_networking(const bt_device_class_t *dc); 74 void device_class_set_networking(bt_device_class_t *dc, bool set); 75 76 bool device_class_get_rendering(const bt_device_class_t *dc); 77 void device_class_set_rendering(bt_device_class_t *dc, bool set); 78 79 bool device_class_get_capturing(const bt_device_class_t *dc); 80 void device_class_set_capturing(bt_device_class_t *dc, bool set); 81 82 bool device_class_get_object_transfer(const bt_device_class_t *dc); 83 void device_class_set_object_transfer(bt_device_class_t *dc, bool set); 84 85 bool device_class_get_audio(const bt_device_class_t *dc); 86 void device_class_set_audio(bt_device_class_t *dc, bool set); 87 88 bool device_class_get_telephony(const bt_device_class_t *dc); 89 void device_class_set_telephony(bt_device_class_t *dc, bool set); 90 91 bool device_class_get_information(const bt_device_class_t *dc); 92 void device_class_set_information(bt_device_class_t *dc, bool set); 93