Change logging for node numbers. Add new Log::Write method that takes a

node number as an argument. All formatting is now done in the log object
instead of being scattered around. Also added a new helper routine that
takes a Msg object and returns the target node id. In the case of no
message it returns 0 and no node number will be output in the log. See
Driver::GetNodeNumber.
Not all the classes use the new Log::Write yet.
Retreive SUC node id. Just uncomment existing code.
Add error checking to pthreads mutex calls.
Don't do the Query_Wakeup phase for FLiRS nodes as they don't seem to
respond to wakeup class messages and they will respond to others.
Add missing LockNodes/ReleaseNodes around node array scan when removing
controller that returns 0 for node number.
This commit is contained in:
glsatz 2012-02-28 23:55:50 +00:00
parent bd9f9c6ac3
commit 1a2b57f9c7
26 changed files with 483 additions and 372 deletions

View file

@ -57,7 +57,7 @@
Accumulate energy when Battery Powered. Accumulate energy when Battery Powered.
</Help> </Help>
</Value> </Value>
<Value type="byte" index="20" genre="config" label="USB powered" units="" min="0" max="1" read_only="true"> <Value type="byte" index="20" genre="config" label="USB powered" units="" min="0" max="1" read_only="true" value="0">
<Help> <Help>
This byte denotes whether the product is using batteries (value = 0) or using USB power (value = 1). This byte denotes whether the product is using batteries (value = 0) or using USB power (value = 1).
</Help> </Help>
@ -173,6 +173,10 @@
</Value> </Value>
</CommandClass> </CommandClass>
<!-- COMMAND_CLASS_WAKE_UP. This class is in the list reported by the HEM, but it does not
respond to requests. It still needs to be supported so that wake up notifications are handled. -->
<CommandClass id="132" create_vars="false" />
<!-- Association Groups --> <!-- Association Groups -->
<CommandClass id="133"> <CommandClass id="133">
<Associations num_groups="1"> <Associations num_groups="1">

View file

@ -556,7 +556,6 @@ int HID_API_EXPORT hid_get_feature_report(hid_device *dev, unsigned char *data,
if (res < 0) if (res < 0)
perror("ioctl (GFEATURE)"); perror("ioctl (GFEATURE)");
return res; return res;
} }

File diff suppressed because it is too large Load diff

View file

@ -446,38 +446,15 @@ namespace OpenZWave
// Retrieving Node information // Retrieving Node information
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
public: public:
string GetNodeString( uint8 const _nodeId )const uint8 GetNodeNumber( Msg const* _msg )const
{
if( _nodeId == 0xff )
{
return "contrlr";
}
else
{
char buf[10];
snprintf( buf, sizeof(buf), "Node%03d", _nodeId );
return buf;
}
}
string GetNodeString( Msg const* _msg )const
{ {
if( _msg == NULL ) if( _msg == NULL )
{ {
return "unknown"; return 0;
} }
else else
{ {
uint8 const nodeId = _msg->GetTargetNodeId(); return _msg->GetTargetNodeId();
if( nodeId == 0xff )
{
return "contrlr";
}
else
{
char buf[10];
snprintf( buf, sizeof(buf), "Node%03d", nodeId );
return buf;
}
} }
} }
private: private:
@ -593,7 +570,7 @@ namespace OpenZWave
uint8 m_controllerCommandNode; uint8 m_controllerCommandNode;
uint8 m_controllerCommandArg; uint8 m_controllerCommandArg;
uint8 m_SUCNode;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Virtual Node commands // Virtual Node commands

View file

