TinyB  0.5.1
TinyB - The Tiny Bluetooth LE library
BluetoothGattService.hpp
1 /*
2  * Author: Petre Eftime <petre.p.eftime@intel.com>
3  * Copyright (c) 2015 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #pragma once
26 #include "BluetoothObject.hpp"
27 #include "BluetoothManager.hpp"
28 #include "BluetoothGattCharacteristic.hpp"
29 #include <vector>
30 
31 /* Forward declaration of types */
32 struct _Object;
33 typedef struct _Object Object;
34 struct _GattService1;
35 typedef struct _GattService1 GattService1;
36 
42 {
43 
44 friend class tinyb::BluetoothManager;
45 friend class tinyb::BluetoothEventManager;
46 friend class tinyb::BluetoothDevice;
48 
49 private:
50  GattService1 *object;
51 
52 protected:
53  BluetoothGattService(GattService1 *object);
54 
55  static std::unique_ptr<BluetoothGattService> make(Object *object,
56  BluetoothType type = BluetoothType::GATT_SERVICE,
57  std::string *name = nullptr,
58  std::string *identifier = nullptr,
59  BluetoothObject *parent = nullptr);
60 
61 public:
62 
63  static std::string java_class() {
64  return std::string(JAVA_PACKAGE "/BluetoothGattService");
65  }
66  static BluetoothType class_type() { return BluetoothType::GATT_SERVICE; }
67 
68  virtual std::string get_java_class() const;
69  virtual std::string get_class_name() const;
70  virtual std::string get_object_path() const;
71  virtual BluetoothType get_bluetooth_type() const;
72 
75  virtual BluetoothGattService *clone() const;
76 
77  std::unique_ptr<BluetoothGattCharacteristic> find(
78  std::string *identifier,
79  std::chrono::milliseconds timeout = std::chrono::milliseconds::zero())
80  {
81 
83  return manager->find<BluetoothGattCharacteristic>(nullptr, identifier, this, timeout);
84  }
85 
86  /* D-Bus property accessors: */
87 
91  std::string get_uuid ();
92 
97 
101  bool get_primary ();
102 
106  std::vector<std::unique_ptr<BluetoothGattCharacteristic>> get_characteristics ();
107 
108 };
Definition: BluetoothObject.hpp:63
std::vector< std::unique_ptr< BluetoothGattCharacteristic > > get_characteristics()
virtual BluetoothType get_bluetooth_type() const
static BluetoothManager * get_bluetooth_manager()
std::unique_ptr< T > find(std::string *name, std::string *identifier, BluetoothObject *parent, std::chrono::milliseconds timeout=std::chrono::milliseconds::zero())
Definition: BluetoothManager.hpp:113
virtual std::string get_class_name() const
BluetoothDevice get_device()
Definition: BluetoothGattService.hpp:41
virtual std::string get_object_path() const
Definition: BluetoothManager.hpp:31
virtual BluetoothGattService * clone() const
virtual std::string get_java_class() const
Definition: BluetoothGattCharacteristic.hpp:44
Definition: BluetoothDevice.hpp:45