Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
hfedcba committed May 22, 2018
2 parents 01851ae + 18eb7d8 commit 5f69732
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 18 deletions.
6 changes: 5 additions & 1 deletion misc/Config Directory/homematicbidcos.conf
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,13 @@ processBroadcastWithAesEnabled = false
## The client key file
#keyFile =

## Use the ID defined above to verify the common name of the certificate
## Default: false
#useIdForHostnameVerification = true

## Default: responseDelay = 95
## Should be "95" for CUL or COC, "100" for TI CC1101, "90" for Homegear Gateway and "60" for HM-CFG-LAN or HM-LGW
#responseDelay = 90
#responseDelay = 95

#######################################
### HomeMatic Wireless LAN Gateway ###
Expand Down
12 changes: 9 additions & 3 deletions src/BidCoS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ PVariable BidCoS::getPairingInfo()
field->structValue->emplace("type", std::make_shared<BaseLib::Variable>(std::string("string")));
interface->structValue->emplace("host", field);

field = std::make_shared<BaseLib::Variable>(BaseLib::VariableType::tStruct);
field->structValue->emplace("pos", std::make_shared<BaseLib::Variable>(2));
field->structValue->emplace("label", std::make_shared<BaseLib::Variable>(std::string("l10n.common.password")));
field->structValue->emplace("type", std::make_shared<BaseLib::Variable>(std::string("string")));
interface->structValue->emplace("password", field);

field = std::make_shared<BaseLib::Variable>(BaseLib::VariableType::tStruct);
field->structValue->emplace("pos", std::make_shared<BaseLib::Variable>(2));
field->structValue->emplace("label", std::make_shared<BaseLib::Variable>(std::string("l10n.common.default")));
Expand All @@ -221,17 +227,17 @@ PVariable BidCoS::getPairingInfo()

field = std::make_shared<BaseLib::Variable>(BaseLib::VariableType::tStruct);
field->structValue->emplace("type", std::make_shared<BaseLib::Variable>(std::string("string")));
field->structValue->emplace("const", std::make_shared<BaseLib::Variable>(std::string("/etc/homegear/ca/ca.crt")));
field->structValue->emplace("const", std::make_shared<BaseLib::Variable>(std::string("/etc/homegear/ca/cacert.pem")));
interface->structValue->emplace("caFile", field);

field = std::make_shared<BaseLib::Variable>(BaseLib::VariableType::tStruct);
field->structValue->emplace("type", std::make_shared<BaseLib::Variable>(std::string("string")));
field->structValue->emplace("const", std::make_shared<BaseLib::Variable>(std::string("/etc/homegear/ca/gateway-client.crt")));
field->structValue->emplace("const", std::make_shared<BaseLib::Variable>(std::string("/etc/homegear/ca/certs/gateway-client.crt")));
interface->structValue->emplace("certFile", field);

field = std::make_shared<BaseLib::Variable>(BaseLib::VariableType::tStruct);
field->structValue->emplace("type", std::make_shared<BaseLib::Variable>(std::string("string")));
field->structValue->emplace("const", std::make_shared<BaseLib::Variable>(std::string("/etc/homegear/ca/gateway-client.key")));
field->structValue->emplace("const", std::make_shared<BaseLib::Variable>(std::string("/etc/homegear/ca/private/gateway-client.key")));
interface->structValue->emplace("keyFile", field);

field = std::make_shared<BaseLib::Variable>(BaseLib::VariableType::tStruct);
Expand Down
3 changes: 2 additions & 1 deletion src/PhysicalInterfaces/HomegearGateway.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,15 @@ void HomegearGateway::startListening()

if(_settings->host.empty() || _settings->port.empty() || _settings->caFile.empty() || _settings->certFile.empty() || _settings->keyFile.empty())
{
_out.printError("Error: Configuration of Homegear Gateway is incomplete. Please correct it in \"homematic.conf\".");
_out.printError("Error: Configuration of Homegear Gateway is incomplete. Please correct it in \"homematicbidcos.conf\".");
return;
}

