hunting/hal/src/SdCardHal.h
2024-05-11 17:25:45 +08:00

42 lines
1.5 KiB
C++

/*
* Copyright (c) 2023 Fancy Code.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SD_CARD_HAL_H
#define SD_CARD_HAL_H
#include "IHalCpp.h"
#include <thread>
class SdCardHal : public VSdCardHal, public std::enable_shared_from_this<SdCardHal>
{
public:
SdCardHal();
virtual ~SdCardHal() = default;
void SetSdCardMonitor(std::shared_ptr<VSdCardHalMonitor> &monitor) override;
SdCardHalStatus GetSdCardStatus(void) override;
StatusCode GetCapacity(unsigned long long &totalSizeMB, unsigned long long &freeSizeMB, unsigned long long &usedSizeMB) override;
void Init(void);
void UnInit(void);
void DevDetectingThread(void);
private:
void ReportDetecedChangedResult(const SdCardHalStatus &status);
const char *PrintfStatusString(const SdCardHalStatus &status);
private:
SdCardHalStatus mStatus;
bool mThreadRuning;
std::thread mDevDetectingThread;
std::weak_ptr<VSdCardHalMonitor> mMonitor;
int mDeviceFd;
};
#endif