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 MY_FILE_DESCRIPTOR_LISTENER_H 17 #define MY_FILE_DESCRIPTOR_LISTENER_H 18 19 #include <atomic> 20 #include <fcntl.h> 21 #include <sys/socket.h> 22 23 #include "event_handler.h" 24 #include "event_runner.h" 25 #include "file_descriptor_listener.h" 26 #include "medical_native_type.h" 27 #include "medical_sensor_data_channel.h" 28 29 namespace OHOS { 30 namespace Sensors { 31 class MyFileDescriptorListener : public AppExecFwk::FileDescriptorListener { 32 public: 33 explicit MyFileDescriptorListener(); 34 35 ~MyFileDescriptorListener() = default; 36 37 void OnReadable(int32_t fileDescriptor) override; 38 39 void OnWritable(int32_t fileDescriptor) override; 40 41 void OnShutdown(int32_t fileDescriptor) override; 42 43 void OnException(int32_t fileDescriptor) override; 44 45 void SetChannel(MedicalSensorDataChannel* channel); 46 47 private: 48 MedicalSensorDataChannel* channel_; 49 struct TransferMedicalSensorEvents *receiveDataBuff_ = nullptr; 50 }; 51 } // namespace Sensors 52 } // namespace OHOS 53 #endif // MY_FILE_DESCRIPTOR_LISTENER_H 54