_tcpSocket.reset(new BaseLib::TcpSocket(_bl, _settings->host, _settings->port, true, _settings->caFile, true, _settings->certFile, _settings->keyFile));
_tcpSocket->setConnectionRetries(1);
_tcpSocket->setReadTimeout(5000000);
_tcpSocket->setWriteTimeout(5000000);
if(_settings->useIdForHostnameVerification) _tcpSocket->setVerificationHostname(_settings->id);
_stopCallbackThread = false;
if(_settings->listenThreadPriority > -1) _bl->threadManager.start(_listenThread, true, _settings->listenThreadPriority, _settings->listenThreadPolicy, &HomegearGateway::listen, this);
else _bl->threadManager.start(_listenThread, true, &HomegearGateway::listen, this);
Expand Down
18 changes: 8 additions & 10 deletions src/PhysicalInterfaces/TICC1100.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ TICC1100::TICC1100(std::shared_ptr<BaseLib::Systems::PhysicalInterfaceSettings>
_out.init(GD::bl);
_out.setPrefix(GD::out.getPrefix() + "TI CC110X \"" + settings->id + "\": ");

_sending = false;
_sendingPending = false;
_firstPacket = true;

if(settings->listenThreadPriority == -1)
{
settings->listenThreadPriority = 45;
Expand Down Expand Up @@ -315,8 +319,8 @@ void TICC1100::disableUpdateMode()
{
setConfig();
stopListening();
_updateMode = false;
startListening();
_updateMode = false;
}
catch(const std::exception& ex)
{
Expand Down Expand Up @@ -523,8 +527,8 @@ void TICC1100::forceSendPacket(std::shared_ptr<BidCoSPacket> packet)
try
{
if(_fileDescriptor->descriptor == -1 || _gpioDescriptors[1]->descriptor == -1 || _stopped) return;
bool burst = packet->controlByte() & 0x10;
if(!packet) return;
bool burst = packet->controlByte() & 0x10;
std::vector<uint8_t> decodedPacket = packet->byteArray();
std::vector<uint8_t> encodedPacket(decodedPacket.size());
encodedPacket[0] = decodedPacket[0];
Expand Down Expand Up @@ -625,33 +629,28 @@ void TICC1100::readwrite(std::vector<uint8_t>& data)
{
try
{
_sendMutex.lock();
std::lock_guard<std::mutex> sendGuard(_sendMutex);
_transfer.tx_buf = (uint64_t)&data[0];
_transfer.rx_buf = (uint64_t)&data[0];
_transfer.len = (uint32_t)data.size();
if(_bl->debugLevel >= 6) _out.printDebug("Debug: Sending: " + _bl->hf.getHexString(data));
if(!ioctl(_fileDescriptor->descriptor, SPI_IOC_MESSAGE(1), &_transfer))
{
_sendMutex.unlock();
_out.printError("Couldn't write to device " + _settings->device + ": " + std::string(strerror(errno)));
return;
}
if(_bl->debugLevel >= 6) _out.printDebug("Debug: Received: " + _bl->hf.getHexString(data));
_sendMutex.unlock();
}
catch(const std::exception& ex)
{
_sendMutex.unlock();
_out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
}
catch(BaseLib::Exception& ex)
{
_sendMutex.unlock();
_out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
}
catch(...)
{
_sendMutex.unlock();
_out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__);
}
}
Expand Down Expand Up @@ -839,7 +838,7 @@ void TICC1100::enableRX(bool flushRXFIFO)
try
{
if(_fileDescriptor->descriptor == -1) return;
_txMutex.lock();
std::lock_guard<std::timed_mutex> txGuard(_txMutex);
if(flushRXFIFO) sendCommandStrobe(CommandStrobes::Enum::SFRX);
sendCommandStrobe(CommandStrobes::Enum::SRX);
}
Expand All @@ -855,7 +854,6 @@ void TICC1100::enableRX(bool flushRXFIFO)
{
_out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__);
}
_txMutex.unlock();
}

void TICC1100::initChip()
Expand Down
6 changes: 3 additions & 3 deletions src/PhysicalInterfaces/TICC1100.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ class TICC1100 : public IBidCoSInterface
std::vector<uint8_t> _patable;
struct spi_ioc_transfer _transfer;
std::timed_mutex _txMutex;
bool _sending = false;
bool _sendingPending = false;
bool _firstPacket = true;
std::atomic_bool _sending;
std::atomic_bool _sendingPending;
std::atomic_bool _firstPacket;

void setConfig();
void setupDevice();
Expand Down

0 comments on commit 5f69732

Please sign in to comment.