Skip to content

Commit

Permalink
fix: PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
rickbassham committed Mar 15, 2024
1 parent 4aefbb9 commit e76a6d2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 40 deletions.
24 changes: 4 additions & 20 deletions drivers/auxiliary/dragonlight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const char *DragonLIGHT::getDefaultName()

bool DragonLIGHT::EnableLightBox(bool enable)
{
LOGF_INFO("EnableLightBox: %d\n", enable);
LOGF_DEBUG("EnableLightBox: %d", enable);

httplib::Client cli(IPAddressTP[0].getText(), 80);

Expand All @@ -121,17 +121,7 @@ bool DragonLIGHT::EnableLightBox(bool enable)
return false;
}

IDLog("EnableLightBox: %d\n", result.value().status);
IDLog("EnableLightBox: %s\n", result.value().body.c_str());

if (result.value().status == 200)
{
return true;
}
else
{
return false;
}
return (result.value().status == 200);
}

bool DragonLIGHT::SetLightBoxBrightness(uint16_t value)
Expand Down Expand Up @@ -314,14 +304,12 @@ void DragonLIGHT::updateStatus()

void DragonLIGHT::discoverDevices()
{
IDLog("Sending discovery packet\n");

int s;

s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (s == -1)
{
IDLog("Error creating socket\n");
LOG_ERROR("Error creating socket for discovery.");
return;
}

Expand Down Expand Up @@ -354,8 +342,6 @@ void DragonLIGHT::discoverDevices()
if (n < 0)
break;

IDLog("Received: %s\n", recvbuff);

nlohmann::json doc = nlohmann::json::parse(recvbuff, nullptr, false, true);

if (!doc.is_discarded() && doc.contains("deviceType"))
Expand All @@ -366,12 +352,10 @@ void DragonLIGHT::discoverDevices()
std::string deviceType = doc["deviceType"];
std::string serialNumber = doc["SerialNumber"].is_string() ? doc["SerialNumber"].get<std::string>() : "";

LOGF_INFO("Found %s %s at %s\n", deviceType.c_str(), serialNumber.c_str(), deviceIP);
LOGF_INFO("Found %s %s at %s", deviceType.c_str(), serialNumber.c_str(), deviceIP);
}
}

IDLog("discovery complete\n");

close(s);

DiscoverSwitchSP.reset();
Expand Down
26 changes: 6 additions & 20 deletions drivers/dome/dragonlair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ bool DragonLAIR::initProperties()

addAuxControls();

LOGF_INFO("Can Park: %d\n", CanPark());

return true;
}

Expand All @@ -100,8 +98,6 @@ bool DragonLAIR::ISSnoopDevice(XMLEle *root)

bool DragonLAIR::Connect()
{
IDLog("Connecting...\n");

if (strlen(IPAddressTP[0].getText()) == 0)
{
LOG_ERROR("IP Address is not set.");
Expand Down Expand Up @@ -288,8 +284,6 @@ void DragonLAIR::updateStatus()

try
{
IDLog("Updating status...\n");

httplib::Result result = cli.Get("/indi/status");
if (!result)
{
Expand Down Expand Up @@ -343,8 +337,6 @@ void DragonLAIR::updateStatus()
bool isRoofClosing = j["roof"]["isRoofClosing"];
bool isRoofOpening = j["roof"]["isRoofOpening"];

IDLog("Dome state: %d\n", Dome::getDomeState());

if (isRoofFullyClosed)
{
if (Dome::getDomeState() != DOME_PARKED)
Expand Down Expand Up @@ -385,7 +377,7 @@ void DragonLAIR::updateStatus()
}
catch(const std::exception &e)
{
LOGF_ERROR("Error on updateStatus: %s\n", e.what());
LOGF_ERROR("Error on updateStatus: %s", e.what());
}
}

Expand Down Expand Up @@ -419,7 +411,7 @@ void DragonLAIR::openRoof()
}
catch(const std::exception &e)
{
LOGF_ERROR("Error on openRoof: %s\n", e.what());
LOGF_ERROR("Error on openRoof: %s", e.what());
}
}

Expand Down Expand Up @@ -453,7 +445,7 @@ void DragonLAIR::closeRoof()
}
catch(const std::exception &e)
{
LOGF_ERROR("Error on closeRoof: %s\n", e.what());
LOGF_ERROR("Error on closeRoof: %s", e.what());
}
}

Expand Down Expand Up @@ -487,7 +479,7 @@ void DragonLAIR::stopRoof()
}
catch(const std::exception &e)
{
LOGF_ERROR("Error on stopRoof: %s\n", e.what());
LOGF_ERROR("Error on stopRoof: %s", e.what());
}
}

Expand All @@ -497,14 +489,12 @@ void DragonLAIR::stopRoof()

void DragonLAIR::discoverDevices()
{
IDLog("Sending discovery packet\n");

int s;

s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (s == -1)
{
IDLog("Error creating socket\n");
LOG_ERROR("Error creating socket for discovery.");
return;
}

Expand Down Expand Up @@ -537,8 +527,6 @@ void DragonLAIR::discoverDevices()
if (n < 0)
break;

IDLog("Received: %s\n", recvbuff);

nlohmann::json doc = nlohmann::json::parse(recvbuff, nullptr, false, true);

if (!doc.is_discarded() && doc.contains("deviceType"))
Expand All @@ -549,12 +537,10 @@ void DragonLAIR::discoverDevices()
std::string deviceType = doc["deviceType"];
std::string serialNumber = doc["serialNumber"];

LOGF_INFO("Found %s %s at %s\n", deviceType.c_str(), serialNumber.c_str(), deviceIP);
LOGF_INFO("Found %s %s at %s", deviceType.c_str(), serialNumber.c_str(), deviceIP);
}
}

IDLog("discovery complete\n");

close(s);

DiscoverSwitchSP.reset();
Expand Down

0 comments on commit e76a6d2

Please sign in to comment.