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 <vector> 20 21 #include "refbase.h" 22 23 #include "sensor_agent_type.h" 24 25 namespace OHOS { 26 namespace Sensors { 27 constexpr int32_t CIRCULAR_BUF_LEN = 1024; 28 constexpr int32_t SENSOR_DATA_LENGHT = 64; 29 30 struct CircularEventBuf { 31 struct SensorEvent *circularBuf; 32 int32_t readPosition; 33 int32_t writePosition; 34 int32_t eventNum; 35 }; 36 37 class ReportDataCallback : public RefBase { 38 public: 39 ReportDataCallback(); 40 ~ReportDataCallback(); 41 int32_t ZReportDataCallback(const struct SensorEvent *event, sptr<ReportDataCallback> cb); 42 struct CircularEventBuf &GetEventData(); 43 struct CircularEventBuf eventsBuf_; 44 }; 45 46 using ZReportDataCb = int32_t (ReportDataCallback::*)(const struct SensorEvent *event, sptr<ReportDataCallback> cb); 47 } // namespace Sensors 48 } // namespace OHOS 49 #endif // REPORT_DATA_CALLBACK_H 50