• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-2022 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_SERVICE_H
17 #define DEVICE_INFO_SERVICE_H
18 
19 #include <cstdint>
20 #include <memory>
21 #include <string>
22 #include "gatt_server_service.h"
23 #include "di_service_over_bredr.h"
24 #include "gatt_data.h"
25 
26 /*
27  * @brief The bluetooth system.
28  */
29 namespace OHOS {
30 namespace bluetooth {
31 class DeviceInformationService {
32 public:
33     /**
34      * @brief Device Information Service.
35      *
36      */
37     explicit DeviceInformationService(GattServerService &service);
38 
39     /**
40      * @brief Destructor.
41      */
42     ~DeviceInformationService();
43 
44     int RegisterService();
45     void DeregisterService() const;
46 
47     int RegisterSDP();
48     void DeregisterSDP() const;
49 
50     BT_DISALLOW_COPY_AND_ASSIGN(DeviceInformationService);
51 
52 private:
53     static const uint16_t GATT_UUID_MANUFACTURER_NAME_STRING_CHAR;
54     static const uint16_t GATT_UUID_MODEL_NUMBER_STRING_CHAR;
55     static const uint16_t GATT_UUID_PNP_ID_CHAR;
56     static const uint16_t GATT_UUID_IEEE_REGULATORY_CERTIFICATION_DATA_LIST_CHAR;
57     static const uint16_t GATT_UUID_SERIAL_NUMBER_STRING_CHAR;
58     static const uint16_t GATT_UUID_SOFTWARE_REVISION_STRING_CHAR;
59     static const uint16_t GATT_UUID_SYSTEM_ID_CHAR;
60     static const uint16_t GATT_UUID_HARDWARE_REVISION_STRING_CHAR;
61     static const uint16_t GATT_UUID_FIRMWARE_REVISION_STRING_CHAR;
62     static const std::string DEFAULT_MANUFACTURER_NAME;
63     static const std::string DEFAULT_MODEL_NUMBER;
64     static const std::string DEFAULT_SERIAL_NUMBER;
65     static const std::string DEFAULT_HARDWARE_REVISION;
66     static const std::string DEFAULT_FIRMWARE_REVISION;
67     static const std::string DEFAULT_SOFTWARE_REVISION;
68     static const std::string DEFAULT_SYSTEM_ID;
69     static const std::string DEFAULT_IEEE_REGULATORY_CERTIFICATION_DATA_LIST;
70     static const std::string DEFAULT_PNP_ID;
71 
72     class GattServerCallbackImpl;
73 
74     std::unique_ptr<Service> instance_ = {nullptr};
75     std::unique_ptr<DiServiceOverBredrInterface> sdpRegister_ = {nullptr};
76     GattServerService &serverService_;
77     int appId_ = -1;
78     std::shared_ptr<GattServerCallbackImpl> serviceCallback_;
79 
80     std::unique_ptr<Service> BuildService();
81     static std::string GetSystemId();
82     static std::string GetPnpId();
83     static std::string GetIEEEInfo();
84     static std::string GetManufactureName();
85     static std::string GetModelNumber();
86     static std::string GetSerialNumber();
87     static std::string GetHardwareRevision();
88     static std::string GetFirmwareRevision();
89     static std::string GetSoftwareRevision();
90 };
91 }  // namespace bluetooth
92 }  // namespace OHOS
93 
94 #endif  // DEVICE_INFO_SERVICE_H