Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/tuyanet.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2022-07-11 14:35:11 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2022-07-11 14:35:11 +0300
commita2c7515e481514aee47663a852548902d77f7328 (patch)
tree3dbaa2c2abdd7facbc396f6a1835b59ca064b658
parent66474cdbedaba328ffca4417a7e46e50dff4bc90 (diff)
Refactoring.
-rw-r--r--TuyaIRControl.cs34
1 files changed, 26 insertions, 8 deletions
diff --git a/TuyaIRControl.cs b/TuyaIRControl.cs
index 9a399a3..b8c7139 100644
--- a/TuyaIRControl.cs
+++ b/TuyaIRControl.cs
@@ -14,6 +14,25 @@ namespace com.clusterrr.TuyaNet
/// </summary>
public class TuyaIRControl : TuyaDevice
{
+ public const int DP_SEND_IR = 201; // ir_send, send and report (read-write)
+ public const int DP_LEARNED_ID = 202; // ir_study_code, report only (read-only)
+ public const string NSDP_CONTROL = "control"; // The control commands
+ public const string NSDP_STUDY_CODE = "study_code"; // Report learned IR codes
+ public const string NSDP_IR_CODE = "ir_code"; // IR signal decoding2
+ public const string NSDP_KEY_CODE = "key_code"; // Remote key code
+ public const string NSDP_KEY_CODE2 = "key_code2"; // Remote key code 2
+ public const string NSDP_KEY_CODE3 = "key_code3"; // Remote key code 3
+ public const string NSDP_KEY_CODE4 = "key_code4"; // Remote key code 4
+ public const string NSDP_KEY_STUDY = "key_study"; // Send the learning code 1
+ public const string NSDP_KEY_STUDY2 = "key_study2"; // Send the learning code 2
+ public const string NSDP_KEY_STUDY3 = "key_study3"; // Send the learning code 3
+ public const string NSDP_KEY_STUDY4 = "key_study4"; // Send the learning code 4
+ public const string NSDP_DELAY_TIME = "delay_time"; // IR code transmission delay
+ public const string NSDP_TYPE = "type"; // The identifier of an IR library
+ public const string NSDP_DELAY = "delay"; // Actually used but not documented
+ public const string NSDP_HEAD = "head"; // Actually used but not documented
+ public const string NSDP_KEY1 = "key1"; // Actually used but not documented
+
/// <summary>
/// Creates a new instance of the TuyaDevice class.
/// </summary>
@@ -56,7 +75,7 @@ namespace com.clusterrr.TuyaNet
{
var subCmd = new Dictionary<string, object>()
{
- { "control", "study_exit" }
+ { NSDP_CONTROL, "study_exit" }
};
var subCmdJson = JsonConvert.SerializeObject(subCmd);
await SetDpsAsync(new Dictionary<int, object>() { { 201, subCmdJson } }, nullRetries: 0, allowEmptyResponse: true, cancellationToken: cancellationToken);
@@ -65,7 +84,7 @@ namespace com.clusterrr.TuyaNet
subCmd = new Dictionary<string, object>()
{
- { "control", "study" }
+ { NSDP_CONTROL, "study" }
};
subCmdJson = JsonConvert.SerializeObject(subCmd);
await SetDpsAsync(new Dictionary<int, object>() { { 201, subCmdJson } }, cancellationToken: cancellationToken);
@@ -86,7 +105,7 @@ namespace com.clusterrr.TuyaNet
{
var subCmd = new Dictionary<string, object>()
{
- { "control", "study_exit" }
+ { NSDP_CONTROL, "study_exit" }
};
var subCmdJson = JsonConvert.SerializeObject(subCmd);
await SetDpsAsync(new Dictionary<int, object>() { { 201, subCmdJson } }, nullRetries: 0, allowEmptyResponse: true, cancellationToken: cancellationToken);
@@ -104,11 +123,10 @@ namespace com.clusterrr.TuyaNet
{
var subCmd = new Dictionary<string, object>()
{
- { "control", "send_ir" },
- { "head", "" },
- { "key1", buttonCode.Length % 4 == 0 ? "1" + buttonCode : buttonCode }, // code need to be padded with "1" (wtf?)
- { "type", 0 },
- { "delay", 0 }
+ { NSDP_CONTROL, "send_ir" },
+ { NSDP_KEY1, buttonCode.Length % 4 == 0 ? "1" + buttonCode : buttonCode }, // code need to be padded with "1" (wtf?)
+ { NSDP_TYPE, 0 },
+ { NSDP_DELAY, 0 }
};
var subCmdJson = JsonConvert.SerializeObject(subCmd);
await SetDpsAsync(new Dictionary<int, object>() { { 201, subCmdJson } }, retries: retries,