Line No. | Rev | Author | Line |
---|---|---|---|
1 | 32 | kaklik | /****************************************************************************** |
2 | |||
3 | MRF24WB0M Driver iwconfig |
||
4 | Module for Microchip TCP/IP Stack |
||
5 | -Provides access to MRF24WB0M WiFi controller |
||
6 | -Reference: MRF24WB0M Data sheet, IEEE 802.11 Standard |
||
7 | |||
8 | ******************************************************************************* |
||
9 | FileName: WFConsoleIwconfig.c |
||
10 | Dependencies: TCP/IP Stack header files |
||
11 | Processor: PIC18, PIC24F, PIC24H, dsPIC30F, dsPIC33F, PIC32 |
||
12 | Compiler: Microchip C32 v1.10b or higher |
||
13 | Microchip C30 v3.22 or higher |
||
14 | Microchip C18 v3.34 or higher |
||
15 | Company: Microchip Technology, Inc. |
||
16 | |||
17 | Software License Agreement |
||
18 | |||
19 | Copyright (C) 2002-2010 Microchip Technology Inc. All rights reserved. |
||
20 | |||
21 | Microchip licenses to you the right to use, modify, copy, and distribute: |
||
22 | (i) the Software when embedded on a Microchip microcontroller or digital |
||
23 | signal controller product ("Device") which is integrated into |
||
24 | Licensee's product; or |
||
25 | (ii) ONLY the Software driver source files ENC28J60.c, ENC28J60.h, |
||
26 | ENCX24J600.c and ENCX24J600.h ported to a non-Microchip device used in |
||
27 | conjunction with a Microchip ethernet controller for the sole purpose |
||
28 | of interfacing with the ethernet controller. |
||
29 | |||
30 | You should refer to the license agreement accompanying this Software for |
||
31 | additional information regarding your rights and obligations. |
||
32 | |||
33 | THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY |
||
34 | KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY |
||
35 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND |
||
36 | NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP BE LIABLE FOR ANY INCIDENTAL, |
||
37 | SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST |
||
38 | OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS BY |
||
39 | THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS |
||
40 | FOR INDEMNITY OR CONTRIBUTION, OR OTHER SIMILAR COSTS, WHETHER ASSERTED ON |
||
41 | THE BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR |
||
42 | OTHERWISE. |
||
43 | |||
44 | |||
45 | Author Date Comment |
||
46 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
47 | KH 27 Jan 2010 Updated for MRF24WB0M |
||
48 | ******************************************************************************/ |
||
49 | |||
50 | |||
51 | //============================================================================ |
||
52 | // Includes |
||
53 | //============================================================================ |
||
54 | #include <ctype.h> |
||
55 | #include <stdio.h> |
||
56 | #include <string.h> |
||
57 | |||
58 | #include "TCPIP Stack/TCPIP.h" |
||
59 | #include "TCPIP Stack/WFConsole.h" |
||
60 | |||
61 | #if defined( WF_CONSOLE_IFCFGUTIL ) |
||
62 | |||
63 | #include "TCPIP Stack/WFConsoleIwconfig.h" |
||
64 | #include "TCPIP Stack/WFConsoleMsgs.h" |
||
65 | #include "TCPIP Stack/WFConsoleMsgHandler.h" |
||
66 | |||
67 | #if defined ( EZ_CONFIG_SCAN ) |
||
68 | #include "TCPIP Stack/WFEasyConfig.h" |
||
69 | #endif /* EZ_CONFIG_SCAN */ |
||
70 | //============================================================================ |
||
71 | // Constants |
||
72 | //============================================================================ |
||
73 | |||
74 | //============================================================================ |
||
75 | // Globals |
||
76 | //============================================================================ |
||
77 | |||
78 | static BOOL iwconfigCbInitialized = FALSE; |
||
79 | tWFIwconfigCb iwconfigCb; |
||
80 | |||
81 | //============================================================================ |
||
82 | // Local Function Prototypes |
||
83 | //============================================================================ |
||
84 | static void iwconfigDisplayStatus(void); |
||
85 | static BOOL iwconfigSetSsid(void); |
||
86 | static BOOL iwconfigSetMode(void); |
||
87 | static BOOL iwconfigSetChannel(void); |
||
88 | static BOOL iwconfigSetPower(void); |
||
89 | static BOOL iwconfigSetDomain(void); |
||
90 | static BOOL iwconfigSetRTS(void); |
||
91 | static BOOL iwconfigSetTxRate(void); |
||
92 | |||
93 | |||
94 | /***************************************************************************** |
||
95 | * FUNCTION: do_iwconfig_cmd |
||
96 | * |
||
97 | * RETURNS: None |
||
98 | * |
||
99 | * PARAMS: None |
||
100 | * |
||
101 | * NOTES: Responds to the user invoking iwconfig |
||
102 | *****************************************************************************/ |
||
103 | void do_iwconfig_cmd(void) |
||
104 | { |
||
105 | if ( !iwconfigSetCb() ) |
||
106 | return; |
||
107 | |||
108 | // if user only typed in iwconfig with no other parameters |
||
109 | if (ARGC == 1u) |
||
110 | { |
||
111 | iwconfigDisplayStatus(); |
||
112 | return; |
||
113 | } |
||
114 | |||
115 | if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "ssid") == 0) ) |
||
116 | { |
||
117 | if ( !iwconfigSetSsid() ) |
||
118 | return; |
||
119 | } |
||
120 | else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "mode") == 0) ) |
||
121 | { |
||
122 | if ( !iwconfigSetMode() ) |
||
123 | return; |
||
124 | } |
||
125 | else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "channel") == 0) ) |
||
126 | { |
||
127 | if ( !iwconfigSetChannel() ) |
||
128 | return; |
||
129 | } |
||
130 | else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "power") == 0) ) |
||
131 | { |
||
132 | if ( !iwconfigSetPower() ) |
||
133 | return; |
||
134 | } |
||
135 | else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "domain") == 0) ) |
||
136 | { |
||
137 | if ( !iwconfigSetDomain() ) |
||
138 | return; |
||
139 | } |
||
140 | else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "rts") == 0) ) |
||
141 | { |
||
142 | if ( !iwconfigSetRTS() ) |
||
143 | return; |
||
144 | } |
||
145 | else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "txrate") == 0) ) |
||
146 | { |
||
147 | if ( !iwconfigSetTxRate() ) |
||
148 | return; |
||
149 | } |
||
150 | #if defined ( EZ_CONFIG_SCAN ) |
||
151 | else if ( (2u <= ARGC) && (strcmppgm2ram((char*)ARGV[1], "scan") == 0) ) |
||
152 | { |
||
153 | WFConsolePrintRomStr("Scan...", TRUE); |
||
154 | if (WFStartScan() == WF_SUCCESS) |
||
155 | { |
||
156 | SCAN_SET_DISPLAY(SCANCXT.scanState); |
||
157 | SCANCXT.displayIdx = 0; |
||
158 | } |
||
159 | return; |
||
160 | } |
||
161 | #endif /* EZ_CONFIG_SCAN */ |
||
162 | else |
||
163 | { |
||
164 | WFConsolePrintRomStr("Unknown parameter", TRUE); |
||
165 | return; |
||
166 | } |
||
167 | } |
||
168 | |||
169 | |||
170 | /***************************************************************************** |
||
171 | * FUNCTION: iwconfigSetCb |
||
172 | * |
||
173 | * RETURNS: TRUE or FALSE |
||
174 | * |
||
175 | * PARAMS: None |
||
176 | * |
||
177 | * NOTES: Set the iwconfigCb structure |
||
178 | *****************************************************************************/ |
||
179 | BOOL iwconfigSetCb(void) |
||
180 | { |
||
181 | UINT8 cpId, newCpId; |
||
182 | |||
183 | if ( !iwconfigCbInitialized ) // first time call of iwconfigSetCb |
||
184 | { |
||
185 | memset(&iwconfigCb, 0, sizeof(iwconfigCb)); |
||
186 | iwconfigCbInitialized = TRUE; |
||
187 | } |
||
188 | |||
189 | WF_GetPowerSaveState(&iwconfigCb.powerSaveState); |
||
190 | if (iwconfigCb.powerSaveState == WF_PS_HIBERNATE) |
||
191 | { |
||
192 | WFConsolePrintRomStr("WF device hibernated", TRUE); |
||
193 | return FALSE; |
||
194 | } |
||
195 | |||
196 | WF_CMGetConnectionState(&iwconfigCb.connState, &cpId); |
||
197 | |||
198 | if ( iwconfigCb.cpId == WF_CURRENT_CPID_NONE ) |
||
199 | { |
||
200 | if ( cpId == WF_CURRENT_CPID_NONE ) |
||
201 | { |
||
202 | WF_CPCreate(&newCpId); |
||
203 | iwconfigCb.cpId = newCpId; |
||
204 | } |
||
205 | else if ( cpId == WF_CURRENT_CPID_LIST ) |
||
206 | { |
||
207 | WFConsolePrintRomStr("Conection profile list not supported", TRUE); |
||
208 | return FALSE; |
||
209 | } |
||
210 | else |
||
211 | { |
||
212 | iwconfigCb.cpId = cpId; // use the application-created profile |
||
213 | } |
||
214 | } |
||
215 | else // WF_MIN_NUM_CPID <= iwconfigCb.cpId && iwconfigCb.cpId <= WF_MAX_NUM_CPID |
||
216 | { |
||
217 | if ( cpId == WF_CURRENT_CPID_NONE ) |
||
218 | { |
||
219 | // continue to use iwconfigCb.cpId |
||
220 | } |
||
221 | else if ( cpId == WF_CURRENT_CPID_LIST ) |
||
222 | { |
||
223 | WFConsolePrintRomStr("Conection profile list not supported", TRUE); |
||
224 | |||
225 | WF_CPDelete(iwconfigCb.cpId); |
||
226 | iwconfigCb.cpId = WF_CURRENT_CPID_NONE; |
||
227 | |||
228 | return FALSE; |
||
229 | } |
||
230 | else if ( cpId != iwconfigCb.cpId ) |
||
231 | { |
||
232 | WF_CPDelete(iwconfigCb.cpId); |
||
233 | iwconfigCb.cpId = cpId; // use the application-created profile |
||
234 | } |
||
235 | else // cpId == iwconfigCb.cpId |
||
236 | { |
||
237 | // contine to use iwconfigCb.cpId |
||
238 | } |
||
239 | } |
||
240 | |||
241 | if ((iwconfigCb.connState == WF_CSTATE_NOT_CONNECTED) || (iwconfigCb.connState == WF_CSTATE_CONNECTION_PERMANENTLY_LOST)) |
||
242 | { |
||
243 | iwconfigCb.isIdle = TRUE; |
||
244 | } |
||
245 | else |
||
246 | { |
||
247 | iwconfigCb.isIdle = FALSE; |
||
248 | } |
||
249 | |||
250 | return TRUE; |
||
251 | } |
||
252 | |||
253 | /***************************************************************************** |
||
254 | * FUNCTION: iwconfigDisplayStatus |
||
255 | * |
||
256 | * RETURNS: None |
||
257 | * |
||
258 | * PARAMS: None |
||
259 | * |
||
260 | * NOTES: Responds to the user invoking iwconfig with no parameters |
||
261 | *****************************************************************************/ |
||
262 | static void iwconfigDisplayStatus(void) |
||
263 | { |
||
264 | UINT8 *p; |
||
265 | UINT8 tmp; |
||
266 | UINT8 connectionState; |
||
267 | UINT8 cpId; |
||
268 | |||
269 | union |
||
270 | { |
||
271 | struct |
||
272 | { |
||
273 | UINT8 List[WF_CHANNEL_LIST_LENGTH]; |
||
274 | UINT8 Num; |
||
275 | } Channel; |
||
276 | |||
277 | UINT8 Domain; |
||
278 | |||
279 | struct |
||
280 | { |
||
281 | UINT8 String[WF_MAX_SSID_LENGTH+1]; |
||
282 | UINT8 Len; |
||
283 | } Ssid; |
||
284 | |||
285 | struct |
||
286 | { |
||
287 | UINT8 NetworkType; |
||
288 | } Mode; |
||
289 | |||
290 | struct |
||
291 | { |
||
292 | UINT16 Threshold; |
||
293 | } Rts; |
||
294 | } ws; // workspace |
||
295 | |||
296 | // cpId |
||
297 | { |
||
298 | WFConsolePrintRomStr("\tcpid: ", FALSE); |
||
299 | WFConsolePrintInteger(iwconfigCb.cpId, 'd'); |
||
300 | WFConsolePrintRomStr("", TRUE); |
||
301 | } |
||
302 | |||
303 | // channel |
||
304 | { |
||
305 | WF_CAGetChannelList(ws.Channel.List, &ws.Channel.Num); |
||
306 | WFConsolePrintRomStr("\tchannel: ", FALSE); |
||
307 | |||
308 | p = ws.Channel.List; |
||
309 | tmp = ws.Channel.Num; |
||
310 | |||
311 | while ( --tmp > 0u ) |
||
312 | { |
||
313 | WFConsolePrintInteger(*p, 'd'); |
||
314 | WFConsolePrintRomStr(",", FALSE); |
||
315 | p++; |
||
316 | } |
||
317 | |||
318 | WFConsolePrintInteger(*p, 'd'); |
||
319 | WFConsolePrintRomStr("", TRUE); |
||
320 | } |
||
321 | |||
322 | // domain |
||
323 | { |
||
324 | WF_GetRegionalDomain(&ws.Domain); |
||
325 | |||
326 | WFConsolePrintRomStr("\tdomain: ", FALSE); |
||
327 | |||
328 | if ( ws.Domain == WF_DOMAIN_FCC ) |
||
329 | { |
||
330 | WFConsolePrintRomStr("fcc", TRUE); |
||
331 | } |
||
332 | else if ( ws.Domain == WF_DOMAIN_IC ) |
||
333 | { |
||
334 | WFConsolePrintRomStr("ic", TRUE); |
||
335 | } |
||
336 | else if ( ws.Domain == WF_DOMAIN_ETSI ) |
||
337 | { |
||
338 | WFConsolePrintRomStr("etsi", TRUE); |
||
339 | } |
||
340 | else if ( ws.Domain == WF_DOMAIN_SPAIN ) |
||
341 | { |
||
342 | WFConsolePrintRomStr("spain", TRUE); |
||
343 | } |
||
344 | else if ( ws.Domain == WF_DOMAIN_FRANCE ) |
||
345 | { |
||
346 | WFConsolePrintRomStr("france", TRUE); |
||
347 | } |
||
348 | else if ( ws.Domain == WF_DOMAIN_JAPAN_A ) |
||
349 | { |
||
350 | WFConsolePrintRomStr("japana", TRUE); |
||
351 | } |
||
352 | else if ( ws.Domain == WF_DOMAIN_JAPAN_B ) |
||
353 | { |
||
354 | WFConsolePrintRomStr("japanb", TRUE); |
||
355 | } |
||
356 | else |
||
357 | { |
||
358 | WFConsolePrintRomStr("unknown", TRUE); |
||
359 | } |
||
360 | } |
||
361 | |||
362 | // rts |
||
363 | { |
||
364 | WF_GetRtsThreshold(&ws.Rts.Threshold); |
||
365 | |||
366 | WFConsolePrintRomStr("\trts: ", FALSE); |
||
367 | WFConsolePrintInteger(ws.Rts.Threshold, 'd'); |
||
368 | WFConsolePrintRomStr("", TRUE); |
||
369 | } |
||
370 | |||
371 | // mode |
||
372 | { |
||
373 | |||
374 | WF_CMGetConnectionState(&connectionState, &cpId); |
||
375 | WF_CPGetNetworkType(iwconfigCb.cpId, &ws.Mode.NetworkType); |
||
376 | |||
377 | WFConsolePrintRomStr("\tmode: ", FALSE); |
||
378 | |||
379 | if (iwconfigCb.isIdle) |
||
380 | { |
||
381 | if (iwconfigCb.connState == WF_CSTATE_NOT_CONNECTED) |
||
382 | { |
||
383 | WFConsolePrintRomStr("idle", TRUE); |
||
384 | } |
||
385 | else if (iwconfigCb.connState == WF_CSTATE_CONNECTION_PERMANENTLY_LOST) |
||
386 | { |
||
387 | WFConsolePrintRomStr("idle (connection permanently lost)", TRUE); |
||
388 | } |
||
389 | else |
||
390 | { |
||
391 | WFConsolePrintRomStr("idle (?)", TRUE); |
||
392 | } |
||
393 | } |
||
394 | else |
||
395 | { |
||
396 | WF_CPGetNetworkType(iwconfigCb.cpId, &ws.Mode.NetworkType); |
||
397 | if (ws.Mode.NetworkType == WF_INFRASTRUCTURE) |
||
398 | { |
||
399 | if (iwconfigCb.connState == WF_CSTATE_CONNECTION_IN_PROGRESS) |
||
400 | { |
||
401 | WFConsolePrintRomStr("managed (connection in progress)", TRUE); |
||
402 | } |
||
403 | else if (iwconfigCb.connState == WF_CSTATE_CONNECTED_INFRASTRUCTURE) |
||
404 | { |
||
405 | WFConsolePrintRomStr("managed", TRUE); |
||
406 | } |
||
407 | else if (iwconfigCb.connState == WF_CSTATE_RECONNECTION_IN_PROGRESS) |
||
408 | { |
||
409 | WFConsolePrintRomStr("managed (reconnection in progress)", TRUE); |
||
410 | } |
||
411 | else |
||
412 | { |
||
413 | WFConsolePrintRomStr("managed (?)", TRUE); |
||
414 | } |
||
415 | } |
||
416 | else if (ws.Mode.NetworkType == WF_ADHOC) |
||
417 | { |
||
418 | if (iwconfigCb.connState == WF_CSTATE_CONNECTION_IN_PROGRESS) |
||
419 | { |
||
420 | WFConsolePrintRomStr("adhoc (connection in progress)", TRUE); |
||
421 | } |
||
422 | else if (iwconfigCb.connState == WF_CSTATE_CONNECTED_ADHOC) |
||
423 | { |
||
424 | WFConsolePrintRomStr("adhoc", TRUE); |
||
425 | } |
||
426 | else if (iwconfigCb.connState == WF_CSTATE_RECONNECTION_IN_PROGRESS) |
||
427 | { |
||
428 | WFConsolePrintRomStr("adhoc (reconnection in progress)", TRUE); |
||
429 | } |
||
430 | else |
||
431 | { |
||
432 | WFConsolePrintRomStr("adhoc (?)", TRUE); |
||
433 | } |
||
434 | |||
435 | WFConsolePrintRomStr("adhoc", TRUE); |
||
436 | } |
||
437 | else |
||
438 | { |
||
439 | WFConsolePrintRomStr("unknown", TRUE); |
||
440 | } |
||
441 | } |
||
442 | } |
||
443 | |||
444 | // ssid |
||
445 | { |
||
446 | WF_CPGetSsid(iwconfigCb.cpId, ws.Ssid.String, &ws.Ssid.Len); |
||
447 | ws.Ssid.String[ws.Ssid.Len] = '\0'; |
||
448 | |||
449 | WFConsolePrintRomStr("\tssid: ", FALSE); |
||
450 | WFConsolePrintRamStr(ws.Ssid.String, TRUE); |
||
451 | } |
||
452 | |||
453 | // power |
||
454 | { |
||
455 | switch (iwconfigCb.powerSaveState) |
||
456 | { |
||
457 | case WF_PS_PS_POLL_DTIM_ENABLED: |
||
458 | WFConsolePrintRomStr("\tpwrsave: enabled", TRUE); |
||
459 | WFConsolePrintRomStr("\tdtim rx: enabled", TRUE); |
||
460 | break; |
||
461 | case WF_PS_PS_POLL_DTIM_DISABLED: |
||
462 | WFConsolePrintRomStr("\tpwrsave: enabled", TRUE); |
||
463 | WFConsolePrintRomStr("\tdtim rx: disabled", TRUE); |
||
464 | break; |
||
465 | case WF_PS_OFF: |
||
466 | WFConsolePrintRomStr("\tpwrsave: disabled", TRUE); |
||
467 | break; |
||
468 | default: |
||
469 | WFConsolePrintRomStr("\tpwrsave: unknown(", FALSE); |
||
470 | WFConsolePrintInteger(iwconfigCb.powerSaveState, 'd'); |
||
471 | WFConsolePrintRomStr(")", TRUE); |
||
472 | break; |
||
473 | } |
||
474 | } |
||
475 | } |
||
476 | |||
477 | static BOOL iwconfigSetSsid(void) |
||
478 | { |
||
479 | if ( !iwconfigCb.isIdle ) |
||
480 | { |
||
481 | WFConsolePrintRomStr("SSID can only be set in idle mode", TRUE); |
||
482 | return FALSE; |
||
483 | } |
||
484 | |||
485 | if (ARGC < 3u) |
||
486 | { |
||
487 | WFConsolePrintRomStr("Missing value for last parameter", TRUE); |
||
488 | return FALSE; |
||
489 | } |
||
490 | |||
491 | WF_CPSetSsid(iwconfigCb.cpId, (UINT8 *)ARGV[2], strlen((char*)ARGV[2])); |
||
492 | |||
493 | return TRUE; |
||
494 | } |
||
495 | |||
496 | static BOOL iwconfigSetMode(void) |
||
497 | { |
||
498 | UINT8 networkType; |
||
499 | |||
500 | if (ARGC < 3u) |
||
501 | { |
||
502 | WFConsolePrintRomStr("Missing value for last parameter", TRUE); |
||
503 | return FALSE; |
||
504 | } |
||
505 | |||
506 | WF_CPGetNetworkType(iwconfigCb.cpId, &networkType); |
||
507 | |||
508 | if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "idle") == 0) ) |
||
509 | { |
||
510 | if ( iwconfigCb.isIdle ) |
||
511 | { |
||
512 | WFConsolePrintRomStr("Already in the idle mode", TRUE); |
||
513 | } |
||
514 | else |
||
515 | { |
||
516 | WF_CMDisconnect(); |
||
517 | } |
||
518 | } |
||
519 | else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "managed") == 0) ) |
||
520 | { |
||
521 | if ( iwconfigCb.isIdle ) |
||
522 | { |
||
523 | WF_CPSetNetworkType(iwconfigCb.cpId, WF_INFRASTRUCTURE); |
||
524 | WF_CMConnect(iwconfigCb.cpId); |
||
525 | } |
||
526 | else |
||
527 | { |
||
528 | WF_CPGetNetworkType(iwconfigCb.cpId, &networkType); |
||
529 | if (networkType == WF_INFRASTRUCTURE) |
||
530 | { |
||
531 | WFConsolePrintRomStr("Already in the managed mode", TRUE); |
||
532 | } |
||
533 | else |
||
534 | { |
||
535 | WF_CMDisconnect(); |
||
536 | |||
537 | WF_CPSetNetworkType(iwconfigCb.cpId, WF_INFRASTRUCTURE); |
||
538 | WF_CMConnect(iwconfigCb.cpId); |
||
539 | } |
||
540 | } |
||
541 | } |
||
542 | else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "adhoc") == 0) ) |
||
543 | { |
||
544 | if ( iwconfigCb.isIdle ) |
||
545 | |||
546 | { |
||
547 | WF_CPSetNetworkType(iwconfigCb.cpId, WF_ADHOC); |
||
548 | WF_CPSetAdHocBehavior(iwconfigCb.cpId, WF_ADHOC_CONNECT_THEN_START); |
||
549 | WF_CMConnect(iwconfigCb.cpId); |
||
550 | } |
||
551 | else |
||
552 | { |
||
553 | WF_CPGetNetworkType(iwconfigCb.cpId, &networkType); |
||
554 | if (networkType == WF_ADHOC) |
||
555 | { |
||
556 | WFConsolePrintRomStr("Already in the adhoc mode", TRUE); |
||
557 | } |
||
558 | else |
||
559 | { |
||
560 | WF_CMDisconnect(); |
||
561 | |||
562 | WF_CPSetNetworkType(iwconfigCb.cpId, WF_ADHOC); |
||
563 | WF_CMConnect(iwconfigCb.cpId); |
||
564 | } |
||
565 | } |
||
566 | } |
||
567 | else |
||
568 | { |
||
569 | WFConsolePrintRomStr("Unknown parameter", TRUE); |
||
570 | return FALSE; |
||
571 | } |
||
572 | |||
573 | return TRUE; |
||
574 | } |
||
575 | |||
576 | static BOOL iwconfigSetChannel(void) |
||
577 | { |
||
578 | UINT8 *p1, *p2; |
||
579 | UINT8 *p_channelList; |
||
580 | UINT8 index = 0; |
||
581 | UINT16 temp; |
||
582 | |||
583 | if (ARGC < 3u) |
||
584 | { |
||
585 | WFConsolePrintRomStr("Missing value for last parameter", TRUE); |
||
586 | return FALSE; |
||
587 | } |
||
588 | |||
589 | if ( !iwconfigCb.isIdle ) |
||
590 | { |
||
591 | WFConsolePrintRomStr("Channel can only be set in idle mode", TRUE); |
||
592 | return FALSE; |
||
593 | } |
||
594 | |||
595 | p_channelList = (UINT8*) ARGV[2]; |
||
596 | p1 = p2 = p_channelList; |
||
597 | |||
598 | if ( strlen( (char*) p_channelList) == 0u ) |
||
599 | return FALSE; |
||
600 | |||
601 | if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "all") == 0) ) |
||
602 | { |
||
603 | WF_CASetChannelList(p_channelList, 0); // reset to domain default channel list |
||
604 | return TRUE; |
||
605 | } |
||
606 | |||
607 | do |
||
608 | { |
||
609 | if ( (p2 = (UINT8*) strchr( (const char *) p1, (int) ',')) != NULL ) |
||
610 | { |
||
611 | *p2='\0'; |
||
612 | p2++; |
||
613 | } |
||
614 | |||
615 | if( !ConvertASCIIUnsignedDecimalToBinary((INT8 *)p1, &temp) ) |
||
616 | return FALSE; |
||
617 | |||
618 | p1 = p2; |
||
619 | p_channelList[index] = (UINT8) temp; |
||
620 | index++; |
||
621 | |||
622 | } while ( p2 != NULL ); |
||
623 | |||
624 | WF_CASetChannelList(p_channelList, index); |
||
625 | |||
626 | return TRUE; |
||
627 | } |
||
628 | |||
629 | static BOOL iwconfigSetPower(void) |
||
630 | { |
||
631 | if (ARGC < 3u) |
||
632 | { |
||
633 | WFConsolePrintRomStr("Missing value for last parameter", TRUE); |
||
634 | return FALSE; |
||
635 | } |
||
636 | |||
637 | if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "reenable") == 0) ) |
||
638 | { // reenable power saving |
||
639 | WF_PsPollEnable(TRUE); |
||
640 | } |
||
641 | else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "disable") == 0) ) |
||
642 | { // disable power saving |
||
643 | WF_PsPollDisable(); |
||
644 | } |
||
645 | else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "unicast") == 0) ) |
||
646 | { // enable power saving but don't poll for DTIM |
||
647 | WF_PsPollEnable(FALSE); |
||
648 | } |
||
649 | else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "all") == 0) ) |
||
650 | { // enable power saving and poll for DTIM |
||
651 | WF_PsPollEnable(TRUE); |
||
652 | } |
||
653 | else |
||
654 | { |
||
655 | WFConsolePrintRomStr("Unknown parameter", TRUE); |
||
656 | return FALSE; |
||
657 | } |
||
658 | |||
659 | return TRUE; |
||
660 | } |
||
661 | |||
662 | static BOOL iwconfigSetDomain(void) |
||
663 | { |
||
664 | UINT8 domain; |
||
665 | |||
666 | if (ARGC < 3u) |
||
667 | { |
||
668 | WFConsolePrintRomStr("Missing value for last parameter", TRUE); |
||
669 | return FALSE; |
||
670 | } |
||
671 | |||
672 | if ( !iwconfigCb.isIdle ) |
||
673 | { |
||
674 | WFConsolePrintRomStr("Domain can only be set in idle mode", TRUE); |
||
675 | return FALSE; |
||
676 | } |
||
677 | |||
678 | if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "fcc") == 0) ) |
||
679 | { |
||
680 | domain = WF_DOMAIN_FCC; |
||
681 | } |
||
682 | else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "ic") == 0) ) |
||
683 | { |
||
684 | domain = WF_DOMAIN_IC; |
||
685 | } |
||
686 | else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "etsi") == 0) ) |
||
687 | { |
||
688 | domain = WF_DOMAIN_ETSI; |
||
689 | } |
||
690 | else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "spain") == 0) ) |
||
691 | { |
||
692 | domain = WF_DOMAIN_SPAIN; |
||
693 | } |
||
694 | else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "france") == 0) ) |
||
695 | { |
||
696 | domain = WF_DOMAIN_FRANCE; |
||
697 | } |
||
698 | else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "japana") == 0) ) |
||
699 | { |
||
700 | domain = WF_DOMAIN_JAPAN_A; |
||
701 | } |
||
702 | else if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "japanb") == 0) ) |
||
703 | { |
||
704 | domain = WF_DOMAIN_JAPAN_B; |
||
705 | } |
||
706 | else |
||
707 | { |
||
708 | WFConsolePrintRomStr("Unknown domain", TRUE); |
||
709 | return FALSE; |
||
710 | } |
||
711 | |||
712 | WF_SetRegionalDomain(domain); |
||
713 | WF_CASetChannelList(NULL, 0); // reset to domain default channel list |
||
714 | |||
715 | return TRUE; |
||
716 | } |
||
717 | |||
718 | static BOOL iwconfigSetRTS(void) |
||
719 | { |
||
720 | UINT16 rtsThreshold; |
||
721 | |||
722 | if (ARGC < 3u) |
||
723 | { |
||
724 | WFConsolePrintRomStr("Missing value for last parameter", TRUE); |
||
725 | return FALSE; |
||
726 | } |
||
727 | |||
728 | if( !ConvertASCIIUnsignedDecimalToBinary(ARGV[2], &rtsThreshold) ) |
||
729 | return FALSE; |
||
730 | |||
731 | WF_SetRtsThreshold(rtsThreshold); |
||
732 | |||
733 | return TRUE; |
||
734 | } |
||
735 | |||
736 | static BOOL iwconfigSetTxRate(void) |
||
737 | { |
||
738 | return FALSE; |
||
739 | } |
||
740 | #endif /* WF_CONSOLE_IFCFGUTIL */ |
Powered by WebSVN v2.8.3