?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 32

Line No. Rev Author Line
1 32 kaklik /******************************************************************************
2  
3 MRF24WB0M Driver Connection Profile
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: WFConnectionProfile.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 Created for MRF24WB0M
48 ******************************************************************************/
49  
50 /*
51 *********************************************************************************************************
52 * INCLUDES
53 *********************************************************************************************************
54 */
55  
56 #include "TCPIP Stack/WFMac.h"
57  
58 #if defined(WF_CS_TRIS)
59  
60 /* used for assertions */
61 #ifdef WF_DEBUG
62 #define WF_MODULE_NUMBER WF_MODULE_WF_CONNECTION_PROFILE
63 #endif
64  
65  
66 /*
67 *********************************************************************************************************
68 * LOCAL DATA TYPES
69 *********************************************************************************************************
70 */
71  
72 /* header format for response to CP Get Element message */
73 typedef struct cpElementResponseStruct
74 {
75 tMgmtMsgRxHdr mgmtHdr; /* normal 4-byte hdr for all mgmt responses */
76 UINT8 profileId;
77 UINT8 elementId;
78 UINT8 elementDataLength;
79 /* element data follows */
80 } tCPElementResponseHdr;
81  
82  
83 /*
84 *********************************************************************************************************
85 * LOCAL FUNCTION PROTOTYPES
86 *********************************************************************************************************
87 */
88  
89 static void LowLevel_CPSetElement(UINT8 CpId,
90 UINT8 elementId,
91 UINT8 *p_elementData,
92 UINT8 elementDataLength);
93  
94 static void LowLevel_CPGetElement(UINT8 CpId,
95 UINT8 elementId,
96 UINT8 *p_elementData,
97 UINT8 elementDataLength,
98 UINT8 dataReadAction);
99  
100 /*******************************************************************************
101 Function:
102 void WF_CPCreate(UINT8 *p_CpId)
103  
104 Summary:
105 Creates a Connection Profile on the MRF24WB0M.
106  
107 Description:
108 Requests the MRF24WB0M to create a Connection Profile (CP), assign it an ID,
109 and set all the elements to default values. A maximum of 8 Connection
110 Profiles can exist on the MRF24WB0M (stored in FLASH). Two CP’s can be
111 active in MRF24WB0M memory at any one time.
112  
113 NOTE: First release of this code will not support FLASH, only the two CP’s
114 in memory.
115  
116 Precondition:
117 MACInit must be called first.
118  
119 Parameters:
120 p_CpId -- pointer to where Connection Profile ID will be written. If
121 function fails, the CP ID will be set to 0xff.
122  
123 Returns:
124 None.
125  
126 Remarks:
127 None.
128 *****************************************************************************/
129 void WF_CPCreate(UINT8 *p_CpId)
130 {
131 UINT8 hdr[2];
132  
133 *p_CpId = 0xff;
134  
135 hdr[0] = WF_MGMT_REQUEST_TYPE;
136 hdr[1] = WF_CP_CREATE_PROFILE_SUBTYPE;
137  
138 SendMgmtMsg(hdr,
139 sizeof(hdr),
140 NULL, /* no data */
141 0); /* no data */
142  
143 /* wait for MRF24WB0M management response, read data, free response after read */
144 WaitForMgmtResponseAndReadData(WF_CP_CREATE_PROFILE_SUBTYPE,
145 1, /* num data bytes to read */
146 MGMT_RESP_1ST_DATA_BYTE_INDEX, /* read starting at index 4 */
147 p_CpId); /* write data here */
148 }
149  
150 /*******************************************************************************
151 Function:
152 void WF_CPDelete(UINT8 CpId)
153  
154 Summary:
155 Deletes a Connection Profile on the MRF24WB0M.
156  
157 Description:
158 Deletes the specified Connection Profile. If the Connection Profile was in
159 FLASH it will be erased from FLASH.
160  
161 NOTE: First release of this code will not support FLASH, only the two CP’s
162 in memory.
163  
164 Precondition:
165 MACInit must be called first.
166  
167 Parameters:
168 CpId -- Connection Profile to delete.
169  
170 Returns:
171 None.
172  
173 Remarks:
174 None.
175 *****************************************************************************/
176 void WF_CPDelete(UINT8 CpId)
177 {
178 UINT8 hdr[2];
179  
180 hdr[0] = WF_MGMT_REQUEST_TYPE;
181 hdr[1] = WF_CP_DELETE_PROFILE_SUBTYPE;
182  
183 SendMgmtMsg(hdr,
184 sizeof(hdr),
185 &CpId, /* input data */
186 1); /* data size */
187  
188 /* wait for mgmt response, free it after it comes in (no data needed) */
189 WaitForMgmtResponse(WF_CP_DELETE_PROFILE_SUBTYPE, FREE_MGMT_BUFFER);
190 }
191  
192 /*******************************************************************************
193 Function:
194 void WF_CPGetIds(UINT8 *p_cpIdList)
195  
196 Summary:
197 Retrieves the CP ID bit mask.
198  
199 Description:
200 Returns a list of all Connection Profile ID’s that have been created on the
201 MRF24WB0M. This is not to be confused with the Connection Algorithm’s
202 connectionProfileList. This function returns a bit mask corresponding to a
203 list of all Connection Profiles that have been created (whether they are in
204 the connectionProfileList or not). Any Connection Profiles that have been
205 saved to FLASH will be included.
206  
207 Note: the first release will only support two Connection Profiles in memory.
208 Saving CP’s to FLASH will not be supported.
209  
210 Precondition:
211 MACInit must be called first.
212  
213 Parameters:
214 p_cpIdList -- pointer to value representing the bit mask where each bit
215 index (plus 1) corresponds to a Connection Profile ID that has
216 been created. For example, if this value is 0x41, then
217 Connection Profile ID’s 1 and and 4 have been created.
218  
219 Returns:
220 None.
221  
222 Remarks:
223 None.
224 *****************************************************************************/
225 void WF_CPGetIds(UINT8 *p_cpIdList)
226 {
227 UINT8 hdr[2];
228  
229 hdr[0] = WF_MGMT_REQUEST_TYPE;
230 hdr[1] = WF_CP_GET_ID_LIST_SUBTYPE;
231  
232 SendMgmtMsg(hdr,
233 sizeof(hdr),
234 NULL,
235 0);
236  
237 /* wait for mgmt response, read data, free after read */
238 WaitForMgmtResponseAndReadData(WF_CP_GET_ID_LIST_SUBTYPE,
239 1, /* num data bytes to read */
240 MGMT_RESP_1ST_DATA_BYTE_INDEX, /* only used if num data bytes > 0 */
241 p_cpIdList); /* only used if num data bytes > 0 */
242 }
243  
244 #if defined(WF_USE_GROUP_SET_GETS)
245 /*******************************************************************************
246 Function:
247 void WF_CPSetElements(UINT8 CpId, tWFCPElements *p_elements)
248  
249 Summary:
250 Writes out data for a specific connection profile element.
251  
252 Description:
253 Sets all Connection Profile elements. If the Host CPU does not have enough
254 memory to create a structure of this size then call the individual set
255 functions.
256  
257 Precondition:
258 MACInit must be called.
259  
260 Parameters:
261 CpId -- Connectino Profile ID.
262 p_elements -- Pointer to Connection Profile elements structure.
263  
264 Returns:
265 None.
266  
267 Remarks:
268 None.
269 *****************************************************************************/
270 void WF_CPSetElements(UINT8 CpId, tWFCPElements *p_elements)
271 {
272 WF_ASSERT(p_elements->ssidLength <= WF_MAX_SSID_LENGTH);
273  
274 LowLevel_CPSetElement(CpId, /* CP ID */
275 WF_CP_ELEMENT_ALL, /* Element ID */
276 (UINT8 *)p_elements, /* pointer to element data */
277 sizeof(tWFCPElements)); /* number of element data bytes */
278 }
279  
280 /*******************************************************************************
281 Function:
282 void WF_CPGetElements(UINT8 CpId, tWFCPElements *p_elements)
283  
284 Summary:
285 Reads the Connection Profile elements for the specified ID.
286  
287 Description:
288 Gets all Connection Profile elements for the specified CP ID. If the Host
289 CPU does not have enough memory to create a structure of this size then call
290 the individual get functions.
291  
292 Precondition:
293 MACInit must be called first.
294  
295 Parameters:
296 CpId -- Connectino Profile ID.
297 p_elements -- Pointer to Connection Profile elements structure.
298  
299 Returns:
300 None.
301  
302 Remarks:
303 None.
304 *****************************************************************************/
305 void WF_CPGetElements(UINT8 CpId, tWFCPElements *p_elements)
306 {
307 LowLevel_CPGetElement(CpId, /* CP ID */
308 WF_CP_ELEMENT_ALL, /* Element ID */
309 (UINT8 *)p_elements, /* pointer to element data */
310 sizeof(tWFCPElements), /* number of element data bytes */
311 TRUE); /* read data and free buffer */
312 }
313 #endif /* WF_USE_GROUP_SET_GETS */
314  
315 #if defined(WF_USE_INDIVIDUAL_SET_GETS)
316 /*******************************************************************************
317 Function:
318 void WF_CPSetSsid(UINT8 CpId, UINT8 *p_ssid, UINT8 *p_ssidLength)
319  
320 Summary:
321 Sets the SSID for the specified Connection Profile ID.
322  
323 Description:
324 Sets the SSID and SSID Length elements in the Connection Profile.
325  
326 Precondition:
327 MACInit must be called first.
328  
329 Parameters:
330 CpId -- Connection Profile ID
331 p_ssid -- pointer to the SSID string
332 ssidLength -- number of bytes in the SSID
333  
334 Returns:
335 None.
336  
337 Remarks:
338 None.
339 *****************************************************************************/
340 void WF_CPSetSsid(UINT8 CpId, UINT8 *p_ssid, UINT8 ssidLength)
341 {
342 WF_ASSERT(ssidLength <= WF_MAX_SSID_LENGTH);
343 LowLevel_CPSetElement(CpId, /* CP ID */
344 WF_CP_ELEMENT_SSID, /* Element ID */
345 (UINT8 *)p_ssid, /* pointer to element data */
346 ssidLength); /* number of element data bytes */
347  
348 }
349  
350 /*******************************************************************************
351 Function:
352 void WF_CPGetSsid(UINT8 CpId, UINT8 *p_ssid, UINT8 *p_ssidLength)
353  
354 Summary:
355 Gets the SSID for the specified Connection Profile ID.
356  
357 Description:
358 Gets the SSID and SSID Length elements in the Connection Profile.
359  
360 Precondition:
361 MACInit must be called first.
362  
363 Parameters:
364 CpId -- Connection Profile ID
365 p_ssid -- pointer to the SSID string
366 ssidLength -- number of bytes in the SSID
367  
368 Returns:
369 None.
370  
371 Remarks:
372 None.
373 *****************************************************************************/
374 void WF_CPGetSsid(UINT8 CpId, UINT8 *p_ssid, UINT8 *p_ssidLength)
375 {
376 tCPElementResponseHdr mgmtHdr;
377  
378 /* Request SSID, but don't have this function read data or free response buffer. */
379 LowLevel_CPGetElement(CpId, /* Connection Profile ID */
380 WF_CP_ELEMENT_SSID, /* Element ID */
381 NULL, /* ptr to element data (not used here */
382 0, /* num data bytes to read (not used here */
383 FALSE); /* no read, leave response mounted */
384  
385 /* At this point, management response is mounted and ready to be read. */
386 /* Set raw index to 0, read normal 4 byte header plus the next 3 bytes, these will be: */
387 /* profile id [4] */
388 /* element id [5] */
389 /* element data length [6] */
390 RawRead(RAW_RX_ID, 0, sizeof(tCPElementResponseHdr), (UINT8 *)&mgmtHdr);
391  
392 /* extract SSID length and write to caller */
393 *p_ssidLength = mgmtHdr.elementDataLength;
394  
395 /* copy SSID name to callers buffer */
396 RawRead(RAW_RX_ID, sizeof(tCPElementResponseHdr), *p_ssidLength, p_ssid);
397  
398 /* free management buffer */
399 DeallocateMgmtRxBuffer();
400 }
401  
402 /*******************************************************************************
403 Function:
404 void WF_CPSetBssid(UINT8 CpId, UINT8 *p_bssid)
405  
406 Summary:
407 Sets the BSSID for the specified Connection Profile ID.
408  
409 Description:
410 Sets the BSSID element in a Connection Profile.
411  
412 Precondition:
413 MACInit must be called first.
414  
415 Parameters:
416 CpId -- Connection Profile ID
417 p_bssid -- pointer to the BSSID
418  
419 Returns:
420 None.
421  
422 Remarks:
423 None.
424 *****************************************************************************/
425 void WF_CPSetBssid(UINT8 CpId, UINT8 *p_bssid)
426 {
427 LowLevel_CPSetElement(CpId, /* CP ID */
428 WF_CP_ELEMENT_BSSID, /* Element ID */
429 p_bssid, /* pointer to element data */
430 WF_BSSID_LENGTH); /* number of element data bytes */
431 }
432  
433 /*******************************************************************************
434 Function:
435 void WF_CPGetBssid(UINT8 CpId, UINT8 *p_bssid)
436  
437 Summary:
438 Gets the BSSID for the specified Connection Profile ID.
439  
440 Description:
441 Gets the BSSID element in a Connection Profile.
442  
443 Precondition:
444 MACInit must be called first.
445  
446 Parameters:
447 CpId -- Connection Profile ID
448 p_bssid -- pointer to the BSSID
449  
450 Returns:
451 None.
452  
453 Remarks:
454 None.
455 *****************************************************************************/
456 void WF_CPGetBssid(UINT8 CpId, UINT8 *p_bssid)
457 {
458 LowLevel_CPGetElement(CpId, /* CP ID */
459 WF_CP_ELEMENT_BSSID, /* Element ID */
460 p_bssid, /* pointer to element data */
461 WF_BSSID_LENGTH, /* number of element data bytes */
462 TRUE); /* read data, free buffer after read */
463 }
464  
465 /*******************************************************************************
466 Function:
467 void WF_CPSetNetworkType(UINT8 CpId, UINT8 networkType)
468  
469 Summary:
470 Sets the network for the specified Connection Profile ID.
471  
472 Description:
473 Sets the Network Type element a Connection Profile. Allowable values are:
474 * WF_INFRASTRUCTURE
475 * WF_ADHOC
476  
477 Precondition:
478 MACInit must be called first.
479  
480 Parameters:
481 CpId -- Connection Profile ID
482 networkType -- type of network to create (infrastructure or adhoc)
483  
484 Returns:
485 None.
486  
487 Remarks:
488 None.
489 *****************************************************************************/
490 void WF_CPSetNetworkType(UINT8 CpId, UINT8 networkType)
491 {
492 LowLevel_CPSetElement(CpId, /* CP ID */
493 WF_CP_ELEMENT_NETWORK_TYPE, /* Element ID */
494 &networkType, /* pointer to element data */
495 1); /* number of element data bytes */
496 }
497  
498 /*******************************************************************************
499 Function:
500 void WF_CPGetNetworkType(UINT8 CpId, UINT8 networkType)
501  
502 Summary:
503 Gets the network for the specified Connection Profile ID.
504  
505 Description:
506 Gets the Network Type element a Connection Profile. Allowable values are:
507 * WF_INFRASTRUCTURE
508 * WF_ADHOC
509  
510 Precondition:
511 MACInit must be called first.
512  
513 Parameters:
514 CpId -- Connection Profile ID
515 networkType -- type of network to create (infrastructure or adhoc)
516  
517 Returns:
518 None.
519  
520 Remarks:
521 None.
522 *****************************************************************************/
523 void WF_CPGetNetworkType(UINT8 CpId, UINT8 *p_networkType)
524 {
525 LowLevel_CPGetElement(CpId, /* conn. profile ID */
526 WF_CP_ELEMENT_NETWORK_TYPE, /* element ID */
527 p_networkType, /* element data pointer */
528 1, /* read one byte */
529 TRUE); /* read data, free buffer */
530 }
531  
532 /*******************************************************************************
533 Function:
534 void WF_CPSetSecurity(UINT8 CpId,
535 UINT8 securityType,
536 UINT8 wepKeyIndex,
537 UINT8 *p_securityKey,
538 UINT8 securityKeyLength)
539  
540 Summary:
541 Sets the security for the specified Connection Profile.
542  
543 Description:
544 Configures security for a Connection Profile.
545  
546 <table>
547 Security Key Length
548 -------- --- ------
549 WF_SECURITY_OPEN N/A N/A
550 WF_SECURITY_WEP_40 hex 4, 5 byte keys
551 WF_SECURITY_WEP_104 hex 4, 13 byte keys
552 WF_SECURITY_WPA_WITH_KEY hex 32 bytes
553 WF_SECURITY_WPA_WITH_PASS_PHRASE ascii 8-63 ascii characters
554 WF_SECURITY_WPA2_WITH_KEY hex 32 bytes
555 WF_SECURITY_WPA2_WITH_PASS_PHRASE ascii 8-63 ascii characters
556 WF_SECURITY_WPA_AUTO_WITH_KEY hex 32 bytes
557 WF_SECURITY_WPA_AUTO_WITH_PASS_PHRASE ascii 8-63 ascii characters
558 </table>
559  
560 Precondition:
561 MACInit must be called first.
562  
563 Parameters:
564 CpId -- Connection Profile ID
565 securityType -- value corresponding to the security type desired.
566 wepKeyIndex -- 0 thru 3 (only used if security type is WF_SECURITY_WEP_40 or
567 WF_SECURITY_WEP_104)
568 p_securityKey -- binary key or passphrase (not used if security is
569 WF_SECURITY_OPEN)
570 securityKeyLength -- number of bytes in p_securityKey (not used if security
571 is WF_SECURITY_OPEN)
572  
573 Returns:
574 None.
575  
576 Remarks:
577 None.
578 *****************************************************************************/
579 void WF_CPSetSecurity(UINT8 CpId,
580 UINT8 securityType,
581 UINT8 wepKeyIndex,
582 UINT8 *p_securityKey,
583 UINT8 securityKeyLength)
584 {
585 UINT8 hdrBuf[7];
586 UINT8 *p_key;
587  
588 /* Write out header portion of msg */
589 hdrBuf[0] = WF_MGMT_REQUEST_TYPE; /* indicate this is a mgmt msg */
590 hdrBuf[1] = WF_CP_SET_ELEMENT_SUBTYPE; /* mgmt request subtype */
591 hdrBuf[2] = CpId; /* Connection Profile ID */
592 hdrBuf[3] = WF_CP_ELEMENT_SECURITY; /* Element ID */
593  
594 /* Next to header bytes are really part of data, but need to put them in header */
595 /* bytes in order to prepend to security key */
596 hdrBuf[5] = securityType;
597 hdrBuf[6] = wepKeyIndex;
598  
599 /* if security is open (no key) */
600 if (securityType == WF_SECURITY_OPEN)
601 {
602 hdrBuf[4] = 2; /* Only data is security type and wep index */
603 p_key = NULL;
604 securityKeyLength = 0;
605  
606 }
607 /* else security is selected, so need to send key */
608 else
609 {
610 hdrBuf[4] = 2 + securityKeyLength; /* data is security type + wep index + key */
611 p_key = p_securityKey;
612 }
613  
614 SendMgmtMsg(hdrBuf, /* msg header which includes the security type and WEP index) */
615 sizeof(hdrBuf), /* msg header length */
616 p_key, /* msg data (security key), can be NULL */
617 securityKeyLength); /* msg data length (will be 0 if p_securityKey is NULL) */
618  
619 /* wait for mgmt response, free after it comes in, don't need data bytes */
620 WaitForMgmtResponse(WF_CP_SET_ELEMENT_SUBTYPE, FREE_MGMT_BUFFER);
621 }
622  
623 /*******************************************************************************
624 Function:
625 void WF_CPGetSecurity(UINT8 CpId,
626 UINT8 securityType,
627 UINT8 wepKeyIndex,
628 UINT8 *p_securityKey,
629 UINT8 securityKeyLength)
630  
631 Summary:
632 Gets the security for the specified Connection Profile.
633  
634 Description:
635 Configures security for a Connection Profile.
636  
637 <table>
638 Security Key Length
639 -------- --- ------
640 WF_SECURITY_OPEN N/A N/A
641 WF_SECURITY_WEP_40 hex 4, 5 byte keys
642 WF_SECURITY_WEP_104 hex 4, 13 byte keys
643 WF_SECURITY_WPA_WITH_KEY hex 32 bytes
644 WF_SECURITY_WPA_WITH_PASS_PHRASE ascii 8-63 ascii characters
645 WF_SECURITY_WPA2_WITH_KEY hex 32 bytes
646 WF_SECURITY_WPA2_WITH_PASS_PHRASE ascii 8-63 ascii characters
647 WF_SECURITY_WPA_AUTO_WITH_KEY hex 32 bytes
648 WF_SECURITY_WPA_AUTO_WITH_PASS_PHRASE ascii 8-63 ascii characters
649 </table>
650  
651 Precondition:
652 MACInit must be called first.
653  
654 Parameters:
655 CpId -- Connection Profile ID
656 securityType -- value corresponding to the security type desired.
657 wepKeyIndex -- 0 thru 3 (only used if security type is WF_SECURITY_WEP_40 or
658 WF_SECURITY_WEP_104)
659 p_securityKey -- binary key or passphrase (not used if security is
660 WF_SECURITY_OPEN)
661 securityKeyLength -- number of bytes in p_securityKey (not used if security
662 is WF_SECURITY_OPEN)
663  
664 Returns:
665 None.
666  
667 Remarks:
668 None.
669 *****************************************************************************/
670 void WF_CPGetSecurity(UINT8 CpId,
671 UINT8 *p_securityType,
672 UINT8 *p_wepKeyIndex,
673 UINT8 *p_securityKey,
674 UINT8 *p_securityKeyLength)
675 {
676 tCPElementResponseHdr mgmtHdr;
677 UINT8 keyLength;
678  
679 /* send request, wait for mgmt response, do not read and do not free up response buffer */
680 LowLevel_CPGetElement(CpId,
681 WF_CP_ELEMENT_SECURITY, /* Element ID */
682 NULL, /* do not read */
683 0, /* do not read */
684 FALSE); /* do not read, do not free mgmt buffer */
685  
686 /* at this point, management response is mounted and ready to be read */
687  
688 /* At this point, management response is mounted and ready to be read. */
689 /* Set raw index to 0, read normal 4 byte header plus the next 3 bytes, these will be: */
690 /* profile id [4] */
691 /* element id [5] */
692 /* element data length [6] */
693 RawRead(RAW_RX_ID, 0, sizeof(tCPElementResponseHdr), (UINT8 *)&mgmtHdr);
694  
695 RawRead(RAW_RX_ID, /* raw Id */
696 sizeof(tCPElementResponseHdr) + 0, /* index of security type [7] */
697 1, /* read one byte */
698 p_securityType); /* copy that byte here */
699  
700 RawRead(RAW_RX_ID, /* raw Id */
701 sizeof(tCPElementResponseHdr) + 1 , /* index of WEP key index [8] */
702 1, /* read one byte */
703 p_wepKeyIndex); /* copy that byte here */
704  
705 /* determine security key length and read if it is present */
706 keyLength = mgmtHdr.elementDataLength - 2;
707 if (keyLength > 0)
708 {
709 *p_securityKeyLength = keyLength;
710  
711 RawRead(RAW_RX_ID, /* raw Id */
712 sizeof(tCPElementResponseHdr) + 2, /* index of first key byte */
713 keyLength, /* number of bytes to read */
714 p_securityKey); /* copy bytes here */
715  
716 }
717 /* no security key, so set key length param to 0 */
718 else
719 {
720 *p_securityKeyLength = 0;
721 }
722 }
723  
724 /*******************************************************************************
725 Function:
726 void WF_CPSetDefaultWepKeyIndex(UINT8 CpId, UINT8 defaultWepKeyIndex)
727  
728 Summary:
729 Selects one of the 4 WEP keys to use.
730  
731 Description:
732 Only applicable if the Connection Profile security type is either
733 WF_SECURITY_WEP_40 or WF_SECURITY_WEP_104. Selects which of the four WEP
734 keys to use.
735  
736 Precondition:
737 MACInit must be called first.
738  
739 Parameters:
740 CpId -- Connection Profile ID
741 defaultWepKeyIndex -- index of WEP key to use (0 - 3)
742  
743 Returns:
744 None.
745  
746 Remarks:
747 Note that only key 0 amongst AP manufacturers is typically used. Using any
748 of the other three keys may be unpredictable from brand to brand.
749 *****************************************************************************/
750 void WF_CPSetDefaultWepKeyIndex(UINT8 CpId, UINT8 defaultWepKeyIndex)
751 {
752 LowLevel_CPSetElement(CpId, /* CP ID */
753 WF_CP_ELEMENT_WEP_KEY_INDEX, /* Element ID */
754 &defaultWepKeyIndex, /* pointer to element data */
755 1); /* number of element data bytes */
756 }
757  
758 /*******************************************************************************
759 Function:
760 void WF_CPGetDefaultWepKeyIndex(UINT8 CpId, UINT8 *p_defaultWepKeyIndex)
761  
762 Summary:
763 Gets the value of the active WEP keys to use.
764  
765 Description:
766 Only applicable if the Connection Profile security type is either
767 WF_SECURITY_WEP_40 or WF_SECURITY_WEP_104. Selects which of the four WEP
768 keys to use.
769  
770 Precondition:
771 MACInit must be called first.
772  
773 Parameters:
774 CpId -- Connection Profile ID
775 p_defaultWepKeyIndex -- pointer to index of WEP key to use (0 - 3)
776  
777 Returns:
778 None.
779  
780 Remarks:
781 Note that only key 0 amongst AP manufacturers is typically used. Using any
782 of the other three keys may be unpredictable from brand to brand.
783 *****************************************************************************/
784 void WF_CPGetDefaultWepKeyIndex(UINT8 CpId, UINT8 *p_defaultWepKeyIndex)
785 {
786 LowLevel_CPGetElement(CpId, /* conn. profile ID */
787 WF_CP_ELEMENT_WEP_KEY_INDEX, /* element ID */
788 p_defaultWepKeyIndex, /* element data pointer */
789 1, /* read one byte */
790 TRUE); /* read data, free buffer */
791 }
792  
793 /*******************************************************************************
794 Function:
795 void WF_CPSetAdHocBehavior(UINT8 CpId, UINT8 adHocBehavior)
796  
797 Summary:
798 Selects the desired Ad Hoc behavior
799  
800 Description:
801 Sets the AdHoc behavior within a Connection Profile. Allowable values are:
802 * WF_ADHOC_CONNECT_THEN_START
803 * WF_ADHOC_CONNECT_ONLY
804 * WF_ADHOC_START_ONLY
805  
806 Precondition:
807 MACInit must be called first.
808  
809 Parameters:
810 CpId -- Connection Profile ID
811 adHocBehavior -- value of the adhoc behavior for this connection profile.
812  
813 Returns:
814 None.
815  
816 Remarks:
817 None.
818 *****************************************************************************/
819 void WF_CPSetAdHocBehavior(UINT8 CpId, UINT8 adHocBehavior)
820 {
821 LowLevel_CPSetElement(CpId, /* CP ID */
822 WF_CP_ELEMENT_ADHOC_BEHAVIOR, /* Element ID */
823 &adHocBehavior, /* pointer to element data */
824 1); /* number of element data bytes */
825 }
826  
827 /*******************************************************************************
828 Function:
829 void WF_CPGetAdHocBehavior(UINT8 CpId, UINT8 *p_adHocBehavior)
830  
831 Summary:
832 Gets the desired Ad Hoc behavior
833  
834 Description:
835 Gets the AdHoc behavior within a Connection Profile. Allowable values are:
836 * WF_ADHOC_CONNECT_THEN_START
837 * WF_ADHOC_CONNECT_ONLY
838 * WF_ADHOC_START_ONLY
839  
840 Precondition:
841 MACInit must be called first.
842  
843 Parameters:
844 CpId -- Connection Profile ID
845 adHocBehavior -- pointer to location of the adhoc behavior value for this
846 connection profile.
847  
848 Returns:
849 None.
850  
851 Remarks:
852 None.
853 *****************************************************************************/
854 void WF_CPGetAdHocBehavior(UINT8 CpId, UINT8 *p_adHocBehavior)
855 {
856 LowLevel_CPGetElement(CpId, /* conn. profile ID */
857 WF_CP_ELEMENT_ADHOC_BEHAVIOR, /* element ID */
858 p_adHocBehavior, /* element data pointer */
859 1, /* read one byte */
860 TRUE); /* read data, free buffer */
861 }
862 #endif /* WF_USE_INDIVIDUAL_SET_GETS */
863  
864 /*******************************************************************************
865 Function:
866 static void LowLevel_CPSetElement(UINT8 CpId,
867 UINT8 elementId,
868 UINT8 *p_elementData,
869 UINT8 elementDataLength)
870  
871 Summary:
872 Set an element of the connection profile on the MRF24WB0M.
873  
874 Description:
875 All Connection Profile 'Set Element' functions call this function to
876 construct the management message. The caller must fix up any endian issues
877 prior to calling this function.
878  
879 Precondition:
880 MACInit must be called first.
881  
882 Parameters:
883 CpId -- Connection Profile ID
884 elementId -- element that is being set
885 p_elementData -- pointer to element data
886 elementDataLength -- number of bytes pointed to by p_elementData
887  
888 Returns:
889 None.
890  
891 Remarks:
892 None.
893 *****************************************************************************/
894 static void LowLevel_CPSetElement(UINT8 CpId,
895 UINT8 elementId,
896 UINT8 *p_elementData,
897 UINT8 elementDataLength)
898 {
899 UINT8 hdrBuf[5];
900  
901 /* Write out header portion of msg */
902 hdrBuf[0] = WF_MGMT_REQUEST_TYPE; /* indicate this is a mgmt msg */
903 hdrBuf[1] = WF_CP_SET_ELEMENT_SUBTYPE; /* mgmt request subtype */
904 hdrBuf[2] = CpId; /* Connection Profile ID */
905 hdrBuf[3] = elementId; /* Element ID */
906 hdrBuf[4] = elementDataLength; /* number of bytes of element data */
907  
908 SendMgmtMsg(hdrBuf, /* msg header */
909 sizeof(hdrBuf), /* msg header length */
910 p_elementData, /* msg data */
911 elementDataLength); /* msg data length */
912  
913 /* wait for mgmt response, free after it comes in, don't need data bytes */
914 WaitForMgmtResponse(WF_CP_SET_ELEMENT_SUBTYPE, FREE_MGMT_BUFFER);
915  
916 }
917  
918 /*******************************************************************************
919 Function:
920 static void LowLevel_CPGetElement(UINT8 CpId,
921 UINT8 elementId,
922 UINT8 *p_elementData,
923 UINT8 elementDataLength,
924 UINT8 dataReadAction)
925  
926 Summary:
927 Get an element of the connection profile on the MRF24WB0M.
928  
929 Description:
930 All Connection Profile 'Get Element' functions call this function to
931 construct the management message. The caller must fix up any endian issues
932 prior to calling this function.
933  
934 Precondition:
935 MACInit must be called first.
936  
937 Parameters:
938 CpId -- Connection Profile ID
939 elementId -- element that is being read
940 p_elementData -- pointer to where element data will be written
941 elementDataLength -- number of element data bytes that will be read
942 dataReadAction -- if TRUE then read data per paramters and free mgmt
943 response buffer. If FALSE then return after response
944 received, do not read any data as the caller will do that,
945 and don't free buffer, as caller will do that as well.
946  
947 Returns:
948 None.
949  
950 Remarks:
951 None.
952 *****************************************************************************/
953 static void LowLevel_CPGetElement(UINT8 CpId,
954 UINT8 elementId,
955 UINT8 *p_elementData,
956 UINT8 elementDataLength,
957 UINT8 dataReadAction) /* TRUE or FALSE */
958 {
959 UINT8 hdrBuf[4];
960  
961 hdrBuf[0] = WF_MGMT_REQUEST_TYPE; /* indicate this is a mgmt msg */
962 hdrBuf[1] = WF_CP_GET_ELEMENT_SUBTYPE; /* mgmt request subtype */
963 hdrBuf[2] = CpId; /* Connection Profile ID */
964 hdrBuf[3] = elementId; /* Element ID */
965  
966 SendMgmtMsg(hdrBuf, /* msg header */
967 sizeof(hdrBuf), /* msg header length */
968 NULL, /* msg data */
969 0); /* msg data length */
970  
971 if (dataReadAction == (UINT8)TRUE)
972 {
973 /* wait for mgmt response, read desired data, and then free response buffer */
974 WaitForMgmtResponseAndReadData(WF_CP_GET_ELEMENT_SUBTYPE,
975 elementDataLength, /* num data bytes to read */
976 sizeof(tCPElementResponseHdr), /* index of first byte of element data */
977 p_elementData); /* where to write element data */
978 }
979 else
980 {
981 /* wait for mgmt response, don't read any data bytes, do not release mgmt buffer */
982 WaitForMgmtResponse(WF_CP_GET_ELEMENT_SUBTYPE, DO_NOT_FREE_MGMT_BUFFER);
983 }
984 }
985  
986  
987 #endif /* WF_CS_TRIS */
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3