30 fprintf(stdout, "mbsePi-apps send v%s\n\n", VERSION); |
30 fprintf(stdout, "mbsePi-apps send v%s\n\n", VERSION); |
31 fprintf(stdout, "Usage: send [-t type ] [-f family ] [-g group ] [-d device] [-s state ] [-h]\n"); |
31 fprintf(stdout, "Usage: send [-t type ] [-f family ] [-g group ] [-d device] [-s state ] [-h]\n"); |
32 fprintf(stdout, " send -t A -g 00001 -d 00001 -s 1\n"); |
32 fprintf(stdout, " send -t A -g 00001 -d 00001 -s 1\n"); |
33 fprintf(stdout, " send -t B -g 2 -d 2 -s 0\n"); |
33 fprintf(stdout, " send -t B -g 2 -d 2 -s 0\n"); |
34 fprintf(stdout, " send -t C -f c -g 3 -d 3 -s 1\n"); |
34 fprintf(stdout, " send -t C -f c -g 3 -d 3 -s 1\n"); |
35 fprintf(stdout, " send -t D -g A -d 2 -s 0\n"); |
35 fprintf(stdout, "\n"); |
|
36 fprintf(stdout, " send -t E -g A -d 2 -s 0\n"); |
36 } |
37 } |
37 |
38 |
38 |
39 |
39 |
40 |
40 int isAcode(char *s) |
41 int isAcode(char *s) |
116 } |
117 } |
117 |
118 |
118 /* |
119 /* |
119 * Check all option and combinations |
120 * Check all option and combinations |
120 */ |
121 */ |
121 if ((cType < 'A') || (cType > 'D')) { |
122 if ((cType < 'A') || (cType > 'E')) { |
122 fprintf(stderr, "Type must be A, B, C or D\n"); |
123 fprintf(stderr, "Type must be A, B, C or E\n"); |
123 return 1; |
124 return 1; |
124 } |
125 } |
125 if ((iState < 0) || (iState > 1)) { |
126 if ((iState < 0) || (iState > 1)) { |
126 fprintf(stderr, "State must be 0 or 1\n"); |
127 fprintf(stderr, "State must be 0 or 1\n"); |
127 return 1; |
128 return 1; |
161 if ((iDevice < 1) || (iDevice > 4)) { |
162 if ((iDevice < 1) || (iDevice > 4)) { |
162 fprintf(stderr, "Device must be 1..4\n"); |
163 fprintf(stderr, "Device must be 1..4\n"); |
163 return 1; |
164 return 1; |
164 } |
165 } |
165 } |
166 } |
166 if (cType == 'D') { |
167 if (cType == 'E') { |
167 if ((iDevice < 1) || (iDevice > 3)) { |
168 if ((iDevice < 1) || (iDevice > 3)) { |
168 fprintf(stderr, "Device must be 1..3\n"); |
169 fprintf(stderr, "Device must be 1..3\n"); |
169 return 1; |
170 return 1; |
170 } |
171 } |
171 if ((cGroup < 'A') || (cGroup > 'D')) { |
172 if ((cGroup < 'A') || (cGroup > 'D')) { |
192 |
193 |
193 enableTransmit(PIN); |
194 enableTransmit(PIN); |
194 switch (cType) { |
195 switch (cType) { |
195 case 'A': |
196 case 'A': |
196 printf("Type A sending group[%s] device[%s] command[%d]\n", sGroup, sDevice, iState); |
197 printf("Type A sending group[%s] device[%s] command[%d]\n", sGroup, sDevice, iState); |
197 if (iState) |
198 toggleTypeA(sGroup, sDevice, iState); |
198 switchOn_A(sGroup, sDevice); |
|
199 else |
|
200 switchOff_A(sGroup, sDevice); |
|
201 break; |
199 break; |
202 case 'B': |
200 case 'B': |
203 printf("Type B sending group[%d] device[%i] command[%i]\n", iGroup, iDevice, iState); |
201 printf("Type B sending group[%d] device[%i] command[%i]\n", iGroup, iDevice, iState); |
204 if (iState) |
202 toggleTypeB(iGroup, iDevice, iState); |
205 switchOn_B(iGroup, iDevice); |
|
206 else |
|
207 switchOff_B(iGroup, iDevice); |
|
208 break; |
203 break; |
209 case 'C': |
204 case 'C': |
210 printf("Type C sending family[%c] group[%d] device[%i] command[%i]\n", cFamily, iGroup, iDevice, iState); |
205 printf("Type C sending family[%c] group[%d] device[%i] command[%i]\n", cFamily, iGroup, iDevice, iState); |
211 if (iState) |
206 toggleTypeC(cFamily, iGroup, iDevice, iState); |
212 switchOn_C(cFamily, iGroup, iDevice); |
207 break; |
213 else |
208 case 'E': |
214 switchOff_C(cFamily, iGroup, iDevice); |
209 printf("Type E sending group[%c] device[%i] command[%i]\n", cGroup, iDevice, iState); |
215 break; |
210 toggleTypeE(cGroup, iDevice, iState); |
216 case 'D': |
|
217 printf("Type D sending group[%c] device[%i] command[%i]\n", cGroup, iDevice, iState); |
|
218 if (iState) |
|
219 switchOn_D(cGroup, iDevice); |
|
220 else |
|
221 switchOff_D(cGroup, iDevice); |
|
222 break; |
211 break; |
223 } |
212 } |
224 disableTransmit(); |
213 disableTransmit(); |
225 |
214 |
226 return 0; |
215 return 0; |