• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef DEVICE_INFO_H
17 #define DEVICE_INFO_H
18 
19 #include "context.h"
20 #include "di_config.h"
21 #include "interface_profile.h"
22 
23 namespace bluetooth {
24 constexpr uint16_t UUID_SERVICE_CLASS_PNP_INFORMATION = 0x1200;
25 constexpr uint16_t ATTR_ID_SPECIFICATION_ID = 0x0200;
26 constexpr uint16_t ATTR_ID_VENDOR_ID = 0x0201;
27 constexpr uint16_t ATTR_ID_PRODUCT_ID = 0x0202;
28 constexpr uint16_t ATTR_ID_VERSION = 0x0203;
29 constexpr uint16_t ATTR_ID_PRIMARY_RECORD = 0x0204;
30 constexpr uint16_t ATTR_ID_VENDOR_ID_SOURCE = 0x0205;
31 constexpr uint16_t CLASS_ID_NUMBER = 0x0001;
32 
33 constexpr uint16_t DEFAULT_SPECIFICATION_ID = 0x0103;
34 constexpr uint16_t DEFAULT_VENDOR_ID = 0x23A1;
35 constexpr uint16_t DEFAULT_PRODUCT_ID = 0x3020;
36 constexpr uint16_t DEFAULT_VERSION = 0x1234;
37 constexpr bool DEFAULT_PRIMARY_RECORD = false;
38 constexpr uint16_t DEFAULT_VENDOR_ID_SOURCE = 0x0001;
39 
40 class DIService : public IProfile, public utility::Context {
41 public:
42     DIService();
43     ~DIService();
44 
45     void Enable() override;
46     void Disable() override;
47     utility::Context *GetContext() override;
48 
49     int Connect(const RawAddress &device) override;
50     int Disconnect(const RawAddress &device) override;
51     std::list<RawAddress> GetConnectDevices() override;
52     int GetConnectState() override;
53     int GetMaxConnectNum() override;
54 
55     /**
56      * @brief DIService start up. Load config file and register DI .
57      *
58      * @since 1.0
59      * @version 1.0
60      */
61     void StartUp();
62 
63     /**
64      * @brief DIService shut down. Save config file and disable stack.
65      *
66      * @since 1.0
67      * @version 1.0
68      */
69     void ShutDown();
70 
71 private:
72     bool RegisterDIService();
73     bool DeregisterDIService() const;
74     void LoadDeviceInfo();
75 
76     DIConfig &config_;
77     bool priRecord_ {DEFAULT_PRIMARY_RECORD};
78     uint16_t specId_ {DEFAULT_SPECIFICATION_ID};
79     uint16_t vendorId_ {DEFAULT_VENDOR_ID};
80     uint16_t procId_ {DEFAULT_PRODUCT_ID};
81     uint16_t version_ {DEFAULT_VERSION};
82     uint16_t venIdSrc_ {DEFAULT_VENDOR_ID_SOURCE};
83     uint32_t handle_ {};
84 };
85 }  // namespace bluetooth
86 
87 #endif  // DEVICE_INFO_H