@ -209,7 +209,7 @@ void Node::AdvanceQueries
// determines, among other things, whether this node is a listener, its maximum baud rate and its device classes // determines, among other things, whether this node is a listener, its maximum baud rate and its device classes
if( !ProtocolInfoReceived() ) if( !ProtocolInfoReceived() )
{ {
Log::Write( LogLevel_Detail, "Node%03d, QueryStage_ProtocolInfo", m_nodeId ); Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_ProtocolInfo" );
Msg* msg = new Msg( "Get Node Protocol Info", m_nodeId, REQUEST, FUNC_ID_ZW_GET_NODE_PROTOCOL_INFO, false ); Msg* msg = new Msg( "Get Node Protocol Info", m_nodeId, REQUEST, FUNC_ID_ZW_GET_NODE_PROTOCOL_INFO, false );
msg->Append( m_nodeId ); msg->Append( m_nodeId );
GetDriver()->SendMsg( msg, Driver::MsgQueue_Query ); GetDriver()->SendMsg( msg, Driver::MsgQueue_Query );
@ -227,12 +227,14 @@ void Node::AdvanceQueries
{ {
// For sleeping devices other than controllers, we need to defer the usual requests until // For sleeping devices other than controllers, we need to defer the usual requests until
// we have told the device to send it's wake-up notifications to the PC controller. // we have told the device to send it's wake-up notifications to the PC controller.
Log::Write( LogLevel_Detail, "Node%03d, QueryStage_WakeUp", m_nodeId ); Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_WakeUp" );
WakeUp* wakeUp = static_cast<WakeUp*>( GetCommandClass( WakeUp::StaticGetCommandClassId() ) ); WakeUp* wakeUp = static_cast<WakeUp*>( GetCommandClass( WakeUp::StaticGetCommandClassId() ) );
// if this device is a "sleeping device" and not a controller // if this device is a "sleeping device" and not a controller and not a
if( wakeUp && !IsController() ) // FLiRS device. FLiRS will wake up when you send them something and they
// don't seem to support Wakeup
if( wakeUp && !IsController() && !IsFrequentListeningDevice() )
{ {
// start the process of requesting node state from this sleeping device // start the process of requesting node state from this sleeping device
wakeUp->Init(); wakeUp->Init();
@ -251,7 +253,7 @@ void Node::AdvanceQueries
// Obtain manufacturer, product type and product ID code from the node device // Obtain manufacturer, product type and product ID code from the node device
// Manufacturer Specific data is requested before the other command class data so // Manufacturer Specific data is requested before the other command class data so
// that we can modify the supported command classes list through the product XML files. // that we can modify the supported command classes list through the product XML files.
Log::Write( LogLevel_Detail, "Node%03d, QueryStage_ManufacturerSpecific1", m_nodeId ); Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_ManufacturerSpecific1" );
ManufacturerSpecific* cc = static_cast<ManufacturerSpecific*>( GetCommandClass( ManufacturerSpecific::StaticGetCommandClassId() ) ); ManufacturerSpecific* cc = static_cast<ManufacturerSpecific*>( GetCommandClass( ManufacturerSpecific::StaticGetCommandClassId() ) );
if( cc ) if( cc )
{ {
@ -269,7 +271,7 @@ void Node::AdvanceQueries
if( !NodeInfoReceived() && !IsController() && m_nodeInfoSupported ) if( !NodeInfoReceived() && !IsController() && m_nodeInfoSupported )
{ {
// obtain from the node a list of command classes that it 1) supports and 2) controls (separated by a mark in the buffer) // obtain from the node a list of command classes that it 1) supports and 2) controls (separated by a mark in the buffer)
Log::Write( LogLevel_Detail, "Node%03d, QueryStage_NodeInfo", m_nodeId ); Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_NodeInfo" );
Msg* msg = new Msg( "Request Node Info", m_nodeId, REQUEST, FUNC_ID_ZW_REQUEST_NODE_INFO, false, true, FUNC_ID_ZW_APPLICATION_UPDATE ); Msg* msg = new Msg( "Request Node Info", m_nodeId, REQUEST, FUNC_ID_ZW_REQUEST_NODE_INFO, false, true, FUNC_ID_ZW_APPLICATION_UPDATE );
msg->Append( m_nodeId ); msg->Append( m_nodeId );
GetDriver()->SendMsg( msg, Driver::MsgQueue_Query ); GetDriver()->SendMsg( msg, Driver::MsgQueue_Query );
@ -290,7 +292,7 @@ void Node::AdvanceQueries
// Obtain manufacturer, product type and product ID code from the node device // Obtain manufacturer, product type and product ID code from the node device
// Manufacturer Specific data is requested before the other command class data so // Manufacturer Specific data is requested before the other command class data so
// that we can modify the supported command classes list through the product XML files. // that we can modify the supported command classes list through the product XML files.
Log::Write( LogLevel_Detail, "Node%03d, QueryStage_ManufacturerSpecific2", m_nodeId ); Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_ManufacturerSpecific2" );
ManufacturerSpecific* cc = static_cast<ManufacturerSpecific*>( GetCommandClass( ManufacturerSpecific::StaticGetCommandClassId() ) ); ManufacturerSpecific* cc = static_cast<ManufacturerSpecific*>( GetCommandClass( ManufacturerSpecific::StaticGetCommandClassId() ) );
if( cc ) if( cc )
{ {
@ -317,7 +319,7 @@ void Node::AdvanceQueries
case QueryStage_Versions: case QueryStage_Versions:
{ {
// Get the version information (if the device supports COMMAND_CLASS_VERSION // Get the version information (if the device supports COMMAND_CLASS_VERSION
Log::Write( LogLevel_Detail, "Node%03d, QueryStage_Versions", m_nodeId ); Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_Versions" );
Version* vcc = static_cast<Version*>( GetCommandClass( Version::StaticGetCommandClassId() ) ); Version* vcc = static_cast<Version*>( GetCommandClass( Version::StaticGetCommandClassId() ) );
if( vcc ) if( vcc )
{ {
@ -343,7 +345,7 @@ void Node::AdvanceQueries
case QueryStage_Instances: case QueryStage_Instances:
{ {
// if the device at this node supports multiple instances, obtain a list of these instances // if the device at this node supports multiple instances, obtain a list of these instances
Log::Write( LogLevel_Detail, "Node%03d, QueryStage_Instances", m_nodeId ); Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_Instances" );
MultiInstance* micc = static_cast<MultiInstance*>( GetCommandClass( MultiInstance::StaticGetCommandClassId() ) ); MultiInstance* micc = static_cast<MultiInstance*>( GetCommandClass( MultiInstance::StaticGetCommandClassId() ) );
if( micc ) if( micc )
{ {
@ -356,7 +358,7 @@ void Node::AdvanceQueries
m_queryStage = QueryStage_Static; m_queryStage = QueryStage_Static;
m_queryRetries = 0; m_queryRetries = 0;
Log::Write( LogLevel_Info, "Node%03d, Essential node queries are complete", m_nodeId ); Log::Write( LogLevel_Info, m_nodeId, "Essential node queries are complete" );
Notification* notification = new Notification( Notification::Type_EssentialNodeQueriesComplete ); Notification* notification = new Notification( Notification::Type_EssentialNodeQueriesComplete );
notification->SetHomeAndNodeIds( m_homeId, m_nodeId ); notification->SetHomeAndNodeIds( m_homeId, m_nodeId );
GetDriver()->QueueNotification( notification ); GetDriver()->QueueNotification( notification );
@ -367,7 +369,7 @@ void Node::AdvanceQueries
{ {
// Request any other static values associated with each command class supported by this node // Request any other static values associated with each command class supported by this node
// examples are supported thermostat operating modes, setpoints and fan modes // examples are supported thermostat operating modes, setpoints and fan modes
Log::Write( LogLevel_Detail, "Node%03d, QueryStage_Static", m_nodeId ); Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_Static" );
for( map<uint8,CommandClass*>::const_iterator it = m_commandClassMap.begin(); it != m_commandClassMap.end(); ++it ) for( map<uint8,CommandClass*>::const_iterator it = m_commandClassMap.begin(); it != m_commandClassMap.end(); ++it )
{ {
if( !it->second->IsAfterMark() ) if( !it->second->IsAfterMark() )
@ -387,7 +389,7 @@ void Node::AdvanceQueries
case QueryStage_Associations: case QueryStage_Associations:
{ {
// if this device supports COMMAND_CLASS_ASSOCIATION, determine to which groups this node belong // if this device supports COMMAND_CLASS_ASSOCIATION, determine to which groups this node belong
Log::Write( LogLevel_Detail, "Node%03d, QueryStage_Associations", m_nodeId ); Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_Associations" );
Association* acc = static_cast<Association*>( GetCommandClass( Association::StaticGetCommandClassId() ) ); Association* acc = static_cast<Association*>( GetCommandClass( Association::StaticGetCommandClassId() ) );
if( acc ) if( acc )
{ {
@ -405,7 +407,7 @@ void Node::AdvanceQueries
case QueryStage_Neighbors: case QueryStage_Neighbors:
{ {
// retrieves this node's neighbors and stores the neighbor bitmap in the node object // retrieves this node's neighbors and stores the neighbor bitmap in the node object
Log::Write( LogLevel_Detail, "Node%03d, QueryStage_Neighbors", m_nodeId ); Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_Neighbors" );
GetDriver()->RequestNodeNeighbors( m_nodeId, CommandClass::RequestFlag_LowPriority ); GetDriver()->RequestNodeNeighbors( m_nodeId, CommandClass::RequestFlag_LowPriority );
m_queryPending = true; m_queryPending = true;
break; break;
@ -414,7 +416,7 @@ void Node::AdvanceQueries
{ {
// Request the session values from the command classes in turn // Request the session values from the command classes in turn
// examples of Session information are: current thermostat setpoints, node names and climate control schedules // examples of Session information are: current thermostat setpoints, node names and climate control schedules
Log::Write( LogLevel_Detail, "Node%03d, QueryStage_Session", m_nodeId ); Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_Session" );
for( map<uint8,CommandClass*>::const_iterator it = m_commandClassMap.begin(); it != m_commandClassMap.end(); ++it ) for( map<uint8,CommandClass*>::const_iterator it = m_commandClassMap.begin(); it != m_commandClassMap.end(); ++it )
{ {
if( !it->second->IsAfterMark() ) if( !it->second->IsAfterMark() )
@ -433,7 +435,7 @@ void Node::AdvanceQueries
{ {
// Request the dynamic values from the node, that can change at any time // Request the dynamic values from the node, that can change at any time
// Examples include on/off state, heating mode, temperature, etc. // Examples include on/off state, heating mode, temperature, etc.
Log::Write( LogLevel_Detail, "Node%03d, QueryStage_Dynamic", m_nodeId ); Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_Dynamic" );
m_queryPending = RequestDynamicValues(); m_queryPending = RequestDynamicValues();
if( !m_queryPending ) if( !m_queryPending )
@ -446,7 +448,7 @@ void Node::AdvanceQueries
case QueryStage_Configuration: case QueryStage_Configuration:
{ {
// Request the configurable parameter values from the node. // Request the configurable parameter values from the node.
Log::Write( LogLevel_Detail, "Node%03d, QueryStage_Configuration", m_nodeId ); Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_Configuration" );
if( m_queryConfiguration ) if( m_queryConfiguration )
{ {
if( RequestAllConfigParams( CommandClass::RequestFlag_LowPriority) ) if( RequestAllConfigParams( CommandClass::RequestFlag_LowPriority) )
@ -465,7 +467,7 @@ void Node::AdvanceQueries
case QueryStage_Complete: case QueryStage_Complete:
{ {
// Notify the watchers that the queries are complete for this node // Notify the watchers that the queries are complete for this node
Log::Write( LogLevel_Detail, "Node%03d, QueryStage_Complete", m_nodeId ); Log::Write( LogLevel_Detail, m_nodeId, "QueryStage_Complete" );
Notification* notification = new Notification( Notification::Type_NodeQueriesComplete ); Notification* notification = new Notification( Notification::Type_NodeQueriesComplete );
notification->SetHomeAndNodeIds( m_homeId, m_nodeId ); notification->SetHomeAndNodeIds( m_homeId, m_nodeId );
GetDriver()->QueueNotification( notification ); GetDriver()->QueueNotification( notification );
@ -520,7 +522,7 @@ void Node::QueryStageRetry
uint8 const _maxAttempts // = 0 uint8 const _maxAttempts // = 0
) )
{ {
Log::Write( LogLevel_Info, "QueryStageRetry stage %s requested stage %s max %d retries %d pending %d", c_queryStageNames[_stage], c_queryStageNames[m_queryStage], _maxAttempts, m_queryRetries, m_queryPending); Log::Write( LogLevel_Info, m_nodeId, "QueryStageRetry stage %s requested stage %s max %d retries %d pending %d", c_queryStageNames[_stage], c_queryStageNames[m_queryStage], _maxAttempts, m_queryRetries, m_queryPending);
// Check that we are actually on the specified stage // Check that we are actually on the specified stage
if( _stage != m_queryStage ) if( _stage != m_queryStage )
@ -1000,7 +1002,7 @@ void Node::UpdateProtocolInfo
if( _data[4] == 0 ) if( _data[4] == 0 )
{ {
// Node doesn't exist if Generic class is zero. // Node doesn't exist if Generic class is zero.
Log::Write( LogLevel_Info, " Protocol Info for Node %d reports node nonexistent", m_nodeId ); Log::Write( LogLevel_Info, m_nodeId, " Protocol Info for Node %d reports node nonexistent", m_nodeId );
return; return;
} }
@ -1034,20 +1036,19 @@ void Node::UpdateProtocolInfo
// and now just request the optional classes regardless. // and now just request the optional classes regardless.
// bool optional = (( _data[1] & 0x80 ) != 0 ); // bool optional = (( _data[1] & 0x80 ) != 0 );
string nodestr = GetDriver()->GetNodeString( m_nodeId ); Log::Write( LogLevel_Info, m_nodeId, " Protocol Info for Node %d:", m_nodeId );
Log::Write( LogLevel_Info, "%s, Protocol Info for Node %d:", nodestr.c_str(), m_nodeId );
if( m_listening ) if( m_listening )
Log::Write( LogLevel_Info, "%s, Listening = true", nodestr.c_str() ); Log::Write( LogLevel_Info, m_nodeId, " Listening = true" );
else else
{ {
Log::Write( LogLevel_Info, "%s, Listening = false", nodestr.c_str() ); Log::Write( LogLevel_Info, m_nodeId, " Listening = false" );
Log::Write( LogLevel_Info, "%s, Frequent = %s", nodestr.c_str(), m_frequentListening ? "true" : "false" ); Log::Write( LogLevel_Info, m_nodeId, " Frequent = %s", m_frequentListening ? "true" : "false" );
} }
Log::Write( LogLevel_Info, "%s, Beaming = %s", nodestr.c_str(), m_beaming ? "true" : "false" ); Log::Write( LogLevel_Info, m_nodeId, " Beaming = %s", m_beaming ? "true" : "false" );
Log::Write( LogLevel_Info, "%s, Routing = %s", nodestr.c_str(), m_routing ? "true" : "false" ); Log::Write( LogLevel_Info, m_nodeId, " Routing = %s", m_routing ? "true" : "false" );
Log::Write( LogLevel_Info, "%s, Max Baud Rate = %d", nodestr.c_str(), m_maxBaudRate ); Log::Write( LogLevel_Info, m_nodeId, " Max Baud Rate = %d", m_maxBaudRate );
Log::Write( LogLevel_Info, "%s, Version = %d", nodestr.c_str(), m_version ); Log::Write( LogLevel_Info, m_nodeId, " Version = %d", m_version );
Log::Write( LogLevel_Info, "%s, Security = %s", nodestr.c_str(), m_security ? "true" : "false" ); Log::Write( LogLevel_Info, m_nodeId, " Security = %s", m_security ? "true" : "false" );
// Set up the device class based data for the node, including mandatory command classes // Set up the device class based data for the node, including mandatory command classes
SetDeviceClasses( _data[3], _data[4], _data[5] ); SetDeviceClasses( _data[3], _data[4], _data[5] );
@ -1071,9 +1072,8 @@ void Node::UpdateNodeInfo
{ {
if( !NodeInfoReceived() ) if( !NodeInfoReceived() )
{ {
string nodestr = GetDriver()->GetNodeString( m_nodeId );
// Add the command classes specified by the device // Add the command classes specified by the device
Log::Write( LogLevel_Info, "%s, Optional command classes for node %d:", nodestr.c_str(), m_nodeId ); Log::Write( LogLevel_Info, m_nodeId, " Optional command classes for node %d:", m_nodeId );
bool newCommandClasses = false; bool newCommandClasses = false;
uint32 i; uint32 i;
@ -1091,9 +1091,9 @@ void Node::UpdateNodeInfo
if( !newCommandClasses ) if( !newCommandClasses )
{ {
Log::Write( LogLevel_Info, "%s, None", nodestr.c_str() ); Log::Write( LogLevel_Info, m_nodeId, " None" );
} }
Log::Write( LogLevel_Info, "%s, Optional command classes controlled by node %d:", nodestr.c_str(), m_nodeId ); Log::Write( LogLevel_Info, m_nodeId, " Optional command classes controlled by node %d:", m_nodeId );
newCommandClasses = false; newCommandClasses = false;
continue; continue;
} }
@ -1113,19 +1113,19 @@ void Node::UpdateNodeInfo
// call at the end of this method have been processed. // call at the end of this method have been processed.
pCommandClass->SetInstance( 1 ); pCommandClass->SetInstance( 1 );
newCommandClasses = true; newCommandClasses = true;
Log::Write( LogLevel_Info, "%s, %s", nodestr.c_str(), pCommandClass->GetCommandClassName().c_str() ); Log::Write( LogLevel_Info, m_nodeId, " %s", pCommandClass->GetCommandClassName().c_str() );
} }
} }
else else
{ {
Log::Write( LogLevel_Info, "%s, CommandClass 0x%.2x - NOT REQUIRED", nodestr.c_str(), _data[i] ); Log::Write( LogLevel_Info, m_nodeId, " CommandClass 0x%.2x - NOT REQUIRED", _data[i] );
} }
} }
if( !newCommandClasses ) if( !newCommandClasses )
{ {
// No additional command classes over the mandatory ones. // No additional command classes over the mandatory ones.
Log::Write( LogLevel_Info, "%s, None", nodestr.c_str() ); Log::Write( LogLevel_Info, m_nodeId, " None" );
} }
SetStaticRequests(); SetStaticRequests();
@ -1238,14 +1238,14 @@ void Node::ApplicationCommandHandler
{ {
// This is a controller replication message, and we do not support it. // This is a controller replication message, and we do not support it.
// We have to at least acknowledge the message to avoid locking the sending device. // We have to at least acknowledge the message to avoid locking the sending device.
Log::Write( LogLevel_Info, "Node%03d, ApplicationCommandHandler - Default acknowledgement of controller replication data", m_nodeId ); Log::Write( LogLevel_Info, m_nodeId, "ApplicationCommandHandler - Default acknowledgement of controller replication data" );
Msg* msg = new Msg( "Replication Command Complete", m_nodeId, REQUEST, FUNC_ID_ZW_REPLICATION_COMMAND_COMPLETE, false ); Msg* msg = new Msg( "Replication Command Complete", m_nodeId, REQUEST, FUNC_ID_ZW_REPLICATION_COMMAND_COMPLETE, false );
GetDriver()->SendMsg( msg, Driver::MsgQueue_Command ); GetDriver()->SendMsg( msg, Driver::MsgQueue_Command );
} }
else else
{ {
Log::Write( LogLevel_Info, "Node%03d, ApplicationCommandHandler - Unhandled Command Class 0x%.2x", m_nodeId, _data[5] ); Log::Write( LogLevel_Info, m_nodeId, "ApplicationCommandHandler - Unhandled Command Class 0x%.2x", _data[5] );
} }
} }
} }
@ -1292,7 +1292,7 @@ CommandClass* Node::AddCommandClass
} }
else else
{ {
Log::Write( LogLevel_Info, "Node%03d, AddCommandClass - Unsupported Command Class 0x%.2x", m_nodeId, _commandClassId ); Log::Write( LogLevel_Info, m_nodeId, "AddCommandClass - Unsupported Command Class 0x%.2x", _commandClassId );
} }
return NULL; return NULL;
@ -1321,7 +1321,7 @@ void Node::RemoveCommandClass
} }
// Destroy the command class object and remove it from our map // Destroy the command class object and remove it from our map
Log::Write( LogLevel_Info, "Node%03d, RemoveCommandClass - Removed support for %s", m_nodeId, it->second->GetCommandClassName().c_str() ); Log::Write( LogLevel_Info, m_nodeId, "RemoveCommandClass - Removed support for %s", it->second->GetCommandClassName().c_str() );
delete it->second; delete it->second;
m_commandClassMap.erase( it ); m_commandClassMap.erase( it );
@ -1828,7 +1828,7 @@ bool Node::CreateValueFromXML
case ValueID::ValueType_Short: { value = new ValueShort(); break; } case ValueID::ValueType_Short: { value = new ValueShort(); break; }
case ValueID::ValueType_String: { value = new ValueString(); break; } case ValueID::ValueType_String: { value = new ValueString(); break; }
case ValueID::ValueType_Button: { value = new ValueButton(); break; } case ValueID::ValueType_Button: { value = new ValueButton(); break; }
default: { Log::Write( LogLevel_Info, "Unknown ValueType in XML: %s", _valueElement->Attribute( "type" ) ); break; } default: { Log::Write( LogLevel_Info, m_nodeId, "Unknown ValueType in XML: %s", _valueElement->Attribute( "type" ) ); break; }
} }
if( value ) if( value )
@ -2101,7 +2101,7 @@ void Node::AutoAssociate
if( group->IsAuto() && !group->Contains( controllerNodeId ) ) if( group->IsAuto() && !group->Contains( controllerNodeId ) )
{ {
// Associate the controller into the group // Associate the controller into the group
Log::Write( LogLevel_Info, "%s, Adding the controller to group %d (%s) of node %d", GetDriver()->GetNodeString( GetNodeId() ).c_str(), group->GetIdx(), group->GetLabel().c_str(), GetNodeId() ); Log::Write( LogLevel_Info, m_nodeId, "Adding the controller to group %d (%s) of node %d", group->GetIdx(), group->GetLabel().c_str(), GetNodeId() );
group->AddAssociation( controllerNodeId ); group->AddAssociation( controllerNodeId );
} }
} }
@ -2185,15 +2185,14 @@ bool Node::SetDeviceClasses
// Get the basic device class label // Get the basic device class label
map<uint8,string>::iterator bit = s_basicDeviceClasses.find( _basic ); map<uint8,string>::iterator bit = s_basicDeviceClasses.find( _basic );
string nodestr = GetDriver()->GetNodeString( m_nodeId );
if( bit != s_basicDeviceClasses.end() ) if( bit != s_basicDeviceClasses.end() )
{ {
m_type = bit->second; m_type = bit->second;
Log::Write( LogLevel_Info, "%s, Basic device class (0x%.2x) - %s", nodestr.c_str(), m_basic, m_type.c_str() ); Log::Write( LogLevel_Info, m_nodeId, " Basic device class (0x%.2x) - %s", m_basic, m_type.c_str() );
} }
else else
{ {
Log::Write( LogLevel_Info, "%s, Basic device class unknown", nodestr.c_str() ); Log::Write( LogLevel_Info, m_nodeId, " Basic device class unknown" );
} }
// Apply any Generic device class data // Apply any Generic device class data
@ -2204,7 +2203,7 @@ bool Node::SetDeviceClasses
GenericDeviceClass* genericDeviceClass = git->second; GenericDeviceClass* genericDeviceClass = git->second;
m_type = genericDeviceClass->GetLabel(); m_type = genericDeviceClass->GetLabel();
Log::Write( LogLevel_Info, "%s, Generic device Class (0x%.2x) - %s", nodestr.c_str(), m_generic, m_type.c_str() ); Log::Write( LogLevel_Info, m_nodeId, " Generic device Class (0x%.2x) - %s", m_generic, m_type.c_str() );
// Add the mandatory command classes for this generic class type // Add the mandatory command classes for this generic class type
AddMandatoryCommandClasses( genericDeviceClass->GetMandatoryCommandClasses() ); AddMandatoryCommandClasses( genericDeviceClass->GetMandatoryCommandClasses() );
@ -2217,7 +2216,7 @@ bool Node::SetDeviceClasses
{ {
m_type = specificDeviceClass->GetLabel(); m_type = specificDeviceClass->GetLabel();
Log::Write( LogLevel_Info, "%s, Specific device class (0x%.2x) - %s", nodestr.c_str(), m_specific, m_type.c_str() ); Log::Write( LogLevel_Info, m_nodeId, " Specific device class (0x%.2x) - %s", m_specific, m_type.c_str() );
// Add the mandatory command classes for this specific class type // Add the mandatory command classes for this specific class type
AddMandatoryCommandClasses( specificDeviceClass->GetMandatoryCommandClasses() ); AddMandatoryCommandClasses( specificDeviceClass->GetMandatoryCommandClasses() );
@ -2230,12 +2229,12 @@ bool Node::SetDeviceClasses
} }
else else
{ {
Log::Write( LogLevel_Info, "%s, No specific device class defined", nodestr.c_str() ); Log::Write( LogLevel_Info, m_nodeId, " No specific device class defined" );
} }
} }
else else
{ {
Log::Write( LogLevel_Info, "%s, No generic or specific device classes defined", nodestr.c_str() ); Log::Write( LogLevel_Info, m_nodeId, " No generic or specific device classes defined" );
} }
// Deal with sleeping devices // Deal with sleeping devices
@ -2261,34 +2260,34 @@ bool Node::SetDeviceClasses
{ {
map<uint8,CommandClass*>::const_iterator cit; map<uint8,CommandClass*>::const_iterator cit;
Log::Write( LogLevel_Info, "%s, Mandatory Command Classes for Node %d:", nodestr.c_str(), m_nodeId ); Log::Write( LogLevel_Info, m_nodeId, " Mandatory Command Classes for Node %d:", m_nodeId );
bool reportedClasses = false; bool reportedClasses = false;
for( cit = m_commandClassMap.begin(); cit != m_commandClassMap.end(); ++cit ) for( cit = m_commandClassMap.begin(); cit != m_commandClassMap.end(); ++cit )
{ {
if( !cit->second->IsAfterMark() ) if( !cit->second->IsAfterMark() )
{ {
Log::Write( LogLevel_Info, "%s, %s", nodestr.c_str(), cit->second->GetCommandClassName().c_str() ); Log::Write( LogLevel_Info, m_nodeId, " %s", cit->second->GetCommandClassName().c_str() );
reportedClasses = true; reportedClasses = true;
} }
} }
if( !reportedClasses ) if( !reportedClasses )
{ {
Log::Write( LogLevel_Info, "%s, None", nodestr.c_str() ); Log::Write( LogLevel_Info, m_nodeId, " None" );
} }
Log::Write( LogLevel_Info, "%s, Mandatory Command Classes controlled by Node %d:", nodestr.c_str(), m_nodeId ); Log::Write( LogLevel_Info, m_nodeId, " Mandatory Command Classes controlled by Node %d:", m_nodeId );
reportedClasses = false; reportedClasses = false;
for( cit = m_commandClassMap.begin(); cit != m_commandClassMap.end(); ++cit ) for( cit = m_commandClassMap.begin(); cit != m_commandClassMap.end(); ++cit )
{ {
if( cit->second->IsAfterMark() ) if( cit->second->IsAfterMark() )
{ {
Log::Write( LogLevel_Info, "%s, %s", nodestr.c_str(), cit->second->GetCommandClassName().c_str() ); Log::Write( LogLevel_Info, m_nodeId, " %s", cit->second->GetCommandClassName().c_str() );
reportedClasses = true; reportedClasses = true;
} }
} }
if( !reportedClasses ) if( !reportedClasses )
{ {
Log::Write( LogLevel_Info, "%s, None", nodestr.c_str() ); Log::Write( LogLevel_Info, m_nodeId, " None" );
} }
} }

View file

@ -194,13 +194,13 @@ void Association::RequestAllGroups
if( m_numGroups == 0xff ) if( m_numGroups == 0xff )
{ {
// We start with group 255, and will then move to group 1, 2 etc and stop when we find a group with a maxAssociations of zero. // We start with group 255, and will then move to group 1, 2 etc and stop when we find a group with a maxAssociations of zero.
Log::Write( LogLevel_Info, "%s, Number of association groups reported for node %d is 255, which requires special case handling.", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId() ); Log::Write( LogLevel_Info, GetNodeId(), "Number of association groups reported for node %d is 255, which requires special case handling.", GetNodeId() );
QueryGroup( 0xff, _requestFlags ); QueryGroup( 0xff, _requestFlags );
} }
else else
{ {
// We start with group 1, and will then move to group 2, 3 etc and stop when the group index is greater than m_numGroups. // We start with group 1, and will then move to group 2, 3 etc and stop when the group index is greater than m_numGroups.
Log::Write( LogLevel_Info, "%s, Number of association groups reported for node %d is %d.", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), m_numGroups ); Log::Write( LogLevel_Info, GetNodeId(), "Number of association groups reported for node %d is %d.", GetNodeId(), m_numGroups );
QueryGroup( 1, _requestFlags ); QueryGroup( 1, _requestFlags );
} }
} }
@ -226,7 +226,7 @@ bool Association::HandleMsg
// Retrieve the number of groups this device supports. // Retrieve the number of groups this device supports.
// The groups will be queried with the session data. // The groups will be queried with the session data.
m_numGroups = _data[1]; m_numGroups = _data[1];
Log::Write( LogLevel_Info, "%s, Received Association Groupings report from node %d. Number of groups is %d", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), m_numGroups ); Log::Write( LogLevel_Info, GetNodeId(), "Received Association Groupings report from node %d. Number of groups is %d", GetNodeId(), m_numGroups );
ClearStaticRequest( StaticRequest_Values ); ClearStaticRequest( StaticRequest_Values );
handled = true; handled = true;
} }
@ -243,13 +243,13 @@ bool Association::HandleMsg
{ {
uint8 numAssociations = _length - 5; uint8 numAssociations = _length - 5;
Log::Write( LogLevel_Info, "%s, Received Association report from node %d, group %d, containing %d associations", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), groupIdx, numAssociations ); Log::Write( LogLevel_Info, GetNodeId(), "Received Association report from node %d, group %d, containing %d associations", GetNodeId(), groupIdx, numAssociations );
if( numAssociations ) if( numAssociations )
{ {
Log::Write( LogLevel_Info, "%s, The group contains:", GetDriver()->GetNodeString( GetNodeId() ).c_str() ); Log::Write( LogLevel_Info, GetNodeId(), " The group contains:" );
for( i=0; i<numAssociations; ++i ) for( i=0; i<numAssociations; ++i )
{ {
Log::Write( LogLevel_Info, "%s, Node %d", GetDriver()->GetNodeString( GetNodeId() ).c_str(), _data[i+4] ); Log::Write( LogLevel_Info, GetNodeId(), " Node %d", _data[i+4] );
m_pendingMembers.push_back( _data[i+4] ); m_pendingMembers.push_back( _data[i+4] );
} }
} }
@ -258,7 +258,7 @@ bool Association::HandleMsg
if( numReportsToFollow ) if( numReportsToFollow )
{ {
// We're expecting more reports for this group // We're expecting more reports for this group
Log::Write( LogLevel_Info, "%s, %d more association reports expected for node %d, group %d", GetDriver()->GetNodeString( GetNodeId() ).c_str(), numReportsToFollow, GetNodeId(), groupIdx ); Log::Write( LogLevel_Info, GetNodeId(), "%d more association reports expected for node %d, group %d", numReportsToFollow, GetNodeId(), groupIdx );
return true; return true;
} }
else else
@ -280,7 +280,7 @@ bool Association::HandleMsg
else else
{ {
// maxAssociations is zero, so we've reached the end of the query process // maxAssociations is zero, so we've reached the end of the query process
Log::Write( LogLevel_Info, "%s, Max associations for node %d, group %d is zero. Querying associations for this node is complete.", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), groupIdx ); Log::Write( LogLevel_Info, GetNodeId(), "Max associations for node %d, group %d is zero. Querying associations for this node is complete.", GetNodeId(), groupIdx );
node->AutoAssociate(); node->AutoAssociate();
m_queryAll = false; m_queryAll = false;
} }
@ -303,7 +303,7 @@ bool Association::HandleMsg
else else
{ {
// We're all done // We're all done
Log::Write( LogLevel_Info, "%s, Querying associations for node %d is complete.", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId() ); Log::Write( LogLevel_Info, GetNodeId(), "Querying associations for node %d is complete.", GetNodeId() );
node->AutoAssociate(); node->AutoAssociate();
m_queryAll = false; m_queryAll = false;
} }
@ -326,7 +326,7 @@ void Association::QueryGroup
uint32 const _requestFlags uint32 const _requestFlags
) )
{ {
Log::Write( LogLevel_Info, "%s, Get Associations for group %d of node %d", GetDriver()->GetNodeString( GetNodeId() ).c_str(), _groupIdx, GetNodeId() ); Log::Write( LogLevel_Info, GetNodeId(), "Get Associations for group %d of node %d", _groupIdx, GetNodeId() );
Msg* msg = new Msg( "Get Associations", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); Msg* msg = new Msg( "Get Associations", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
msg->Append( GetNodeId() ); msg->Append( GetNodeId() );
msg->Append( 3 ); msg->Append( 3 );
@ -347,7 +347,7 @@ void Association::Set
uint8 _targetNodeId uint8 _targetNodeId
) )
{ {
Log::Write( LogLevel_Info, "%s, Association::Set - Adding node %d to group %d of node %d", GetDriver()->GetNodeString( GetNodeId() ).c_str(), _targetNodeId, _groupIdx, GetNodeId() ); Log::Write( LogLevel_Info, GetNodeId(), "Association::Set - Adding node %d to group %d of node %d", _targetNodeId, _groupIdx, GetNodeId() );
Msg* msg = new Msg( "Association Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); Msg* msg = new Msg( "Association Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
msg->Append( GetNodeId() ); msg->Append( GetNodeId() );
@ -370,7 +370,7 @@ void Association::Remove
uint8 _targetNodeId uint8 _targetNodeId
) )
{ {
Log::Write( LogLevel_Info, "%s, Association::Remove - Removing node %d from group %d of node %d", GetDriver()->GetNodeString( GetNodeId() ).c_str(), _targetNodeId, _groupIdx, GetNodeId() ); Log::Write( LogLevel_Info, GetNodeId(), "Association::Remove - Removing node %d from group %d of node %d", _targetNodeId, _groupIdx, GetNodeId() );
Msg* msg = new Msg( "Association Remove", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); Msg* msg = new Msg( "Association Remove", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
msg->Append( GetNodeId() ); msg->Append( GetNodeId() );

View file

@ -101,7 +101,7 @@ bool Basic::HandleMsg
if( BasicCmd_Report == (BasicCmd)_data[0] ) if( BasicCmd_Report == (BasicCmd)_data[0] )
{ {
// Level // Level
Log::Write( LogLevel_Info, "%s, Received Basic report from node %d: level=%d", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), _data[1] ); Log::Write( LogLevel_Info, GetNodeId(), "Received Basic report from node %d: level=%d", GetNodeId(), _data[1] );
if( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, 0 ) ) ) if( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, 0 ) ) )
{ {
value->OnValueRefreshed( _data[1] ); value->OnValueRefreshed( _data[1] );
@ -113,7 +113,7 @@ bool Basic::HandleMsg
if( BasicCmd_Set == (BasicCmd)_data[0] ) if( BasicCmd_Set == (BasicCmd)_data[0] )
{ {
// Commmand received from the node. Handle as a notifcation event // Commmand received from the node. Handle as a notifcation event
Log::Write( LogLevel_Info, "%s, Received Basic set from node %d: level=%d. Sending event notification.", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), _data[1] ); Log::Write( LogLevel_Info, GetNodeId(), "Received Basic set from node %d: level=%d. Sending event notification.", GetNodeId(), _data[1] );
Notification* notification = new Notification( Notification::Type_NodeEvent ); Notification* notification = new Notification( Notification::Type_NodeEvent );
notification->SetHomeAndNodeIds( GetHomeId(), GetNodeId() ); notification->SetHomeAndNodeIds( GetHomeId(), GetNodeId() );
@ -138,7 +138,7 @@ bool Basic::SetValue
{ {
ValueByte const* value = static_cast<ValueByte const*>(&_value); ValueByte const* value = static_cast<ValueByte const*>(&_value);
Log::Write( LogLevel_Info, "%s, Basic::Set - Setting node %d to level %d", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), value->GetValue() ); Log::Write( LogLevel_Info, GetNodeId(), "Basic::Set - Setting node %d to level %d", GetNodeId(), value->GetValue() );
Msg* msg = new Msg( "Basic Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); Msg* msg = new Msg( "Basic Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
msg->SetInstance( this, _value.GetID().GetInstance() ); msg->SetInstance( this, _value.GetID().GetInstance() );
msg->Append( GetNodeId() ); msg->Append( GetNodeId() );
@ -202,7 +202,7 @@ bool Basic::SetMapping
{ {
if( CommandClass* cc = node->GetCommandClass( _commandClassId ) ) if( CommandClass* cc = node->GetCommandClass( _commandClassId ) )
{ {
Log::Write( LogLevel_Info, "%s, COMMAND_CLASS_BASIC will be mapped to %s", GetDriver()->GetNodeString( GetNodeId() ).c_str(), cc->GetCommandClassName().c_str() ); Log::Write( LogLevel_Info, GetNodeId(), " COMMAND_CLASS_BASIC will be mapped to %s", cc->GetCommandClassName().c_str() );
m_mapping = _commandClassId; m_mapping = _commandClassId;
res = true; res = true;
} }

View file

@ -111,7 +111,7 @@ bool Battery::HandleMsg
batteryLevel = 0; batteryLevel = 0;
} }
Log::Write( LogLevel_Info, "%s, Received Battery report from node %d: level=%d", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), batteryLevel ); Log::Write( LogLevel_Info, GetNodeId(), "Received Battery report from node %d: level=%d", GetNodeId(), batteryLevel );
if( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, 0 ) ) ) if( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, 0 ) ) )
{ {

View file

@ -56,7 +56,7 @@ bool Hail::HandleMsg
{ {
// We have received a hail from the Z-Wave device. // We have received a hail from the Z-Wave device.
// Request an update of the dynamic values. // Request an update of the dynamic values.
Log::Write( LogLevel_Info, "Received Hail command from node %d", GetNodeId() ); Log::Write( LogLevel_Info, GetNodeId(), "Received Hail command from node %d", GetNodeId() );
if( Node* node = GetNodeUnsafe() ) if( Node* node = GetNodeUnsafe() )
{ {
node->RequestDynamicValues(); node->RequestDynamicValues();

View file

@ -193,8 +193,8 @@ bool ManufacturerSpecific::HandleMsg
LoadConfigXML( configPath ); LoadConfigXML( configPath );
} }
Log::Write( LogLevel_Info, "%s, Received manufacturer specific report from node %d: Manufacturer=%s, Product=%s", Log::Write( LogLevel_Info, GetNodeId(), "Received manufacturer specific report from node %d: Manufacturer=%s, Product=%s",
GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), node->GetManufacturerName().c_str(), node->GetProductName().c_str() ); GetNodeId(), node->GetManufacturerName().c_str(), node->GetProductName().c_str() );
ClearStaticRequest( StaticRequest_Values ); ClearStaticRequest( StaticRequest_Values );
node->m_manufacturerSpecificClassReceived = true; node->m_manufacturerSpecificClassReceived = true;
} }
@ -226,13 +226,12 @@ bool ManufacturerSpecific::LoadProductXML
Options::Get()->GetOptionAsString( "ConfigPath", &configPath ); Options::Get()->GetOptionAsString( "ConfigPath", &configPath );
string filename = configPath + "manufacturer_specific.xml"; string filename = configPath + "manufacturer_specific.xml";
string nodestr = _node->GetDriver()->GetNodeString( _node->GetNodeId() );
TiXmlDocument* pDoc = new TiXmlDocument(); TiXmlDocument* pDoc = new TiXmlDocument();
if( !pDoc->LoadFile( filename.c_str(), TIXML_ENCODING_UTF8 ) ) if( !pDoc->LoadFile( filename.c_str(), TIXML_ENCODING_UTF8 ) )
{ {
delete pDoc; delete pDoc;
Log::Write( LogLevel_Info, "%s, Unable to load %s", nodestr.c_str(), filename.c_str() ); Log::Write( LogLevel_Info, _node->m_nodeId, "Unable to load %s", filename.c_str() );
return false; return false;
} }
@ -251,7 +250,7 @@ bool ManufacturerSpecific::LoadProductXML
str = manufacturerElement->Attribute( "id" ); str = manufacturerElement->Attribute( "id" );
if( !str ) if( !str )
{ {
Log::Write( LogLevel_Info, "%s, Error in manufacturer_specific.xml at line %d - missing manufacturer id attribute", nodestr.c_str(), manufacturerElement->Row() ); Log::Write( LogLevel_Info, _node->m_nodeId, "Error in manufacturer_specific.xml at line %d - missing manufacturer id attribute", manufacturerElement->Row() );
delete pDoc; delete pDoc;
return false; return false;
} }
@ -260,7 +259,7 @@ bool ManufacturerSpecific::LoadProductXML
str = manufacturerElement->Attribute( "name" ); str = manufacturerElement->Attribute( "name" );
if( !str ) if( !str )
{ {
Log::Write( LogLevel_Info, "%s, Error in manufacturer_specific.xml at line %d - missing manufacturer name attribute", nodestr.c_str(), manufacturerElement->Row() ); Log::Write( LogLevel_Info, _node->m_nodeId, "Error in manufacturer_specific.xml at line %d - missing manufacturer name attribute", manufacturerElement->Row() );
delete pDoc; delete pDoc;
return false; return false;
} }
@ -278,7 +277,7 @@ bool ManufacturerSpecific::LoadProductXML
str = productElement->Attribute( "type" ); str = productElement->Attribute( "type" );
if( !str ) if( !str )
{ {
Log::Write( LogLevel_Info, "%s, Error in manufacturer_specific.xml at line %d - missing product type attribute", nodestr.c_str(), productElement->Row() ); Log::Write( LogLevel_Info, _node->m_nodeId, "Error in manufacturer_specific.xml at line %d - missing product type attribute", productElement->Row() );
delete pDoc; delete pDoc;
return false; return false;
} }
@ -287,7 +286,7 @@ bool ManufacturerSpecific::LoadProductXML
str = productElement->Attribute( "id" ); str = productElement->Attribute( "id" );
if( !str ) if( !str )
{ {
Log::Write( LogLevel_Info, "%s, Error in manufacturer_specific.xml at line %d - missing product id attribute", nodestr.c_str(), productElement->Row() ); Log::Write( LogLevel_Info, _node->m_nodeId, "Error in manufacturer_specific.xml at line %d - missing product id attribute", productElement->Row() );
delete pDoc; delete pDoc;
return false; return false;
} }
@ -296,7 +295,7 @@ bool ManufacturerSpecific::LoadProductXML
str = productElement->Attribute( "name" ); str = productElement->Attribute( "name" );
if( !str ) if( !str )
{ {
Log::Write( LogLevel_Info, "%s, Error in manufacturer_specific.xml at line %d - missing product name attribute", nodestr.c_str(), productElement->Row() ); Log::Write( LogLevel_Info, _node->m_nodeId, "Error in manufacturer_specific.xml at line %d - missing product name attribute", productElement->Row() );
delete pDoc; delete pDoc;
return false; return false;
} }
@ -383,11 +382,11 @@ bool ManufacturerSpecific::LoadConfigXML
string filename = configPath + _configXML; string filename = configPath + _configXML;
TiXmlDocument* doc = new TiXmlDocument(); TiXmlDocument* doc = new TiXmlDocument();
Log::Write( LogLevel_Info, "%s, Opening config param file %s", GetDriver()->GetNodeString( GetNodeId() ).c_str(), filename.c_str() ); Log::Write( LogLevel_Info, GetNodeId(), " Opening config param file %s", filename.c_str() );
if( !doc->LoadFile( filename.c_str(), TIXML_ENCODING_UTF8 ) ) if( !doc->LoadFile( filename.c_str(), TIXML_ENCODING_UTF8 ) )
{ {
delete doc; delete doc;
Log::Write( LogLevel_Info, "%s, Unable to find or load Config Param file %s", GetDriver()->GetNodeString( GetNodeId() ).c_str(), filename.c_str() ); Log::Write( LogLevel_Info, GetNodeId(), "Unable to find or load Config Param file %s", filename.c_str() );
return false; return false;
} }

View file

@ -339,7 +339,7 @@ bool Meter::HandleSupportedReport
node->CreateValueButton( ValueID::ValueGenre_System, GetCommandClassId(), _instance, MeterIndex_Reset, "Reset", 0 ); node->CreateValueButton( ValueID::ValueGenre_System, GetCommandClassId(), _instance, MeterIndex_Reset, "Reset", 0 );
} }
Log::Write( LogLevel_Info, "%s, Received Meter supported report from node %d, %s", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), msg.c_str() ); Log::Write( LogLevel_Info, GetNodeId(), "Received Meter supported report from node %d, %s", GetNodeId(), msg.c_str() );
return true; return true;
} }
@ -411,7 +411,7 @@ bool Meter::HandleReport
if( ValueDecimal* value = static_cast<ValueDecimal*>( GetValue( _instance, 0 ) ) ) if( ValueDecimal* value = static_cast<ValueDecimal*>( GetValue( _instance, 0 ) ) )
{ {
Log::Write( LogLevel_Info, "%s, Received Meter report from node %d: %s=%s%s", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), label.c_str(), valueStr.c_str(), units.c_str() ); Log::Write( LogLevel_Info, GetNodeId(), "Received Meter report from node %d: %s=%s%s", GetNodeId(), label.c_str(), valueStr.c_str(), units.c_str() );
value->SetLabel( label ); value->SetLabel( label );
value->SetUnits( units ); value->SetUnits( units );
value->OnValueRefreshed( valueStr ); value->OnValueRefreshed( valueStr );
@ -435,7 +435,7 @@ bool Meter::HandleReport
if( ValueDecimal* value = static_cast<ValueDecimal*>( GetValue( _instance, baseIndex ) ) ) if( ValueDecimal* value = static_cast<ValueDecimal*>( GetValue( _instance, baseIndex ) ) )
{ {
Log::Write( LogLevel_Info, "%s, Received Meter report from node %d: %s%s=%s%s", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), exporting ? "Exporting ": "", value->GetLabel().c_str(), valueStr.c_str(), value->GetUnits().c_str() ); Log::Write( LogLevel_Info, GetNodeId(), "Received Meter report from node %d: %s%s=%s%s", GetNodeId(), exporting ? "Exporting ": "", value->GetLabel().c_str(), valueStr.c_str(), value->GetUnits().c_str() );
value->OnValueRefreshed( valueStr ); value->OnValueRefreshed( valueStr );
if( value->GetPrecision() != precision ) if( value->GetPrecision() != precision )
{ {
@ -464,7 +464,7 @@ bool Meter::HandleReport
{ {
precision = 0; precision = 0;
valueStr = ExtractValue( &_data[2], &scale, &precision, 3+size ); valueStr = ExtractValue( &_data[2], &scale, &precision, 3+size );
Log::Write( LogLevel_Info, "%s, Previous value was %s%s, received %d seconds ago.", GetDriver()->GetNodeString( GetNodeId() ).c_str(), valueStr.c_str(), previous->GetUnits().c_str(), delta ); Log::Write( LogLevel_Info, GetNodeId(), " Previous value was %s%s, received %d seconds ago.", valueStr.c_str(), previous->GetUnits().c_str(), delta );
previous->OnValueRefreshed( valueStr ); previous->OnValueRefreshed( valueStr );
if( previous->GetPrecision() != precision ) if( previous->GetPrecision() != precision )
{ {

View file

@ -49,7 +49,7 @@ bool MultiCmd::HandleMsg
{ {
if( MultiCmdCmd_Encap == (MultiCmdCmd)_data[0] ) if( MultiCmdCmd_Encap == (MultiCmdCmd)_data[0] )
{ {
Log::Write( LogLevel_Info, "%s, Received encapsulated multi-command from node %d", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId() ); Log::Write( LogLevel_Info, GetNodeId(), "Received encapsulated multi-command from node %d", GetNodeId() );
if( Node const* node = GetNodeUnsafe() ) if( Node const* node = GetNodeUnsafe() )
{ {
@ -69,7 +69,7 @@ bool MultiCmd::HandleMsg
} }
} }
Log::Write( LogLevel_Info, "%s, End of encapsulated multi-command from node %d", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId() ); Log::Write( LogLevel_Info, GetNodeId(), "End of encapsulated multi-command from node %d", GetNodeId() );
return true; return true;
} }
return false; return false;

View file

@ -209,7 +209,7 @@ void MultiInstance::HandleMultiInstanceReport
if( CommandClass* pCommandClass = node->GetCommandClass( commandClassId ) ) if( CommandClass* pCommandClass = node->GetCommandClass( commandClassId ) )
{ {
Log::Write( LogLevel_Info, "%s, Received MultiInstanceReport from node %d for %s: Number of instances = %d", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), pCommandClass->GetCommandClassName().c_str(), instances ); Log::Write( LogLevel_Info, GetNodeId(), "Received MultiInstanceReport from node %d for %s: Number of instances = %d", GetNodeId(), pCommandClass->GetCommandClassName().c_str(), instances );
pCommandClass->SetInstances( instances ); pCommandClass->SetInstances( instances );
pCommandClass->ClearStaticRequest( StaticRequest_Instances ); pCommandClass->ClearStaticRequest( StaticRequest_Instances );
} }
@ -237,7 +237,7 @@ void MultiInstance::HandleMultiInstanceEncap
if( CommandClass* pCommandClass = node->GetCommandClass( commandClassId ) ) if( CommandClass* pCommandClass = node->GetCommandClass( commandClassId ) )
{ {
Log::Write( LogLevel_Info, "%s, Received a MultiInstanceEncap from node %d, instance %d, for Command Class %s", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), instance, pCommandClass->GetCommandClassName().c_str() ); Log::Write( LogLevel_Info, GetNodeId(), "Received a MultiInstanceEncap from node %d, instance %d, for Command Class %s", GetNodeId(), instance, pCommandClass->GetCommandClassName().c_str() );
pCommandClass->HandleMsg( &_data[3], _length-3, instance ); pCommandClass->HandleMsg( &_data[3], _length-3, instance );
} }
} }
@ -264,7 +264,7 @@ void MultiInstance::HandleMultiChannelEndPointReport
if( m_endPointsAreSameClass ) if( m_endPointsAreSameClass )
{ {
Log::Write( LogLevel_Info, "%s, Received MultiChannelEndPointReport from node %d. All %d endpoints are the same.", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), m_numEndpoints ); Log::Write( LogLevel_Info, GetNodeId(), "Received MultiChannelEndPointReport from node %d. All %d endpoints are the same.", GetNodeId(), m_numEndpoints );
// Send a single capability request to endpoint 1 (since all classes are the same) // Send a single capability request to endpoint 1 (since all classes are the same)
char str[128]; char str[128];
@ -280,8 +280,8 @@ void MultiInstance::HandleMultiChannelEndPointReport
} }
else else
{ {
Log::Write( LogLevel_Info, "%s, Received MultiChannelEndPointReport from node %d. Endpoints are not all the same.", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId() ); Log::Write( LogLevel_Info, GetNodeId(), "Received MultiChannelEndPointReport from node %d. Endpoints are not all the same.", GetNodeId() );
Log::Write( LogLevel_Info, "%s, Starting search for endpoints by generic class...", GetDriver()->GetNodeString( GetNodeId() ).c_str() ); Log::Write( LogLevel_Info, GetNodeId(), " Starting search for endpoints by generic class..." );
// This is where things get really ugly. We need to get the capabilities of each // This is where things get really ugly. We need to get the capabilities of each
// endpoint, but we only know how many there are, not which indices they // endpoint, but we only know how many there are, not which indices they
@ -320,9 +320,9 @@ void MultiInstance::HandleMultiChannelCapabilityReport
uint8 endPoint = _data[1] & 0x7f; uint8 endPoint = _data[1] & 0x7f;
bool dynamic = ((_data[1] & 0x80)!=0); bool dynamic = ((_data[1] & 0x80)!=0);
Log::Write( LogLevel_Info, "%s, Received MultiChannelCapabilityReport from node %d for endpoint %d", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), endPoint ); Log::Write( LogLevel_Info, GetNodeId(), "Received MultiChannelCapabilityReport from node %d for endpoint %d", GetNodeId(), endPoint );
Log::Write( LogLevel_Info, "%s, Endpoint is%sdynamic, and is a %s", GetDriver()->GetNodeString( GetNodeId() ).c_str(), dynamic ? " " : " not ", node->GetEndPointDeviceClassLabel( _data[2], _data[3] ).c_str() ); Log::Write( LogLevel_Info, GetNodeId(), " Endpoint is%sdynamic, and is a %s", dynamic ? " " : " not ", node->GetEndPointDeviceClassLabel( _data[2], _data[3] ).c_str() );
Log::Write( LogLevel_Info, "%s, Command classes supported by the endpoint are:", GetDriver()->GetNodeString( GetNodeId() ).c_str() ); Log::Write( LogLevel_Info, GetNodeId(), " Command classes supported by the endpoint are:" );
// Store the command classes for later use // Store the command classes for later use
bool afterMark = false; bool afterMark = false;
@ -351,13 +351,13 @@ void MultiInstance::HandleMultiChannelCapabilityReport
} }
if( cc ) if( cc )
{ {
Log::Write( LogLevel_Info, "%s, %s", GetDriver()->GetNodeString( GetNodeId() ).c_str(), cc->GetCommandClassName().c_str() ); Log::Write( LogLevel_Info, GetNodeId(), " %s", cc->GetCommandClassName().c_str() );
} }
} }
if( ( endPoint == 1 ) && m_endPointsAreSameClass ) if( ( endPoint == 1 ) && m_endPointsAreSameClass )
{ {
Log::Write( LogLevel_Info, "%s, All endpoints in this device are the same as endpoint 1. Searching for the other endpoints...", GetDriver()->GetNodeString( GetNodeId() ).c_str() ); Log::Write( LogLevel_Info, GetNodeId(), "All endpoints in this device are the same as endpoint 1. Searching for the other endpoints..." );
// All end points have the same command classes. // All end points have the same command classes.
// We just need to find them... // We just need to find them...
@ -399,7 +399,7 @@ void MultiInstance::HandleMultiChannelEndPointFindReport
uint32 const _length uint32 const _length
) )
{ {
Log::Write( LogLevel_Info, "%s, Received MultiChannelEndPointFindReport from node %d", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId() ); Log::Write( LogLevel_Info, GetNodeId(), "Received MultiChannelEndPointFindReport from node %d", GetNodeId() );
uint8 numEndPoints = _length - 5; uint8 numEndPoints = _length - 5;
for( uint8 i=0; i<numEndPoints; ++i ) for( uint8 i=0; i<numEndPoints; ++i )
{ {
@ -416,7 +416,7 @@ void MultiInstance::HandleMultiChannelEndPointFindReport
CommandClass* cc = node->GetCommandClass( commandClassId ); CommandClass* cc = node->GetCommandClass( commandClassId );
if( cc ) if( cc )
{ {
Log::Write( LogLevel_Info, "%s, Endpoint %d: Adding %s", GetDriver()->GetNodeString( GetNodeId() ).c_str(), endPoint, cc->GetCommandClassName().c_str() ); Log::Write( LogLevel_Info, GetNodeId(), " Endpoint %d: Adding %s", endPoint, cc->GetCommandClassName().c_str() );
cc->SetInstance( endPoint ); cc->SetInstance( endPoint );
} }
} }
@ -483,7 +483,7 @@ void MultiInstance::HandleMultiChannelEncap
uint8 commandClassId = _data[3]; uint8 commandClassId = _data[3];
if( CommandClass* pCommandClass = node->GetCommandClass( commandClassId ) ) if( CommandClass* pCommandClass = node->GetCommandClass( commandClassId ) )
{ {
Log::Write( LogLevel_Info, "%s, Received a MultiChannelEncap from node %d, endpoint %d for Command Class %s", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), endPoint, pCommandClass->GetCommandClassName().c_str() ); Log::Write( LogLevel_Info, GetNodeId(), "Received a MultiChannelEncap from node %d, endpoint %d for Command Class %s", GetNodeId(), endPoint, pCommandClass->GetCommandClassName().c_str() );
pCommandClass->HandleMsg( &_data[4], _length-4, endPoint ); pCommandClass->HandleMsg( &_data[4], _length-4, endPoint );
} }
} }

View file

@ -208,7 +208,7 @@ bool SensorMultilevel::HandleMsg
value->SetUnits(units); value->SetUnits(units);
} }
Log::Write( LogLevel_Info, "%s, Received SensorMultiLevel report from node %d, instance %d: value=%s%s", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), _instance, valueStr.c_str(), value->GetUnits().c_str() ); Log::Write( LogLevel_Info, GetNodeId(), "Received SensorMultiLevel report from node %d, instance %d: value=%s%s", GetNodeId(), _instance, valueStr.c_str(), value->GetUnits().c_str() );
if( value->GetPrecision() != precision ) if( value->GetPrecision() != precision )
{ {
value->SetPrecision( precision ); value->SetPrecision( precision );

View file

@ -113,7 +113,7 @@ bool SwitchAll::HandleMsg
{ {
value->OnValueRefreshed( (int32)_data[1] ); value->OnValueRefreshed( (int32)_data[1] );
value->Release(); value->Release();
Log::Write( LogLevel_Info, "%s, Received SwitchAll report from node %d: %s", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), value->GetItem().m_label.c_str() ); Log::Write( LogLevel_Info, GetNodeId(), "Received SwitchAll report from node %d: %s", GetNodeId(), value->GetItem().m_label.c_str() );
} }
return true; return true;
} }
@ -135,7 +135,7 @@ bool SwitchAll::SetValue
ValueList const* value = static_cast<ValueList const*>(&_value); ValueList const* value = static_cast<ValueList const*>(&_value);
ValueList::Item const& item = value->GetItem(); ValueList::Item const& item = value->GetItem();
Log::Write( LogLevel_Info, "%s, SwitchAll::Set - %s on node %d", GetDriver()->GetNodeString( GetNodeId() ).c_str(), item.m_label.c_str(), GetNodeId() ); Log::Write( LogLevel_Info, GetNodeId(), "SwitchAll::Set - %s on node %d", item.m_label.c_str(), GetNodeId() );
Msg* msg = new Msg( "SwitchAllCmd_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); Msg* msg = new Msg( "SwitchAllCmd_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
msg->SetInstance( this, _value.GetID().GetInstance() ); msg->SetInstance( this, _value.GetID().GetInstance() );
msg->Append( GetNodeId() ); msg->Append( GetNodeId() );
@ -161,7 +161,7 @@ void SwitchAll::Off
uint8 const _nodeId uint8 const _nodeId
) )
{ {
Log::Write( LogLevel_Info, "%s, SwitchAll::Off (Node=%d)", _driver->GetNodeString( _nodeId ).c_str(), _nodeId ); Log::Write( LogLevel_Info, _nodeId, "SwitchAll::Off (Node=%d)", _nodeId );
Msg* msg = new Msg( "SwitchAllCmd_Off", _nodeId, REQUEST, FUNC_ID_ZW_SEND_DATA, true ); Msg* msg = new Msg( "SwitchAllCmd_Off", _nodeId, REQUEST, FUNC_ID_ZW_SEND_DATA, true );
msg->Append( _nodeId ); msg->Append( _nodeId );
msg->Append( 2 ); msg->Append( 2 );
@ -181,7 +181,7 @@ void SwitchAll::On
uint8 const _nodeId uint8 const _nodeId
) )
{ {
Log::Write( LogLevel_Info, "%s, SwitchAll::On (Node=%d)", _driver->GetNodeString( _nodeId ).c_str(), _nodeId ); Log::Write( LogLevel_Info, _nodeId, "SwitchAll::On (Node=%d)", _nodeId );
Msg* msg = new Msg( "SwitchAllCmd_On", _nodeId, REQUEST, FUNC_ID_ZW_SEND_DATA, true ); Msg* msg = new Msg( "SwitchAllCmd_On", _nodeId, REQUEST, FUNC_ID_ZW_SEND_DATA, true );
msg->Append( _nodeId ); msg->Append( _nodeId );
msg->Append( 2 ); msg->Append( 2 );

View file

@ -99,7 +99,7 @@ bool SwitchBinary::HandleMsg
{ {
if (SwitchBinaryCmd_Report == (SwitchBinaryCmd)_data[0]) if (SwitchBinaryCmd_Report == (SwitchBinaryCmd)_data[0])
{ {
Log::Write( LogLevel_Info, "%s, Received SwitchBinary report from node %d: level=%s", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), _data[1] ? "On" : "Off" ); Log::Write( LogLevel_Info, GetNodeId(), "Received SwitchBinary report from node %d: level=%s", GetNodeId(), _data[1] ? "On" : "Off" );
if( ValueBool* value = static_cast<ValueBool*>( GetValue( _instance, 0 ) ) ) if( ValueBool* value = static_cast<ValueBool*>( GetValue( _instance, 0 ) ) )
{ {
@ -125,7 +125,7 @@ bool SwitchBinary::SetValue
{ {
ValueBool const* value = static_cast<ValueBool const*>(&_value); ValueBool const* value = static_cast<ValueBool const*>(&_value);
Log::Write( LogLevel_Info, "%s, SwitchBinary::Set - Setting node %d to %s", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), value->GetValue() ? "On" : "Off" ); Log::Write( LogLevel_Info, GetNodeId(), "SwitchBinary::Set - Setting node %d to %s", GetNodeId(), value->GetValue() ? "On" : "Off" );
Msg* msg = new Msg( "SwitchBinary Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true ); Msg* msg = new Msg( "SwitchBinary Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
msg->SetInstance( this, _value.GetID().GetInstance() ); msg->SetInstance( this, _value.GetID().GetInstance() );
msg->Append( GetNodeId() ); msg->Append( GetNodeId() );

View file

@ -171,7 +171,7 @@ bool Version::HandleMsg
snprintf( protocol, sizeof(protocol), "%d.%.2d", _data[2], _data[3] ); snprintf( protocol, sizeof(protocol), "%d.%.2d", _data[2], _data[3] );
snprintf( application, sizeof(application), "%d.%.2d", _data[4], _data[5] ); snprintf( application, sizeof(application), "%d.%.2d", _data[4], _data[5] );
Log::Write( LogLevel_Info, "%s, Received Version report from node %d: Library=%s, Protocol=%s, Application=%s", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), library, protocol, application ); Log::Write( LogLevel_Info, GetNodeId(), "Received Version report from node %d: Library=%s, Protocol=%s, Application=%s", GetNodeId(), library, protocol, application );
ClearStaticRequest( StaticRequest_Values ); ClearStaticRequest( StaticRequest_Values );
if( ValueString* libraryValue = static_cast<ValueString*>( GetValue( _instance, VersionIndex_Library ) ) ) if( ValueString* libraryValue = static_cast<ValueString*>( GetValue( _instance, VersionIndex_Library ) ) )
@ -197,7 +197,7 @@ bool Version::HandleMsg
{ {
if( CommandClass* pCommandClass = node->GetCommandClass( _data[1] ) ) if( CommandClass* pCommandClass = node->GetCommandClass( _data[1] ) )
{ {
Log::Write( LogLevel_Info, "%s, Received Command Class Version report from node %d: CommandClass=%s, Version=%d", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), pCommandClass->GetCommandClassName().c_str(), _data[2] ); Log::Write( LogLevel_Info, GetNodeId(), "Received Command Class Version report from node %d: CommandClass=%s, Version=%d", GetNodeId(), pCommandClass->GetCommandClassName().c_str(), _data[2] );
pCommandClass->ClearStaticRequest( StaticRequest_Version ); pCommandClass->ClearStaticRequest( StaticRequest_Version );
pCommandClass->SetVersion( _data[2] ); pCommandClass->SetVersion( _data[2] );
} }

View file

@ -174,7 +174,7 @@ bool WakeUp::HandleMsg
if( _length < 6 ) if( _length < 6 )
{ {
Log::Write( LogLevel_Warning, "" ); Log::Write( LogLevel_Warning, "" );
Log::Write( LogLevel_Warning, "%s, Unusual response: WakeUpCmd_IntervalReport with len = %d. Ignored.", GetDriver()->GetNodeString( GetNodeId() ).c_str(), _length ); Log::Write( LogLevel_Warning, GetNodeId(), "Unusual response: WakeUpCmd_IntervalReport with len = %d. Ignored.", _length );
value->Release(); value->Release();
return false; return false;
} }
@ -185,7 +185,7 @@ bool WakeUp::HandleMsg
uint8 targetNodeId = _data[4]; uint8 targetNodeId = _data[4];
Log::Write( LogLevel_Info, "%s, Received Wakeup Interval report from node %d: Interval=%d, Target Node=%d", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), interval, targetNodeId ); Log::Write( LogLevel_Info, GetNodeId(), "Received Wakeup Interval report from node %d: Interval=%d, Target Node=%d", GetNodeId(), interval, targetNodeId );
value->OnValueRefreshed( (int32)interval ); value->OnValueRefreshed( (int32)interval );
@ -201,7 +201,7 @@ bool WakeUp::HandleMsg
else if( WakeUpCmd_Notification == (WakeUpCmd)_data[0] ) else if( WakeUpCmd_Notification == (WakeUpCmd)_data[0] )
{ {
// The device is awake. // The device is awake.
Log::Write( LogLevel_Info, "%s, Received Wakeup Notification from node %d", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId() ); Log::Write( LogLevel_Info, GetNodeId(), "Received Wakeup Notification from node %d", GetNodeId() );
m_notification = true; m_notification = true;
SetAwake( true ); SetAwake( true );
return true; return true;
@ -263,7 +263,7 @@ void WakeUp::SetAwake
if( m_awake != _state ) if( m_awake != _state )
{ {
m_awake = _state; m_awake = _state;
Log::Write( LogLevel_Info, "%s, Node %d has been marked as %s", GetDriver()->GetNodeString( GetNodeId() ).c_str(), GetNodeId(), m_awake ? "awake" : "asleep" ); Log::Write( LogLevel_Info, GetNodeId(), " Node %d has been marked as %s", GetNodeId(), m_awake ? "awake" : "asleep" );
} }
if( m_awake ) if( m_awake )

View file

@ -43,7 +43,7 @@ void Controller::PlayInitSequence
_driver->SendMsg( new Msg( "FUNC_ID_ZW_MEMORY_GET_ID", 0xff, REQUEST, FUNC_ID_ZW_MEMORY_GET_ID, false ), Driver::MsgQueue_Command); _driver->SendMsg( new Msg( "FUNC_ID_ZW_MEMORY_GET_ID", 0xff, REQUEST, FUNC_ID_ZW_MEMORY_GET_ID, false ), Driver::MsgQueue_Command);
_driver->SendMsg( new Msg( "FUNC_ID_ZW_GET_CONTROLLER_CAPABILITIES", 0xff, REQUEST, FUNC_ID_ZW_GET_CONTROLLER_CAPABILITIES, false ), Driver::MsgQueue_Command); _driver->SendMsg( new Msg( "FUNC_ID_ZW_GET_CONTROLLER_CAPABILITIES", 0xff, REQUEST, FUNC_ID_ZW_GET_CONTROLLER_CAPABILITIES, false ), Driver::MsgQueue_Command);
_driver->SendMsg( new Msg( "FUNC_ID_SERIAL_API_GET_CAPABILITIES", 0xff, REQUEST, FUNC_ID_SERIAL_API_GET_CAPABILITIES, false ), Driver::MsgQueue_Command); _driver->SendMsg( new Msg( "FUNC_ID_SERIAL_API_GET_CAPABILITIES", 0xff, REQUEST, FUNC_ID_SERIAL_API_GET_CAPABILITIES, false ), Driver::MsgQueue_Command);
//_driver->SendMsg( new Msg( "FUNC_ID_ZW_GET_SUC_NODE_ID", 0xff, REQUEST, FUNC_ID_ZW_GET_SUC_NODE_ID, false ), Driver::MsgQueue_Command); _driver->SendMsg( new Msg( "FUNC_ID_ZW_GET_SUC_NODE_ID", 0xff, REQUEST, FUNC_ID_ZW_GET_SUC_NODE_ID, false ), Driver::MsgQueue_Command);
// FUNC_ID_ZW_GET_VIRTUAL_NODES & FUNC_ID_SERIAL_API_GET_INIT_DATA has moved into the handler for FUNC_ID_SERIAL_API_GET_CAPABILITIES // FUNC_ID_ZW_GET_VIRTUAL_NODES & FUNC_ID_SERIAL_API_GET_INIT_DATA has moved into the handler for FUNC_ID_SERIAL_API_GET_CAPABILITIES
} }

View file

@ -145,7 +145,7 @@ void Log::SetLoggingState
if( _queueLevel <= _saveLevel ) if( _queueLevel <= _saveLevel )
Log::Write( LogLevel_Warning, "Only lower priority messages may be queued for error-driven display." ); Log::Write( LogLevel_Warning, "Only lower priority messages may be queued for error-driven display." );
if( _dumpTrigger >= _queueLevel ) if( _dumpTrigger >= _queueLevel )
Log::Write( LogLevel_Warning, "The trigger for dumping queued messages must be a higher-priority message than the level that is queued.." ); Log::Write( LogLevel_Warning, "The trigger for dumping queued messages must be a higher-priority message than the level that is queued." );
// s_dologging is true if any messages are to be saved in file or queue // s_dologging is true if any messages are to be saved in file or queue
if( (_saveLevel > LogLevel_Always) || if( (_saveLevel > LogLevel_Always) ||
@ -190,11 +190,36 @@ void Log::Write
{ {
if( s_instance && s_dologging && s_instance->m_pImpl ) if( s_instance && s_dologging && s_instance->m_pImpl )
{ {
s_instance->m_logMutex->Lock(); // double locks if recursive
va_list args;
va_start( args, _format );
s_instance->m_pImpl->Write( _level, 0, _format, args );
va_end( args );
s_instance->m_logMutex->Unlock();
}
}
//-----------------------------------------------------------------------------
// <Log::Write>
// Write to the log
//-----------------------------------------------------------------------------
void Log::Write
(
LogLevel _level,
uint8 const _nodeId,
char const* _format,
...
)
{
if( s_instance && s_dologging && s_instance->m_pImpl )
{
if( _level != LogLevel_Internal )
s_instance->m_logMutex->Lock(); s_instance->m_logMutex->Lock();
va_list args; va_list args;
va_start( args, _format ); va_start( args, _format );
s_instance->m_pImpl->Write( _level, _format, args ); s_instance->m_pImpl->Write( _level, _nodeId, _format, args );
va_end( args ); va_end( args );
if( _level != LogLevel_Internal )
s_instance->m_logMutex->Unlock(); s_instance->m_logMutex->Unlock();
} }
} }

View file

@ -56,7 +56,7 @@ namespace OpenZWave
public: public:
i_LogImpl() { } ; i_LogImpl() { } ;
virtual ~i_LogImpl() { } ; virtual ~i_LogImpl() { } ;
virtual void Write( LogLevel _level, char const* _format, va_list _args ) = 0; virtual void Write( LogLevel _level, uint8 const _nodeId, char const* _format, va_list _args ) = 0;
virtual void QueueDump() = 0; virtual void QueueDump() = 0;
virtual void QueueClear() = 0; virtual void QueueClear() = 0;
virtual void SetLoggingState( LogLevel _saveLevel, LogLevel _queueLevel, LogLevel _dumpTrigger ) = 0; virtual void SetLoggingState( LogLevel _saveLevel, LogLevel _queueLevel, LogLevel _dumpTrigger ) = 0;
@ -150,6 +150,17 @@ namespace OpenZWave
*/ */
static void Write( LogLevel _level, char const* _format, ... ); static void Write( LogLevel _level, char const* _format, ... );
/**
* Write an entry to the log.
* Writes a formatted string to the log.
* \param _level Specifies the type of log message (Error, Warning, Debug, etc.)
* \param _nodeId Node Id this entry is about.
* \param _format. A string formatted in the same manner as used with printf etc.
* \param ... a variable number of arguments, to be included in the formatted string.
* \see Create, Destroy
*/
static void Write( LogLevel _level, uint8 const _nodeId, char const* _format, ... );
/** /**
* Send the queued log messages to the log output. * Send the queued log messages to the log output.
*/ */

View file

@ -92,12 +92,14 @@ LogImpl::~LogImpl
void LogImpl::Write void LogImpl::Write
( (
LogLevel _logLevel, LogLevel _logLevel,
uint8 const _nodeId,
char const* _format, char const* _format,
va_list _args va_list _args
) )
{ {
// create a timestamp string // create a timestamp string
string timeStr = GetTimeStampString(); string timeStr = GetTimeStampString();
string nodeStr = GetNodeString( _nodeId );
// handle this message // handle this message
if( (_logLevel <= m_queueLevel) || (_logLevel == LogLevel_Internal) ) // we're going to do something with this message... if( (_logLevel <= m_queueLevel) || (_logLevel == LogLevel_Internal) ) // we're going to do something with this message...
@ -125,6 +127,8 @@ void LogImpl::Write
{ {
strcpy( outBufPtr, timeStr.c_str() ); strcpy( outBufPtr, timeStr.c_str() );
outBufPtr += timeStr.length(); outBufPtr += timeStr.length();
strcpy( outBufPtr, nodeStr.c_str() );
outBufPtr += nodeStr.length();
} }
if( lineLen > 0 ) if( lineLen > 0 )
@ -259,6 +263,32 @@ string LogImpl::GetTimeStampString
return str; return str;
} }
//-----------------------------------------------------------------------------
// <LogImpl::GetNodeString>
// Generate a string with formatted node id
//-----------------------------------------------------------------------------
string LogImpl::GetNodeString
(
uint8 const _nodeId
)
{
if( _nodeId == 0 )
{
return "";
}
else
if( _nodeId == 255 ) // should make distinction between broadcast and controller better for SwitchAll broadcast
{
return "contrlr, ";
}
else
{
char buf[20];
snprintf( buf, sizeof(buf), "Node%03d, ", _nodeId );
return buf;
}
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// <LogImpl::GetThreadId> // <LogImpl::GetThreadId>
// Generate a string with formatted thread id // Generate a string with formatted thread id

View file

@ -44,7 +44,7 @@ namespace OpenZWave
LogImpl( string const& _filename, bool const _bAppendLog, bool const _bConsoleOutput, LogLevel const _saveLevel, LogLevel const _queueLevel, LogLevel const _dumpTrigger ); LogImpl( string const& _filename, bool const _bAppendLog, bool const _bConsoleOutput, LogLevel const _saveLevel, LogLevel const _queueLevel, LogLevel const _dumpTrigger );
~LogImpl(); ~LogImpl();
void Write( LogLevel _level, char const* _format, va_list _args ); void Write( LogLevel _level, uint8 const _nodeId, char const* _format, va_list _args );
void Queue( char const* _buffer ); void Queue( char const* _buffer );
void QueueDump(); void QueueDump();
void QueueClear(); void QueueClear();
@ -52,6 +52,7 @@ namespace OpenZWave
void SetLogFileName( string _filename ); void SetLogFileName( string _filename );
string GetTimeStampString(); string GetTimeStampString();
string GetNodeString( uint8 const _nodeId );
string GetThreadId(); string GetThreadId();
string m_filename; /**< filename specified by user (default is ozw_log.txt) */ string m_filename; /**< filename specified by user (default is ozw_log.txt) */

View file

@ -30,6 +30,7 @@
#include "Log.h" #include "Log.h"
#include "MutexImpl.h" #include "MutexImpl.h"
#include <stdio.h>
#include <errno.h> #include <errno.h>
using namespace OpenZWave; using namespace OpenZWave;
@ -47,7 +48,11 @@ MutexImpl::MutexImpl
pthread_mutexattr_init ( &ma ); pthread_mutexattr_init ( &ma );
pthread_mutexattr_settype( &ma, PTHREAD_MUTEX_RECURSIVE ); pthread_mutexattr_settype( &ma, PTHREAD_MUTEX_RECURSIVE );
pthread_mutex_init( &m_criticalSection, &ma ); int err = pthread_mutex_init( &m_criticalSection, &ma );
if( err != 0 )
{
fprintf(stderr, "MutexImpl::MutexImpl error %d (%d)\n", errno, err );
}
pthread_mutexattr_destroy( &ma ); pthread_mutexattr_destroy( &ma );
} }
@ -74,10 +79,15 @@ bool MutexImpl::Lock
if( _bWait ) if( _bWait )
{ {
// We will wait for the lock // We will wait for the lock
pthread_mutex_lock( &m_criticalSection ); int err = pthread_mutex_lock( &m_criticalSection );
if( err == 0 )
{
++m_lockCount; ++m_lockCount;
return true; return true;
} }
fprintf(stderr, "MutexImpl::Lock error %d (%d)\n", errno, err);
return false;
}
// Returns immediately, even if the lock was not available. // Returns immediately, even if the lock was not available.
if( pthread_mutex_trylock( &m_criticalSection ) ) if( pthread_mutex_trylock( &m_criticalSection ) )
@ -105,7 +115,11 @@ void MutexImpl::Unlock
else else
{ {
--m_lockCount; --m_lockCount;
pthread_mutex_unlock( &m_criticalSection ); int err = pthread_mutex_unlock( &m_criticalSection );
if( err != 0 )
{
fprintf(stderr, "MutexImpl::Unlock error %d (%d)\n", errno, err);
}
} }
} }

View file

@ -91,12 +91,14 @@ LogImpl::~LogImpl
void LogImpl::Write void LogImpl::Write
( (
LogLevel _logLevel, LogLevel _logLevel,
uint8 const _nodeId,
char const* _format, char const* _format,
va_list _args va_list _args
) )
{ {
// create a timestamp string // create a timestamp string
string timeStr = GetTimeStampString(); string timeStr = GetTimeStampString();
string nodeStr = GetNodeString( _nodeId );
// handle this message // handle this message
if( (_logLevel <= m_queueLevel) || (_logLevel == LogLevel_Internal) ) // we're going to do something with this message... if( (_logLevel <= m_queueLevel) || (_logLevel == LogLevel_Internal) ) // we're going to do something with this message...
@ -120,10 +122,10 @@ void LogImpl::Write
{ {
if( _logLevel != LogLevel_Internal ) // don't add a second timestamp to display of queued messages if( _logLevel != LogLevel_Internal ) // don't add a second timestamp to display of queued messages
{ {
fprintf( pFile, "%s", timeStr.c_str() ); fprintf( pFile, "%s%s", timeStr.c_str(), nodeStr.c_str() );
if( m_bConsoleOutput ) if( m_bConsoleOutput )
{ {
printf( "%s", timeStr.c_str() ); printf( "%s%s", timeStr.c_str(), nodeStr.c_str() );
} }
} }
@ -246,6 +248,32 @@ string LogImpl::GetTimeStampString
return str; return str;
} }
//-----------------------------------------------------------------------------
// <LogImpl::GetNodeString>
// Generate a string with formatted node id
//-----------------------------------------------------------------------------
string LogImpl::GetNodeString
(
uint8 const _nodeId
)
{
if( _nodeId == 0 )
{
return "";
}
else
if( _nodeId == 255 ) // should make distinction between broadcast and controller better for SwitchAll broadcast
{
return "contrlr, ";
}
else
{
char buf[20];
snprintf( buf, sizeof(buf), "Node%03d, ", _nodeId );
return buf;
}
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// <LogImpl::GetThreadId> // <LogImpl::GetThreadId>
// Generate a string with formatted thread id // Generate a string with formatted thread id

View file

@ -45,7 +45,7 @@ namespace OpenZWave
LogImpl( string const& _filename, bool const _bAppendLog, bool const _bConsoleOutput, LogLevel const _saveLevel, LogLevel const _queueLevel, LogLevel const _dumpTrigger ); LogImpl( string const& _filename, bool const _bAppendLog, bool const _bConsoleOutput, LogLevel const _saveLevel, LogLevel const _queueLevel, LogLevel const _dumpTrigger );
~LogImpl(); ~LogImpl();
void Write( LogLevel _level, char const* _format, va_list _args ); void Write( LogLevel _level, uint8 const _nodeId, char const* _format, va_list _args );
void Queue( char const* _buffer ); void Queue( char const* _buffer );
void QueueDump(); void QueueDump();
void QueueClear(); void QueueClear();