----------------------------------------------------------------------------- Handle a message from the Z-Wave network -----------------------------------------------------------------------------
| 215 | // Handle a message from the Z-Wave network |
| 216 | //----------------------------------------------------------------------------- |
| 217 | bool ManufacturerSpecific::HandleMsg |
| 218 | ( |
| 219 | uint8 const* _data, |
| 220 | uint32 const _length, |
| 221 | uint32 const _instance // = 1 |
| 222 | ) |
| 223 | { |
| 224 | if( ManufacturerSpecificCmd_Report == (ManufacturerSpecificCmd)_data[0] ) |
| 225 | { |
| 226 | |
| 227 | // first two bytes are manufacturer id code |
| 228 | uint16 manufacturerId = (((uint16)_data[1])<<8) | (uint16)_data[2]; |
| 229 | |
| 230 | // next four are product type and product id |
| 231 | uint16 productType = (((uint16)_data[3])<<8) | (uint16)_data[4]; |
| 232 | uint16 productId = (((uint16)_data[5])<<8) | (uint16)_data[6]; |
| 233 | |
| 234 | if( Node* node = GetNodeUnsafe() ) |
| 235 | { |
| 236 | // Attempt to create the config parameters |
| 237 | SetProductDetails(manufacturerId, productType, productId); |
| 238 | ClearStaticRequest( StaticRequest_Values ); |
| 239 | node->m_manufacturerSpecificClassReceived = true; |
| 240 | |
| 241 | if( node->getConfigPath().size() > 0 ) |
| 242 | { |
| 243 | LoadConfigXML( ); |
| 244 | } |
| 245 | |
| 246 | Log::Write( LogLevel_Info, GetNodeId(), "Received manufacturer specific report from node %d: Manufacturer=%s, Product=%s", |
| 247 | GetNodeId(), node->GetManufacturerName().c_str(), node->GetProductName().c_str() ); |
| 248 | Log::Write( LogLevel_Info, GetNodeId(), "Node Identity Codes: %.4x:%.4x:%.4x", manufacturerId, productType, productId ); |
| 249 | } |
| 250 | |
| 251 | // Notify the watchers of the name changes |
| 252 | Notification* notification = new Notification( Notification::Type_NodeNaming ); |
| 253 | notification->SetHomeAndNodeIds( GetHomeId(), GetNodeId() ); |
| 254 | GetDriver()->QueueNotification( notification ); |
| 255 | |
| 256 | return true; |
| 257 | } else if( ManufacturerSpecificCmd_DeviceReport == (ManufacturerSpecificCmd)_data[0] ) { |
| 258 | uint8 deviceIDType = (_data[1] & 0x07); |
| 259 | uint8 dataFormat = (_data[2] & 0xe0)>>0x05; |
| 260 | uint8 data_length = (_data[2] & 0x1f); |
| 261 | uint8 const* deviceIDData = &_data[3]; |
| 262 | string deviceID = ""; |
| 263 | for (int i=0; i<data_length; i++) { |
| 264 | char temp_chr[32]; |
| 265 | memset(temp_chr, 0, sizeof(temp_chr)); |
| 266 | if (dataFormat == 0x00) { |
| 267 | temp_chr[0] = deviceIDData[i]; |
| 268 | } else { |
| 269 | snprintf(temp_chr, sizeof(temp_chr), "%.2x", deviceIDData[i]); |
| 270 | } |
| 271 | deviceID += temp_chr; |
| 272 | } |
| 273 | if (deviceIDType == DeviceSpecificGet_DeviceIDType_FactoryDefault) { |
| 274 | ValueString *default_value = static_cast<ValueString*>( GetValue(_instance, ManufacturerSpecific_DeviceID) ); |
nothing calls this directly
no test coverage detected