Skip to content

Commit f392316

Browse files
committed
Some fixed connecting to HEOS
1 parent b0aa194 commit f392316

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

hardware/HEOS.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,16 @@ void CHEOS::handleConnect()
226226
m_iMissedPongs = 0;
227227
std::string sPort = std::to_string(m_Port);
228228
boost::system::error_code ec;
229-
boost::asio::ip::tcp::resolver resolver(*m_Ios);
229+
boost::asio::io_service io_service;
230+
boost::asio::ip::tcp::resolver resolver(io_service);
230231
boost::asio::ip::tcp::resolver::query query(m_IP, sPort);
231232
boost::asio::ip::tcp::resolver::iterator iter = resolver.resolve(query);
232233
boost::asio::ip::tcp::endpoint endpoint = *iter;
233-
m_Socket = new boost::asio::ip::tcp::socket(*m_Ios);
234+
m_Socket = new boost::asio::ip::tcp::socket(io_service);
234235
m_Socket->connect(endpoint, ec);
235236
if (!ec)
236237
{
237-
_log.Log(LOG_NORM, "HEOS by DENON: Connected to '%s:%s'.", m_IP.c_str(), sPort);
238+
_log.Log(LOG_NORM, "HEOS by DENON: Connected to '%s:%s'.", m_IP.c_str(), sPort.c_str());
238239
m_Socket->async_read_some(boost::asio::buffer(m_Buffer, sizeof m_Buffer), boost::bind(&CHEOS::handleRead, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
239240
// Disable registration for change events following HEOS Controller advise
240241
handleWrite(std::string("heos://system/register_for_change_events?enable=off"));
@@ -256,7 +257,12 @@ void CHEOS::handleConnect()
256257
delete m_Socket;
257258
m_Socket = NULL;
258259
}
260+
}
261+
else
262+
{
263+
_log.Log(LOG_NORM, "HEOS by DENON: Handle Connect, not connected");
259264
}
265+
260266
}
261267
catch (std::exception& e)
262268
{
@@ -657,6 +663,7 @@ bool CHEOS::StartHardware()
657663

658664
//Start worker thread
659665
m_stoprequested = false;
666+
m_Socket = NULL;
660667
m_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&CHEOS::Do_Work, this)));
661668

662669
return (m_thread != NULL);

0 commit comments

Comments
 (0)