Skip to content

Commit

Permalink
Fix compiling for Win32 caused by XiaomiGateway patch
Browse files Browse the repository at this point in the history
  • Loading branch information
gizmocuz committed Oct 17, 2018
1 parent 8d98990 commit 38339b2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions hardware/XiaomiGateway.cpp
Expand Up @@ -12,7 +12,10 @@
#include <openssl/aes.h>
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <ifaddrs.h>

#ifndef WIN32
#include <ifaddrs.h>
#endif

/*
Xiaomi (Aqara) makes a smart home gateway/hub that has support
Expand Down Expand Up @@ -110,6 +113,9 @@ void XiaomiGateway::RemoveFromGatewayList()
// Code from Stack Overflow - https://stackoverflow.com/questions/2146191
int XiaomiGateway::get_local_ipaddr(std::vector<std::string>& ip_addrs)
{
#ifdef WIN32
return 0;
#else
struct ifaddrs *myaddrs, *ifa;
void *in_addr;
char buf[64];
Expand All @@ -119,7 +125,7 @@ int XiaomiGateway::get_local_ipaddr(std::vector<std::string>& ip_addrs)
{
_log.Log(LOG_ERROR, "getifaddrs failed! (when trying to determine local ip address)");
perror("getifaddrs");
exit(1);
return 0;
}

for (ifa = myaddrs; ifa != NULL; ifa = ifa->ifa_next)
Expand Down Expand Up @@ -162,9 +168,9 @@ int XiaomiGateway::get_local_ipaddr(std::vector<std::string>& ip_addrs)

freeifaddrs(myaddrs);
return count;
#endif
}


XiaomiGateway::XiaomiGateway(const int ID)
{
m_HwdID = ID;
Expand Down

0 comments on commit 38339b2

Please sign in to comment.