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 OHOS { 24 namespace bluetooth { 25 constexpr uint16_t UUID_SERVICE_CLASS_PNP_INFORMATION = 0x1200; 26 constexpr uint16_t ATTR_ID_SPECIFICATION_ID = 0x0200; 27 constexpr uint16_t ATTR_ID_VENDOR_ID = 0x0201; 28 constexpr uint16_t ATTR_ID_PRODUCT_ID = 0x0202; 29 constexpr uint16_t ATTR_ID_VERSION = 0x0203; 30 constexpr uint16_t ATTR_ID_PRIMARY_RECORD = 0x0204; 31 constexpr uint16_t ATTR_ID_VENDOR_ID_SOURCE = 0x0205; 32 constexpr uint16_t CLASS_ID_NUMBER = 0x0001; 33 34 constexpr uint16_t DEFAULT_SPECIFICATION_ID = 0x0103; 35 constexpr uint16_t DEFAULT_VENDOR_ID = 0x23A1; 36 constexpr uint16_t DEFAULT_PRODUCT_ID = 0x3020; 37 constexpr uint16_t DEFAULT_VERSION = 0x1234; 38 constexpr bool DEFAULT_PRIMARY_RECORD = false; 39 constexpr uint16_t DEFAULT_VENDOR_ID_SOURCE = 0x0001; 40 41 class DIService : public IProfile, public utility::Context { 42 public: 43 DIService(); 44 ~DIService(); 45 46 void Enable() override; 47 void Disable() override; 48 utility::Context *GetContext() override; 49 50 int Connect(const RawAddress &device) override; 51 int Disconnect(const RawAddress &device) override; 52 std::list<RawAddress> GetConnectDevices() override; 53 int GetConnectState() override; 54 int GetMaxConnectNum() override; 55 56 /** 57 * @brief DIService start up. Load config file and register DI . 58 * 59 * @since 1.0 60 * @version 1.0 61 */ 62 void StartUp(); 63 64 /** 65 * @brief DIService shut down. Save config file and disable stack. 66 * 67 * @since 1.0 68 * @version 1.0 69 */ 70 void ShutDown(); 71 72 private: 73 bool RegisterDIService(); 74 bool DeregisterDIService() const; 75 void LoadDeviceInfo(); 76 77 DIConfig &config_; 78 bool priRecord_ {DEFAULT_PRIMARY_RECORD}; 79 uint16_t specId_ {DEFAULT_SPECIFICATION_ID}; 80 uint16_t vendorId_ {DEFAULT_VENDOR_ID}; 81 uint16_t procId_ {DEFAULT_PRODUCT_ID}; 82 uint16_t version_ {DEFAULT_VERSION}; 83 uint16_t venIdSrc_ {DEFAULT_VENDOR_ID_SOURCE}; 84 uint32_t handle_ {}; 85 }; 86 } // namespace bluetooth 87 } // namespace OHOS 88 89 #endif // DEVICE_INFO_H