Skip to content

Commit

Permalink
Merge branch 'testing'
Browse files Browse the repository at this point in the history
  • Loading branch information
hfedcba committed Jul 27, 2018
2 parents 3ec5f37 + a91052c commit c11a31a
Showing 1 changed file with 0 additions and 54 deletions.
54 changes: 0 additions & 54 deletions src/SonosCentral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,9 @@ void SonosCentral::deletePeer(uint64_t id)
if(_peersById.find(id) != _peersById.end()) _peersById.erase(id);
}

if(_currentPeer && _currentPeer->getID() == id) _currentPeer.reset();

int32_t i = 0;
while(peer.use_count() > 1 && i < 600)
{
if(_currentPeer && _currentPeer->getID() == id) _currentPeer.reset();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
i++;
}
Expand Down Expand Up @@ -479,15 +476,6 @@ std::string SonosCentral::handleCliCommand(std::string command)
try
{
std::ostringstream stringStream;
if(_currentPeer)
{
if(command == "unselect" || command == "u")
{
_currentPeer.reset();
return "Peer unselected.\n";
}
return _currentPeer->handleCliCommand(command);
}
if(command == "help" || command == "h")
{
stringStream << "List of commands:" << std::endl << std::endl;
Expand Down Expand Up @@ -535,7 +523,6 @@ std::string SonosCentral::handleCliCommand(std::string command)
if(!peerExists(peerID)) stringStream << "This peer is not paired to this central." << std::endl;
else
{
if(_currentPeer && _currentPeer->getID() == peerID) _currentPeer.reset();
stringStream << "Removing peer " << std::to_string(peerID) << std::endl;
deletePeer(peerID);
}
Expand Down Expand Up @@ -753,47 +740,6 @@ std::string SonosCentral::handleCliCommand(std::string command)
}
return stringStream.str();
}
else if(command.compare(0, 12, "peers select") == 0 || command.compare(0, 2, "ps") == 0)
{
uint64_t id = 0;

std::stringstream stream(command);
std::string element;
int32_t offset = (command.at(1) == 's') ? 0 : 1;
int32_t index = 0;
while(std::getline(stream, element, ' '))
{
if(index < 1 + offset)
{
index++;
continue;
}
else if(index == 1 + offset)
{
if(element == "help") break;
id = BaseLib::Math::getNumber(element, false);
if(id == 0) return "Invalid id.\n";
}
index++;
}
if(index == 1 + offset)
{
stringStream << "Description: This command selects a peer." << std::endl;
stringStream << "Usage: peers select PEERID" << std::endl << std::endl;
stringStream << "Parameters:" << std::endl;
stringStream << " PEERID:\tThe id of the peer to select. Example: 513" << std::endl;
return stringStream.str();
}

_currentPeer = getPeer(id);
if(!_currentPeer) stringStream << "This peer is not paired to this central." << std::endl;
else
{
stringStream << "Peer with id " << std::hex << std::to_string(id) << " and device type 0x" << _bl->hf.getHexString(_currentPeer->getDeviceType()) << " selected." << std::dec << std::endl;
stringStream << "For information about the peer's commands type: \"help\"" << std::endl;
}
return stringStream.str();
}
else if(command.compare(0, 6, "search") == 0 || command.compare(0, 2, "sp") == 0)
{
std::stringstream stream(command);
Expand Down

0 comments on commit c11a31a

Please sign in to comment.