----------------------------------------------------------------------------- Update a node's routing information -----------------------------------------------------------------------------
| 6843 | // Update a node's routing information |
| 6844 | //----------------------------------------------------------------------------- |
| 6845 | void Driver::UpdateNodeRoutes |
| 6846 | ( |
| 6847 | uint8 const _nodeId, |
| 6848 | bool _doUpdate // = false |
| 6849 | ) |
| 6850 | { |
| 6851 | // Only for routing slaves |
| 6852 | Node* node = GetNodeUnsafe( _nodeId ); |
| 6853 | if( node != NULL && node->GetBasic() == 0x04 ) |
| 6854 | { |
| 6855 | uint8 numGroups = GetNumGroups( _nodeId ); |
| 6856 | uint8 numNodes = 0; |
| 6857 | uint8 nodes[5]; |
| 6858 | InstanceAssociation* associations; |
| 6859 | uint8 i; |
| 6860 | |
| 6861 | // Determine up to 5 destinations |
| 6862 | |
| 6863 | memset( nodes, 0, sizeof(nodes) ); |
| 6864 | for( i = 1; i <= numGroups && numNodes < sizeof(nodes) ; i++ ) |
| 6865 | { |
| 6866 | associations = NULL; |
| 6867 | uint32 len = GetAssociations( _nodeId, i, &associations ); |
| 6868 | for( uint8 j = 0; j < len; j++ ) |
| 6869 | { |
| 6870 | uint8 k; |
| 6871 | /* there is a gcc bug that triggers here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59124 |
| 6872 | * see also https://github.com/OpenZWave/open-zwave/issues/586 |
| 6873 | */ |
| 6874 | for( k = 0; k < numNodes && k < sizeof(nodes); k++ ) |
| 6875 | { |
| 6876 | if( nodes[k] == associations[j].m_nodeId ) |
| 6877 | { |
| 6878 | break; |
| 6879 | } |
| 6880 | } |
| 6881 | if( k >= numNodes && numNodes < sizeof(nodes) ) // not in list so add it |
| 6882 | { |
| 6883 | nodes[numNodes++] = associations[j].m_nodeId; |
| 6884 | } |
| 6885 | } |
| 6886 | if( associations != NULL ) |
| 6887 | { |
| 6888 | delete [] associations; |
| 6889 | } |
| 6890 | } |
| 6891 | if( _doUpdate || numNodes != node->m_numRouteNodes || memcmp( nodes, node->m_routeNodes, sizeof(node->m_routeNodes) ) != 0 ) |
| 6892 | { |
| 6893 | // Figure out what to do if one of these fail. |
| 6894 | BeginControllerCommand( ControllerCommand_DeleteAllReturnRoutes, NULL, NULL, true, _nodeId, 0 ); |
| 6895 | for( i = 0; i < numNodes; i++ ) |
| 6896 | { |
| 6897 | BeginControllerCommand( ControllerCommand_AssignReturnRoute, NULL, NULL, true, _nodeId, nodes[i] ); |
| 6898 | } |
| 6899 | node->m_numRouteNodes = numNodes; |
| 6900 | memcpy( node->m_routeNodes, nodes, sizeof(nodes) ); |
| 6901 | } |
| 6902 | } |
no test coverage detected