MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / WriteMsg

Method WriteMsg

cpp/src/Driver.cpp:1227–1372  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Transmit the current message to the Z-Wave controller -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1225// Transmit the current message to the Z-Wave controller
1226//-----------------------------------------------------------------------------
1227bool Driver::WriteMsg
1228(
1229 string const &msg
1230)
1231{
1232 if( !m_currentMsg )
1233 {
1234 Log::Write( LogLevel_Detail, GetNodeNumber( m_currentMsg ), "WriteMsg %s m_currentMsg=%08x", msg.c_str(), m_currentMsg );
1235 // We try not to hang when this happenes
1236 m_expectedCallbackId = 0;
1237 m_expectedCommandClassId = 0;
1238 m_expectedNodeId = 0;
1239 m_expectedReply = 0;
1240 m_waitingForAck = false;
1241 return false;
1242 }
1243 /* if this is called with m_nonceReportSent > 0 it means that we have
1244 * tried to send a NONCE report and it timed out or was NAK'd
1245 *
1246 */
1247 uint8 attempts;
1248 uint8 nodeId;
1249 if (m_nonceReportSent > 0) {
1250 attempts = m_nonceReportSentAttempt++;
1251 nodeId = m_nonceReportSent;
1252 } else {
1253 attempts = m_currentMsg->GetSendAttempts();
1254 nodeId = m_currentMsg->GetTargetNodeId();
1255 }
1256 LockGuard LG(m_nodeMutex);
1257 Node* node = GetNode( nodeId );
1258 if( attempts >= m_currentMsg->GetMaxSendAttempts() ||
1259 (node != NULL && !node->IsNodeAlive() && !m_currentMsg->IsNoOperation() ) )
1260 {
1261 if( node != NULL && !node->IsNodeAlive() )
1262 {
1263 Log::Write( LogLevel_Error, nodeId, "ERROR: Dropping command because node is presumed dead" );
1264 }
1265 else
1266 {
1267 // That's it - already tried to send GetMaxSendAttempt() times.
1268 Log::Write( LogLevel_Error, nodeId, "ERROR: Dropping command, expected response not received after %d attempt(s)", m_currentMsg->GetMaxSendAttempts() );
1269 }
1270 if( m_currentControllerCommand != NULL )
1271 {
1272 /* its a ControllerCommand that is failed */
1273 UpdateControllerState( ControllerState_Error, ControllerError_Failed);
1274
1275 }
1276
1277 RemoveCurrentMsg();
1278 m_dropped++;
1279 return false;
1280 }
1281
1282 if (( attempts != 0) && (m_nonceReportSent == 0))
1283 {
1284 // this is not the first attempt, so increment the callback id before sending

Callers

nothing calls this directly

Calls 12

WriteFunction · 0.85
IsNodeAliveMethod · 0.80
UpdateCallbackIdMethod · 0.80
GenerateNonceKeyMethod · 0.80
GetBufferMethod · 0.80
GetLengthMethod · 0.80
StopMethod · 0.80
GetCommandClassMethod · 0.80
c_strMethod · 0.45
GetAsStringMethod · 0.45
WriteMethod · 0.45
SetTimeMethod · 0.45

Tested by

no test coverage detected