Skip to content

Commit

Permalink
Merge pull request #10 from PepperDash/feature/testing-updates
Browse files Browse the repository at this point in the history
Feature/testing updates
  • Loading branch information
andrew-welker authored May 16, 2024
2 parents 2dc0144 + b0faa1b commit 977d4ec
Show file tree
Hide file tree
Showing 8 changed files with 555 additions and 302 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/EssentialsPlugins-builds-caller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@ jobs:
getVersion:
uses: PepperDash/workflow-templates/.github/workflows/essentialsplugins-getversion.yml@main
secrets: inherit
build-3Series:
uses: PepperDash/workflow-templates/.github/workflows/essentialsplugins-3Series-builds.yml@main
secrets: inherit
needs: getVersion
if: needs.getVersion.outputs.newVersion == 'true'
with:
newVersion: ${{ needs.getVersion.outputs.newVersion }}
version: ${{ needs.getVersion.outputs.version }}
tag: ${{ needs.getVersion.outputs.tag }}
channel: ${{ needs.getVersion.outputs.channel }}
build-4Series:
uses: PepperDash/workflow-templates/.github/workflows/essentialsplugins-4Series-builds.yml@main
secrets: inherit
Expand Down
27 changes: 27 additions & 0 deletions src/Rs232Commands.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Linq;
using Independentsoft.Email.Mime;
using PepperDash.Core;
using PepperDash.Essentials.Core.Queues;

Expand Down Expand Up @@ -311,6 +312,29 @@ public static IQueueMessage GetInputQuery(IBasicCommunication coms, Action<eComm
}*/
}

public class Rs232Response : IQueueMessage
{
private readonly Action<byte[]> action;
private readonly byte[] _message;

public Rs232Response(byte[] message, Action<byte[]> action)
{
_message = message;

this.action = action;
}

public void Dispatch()
{
if(action == null || _message.Length == 0)
{
return;
}

action(_message);
}
}

public class Rs232Command:IQueueMessage
{
private readonly Action<eCommandType> _action;
Expand All @@ -321,6 +345,8 @@ public class Rs232Command:IQueueMessage

private readonly eCommandType _commandType;

public eCommandType CommandType => _commandType;

public Rs232Command(IBasicCommunication coms, byte[] message, Action<eCommandType> updateCommandAction, eCommandType commandType)
{
if(coms == null)
Expand Down Expand Up @@ -360,6 +386,7 @@ public void Dispatch()
{
_action(_commandType);

Debug.Console(DebugLevels.DebugLevel, "Sending command {0}", _message.ToReadableString());
_comm.SendBytes(_message);
}

Expand Down
7 changes: 5 additions & 2 deletions src/Rs232ParsingUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ public static class Rs232ParsingUtils

public static bool ParsePowerResponse(this byte[] response)
{
Debug.Console(DebugLevels.DebugLevel, "ParsePowerResponse response: {0}", response.ToReadableString());
Debug.Console(DebugLevels.DebugLevel, "ParsePowerResponse response: {0}", ComTextHelper.GetEscapedText(response));

if (response[2] == 0x00)
{

return response[3] == 0x01;
}

Expand All @@ -44,7 +45,7 @@ public static bool ParsePowerResponse(this byte[] response)
public static string ParseInputResponse(this byte[] response)
{
// TODO [ ] actually add in parsing
Debug.Console(DebugLevels.DebugLevel, "ParseInputResponse response: {0}", response.ToReadableString());
Debug.Console(DebugLevels.DebugLevel, "ParseInputResponse response: {0}", ComTextHelper.GetEscapedText(response));

//add together the input type byte & the input number byte
var inputNumber = response[3] << 8 | response[4];
Expand All @@ -62,6 +63,7 @@ public static string ParseInputResponse(this byte[] response)

public static int ParseVolumeResponse(this byte[] response)
{
Debug.Console(DebugLevels.DebugLevel, "ParseVolumeResponse response: {0}", ComTextHelper.GetEscapedText(response));
//not a direct volume response
if (response[3] != 0x01)
{
Expand All @@ -78,6 +80,7 @@ public static int ParseVolumeResponse(this byte[] response)
/// <returns></returns>
public static bool ParseMuteResponse(this byte[] response)
{
Debug.Console(DebugLevels.DebugLevel, "ParseMuteResponse response: {0}", ComTextHelper.GetEscapedText(response));
//not a direct mute response
if (response[3] != 0x01) { return false; }

Expand Down
19 changes: 18 additions & 1 deletion src/SonyBraviaConfig.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using PepperDash.Core;
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using System.Collections.Generic;

namespace SonyBraviaEpi
{
Expand All @@ -11,5 +13,20 @@ public class SonyBraviaConfig
public long? WarmingTimeMs { get; set; }
public long? CoolingTimeMs { get; set; }
public bool ForceRs232 { get; set; }

[JsonProperty("maxVolumeLevel")]
public byte MaxVolumeLevel { get; set; } = 0xFF;

[JsonProperty("activeInputs")]
public List<SonyBraviaInputConfig> ActiveInputs { get; set; } = new List<SonyBraviaInputConfig>();
}

public class SonyBraviaInputConfig:IKeyName
{
[JsonProperty("key")]
public string Key { get; set; } = string.Empty;

[JsonProperty("name")]
public string Name { get; set; } = string.Empty;
}
}
Loading

0 comments on commit 977d4ec

Please sign in to comment.