• 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 REPORT_DATA_CALLBACK_H
17 #define REPORT_DATA_CALLBACK_H
18 
19 #include "refbase.h"
20 #include "sensor_data_event.h"
21 
22 namespace OHOS {
23 namespace Sensors {
24 constexpr int32_t CIRCULAR_BUF_LEN = 1024;
25 constexpr int32_t SENSOR_DATA_LENGTH = 64;
26 
27 struct CircularEventBuf {
28     struct  SensorData *circularBuf;
29     int32_t readPos;
30     int32_t writePosition;
31     int32_t eventNum;
32 };
33 
34 class ReportDataCallback : public RefBase {
35 public:
36     ReportDataCallback();
37     ~ReportDataCallback();
38     int32_t ReportEventCallback(SensorData *sensorData, sptr<ReportDataCallback> cb);
39     CircularEventBuf &GetEventData();
40     CircularEventBuf eventsBuf_;
41 };
42 
43 using ReportDataCb = int32_t (ReportDataCallback::*)(SensorData *sensorData, sptr<ReportDataCallback> cb);
44 }  // namespace Sensors
45 }  // namespace OHOS
46 #endif  // REPORT_DATA_CALLBACK_H
47