Rev 1997 | Rev 2114 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1997 | Rev 2072 | ||
|---|---|---|---|
| 1 | 1 | ||
| 2 | IROut_ModuleNames = [ "irTransmit", "rfTransceive" ]; |
2 | IROut_ModuleNames = [ "irTransmit", "rfTransceive" ]; |
| 3 | IROut_Channels = function() { return [ 0 ]; }; |
3 | IROut_Channels = function() { return [ 0 ]; }; |
| 4 | IROut_Statuses = function() { return [ "Pressed", "Released", "Burst" ]; }; |
4 | IROut_Statuses = function() { return [ "Pressed", "Released", "Burst" ]; }; |
| 5 | IROut_Protocols = function() { return [ "RC5", "RC6", "RCMM", "SIRC", "Sharp", "NEC", "Samsung", "Marantz", "Panasonic", "Sky", "Nexa2" ]; }; |
5 | IROut_Protocols = function() { return [ "RC5", "RC6", "RCMM", "SIRC", "Sharp", "NEC", "Samsung", "Marantz", "Panasonic", "Sky", "Nexa2", "Nexa" ]; }; |
| 6 | IROut_Aliases = function() { return Module_GetAliasNames(IROut_ModuleNames); }; |
6 | IROut_Aliases = function() { return Module_GetAliasNames(IROut_ModuleNames); }; |
| 7 | IROut_AvailableIds = function() { return Module_GetAvailableIds(IROut_ModuleNames); }; |
7 | IROut_AvailableIds = function() { return Module_GetAvailableIds(IROut_ModuleNames); }; |
| 8 | 8 | ||
| 9 | function IROut_StopSend(alias_name) |
9 | function IROut_StopSend(alias_name) |
| 10 | { |
10 | { |
| 11 | if (arguments.length < 1) |
11 | if (arguments.length < 1) |
| 12 | { |
12 | { |
| 13 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
13 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 14 | return false; |
14 | return false; |
| 15 | } |
15 | } |
| 16 | 16 | ||
| 17 | var aliases_data = Module_ResolveAlias(alias_name, IROut_ModuleNames); |
17 | var aliases_data = Module_ResolveAlias(alias_name, IROut_ModuleNames); |
| 18 | var found = false; |
18 | var found = false; |
| 19 | 19 | ||
| 20 | for (var name in aliases_data) |
20 | for (var name in aliases_data) |
| 21 | { |
21 | { |
| 22 | var variables = { |
22 | var variables = { |
| 23 | "Channel" : aliases_data[name]["specific"]["Channel"], |
23 | "Channel" : aliases_data[name]["specific"]["Channel"], |
| 24 | "Status" : "Released" }; |
24 | "Status" : "Released" }; |
| 25 | 25 | ||
| 26 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "IR", variables)) |
26 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "IR", variables)) |
| 27 | { |
27 | { |
| 28 | Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
28 | Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
| 29 | } |
29 | } |
| 30 | else |
30 | else |
| 31 | { |
31 | { |
| 32 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
32 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
| 33 | } |
33 | } |
| 34 | 34 | ||
| 35 | found = true; |
35 | found = true; |
| 36 | } |
36 | } |
| 37 | 37 | ||
| 38 | if (!found) |
38 | if (!found) |
| 39 | { |
39 | { |
| 40 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
40 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
| 41 | return false; |
41 | return false; |
| 42 | } |
42 | } |
| 43 | 43 | ||
| 44 | return true; |
44 | return true; |
| 45 | } |
45 | } |
| 46 | Console_RegisterCommand(IROut_StopSend, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, IROut_Aliases()); }); |
46 | Console_RegisterCommand(IROut_StopSend, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, IROut_Aliases()); }); |
| 47 | 47 | ||
| 48 | function IROut_StartSendAutoComplete(arg_index, args) |
48 | function IROut_StartSendAutoComplete(arg_index, args) |
| 49 | { |
49 | { |
| 50 | if (arg_index == 0) |
50 | if (arg_index == 0) |
| 51 | { |
51 | { |
| 52 | return IROut_Aliases(); |
52 | return IROut_Aliases(); |
| 53 | } |
53 | } |
| 54 | else if (arg_index == 1) |
54 | else if (arg_index == 1) |
| 55 | { |
55 | { |
| 56 | return get_keys(Storage_GetParameters("RemoteList")); |
56 | return get_keys(Storage_GetParameters("RemoteList")); |
| 57 | } |
57 | } |
| 58 | else if (arg_index == 2) |
58 | else if (arg_index == 2) |
| 59 | { |
59 | { |
| 60 | var remote_storage_name = Storage_GetParameter("RemoteList", args[arg_index - 1]); |
60 | var remote_storage_name = Storage_GetParameter("RemoteList", args[arg_index - 1]); |
| 61 | 61 | ||
| 62 | return get_keys(Storage_GetParameters(remote_storage_name)); |
62 | return get_keys(Storage_GetParameters(remote_storage_name)); |
| 63 | } |
63 | } |
| 64 | 64 | ||
| 65 | return []; |
65 | return []; |
| 66 | } |
66 | } |
| - | 67 | ||
| - | 68 | function IROut_Send_Raw(alias_name, protocol, data, status) |
|
| - | 69 | { |
|
| - | 70 | if (arguments.length < 4) |
|
| - | 71 | { |
|
| - | 72 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
|
| - | 73 | return false; |
|
| - | 74 | } |
|
| - | 75 | ||
| - | 76 | var aliases_data = Module_ResolveAlias(alias_name, IROut_ModuleNames); |
|
| - | 77 | ||
| - | 78 | for (var name in aliases_data) |
|
| - | 79 | { |
|
| - | 80 | var variables = { |
|
| - | 81 | "Channel" : aliases_data[name]["specific"]["Channel"], |
|
| - | 82 | "Protocol" : protocol, |
|
| - | 83 | "IRdata" : data, |
|
| - | 84 | "Status" : status }; |
|
| - | 85 | ||
| - | 86 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "IR", variables)) |
|
| - | 87 | { |
|
| - | 88 | Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
|
| - | 89 | } |
|
| - | 90 | else |
|
| - | 91 | { |
|
| - | 92 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
|
| - | 93 | } |
|
| - | 94 | ||
| - | 95 | found = true; |
|
| - | 96 | } |
|
| - | 97 | ||
| - | 98 | if (!found) |
|
| - | 99 | { |
|
| - | 100 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
|
| - | 101 | return false; |
|
| - | 102 | } |
|
| - | 103 | ||
| - | 104 | return true; |
|
| - | 105 | } |
|
| - | 106 | ||
| 67 | 107 | ||
| 68 | function IROut_Send(alias_name, remote_name, button_name, status) |
108 | function IROut_Send(alias_name, remote_name, button_name, status) |
| 69 | { |
109 | { |
| 70 | if (arguments.length < 4) |
110 | if (arguments.length < 4) |
| 71 | { |
111 | { |
| 72 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
112 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 73 | return false; |
113 | return false; |
| 74 | } |
114 | } |
| 75 | - | ||
| 76 | var result_text = ""; |
- | |
| 77 | var aliases_data = Module_ResolveAlias(alias_name, IROut_ModuleNames); |
- | |
| 78 | 115 | ||
| 79 | var remote_storage_name = Storage_GetParameter("RemoteList", remote_name); |
116 | var remote_storage_name = Storage_GetParameter("RemoteList", remote_name); |
| 80 | 117 | ||
| 81 | if (!remote_storage_name) |
118 | if (!remote_storage_name) |
| 82 | { |
119 | { |
| 83 | Log("\033[31mNo such remote name in list, " + remote_name + ".\033[0m\n"); |
120 | Log("\033[31mNo such remote name in list, " + remote_name + ".\033[0m\n"); |
| 84 | return false; |
121 | return false; |
| 85 | } |
122 | } |
| 86 | 123 | ||
| 87 | var button_string = Storage_GetParameter(remote_storage_name, button_name); |
124 | var button_string = Storage_GetParameter(remote_storage_name, button_name); |
| 88 | 125 | ||
| 89 | if (!button_string) |
126 | if (!button_string) |
| 90 | { |
127 | { |
| 91 | Log("\033[31mNo such button " + button_name + " found on remote " + remote + ".\033[0m\n"); |
128 | Log("\033[31mNo such button " + button_name + " found on remote " + remote + ".\033[0m\n"); |
| 92 | return false; |
129 | return false; |
| 93 | } |
130 | } |
| 94 | 131 | ||
| 95 | var button_data = eval("(" + button_string + ")"); |
132 | var button_data = eval("(" + button_string + ")"); |
| 96 | 133 | ||
| 97 | if (typeof button_data["protocol"] == 'undefined' || typeof button_data["data"] == 'undefined') |
134 | if (typeof button_data["protocol"] == 'undefined' || typeof button_data["data"] == 'undefined') |
| 98 | { |
135 | { |
| 99 | Log("\033[31mButton data is corrupt.\033[0m\n"); |
136 | Log("\033[31mButton data is corrupt.\033[0m\n"); |
| 100 | return false; |
137 | return false; |
| 101 | } |
138 | } |
| 102 | 139 | ||
| 103 | for (var name in aliases_data) |
- | |
| 104 | { |
- | |
| 105 | var variables = { |
- | |
| 106 | "Channel" : aliases_data[name]["specific"]["Channel"], |
- | |
| 107 | "Protocol" : button_data["protocol"], |
- | |
| 108 | "IRdata" : button_data["data"], |
- | |
| 109 | "Status" : status }; |
- | |
| 110 | - | ||
| 111 |
|
140 | return IROut_Send_Raw(alias_name, button_data["protocol"], button_data["data"], status); |
| 112 | { |
- | |
| 113 | Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
- | |
| 114 | } |
- | |
| 115 | else |
- | |
| 116 | { |
- | |
| 117 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
- | |
| 118 | } |
- | |
| 119 | - | ||
| 120 | found = true; |
- | |
| 121 | } |
- | |
| 122 | - | ||
| 123 | if (!found) |
- | |
| 124 | { |
- | |
| 125 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
- | |
| 126 | return false; |
- | |
| 127 | } |
- | |
| 128 | - | ||
| 129 | return true; |
- | |
| 130 | } |
141 | } |
| 131 | 142 | ||
| 132 | function IROut_StartSend(alias_name, remote_name, button_name) |
143 | function IROut_StartSend(alias_name, remote_name, button_name) |
| 133 | { |
144 | { |
| 134 | return IROut_Send(alias_name, remote_name, button_name, "Pressed"); |
145 | return IROut_Send(alias_name, remote_name, button_name, "Pressed"); |
| 135 | } |
146 | } |
| 136 | Console_RegisterCommand(IROut_StartSend, IROut_StartSendAutoComplete); |
147 | Console_RegisterCommand(IROut_StartSend, IROut_StartSendAutoComplete); |
| 137 | 148 | ||
| 138 | function IROut_SendBurst(alias_name, remote_name, button_name) |
149 | function IROut_SendBurst(alias_name, remote_name, button_name) |
| 139 | { |
150 | { |
| 140 | return IROut_Send(alias_name, remote_name, button_name, "Burst"); |
151 | return IROut_Send(alias_name, remote_name, button_name, "Burst"); |
| 141 | } |
152 | } |
| 142 | Console_RegisterCommand(IROut_SendBurst, IROut_StartSendAutoComplete); |
153 | Console_RegisterCommand(IROut_SendBurst, IROut_StartSendAutoComplete); |
| 143 | 154 | ||
| 144 | 155 | ||