Skip to content

Commit

Permalink
Cache Files Fixd
Browse files Browse the repository at this point in the history
  • Loading branch information
William C Bonner committed Oct 2, 2023
1 parent 7bfb13a commit 5582d65
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 31 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if (POLICY CMP0141)
endif()

project (GoveeBTTempLogger
VERSION 2.20230929.1
VERSION 2.20231001.1
DESCRIPTION "Listen and log Govee Thermometer Bluetooth Low Energy Advertisments"
HOMEPAGE_URL https://github.com/wcbonner/GoveeBTTempLogger
)
Expand Down
51 changes: 22 additions & 29 deletions goveebttemplogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,41 +433,33 @@ std::string Govee_Temp::WriteCache(void) const
ssValue << "\t" << HumidityMin;
ssValue << "\t" << HumidityMax;
ssValue << "\t" << Battery;
ssValue << "\t" << Averages;
//TODO: Write Model
// ssValue << "\t" << Model;
return(ssValue.str());
}
bool Govee_Temp::ReadCache(const std::string& data)
{
bool rval = false;
char buffer[512];
data.copy(buffer, data.size());
buffer[data.size()] = '\0';
std::string theDate(strtok(buffer, "\t"));
Time = std::atoi(theDate.c_str());
for (auto a : Temperature)
{
std::string theTemp(strtok(NULL, "\t"));
a = std::atof(theTemp.c_str());
}
for (auto a : TemperatureMin)
{
std::string theTemp(strtok(NULL, "\t"));
a = std::atof(theTemp.c_str());
}
for (auto a : TemperatureMax)
{
std::string theTemp(strtok(NULL, "\t"));
a = std::atof(theTemp.c_str());
}
std::string theHumidity(strtok(NULL, "\t"));
Humidity = std::atof(theHumidity.c_str());
std::string theHumidityMin(strtok(NULL, "\t"));
HumidityMin = std::atof(theHumidityMin.c_str());
std::string theHumidityMax(strtok(NULL, "\t"));
HumidityMax = std::atof(theHumidityMax.c_str());
std::string theBattery(strtok(NULL, "\t"));
Battery = std::atoi(theBattery.c_str());
std::istringstream ssValue(data);
ssValue >> Time;
for (auto a = 0; a < sizeof(Temperature) / sizeof(double); a++)
ssValue >> Temperature[a];
for (auto a = 0; a < sizeof(TemperatureMin) / sizeof(double); a++)
ssValue >> TemperatureMin[a];
for (auto a = 0; a < sizeof(TemperatureMax) / sizeof(double); a++)
ssValue >> TemperatureMax[a];
//for (auto a : Temperature)
// ssValue >> a;
//for (auto a : TemperatureMin)
// ssValue >> a;
//for (auto a : TemperatureMax)
// ssValue >> a;
ssValue >> Humidity;
ssValue >> HumidityMin;
ssValue >> HumidityMax;
ssValue >> Battery;
ssValue >> Averages;
// TODO: Read Model
return(rval);
}
Expand Down Expand Up @@ -1342,7 +1334,7 @@ void WriteSVG(std::vector<Govee_Temp>& TheValues, const std::filesystem::path& S
struct stat64 SVGStat;
SVGStat.st_mtim.tv_sec = 0;
if (-1 == stat64(SVGFileName.c_str(), &SVGStat))
if (ConsoleVerbosity > 0)
if (ConsoleVerbosity > 3)
perror(SVGFileName.c_str());
//std::cout << "[" << getTimeISO8601() << "] stat returned error on : " << SVGFileName << std::endl;
if (TheValues.begin()->Time > SVGStat.st_mtim.tv_sec) // only write the file if we have new data
Expand Down Expand Up @@ -3136,6 +3128,7 @@ int main(int argc, char **argv)
ReadTitleMap(SVGTitleMapFilename);
ReadCacheDirectory(); // if cache directory is configured, read it before reading all the normal logs
ReadLoggedData(); // only read the logged data if creating SVG files
GenerateCacheFile(GoveeMRTGLogs); // update cache files if any new data was in logs
WriteAllSVG();
}
///////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion goveebttemplogger.service
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ExecStart=/usr/local/bin/goveebttemplogger \
--verbose 0 \
--log /var/log/goveebttemplogger \
--time 60 \
--svg /var/www/html/goveebttemplogger --battery 8 --minmax 8 \
--svg /var/www/html/goveebttemplogger --battery 8 --minmax 8 --titlemap /var/www/html/goveebttemplogger/gvh-titlemap.txt \
--cache /var/cache/goveebttemplogger \
--download
KillSignal=SIGINT
Expand Down

0 comments on commit 5582d65

Please sign in to comment.