Skip to content

Commit

Permalink
fix to switchbinary/multilevel cc
Browse files Browse the repository at this point in the history
  • Loading branch information
genemars committed Dec 4, 2015
1 parent c38f092 commit 85bb75b
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion ZWaveLib/CommandClasses/Basic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public NodeEvent GetEvent(ZWaveNode node, byte[] message)
if (cmdType == (byte)Command.BasicReport || cmdType == (byte)Command.BasicSet)
{
int levelValue = (int)message[2];
nodeEvent = new NodeEvent(node, EventParameter.Level, (double)levelValue, 0);
nodeEvent = new NodeEvent(node, EventParameter.Basic, (double)levelValue, 0);
}
return nodeEvent;
}
Expand Down
15 changes: 10 additions & 5 deletions ZWaveLib/CommandClasses/SwitchBinary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,26 @@ public NodeEvent GetEvent(ZWaveNode node, byte[] message)
if (cmdType == (byte)Command.SwitchBinaryReport || cmdType == (byte)Command.SwitchBinarySet) // some devices use this instead of report
{
int levelValue = (int)message[2];
nodeEvent = new NodeEvent(node, EventParameter.Level, (double)levelValue, 0);
nodeEvent = new NodeEvent(node, EventParameter.SwitchBinary, (double)levelValue, 0);
}
return nodeEvent;
}

public static ZWaveMessage Set(ZWaveNode node, int value)
{
// same as basic class
return Basic.Set(node, value);
return node.SendDataRequest(new byte[] {
(byte)CommandClass.SwitchBinary,
(byte)Command.SwitchBinarySet,
byte.Parse(value.ToString())
});
}

public static ZWaveMessage Get(ZWaveNode node)
{
// same as basic class
return Basic.Get(node);
return node.SendDataRequest(new byte[] {
(byte)CommandClass.SwitchBinary,
(byte)Command.SwitchBinaryGet
});
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ZWaveLib/CommandClasses/SwitchMultilevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public NodeEvent GetEvent(ZWaveNode node, byte[] message)
if (cmdType == (byte)Command.SwitchMultilevelReport || cmdType == (byte)Command.SwitchMultilevelSet) // some devices use this instead of report
{
int levelValue = (int)message[2];
nodeEvent = new NodeEvent(node, EventParameter.Level, (double)levelValue, 0);
nodeEvent = new NodeEvent(node, EventParameter.SwitchMultilevel, (double)levelValue, 0);
}
return nodeEvent;
}
Expand Down
2 changes: 1 addition & 1 deletion ZWaveLib/CommandClasses/WakeUp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public static void WakeUpNode(ZWaveNode node)
public static void ResendOnWakeUp(ZWaveNode node, byte[] msg)
{
int minCommandLength = 8;
if (msg.Length >= minCommandLength && (msg[6] != (byte)CommandClass.WakeUp && msg[7] != (byte)Command.WakeUpNoMoreInfo))
if (msg.Length >= minCommandLength && !(msg[6] == (byte)CommandClass.WakeUp && msg[7] == (byte)Command.WakeUpNoMoreInfo))
{
byte[] command = new byte[minCommandLength];
Array.Copy(msg, 0, command, 0, minCommandLength);
Expand Down
4 changes: 3 additions & 1 deletion ZWaveLib/Enums/EventParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ namespace ZWaveLib

public enum EventParameter
{
Level,
Basic,
SwitchBinary,
SwitchMultilevel,
ManufacturerSpecific,
MeterKwHour,
MeterKvaHour,
Expand Down
2 changes: 1 addition & 1 deletion ZWaveLib/ZWaveLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<HintPath>..\packages\NLog.4.1.0\lib\net45\NLog.dll</HintPath>
</Reference>
<Reference Include="SerialPortLib">
<HintPath>..\packages\SerialPortLib.1.0.10\lib\SerialPortLib.dll</HintPath>
<HintPath>..\packages\SerialPortLib.1.0.11\lib\SerialPortLib.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions ZWaveLib/ZWaveLib.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>ZWaveLib</id>
<version>1.0.9</version>
<version>1.0.10</version>
<title>ZWaveLib</title>
<authors>Generoso Martello</authors>
<owners>G-Labs</owners>
Expand All @@ -21,9 +21,9 @@ Features
[Source Code and Home Page]
https://github.com/genielabs/zwave-lib-dotnet</description>
<summary>Z-Wave library for Home Automation (.NET / Mono)</summary>
<releaseNotes>- Fixed packet fragmentation issue (affecting RaZberry) and timeout errors occurring with some devices (eg. Fibaro in wall switches).
- Added WakeUp.SendToSleep command
- Added WakeUp on NodeInfo</releaseNotes>
<releaseNotes>- Fixed WakeUp class bug, it was queuing send to sleep commands
- Fixed SwitchBinary class that was sending out messages as Basic cc
- Assigned proper events to Basic, SwitchBinary and SwitchMultilevel report</releaseNotes>
<copyright>G-Labs</copyright>
<tags>zwave z-wave home automation</tags>
<dependencies>
Expand Down
4 changes: 2 additions & 2 deletions ZWaveLib/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NLog" version="4.1.0" targetFramework="net45" />
<package id="SerialPortLib" version="1.0.10" targetFramework="net45" />
<package id="SerialPortLib" version="1.0.11" targetFramework="net45" />
</packages>

0 comments on commit 85bb75b

Please sign in to comment.