• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Chipsea Technologies (Shenzhen) Corp., 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 SENSOR_HDI_CONNECTION_H
17 #define SENSOR_HDI_CONNECTION_H
18 
19 #include "i_sensor_hdi_connection.h"
20 #include "singleton.h"
21 
22 namespace OHOS {
23 namespace Sensors {
24 class SensorHdiConnection : public ISensorHdiConnection, public Singleton<SensorHdiConnection> {
25 public:
26     SensorHdiConnection() = default;
27 
~SensorHdiConnection()28     virtual ~SensorHdiConnection() {}
29 
30     int32_t ConnectHdi() override;
31 
32     int32_t GetSensorList(std::vector<MedicalSensor>& sensorList) override;
33 
34     int32_t EnableSensor(int32_t sensorId) override;
35 
36     int32_t DisableSensor(int32_t sensorId)  override;
37 
38     int32_t SetBatch(int32_t sensorId, int64_t samplingInterval, int64_t reportInterval) override;
39 
40     int32_t SetMode(int32_t sensorId, int32_t mode) override;
41 
42     int32_t SetOption(int32_t sensorId, int32_t option) override;
43 
44     int32_t RunCommand(int32_t sensorId, int32_t cmd, int32_t params) override;
45 
46     int32_t RegisteDataReport(DataCacheFunc cacheData, sptr<ReportDataCache> reportDataCache) override;
47 
48     int32_t DestroyHdiConnection() override;
49 
50 private:
51     DISALLOW_COPY_AND_MOVE(SensorHdiConnection);
52     std::unique_ptr<ISensorHdiConnection> iSensorHdiConnection_;
53     std::vector<MedicalSensor> sensorList_;
54     int32_t connectHdiService();
55 };
56 }  // namespace Sensors
57 }  // namespace OHOS
58 #endif  // SENSOR_HDI_CONNECTION_H