Line No. | Rev | Author | Line |
---|---|---|---|
1 | 32 | kaklik | /****************************************************************************** |
2 | |||
3 | MRF24WB0M Driver Connection Algorithm |
||
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: WFConnectionManager.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 | |||
61 | /* |
||
62 | ********************************************************************************************************* |
||
63 | * DEFINES |
||
64 | ********************************************************************************************************* |
||
65 | */ |
||
66 | |||
67 | /* used for assertions */ |
||
68 | #ifdef WF_DEBUG |
||
69 | #define WF_MODULE_NUMBER WF_MODULE_WF_CONNECTION_ALGORITHM |
||
70 | #endif |
||
71 | |||
72 | |||
73 | /* |
||
74 | ********************************************************************************************************* |
||
75 | * LOCAL DATA TYPES |
||
76 | ********************************************************************************************************* |
||
77 | */ |
||
78 | |||
79 | /* header format for response to CP Get Element message */ |
||
80 | typedef struct caElementResponseStruct |
||
81 | { |
||
82 | tMgmtMsgRxHdr mgmtHdr; /* normal 4-byte hdr for all mgmt responses */ |
||
83 | UINT8 elementId; /* index 4 */ |
||
84 | UINT8 elementDataLength; /* index 5 */ |
||
85 | /* element data follows */ |
||
86 | } tCAElementResponseHdr; |
||
87 | |||
88 | /* WF_CM_DEBUG is used to retrieve connection management debug info from the WiFi chip. Not used by applications */ |
||
89 | #if defined(WF_CM_DEBUG) |
||
90 | /* header format for response to CM Info message */ |
||
91 | typedef struct cmInfoResponseStruct |
||
92 | { |
||
93 | tMgmtMsgRxHdr mgmtHdr; /* normal 4-byte hdr for all mgmt responses */ |
||
94 | //UINT8 infoId; /* index 4 */ |
||
95 | //UINT8 infoDataLength; /* index 5 */ |
||
96 | /* info data follows */ |
||
97 | } tCMInfoResponseHdr; |
||
98 | #endif |
||
99 | |||
100 | /* |
||
101 | ********************************************************************************************************* |
||
102 | * LOCAL GLOBAL VARIABLES |
||
103 | ********************************************************************************************************* |
||
104 | */ |
||
105 | |||
106 | static UINT8 g_EventNotificationAction = WF_NOTIFY_ALL_EVENTS; |
||
107 | |||
108 | |||
109 | /* |
||
110 | ********************************************************************************************************* |
||
111 | * LOCAL FUNCTION PROTOTYPES |
||
112 | ********************************************************************************************************* |
||
113 | */ |
||
114 | |||
115 | static void LowLevel_CASetElement(UINT8 elementId, |
||
116 | UINT8 *p_elementData, |
||
117 | UINT8 elementDataLength); |
||
118 | |||
119 | static void LowLevel_CAGetElement(UINT8 elementId, |
||
120 | UINT8 *p_elementData, |
||
121 | UINT8 elementDataLength, |
||
122 | UINT8 dataReadAction); |
||
123 | |||
124 | static void SetEventNotificationMask(UINT8 eventNotificationBitMask); |
||
125 | |||
126 | |||
127 | #if defined(WF_USE_GROUP_SET_GETS) |
||
128 | /***************************************************************************** |
||
129 | Function: |
||
130 | void WF_CASetElements(tWFCAElements *p_elements) |
||
131 | |||
132 | Summary: |
||
133 | Writes all Connection Algorithm elements. |
||
134 | |||
135 | Description: |
||
136 | Sends a message to the MRF24WB0M which sets all the Connection Algorithm |
||
137 | elements. |
||
138 | |||
139 | Precondition: |
||
140 | MACInit must be called first. |
||
141 | |||
142 | Parameters: |
||
143 | p_elements - pointer to the input structure (tWFCAElements) containing the |
||
144 | connection algorithm elements. |
||
145 | |||
146 | Returns: |
||
147 | None |
||
148 | |||
149 | Remarks: |
||
150 | None |
||
151 | *****************************************************************************/ |
||
152 | void WF_CASetElements(tWFCAElements *p_elements) |
||
153 | { |
||
154 | UINT8 i; |
||
155 | |||
156 | /* Connection Profile lists not supported yet, make sure one is not defined */ |
||
157 | for (i = 0; i < WF_CP_LIST_LENGTH; ++i) |
||
158 | { |
||
159 | /* all elements in list should be 0xff, indicating CP list is unused */ |
||
160 | if (p_elements->connectionProfileList[i] != 0xff) |
||
161 | { |
||
162 | WF_ASSERT(FALSE); |
||
163 | } |
||
164 | } |
||
165 | |||
166 | /* fix up listenInterval, minChannelTime, maxChannelTime, and probeDelay to correct endianness before sending message */ |
||
167 | p_elements->listenInterval = HSTOWFS(p_elements->listenInterval); |
||
168 | p_elements->minChannelTime = HSTOWFS(p_elements->minChannelTime); |
||
169 | p_elements->maxChannelTime = HSTOWFS(p_elements->maxChannelTime); |
||
170 | p_elements->probeDelay = HSTOWFS(p_elements->probeDelay); |
||
171 | |||
172 | /* save application event notification bitmask */ |
||
173 | SetEventNotificationMask(p_elements->eventNotificationAction); |
||
174 | |||
175 | /* temporarily override application event notification in app structure -- set to all events so WiFi driver will be notified */ |
||
176 | p_elements->eventNotificationAction = WF_NOTIFY_ALL_EVENTS; |
||
177 | |||
178 | LowLevel_CASetElement(WF_CA_ELEMENT_ALL, /* Element ID */ |
||
179 | (UINT8 *)p_elements, /* pointer to element data */ |
||
180 | sizeof(tWFCAElements)); /* number of element data bytes */ |
||
181 | |||
182 | /* put listenInterval, minChannelTime, maxChannelTime, and probeDelay back to host endianness */ |
||
183 | p_elements->listenInterval = WFSTOHS(p_elements->listenInterval); |
||
184 | p_elements->minChannelTime = WFSTOHS(p_elements->minChannelTime); |
||
185 | p_elements->maxChannelTime = WFSTOHS(p_elements->maxChannelTime); |
||
186 | p_elements->probeDelay = WFSTOHS(p_elements->probeDelay); |
||
187 | |||
188 | /* restore event notification in application structure to original value */ |
||
189 | p_elements->eventNotificationAction = GetEventNotificationMask(); |
||
190 | |||
191 | } |
||
192 | |||
193 | /***************************************************************************** |
||
194 | Function: |
||
195 | void WF_CAGetElements(tWFCAElements *p_elements) |
||
196 | |||
197 | Summary: |
||
198 | Reads all Connection Algorithm elements. |
||
199 | |||
200 | Description: |
||
201 | Sends a message to the MRF24WB0M which requests all the Connection Algorithm |
||
202 | elements. |
||
203 | |||
204 | Precondition: |
||
205 | MACInit must be called first. |
||
206 | |||
207 | Parameters: |
||
208 | p_elements - pointer to the output structure (tWFCAElements) where the |
||
209 | connection algorithm elements are written. |
||
210 | |||
211 | Returns: |
||
212 | None |
||
213 | |||
214 | Remarks: |
||
215 | None |
||
216 | *****************************************************************************/ |
||
217 | void WF_CAGetElements(tWFCAElements *p_elements) |
||
218 | { |
||
219 | LowLevel_CAGetElement(WF_CA_ELEMENT_ALL, /* element ID */ |
||
220 | (UINT8 *)p_elements, /* pointer to element data */ |
||
221 | sizeof(tWFCAElements), /* num data bytes */ |
||
222 | TRUE); /* read data, free buffer */ |
||
223 | |||
224 | /* fix up endianness for 16-bit values */ |
||
225 | p_elements->listenInterval = HSTOWFS(p_elements->listenInterval); |
||
226 | p_elements->minChannelTime = HSTOWFS(p_elements->minChannelTime); |
||
227 | p_elements->maxChannelTime = HSTOWFS(p_elements->maxChannelTime); |
||
228 | p_elements->probeDelay = HSTOWFS(p_elements->probeDelay); |
||
229 | } |
||
230 | #endif /* WF_USE_GROUP_SET_GETS */ |
||
231 | |||
232 | #if defined(WF_USE_INDIVIDUAL_SET_GETS) |
||
233 | /***************************************************************************** |
||
234 | Function: |
||
235 | void WF_CASetScanType(UINT8 scanType) |
||
236 | |||
237 | Summary: |
||
238 | Sets the Connection Algorith scan type |
||
239 | |||
240 | Description: |
||
241 | Configures the Connection Algorithm for the desired scan type. |
||
242 | |||
243 | Precondition: |
||
244 | MACInit must be called first. |
||
245 | |||
246 | Parameters: |
||
247 | scanType -- desired scan type. Either WF_ACTIVE_SCAN or WF_PASSIVE_SCAN. |
||
248 | |||
249 | Returns: |
||
250 | None |
||
251 | |||
252 | Remarks: |
||
253 | Active scanning causes the MRF24WB0M to send probe requests. Passive |
||
254 | scanning implies the MRF24WB0M only listens for beacons. |
||
255 | Default is WF_ACTIVE_SCAN. |
||
256 | *****************************************************************************/ |
||
257 | void WF_CASetScanType(UINT8 scanType) |
||
258 | { |
||
259 | LowLevel_CASetElement(WF_CA_ELEMENT_SCANTYPE, /* Element ID */ |
||
260 | &scanType, /* pointer to element data */ |
||
261 | sizeof(scanType)); /* number of element data bytes */ |
||
262 | } |
||
263 | |||
264 | /***************************************************************************** |
||
265 | Function: |
||
266 | void WF_CAGetScanType(UINT8 *p_scanType) |
||
267 | |||
268 | Summary: |
||
269 | Gets the Connection Algorith scan type |
||
270 | |||
271 | Description: |
||
272 | Reads the current Connection Algorithm scan type. |
||
273 | |||
274 | Precondition: |
||
275 | MACInit must be called first. |
||
276 | |||
277 | Parameters: |
||
278 | p_scanType -- Pointer where Connection Algorithm scan type is written. |
||
279 | |||
280 | Returns: |
||
281 | None |
||
282 | |||
283 | Remarks: |
||
284 | Active scanning causes the MRF24WB0M to send probe requests. Passive |
||
285 | scanning implies the MRF24wB0M only listens for beacons. |
||
286 | Default is WF_ACTIVE_SCAN. |
||
287 | *****************************************************************************/ |
||
288 | void WF_CAGetScanType(UINT8 *p_scanType) |
||
289 | { |
||
290 | LowLevel_CAGetElement(WF_CA_ELEMENT_SCANTYPE, /* Element ID */ |
||
291 | p_scanType, /* pointer to element data */ |
||
292 | 1, /* number of element data bytes */ |
||
293 | TRUE); /* read data, free buffer */ |
||
294 | } |
||
295 | |||
296 | /***************************************************************************** |
||
297 | Function: |
||
298 | void WF_CASetMinChannelTime(UINT16 minChannelTime) |
||
299 | |||
300 | Summary: |
||
301 | Sets the minimum channel time (in milliseconds) |
||
302 | |||
303 | Description: |
||
304 | The minimum time (in milliseconds) the connection manager will wait for a |
||
305 | probe response after sending a probe request. If no probe responses are |
||
306 | received in minChannelTime then the connection manager will go on to the |
||
307 | next channel, if any are left to scan, or quit. |
||
308 | |||
309 | Precondition: |
||
310 | MACInit must be called first. |
||
311 | |||
312 | Parameters: |
||
313 | minChannelTime -- minimum time to wait for a probe response (in milliseconds) |
||
314 | |||
315 | Returns: |
||
316 | None |
||
317 | |||
318 | Remarks: |
||
319 | Default is 200ms |
||
320 | *****************************************************************************/ |
||
321 | void WF_CASetMinChannelTime(UINT16 minChannelTime) |
||
322 | { |
||
323 | minChannelTime = HSTOWFS(minChannelTime); |
||
324 | LowLevel_CASetElement(WF_CA_ELEMENT_MIN_CHANNEL_TIME, /* Element ID */ |
||
325 | (UINT8 *)&minChannelTime, /* pointer to element data */ |
||
326 | sizeof(minChannelTime)); /* number of element data bytes */ |
||
327 | } |
||
328 | |||
329 | /***************************************************************************** |
||
330 | Function: |
||
331 | void WF_CAGetMinChannelTime(UINT16 *p_minChannelTime) |
||
332 | |||
333 | Summary: |
||
334 | Gets the current Connection Algorithm minimum channel time. |
||
335 | |||
336 | Description: |
||
337 | Gets the minimum time the connection manager waits for a probe response after |
||
338 | sending a probe request. |
||
339 | |||
340 | Precondition: |
||
341 | MACInit must be called first. |
||
342 | |||
343 | Parameters: |
||
344 | p_minChannelTime -- Pointer where minimum time to wait for a probe response |
||
345 | (in milliseconds) will be written. |
||
346 | |||
347 | Returns: |
||
348 | None |
||
349 | |||
350 | Remarks: |
||
351 | None |
||
352 | *****************************************************************************/ |
||
353 | void WF_CAGetMinChannelTime(UINT16 *p_minChannelTime) |
||
354 | { |
||
355 | |||
356 | LowLevel_CAGetElement(WF_CA_ELEMENT_MIN_CHANNEL_TIME, /* Element ID */ |
||
357 | (UINT8 *)p_minChannelTime, /* pointer to element data */ |
||
358 | 2, /* number of element data bytes */ |
||
359 | TRUE); /* read data, free buffer */ |
||
360 | |||
361 | /* fix up endianess before returning */ |
||
362 | *p_minChannelTime = HSTOWFS(*p_minChannelTime); |
||
363 | } |
||
364 | |||
365 | /***************************************************************************** |
||
366 | Function: |
||
367 | void WF_CASetMaxChannelTime(UINT16 maxChannelTime) |
||
368 | |||
369 | Summary: |
||
370 | Sets the maximum channel time (in milliseconds) |
||
371 | |||
372 | Description: |
||
373 | The maximum time (in milliseconds) the connection manager will wait for a |
||
374 | probe response after sending a probe request. If no probe responses are |
||
375 | received in maxChannelTime then the connection manager will go on to the |
||
376 | next channel, if any are left to scan, or quit. |
||
377 | |||
378 | Precondition: |
||
379 | MACInit must be called first. |
||
380 | |||
381 | Parameters: |
||
382 | maxChannelTime -- maximum time to wait for a probe response (in milliseconds) |
||
383 | |||
384 | Returns: |
||
385 | None |
||
386 | |||
387 | Remarks: |
||
388 | Default is 400ms |
||
389 | *****************************************************************************/ |
||
390 | void WF_CASetMaxChannelTime(UINT16 maxChannelTime) |
||
391 | { |
||
392 | maxChannelTime = HSTOWFS(maxChannelTime); /* fix up endianness before sending */ |
||
393 | LowLevel_CASetElement(WF_CA_ELEMENT_MAX_CHANNEL_TIME, /* Element ID */ |
||
394 | (UINT8 *)&maxChannelTime, /* pointer to element data */ |
||
395 | sizeof(maxChannelTime)); /* number of element data bytes */ |
||
396 | } |
||
397 | |||
398 | /***************************************************************************** |
||
399 | Function: |
||
400 | void WF_CAGetMaxChannelTime(UINT16 *p_maxChannelTime) |
||
401 | |||
402 | Summary: |
||
403 | Gets the Max Channel Time (in milliseconds) |
||
404 | |||
405 | Description: |
||
406 | Gets the maximum time the connection manager waits for a probe response after |
||
407 | sending a probe request. |
||
408 | |||
409 | Precondition: |
||
410 | MACInit must be called first. |
||
411 | |||
412 | Parameters: |
||
413 | p_maxChannelTime -- Pointer where maximum channel time is written |
||
414 | |||
415 | Returns: |
||
416 | None |
||
417 | |||
418 | Remarks: |
||
419 | Default is 400ms |
||
420 | *****************************************************************************/ |
||
421 | void WF_CAGetMaxChannelTime(UINT16 *p_maxChannelTime) |
||
422 | { |
||
423 | |||
424 | LowLevel_CAGetElement(WF_CA_ELEMENT_MAX_CHANNEL_TIME, /* Element ID */ |
||
425 | (UINT8 *)p_maxChannelTime, /* pointer to element data */ |
||
426 | sizeof(UINT16), /* number of element data bytes */ |
||
427 | TRUE); /* read data, free buffer */ |
||
428 | |||
429 | /* fix up endianess before returning */ |
||
430 | *p_maxChannelTime = HSTOWFS(*p_maxChannelTime); |
||
431 | } |
||
432 | |||
433 | /***************************************************************************** |
||
434 | Function: |
||
435 | void WF_CASetProbeDelay(UINT16 probeDelay) |
||
436 | |||
437 | Summary: |
||
438 | Sets the Probe Delay (in microseconds) |
||
439 | |||
440 | Description: |
||
441 | The number of microseconds to delay before transmitting a probe request |
||
442 | following the channel change event. |
||
443 | |||
444 | Precondition: |
||
445 | MACInit must be called first. |
||
446 | |||
447 | Parameters: |
||
448 | probeDelay -- Desired probe delay |
||
449 | |||
450 | Returns: |
||
451 | None |
||
452 | |||
453 | Remarks: |
||
454 | Default is 20uS |
||
455 | *****************************************************************************/ |
||
456 | void WF_CASetProbeDelay(UINT16 probeDelay) |
||
457 | { |
||
458 | probeDelay = HSTOWFS(probeDelay); /* fix up endianness before sending */ |
||
459 | LowLevel_CASetElement(WF_CA_ELEMENT_PROBE_DELAY, /* Element ID */ |
||
460 | (UINT8 *)&probeDelay, /* pointer to element data */ |
||
461 | sizeof(probeDelay)); /* number of element data bytes */ |
||
462 | } |
||
463 | |||
464 | /***************************************************************************** |
||
465 | Function: |
||
466 | void WF_CAGetProbeDelay(UINT16 probeDelay) |
||
467 | |||
468 | Summary: |
||
469 | Gets the Probe Delay (in microseconds) |
||
470 | |||
471 | Description: |
||
472 | The number of microseconds to delay before transmitting a probe request |
||
473 | following the channel change event. |
||
474 | |||
475 | Precondition: |
||
476 | MACInit must be called first. |
||
477 | |||
478 | Parameters: |
||
479 | p_probeDelay -- pointer to where probe delay is written |
||
480 | |||
481 | Returns: |
||
482 | None |
||
483 | |||
484 | Remarks: |
||
485 | Default is 20uS |
||
486 | *****************************************************************************/ |
||
487 | void WF_CAGetProbeDelay(UINT16 *p_probeDelay) |
||
488 | { |
||
489 | |||
490 | LowLevel_CAGetElement(WF_CA_ELEMENT_PROBE_DELAY, /* Element ID */ |
||
491 | (UINT8 *)p_probeDelay, /* pointer to element data */ |
||
492 | sizeof(UINT16), /* number of element data bytes */ |
||
493 | TRUE); /* read data, free buffer */ |
||
494 | |||
495 | /* fix up endianess before returning */ |
||
496 | *p_probeDelay = HSTOWFS(*p_probeDelay); |
||
497 | } |
||
498 | |||
499 | /***************************************************************************** |
||
500 | Function: |
||
501 | void WF_CASetScanCount(UINT8 scanCount) |
||
502 | |||
503 | Summary: |
||
504 | Sets the scan count |
||
505 | |||
506 | Description: |
||
507 | The number of times the Connection Manager will scan a channel while attempting |
||
508 | to find a particular WiFi network. |
||
509 | |||
510 | Precondition: |
||
511 | MACInit must be called first. |
||
512 | |||
513 | Parameters: |
||
514 | scanCount -- desired scan count |
||
515 | |||
516 | Returns: |
||
517 | None |
||
518 | |||
519 | Remarks: |
||
520 | Default is 1 |
||
521 | *****************************************************************************/ |
||
522 | void WF_CASetScanCount(UINT8 scanCount) |
||
523 | { |
||
524 | LowLevel_CASetElement(WF_CA_ELEMENT_SCAN_COUNT, /* Element ID */ |
||
525 | &scanCount, /* pointer to element data */ |
||
526 | sizeof(scanCount)); /* number of element data bytes */ |
||
527 | } |
||
528 | |||
529 | /***************************************************************************** |
||
530 | Function: |
||
531 | void WF_CAGetScanCount(UINT8 *p_scanCount) |
||
532 | |||
533 | Summary: |
||
534 | Gets the scan count |
||
535 | |||
536 | Description: |
||
537 | The number of times the Connection Manager will scan a channel while attempting |
||
538 | to find a particular WiFi network. |
||
539 | |||
540 | Precondition: |
||
541 | MACInit must be called first. |
||
542 | |||
543 | Parameters: |
||
544 | p_scanCount -- pointer to where scan count is written |
||
545 | |||
546 | Returns: |
||
547 | None |
||
548 | |||
549 | Remarks: |
||
550 | Default is 1 |
||
551 | *****************************************************************************/ |
||
552 | void WF_CAGetScanCount(UINT8 *p_scanCount) |
||
553 | { |
||
554 | LowLevel_CAGetElement(WF_CA_ELEMENT_SCAN_COUNT, /* Element ID */ |
||
555 | p_scanCount, /* pointer to element data */ |
||
556 | 1, /* number of element data bytes */ |
||
557 | TRUE); /* read data, free buffer */ |
||
558 | } |
||
559 | |||
560 | |||
561 | /***************************************************************************** |
||
562 | Function: |
||
563 | void WF_CASetRssi(UINT8 rssi) |
||
564 | |||
565 | Summary: |
||
566 | Sets the RSSI threshold |
||
567 | |||
568 | Description: |
||
569 | Specifies the RSSI behavior when connecting. This value is only used if |
||
570 | 1) The current Connection Profile has not defined an SSID or BSSID |
||
571 | 2) An SSID is defined in the current Connection Profile and multiple |
||
572 | access points are discovered with the same SSID. |
||
573 | |||
574 | Values: |
||
575 | |||
576 | 1 - 254: Only connect to a network if the RSSI is greater than or equal to |
||
577 | the specified value |
||
578 | 255: Connect to the highest RSSI found |
||
579 | |||
580 | Precondition: |
||
581 | MACInit must be called first. |
||
582 | |||
583 | Parameters: |
||
584 | scanCount -- desired scan count |
||
585 | |||
586 | Returns: |
||
587 | None |
||
588 | |||
589 | Remarks: |
||
590 | Default is 255 |
||
591 | *****************************************************************************/ |
||
592 | void WF_CASetRssi(UINT8 rssi) |
||
593 | { |
||
594 | LowLevel_CASetElement(WF_CA_ELEMENT_RSSI, /* Element ID */ |
||
595 | &rssi, /* pointer to element data */ |
||
596 | sizeof(rssi)); /* number of element data bytes */ |
||
597 | |||
598 | } |
||
599 | |||
600 | /***************************************************************************** |
||
601 | Function: |
||
602 | void WF_CAGetRssi(UINT8 p_rssi) |
||
603 | |||
604 | Summary: |
||
605 | Gets the RSSI threshold |
||
606 | |||
607 | Description: |
||
608 | See WF_CASetRssi |
||
609 | |||
610 | Precondition: |
||
611 | MACInit must be called first. |
||
612 | |||
613 | Parameters: |
||
614 | p_rssi -- pointer to where RSSI value is written |
||
615 | |||
616 | Returns: |
||
617 | None |
||
618 | |||
619 | Remarks: |
||
620 | Default is 255 |
||
621 | *****************************************************************************/ |
||
622 | void WF_CAGetRssi(UINT8 *p_rssi) |
||
623 | { |
||
624 | LowLevel_CAGetElement(WF_CA_ELEMENT_RSSI, /* Element ID */ |
||
625 | p_rssi, /* pointer to element data */ |
||
626 | 1, /* number of element data bytes */ |
||
627 | TRUE); /* read data, free buffer */ |
||
628 | } |
||
629 | |||
630 | |||
631 | /***************************************************************************** |
||
632 | Function: |
||
633 | void WF_CASetConnectionProfileList(UINT8 cpList[WF_CP_LIST_LENGTH]) |
||
634 | |||
635 | Summary: |
||
636 | Not currently supported |
||
637 | |||
638 | Description: |
||
639 | Not currently supported |
||
640 | |||
641 | Precondition: |
||
642 | MACInit must be called first. |
||
643 | |||
644 | Parameters: |
||
645 | cpList -- array of connection profile ID's used to create CP list |
||
646 | |||
647 | Returns: |
||
648 | None |
||
649 | |||
650 | Remarks: |
||
651 | Not currently supported. The list size is always WF_CP_LIST_SIZE. |
||
652 | The list should start at index 0. Unused entries in the list must be set |
||
653 | to 0xff. |
||
654 | *****************************************************************************/ |
||
655 | void WF_CASetConnectionProfileList(UINT8 cpList[WF_CP_LIST_LENGTH]) |
||
656 | { |
||
657 | WF_ASSERT(FALSE); /* Connection Profile lists are not currently supported */ |
||
658 | #if 0 |
||
659 | LowLevel_CASetElement(WF_CA_ELEMENT_CP_LIST, /* Element ID */ |
||
660 | cpList, /* pointer to element data */ |
||
661 | WF_CP_LIST_LENGTH); /* number of element data bytes */ |
||
662 | #endif |
||
663 | |||
664 | } |
||
665 | |||
666 | /***************************************************************************** |
||
667 | Function: |
||
668 | void WF_CAGetConnectionProfileList(UINT8 cpList[WF_CP_LIST_LENGTH]) |
||
669 | |||
670 | Summary: |
||
671 | Not currently supported |
||
672 | |||
673 | Description: |
||
674 | Not currently supported |
||
675 | |||
676 | Precondition: |
||
677 | MACInit must be called first. |
||
678 | |||
679 | Parameters: |
||
680 | cpList -- array of connection profile ID's used to create CP list |
||
681 | |||
682 | Returns: |
||
683 | None |
||
684 | |||
685 | Remarks: |
||
686 | Not currently supported. The list size is always WF_CP_LIST_SIZE. |
||
687 | *****************************************************************************/ |
||
688 | void WF_CAGetConnectionProfileList(UINT8 cpList[WF_CP_LIST_LENGTH]) |
||
689 | { |
||
690 | WF_ASSERT(FALSE); /* Connection Profile lists are not currently supported */ |
||
691 | #if 0 |
||
692 | LowLevel_CAGetElement(WF_CA_ELEMENT_CP_LIST, /* Element ID */ |
||
693 | cpList, /* pointer to element data */ |
||
694 | WF_CP_LIST_LENGTH, /* number of element data bytes */ |
||
695 | TRUE); /* read data, free buffer */ |
||
696 | #endif |
||
697 | } |
||
698 | |||
699 | /***************************************************************************** |
||
700 | Function: |
||
701 | void WF_CASetListRetryCount(UINT8 listRetryCount) |
||
702 | |||
703 | Summary: |
||
704 | Sets the list retry count |
||
705 | |||
706 | Description: |
||
707 | Number of times to cycle through Connection Profile List before giving up on |
||
708 | the connection attempt. Since lists are not yet supported, this function |
||
709 | actually sets the number of times the Connection Manager will try to connect |
||
710 | with the current Connection Profile before giving up. |
||
711 | |||
712 | Precondition: |
||
713 | MACInit must be called first. |
||
714 | |||
715 | Parameters: |
||
716 | listRetryCount - 0 to 254 or WF_RETRY_FOREVER (255) |
||
717 | |||
718 | Returns: |
||
719 | None |
||
720 | |||
721 | Remarks: |
||
722 | None |
||
723 | *****************************************************************************/ |
||
724 | void WF_CASetListRetryCount(UINT8 listRetryCount) |
||
725 | { |
||
726 | LowLevel_CASetElement(WF_CA_ELEMENT_LIST_RETRY_COUNT, /* Element ID */ |
||
727 | &listRetryCount, /* pointer to element data */ |
||
728 | sizeof(listRetryCount)); /* number of element data bytes */ |
||
729 | } |
||
730 | |||
731 | /***************************************************************************** |
||
732 | Function: |
||
733 | void WF_CAGetListRetryCount(UINT8 *p_listRetryCount) |
||
734 | |||
735 | Summary: |
||
736 | Gets the list retry count |
||
737 | |||
738 | Description: |
||
739 | See description in WF_CASetListRetryCount() |
||
740 | |||
741 | Precondition: |
||
742 | MACInit must be called first. |
||
743 | |||
744 | Parameters: |
||
745 | p_listRetryCount - pointer to where list retry count is written. |
||
746 | |||
747 | Returns: |
||
748 | None |
||
749 | |||
750 | Remarks: |
||
751 | None |
||
752 | *****************************************************************************/ |
||
753 | void WF_CAGetListRetryCount(UINT8 *p_listRetryCount) |
||
754 | { |
||
755 | LowLevel_CAGetElement(WF_CA_ELEMENT_LIST_RETRY_COUNT, /* Element ID */ |
||
756 | p_listRetryCount, /* pointer to element data */ |
||
757 | 1, /* number of element data bytes */ |
||
758 | TRUE); /* read data, free buffer */ |
||
759 | } |
||
760 | |||
761 | /******************************************************************************* |
||
762 | Function: |
||
763 | void WF_CASetEventNotificationAction(UINT8 eventNotificationAction) |
||
764 | |||
765 | Summary: |
||
766 | Reads the CA scan type |
||
767 | |||
768 | Description: |
||
769 | Gets the Event Notification Action used by the Connection Algorithm. The |
||
770 | bit mask for the allowable entries is as follows: |
||
771 | |||
772 | <table> |
||
773 | Bit Event |
||
774 | --- ----- |
||
775 | |||
776 | 1 WF_NOTIFY_CONNECTION_ATTEMPT_FAILED |
||
777 | 2 WF_NOTIFY_CONNECTION_TEMPORARILY_LOST |
||
778 | 3 WF_NOTIFY_CONNECTION_PERMANENTLY_LOST |
||
779 | 4 WF_NOTIFY_CONNECTION_REESTABLISHED |
||
780 | </table> |
||
781 | |||
782 | Precondition: |
||
783 | MACInit must be called first. |
||
784 | |||
785 | Parameters: |
||
786 | eventNotificationAction -- Bit mask indicating which events the host wants |
||
787 | to be notifed of. |
||
788 | |||
789 | Returns: |
||
790 | None. |
||
791 | |||
792 | Remarks: |
||
793 | None. |
||
794 | *****************************************************************************/ |
||
795 | void WF_CASetEventNotificationAction(UINT8 eventNotificationAction) |
||
796 | { |
||
797 | /* Remember what events application wants to be notified of. The MRF24WB0M will inform the WiFi driver */ |
||
798 | /* of all events, but only events the application wants to see will ripple up to WF_ProcessEvent(). */ |
||
799 | SetEventNotificationMask(eventNotificationAction); |
||
800 | |||
801 | } |
||
802 | |||
803 | /******************************************************************************* |
||
804 | Function: |
||
805 | void WF_CAGetEventNotificationAction(UINT8 *p_eventNotificationAction) |
||
806 | |||
807 | Summary: |
||
808 | Reads the Connection Algorithm event notification action. |
||
809 | |||
810 | Description: |
||
811 | Gets the Event Notification Action used by the Connection Algorithm. The |
||
812 | value read back will be a bit mask that corresponds to the following table: |
||
813 | |||
814 | <table> |
||
815 | Bit Event |
||
816 | --- ----- |
||
817 | |||
818 | 1 WF_NOTIFY_CONNECTION_ATTEMPT_FAILED |
||
819 | 2 WF_NOTIFY_CONNECTION_TEMPORARILY_LOST |
||
820 | 3 WF_NOTIFY_CONNECTION_PERMANENTLY_LOST |
||
821 | 4 WF_NOTIFY_CONNECTION_REESTABLISHED |
||
822 | </table> |
||
823 | |||
824 | Precondition: |
||
825 | MACInit must be called first. |
||
826 | |||
827 | Parameters: |
||
828 | p_eventNotificationAction -- pointer to where returned value is written. |
||
829 | |||
830 | Returns: |
||
831 | None. |
||
832 | |||
833 | Remarks: |
||
834 | None. |
||
835 | *****************************************************************************/ |
||
836 | void WF_CAGetEventNotificationAction(UINT8 *p_eventNotificationAction) |
||
837 | { |
||
838 | *p_eventNotificationAction = GetEventNotificationMask(); |
||
839 | } |
||
840 | |||
841 | /******************************************************************************* |
||
842 | Function: |
||
843 | void WF_CASetBeaconTimeoutAction(UINT8 beaconTimeoutAction) |
||
844 | |||
845 | Summary: |
||
846 | Action to take if a connection is lost due to a beacon timeout. |
||
847 | |||
848 | Description: |
||
849 | Sets the Beacon Timeout Action used by the Connection Algorithm. |
||
850 | |||
851 | Precondition: |
||
852 | MACInit must be called first. |
||
853 | |||
854 | Parameters: |
||
855 | beaconTimeoutAction -- Action to take if a connection is lost due |
||
856 | to a beacon timeout. Choices are either: |
||
857 | * WF_ATTEMPT_TO_RECONNECT |
||
858 | * WF_DO_NOT_ATTEMPT_TO_RECONNECT |
||
859 | |||
860 | Returns: |
||
861 | None. |
||
862 | |||
863 | Remarks: |
||
864 | None. |
||
865 | *****************************************************************************/ |
||
866 | void WF_CASetBeaconTimeoutAction(UINT8 beaconTimeoutAction) |
||
867 | { |
||
868 | LowLevel_CASetElement(WF_CA_ELEMENT_BEACON_TIMEOUT_ACTION, /* Element ID */ |
||
869 | &beaconTimeoutAction, /* pointer to element data */ |
||
870 | sizeof(beaconTimeoutAction)); /* number of element data bytes */ |
||
871 | |||
872 | } |
||
873 | |||
874 | /******************************************************************************* |
||
875 | Function: |
||
876 | void WF_CAGetBeaconTimeoutAction(UINT8 *p_beaconTimeoutAction) |
||
877 | |||
878 | Summary: |
||
879 | Reads the Connection Algorithm beacon timeout action. |
||
880 | |||
881 | Description: |
||
882 | Gets the Beacon Timeout Action used by the Connection Algorithm. |
||
883 | |||
884 | Precondition: |
||
885 | MACInit must be called first. |
||
886 | |||
887 | Parameters: |
||
888 | p_beaconTimeoutAction -- pointer where returned value is written. The value |
||
889 | will be either: |
||
890 | * WF_ATTEMPT_TO_RECONNECT |
||
891 | * WF_DO_NOT_ATTEMPT_TO_RECONNECT |
||
892 | |||
893 | Returns: |
||
894 | None. |
||
895 | |||
896 | Remarks: |
||
897 | None. |
||
898 | *****************************************************************************/ |
||
899 | void WF_CAGetBeaconTimeoutAction(UINT8 *p_beaconTimeoutAction) |
||
900 | { |
||
901 | LowLevel_CAGetElement(WF_CA_ELEMENT_BEACON_TIMEOUT_ACTION, /* Element ID */ |
||
902 | p_beaconTimeoutAction, /* pointer to element data */ |
||
903 | 1, /* number of element data bytes */ |
||
904 | TRUE); /* read data, free buffer */ |
||
905 | |||
906 | } |
||
907 | |||
908 | /******************************************************************************* |
||
909 | Function: |
||
910 | void WF_CASetDeauthAction(UINT8 deauthAction) |
||
911 | |||
912 | Summary: |
||
913 | Sets the DeauthAction used by the Connection Algorithm. |
||
914 | |||
915 | Description: |
||
916 | Action to take if a connection is lost due to receiving a deauthentification |
||
917 | message from an AP. |
||
918 | |||
919 | Precondition: |
||
920 | MACInit must be called first. |
||
921 | |||
922 | Parameters: |
||
923 | deauthAction -- Action to take in the event of a deauthentication. |
||
924 | Allowable values are: |
||
925 | * WF_ATTEMPT_TO_RECONNECT |
||
926 | * WF_DO_NOT_ATTEMPT_TO_RECONNECT |
||
927 | |||
928 | Returns: |
||
929 | None. |
||
930 | |||
931 | Remarks: |
||
932 | None. |
||
933 | *****************************************************************************/ |
||
934 | void WF_CASetDeauthAction(UINT8 deauthAction) |
||
935 | { |
||
936 | LowLevel_CASetElement(WF_CA_ELEMENT_DEAUTH_ACTION, /* Element ID */ |
||
937 | &deauthAction, /* pointer to element data */ |
||
938 | sizeof(deauthAction)); /* number of element data bytes */ |
||
939 | } |
||
940 | |||
941 | /******************************************************************************* |
||
942 | Function: |
||
943 | void WF_CAGetDeauthAction(UINT8 *p_deauthAction) |
||
944 | |||
945 | Summary: |
||
946 | Reads the Connection Algorithm deauth action. |
||
947 | |||
948 | Description: |
||
949 | Gets the DeauthAction used by the Connection Algorithm. |
||
950 | |||
951 | Precondition: |
||
952 | MACInit must be called first. |
||
953 | |||
954 | Parameters: |
||
955 | p_deauthAction -- pointer where returned value is written. The value will |
||
956 | be either: |
||
957 | * WF_ATTEMPT_TO_RECONNECT |
||
958 | * WF_DO_NOT_ATTEMPT_TO_RECONNECT |
||
959 | |||
960 | Returns: |
||
961 | None. |
||
962 | |||
963 | Remarks: |
||
964 | None. |
||
965 | *****************************************************************************/ |
||
966 | void WF_CAGetDeauthAction(UINT8 *p_deauthAction) |
||
967 | { |
||
968 | LowLevel_CAGetElement(WF_CA_ELEMENT_DEAUTH_ACTION, /* Element ID */ |
||
969 | p_deauthAction, /* pointer to element data */ |
||
970 | 1, /* number of element data bytes */ |
||
971 | TRUE); /* read data, free buffer */ |
||
972 | } |
||
973 | |||
974 | /******************************************************************************* |
||
975 | Function: |
||
976 | void WF_CASetChannelList(UINT8 *p_channelList, UINT8 numChannels) |
||
977 | |||
978 | Summary: |
||
979 | Sets the channel list. |
||
980 | |||
981 | Description: |
||
982 | Sets the Channel List used by the Connection Algorithm. |
||
983 | |||
984 | Precondition: |
||
985 | MACInit must be called first. |
||
986 | |||
987 | Parameters: |
||
988 | p_channelList -- pointer to channel list. |
||
989 | numChannels -- number of channels in p_channelList. If set to 0, the |
||
990 | MRF24WB0M will use all valid channels for the current |
||
991 | regional domain. |
||
992 | |||
993 | Returns: |
||
994 | None. |
||
995 | |||
996 | Remarks: |
||
997 | None. |
||
998 | *****************************************************************************/ |
||
999 | void WF_CASetChannelList(UINT8 *p_channelList, UINT8 numChannels) |
||
1000 | { |
||
1001 | LowLevel_CASetElement(WF_CA_ELEMENT_CHANNEL_LIST, /* Element ID */ |
||
1002 | p_channelList, /* pointer to element data */ |
||
1003 | numChannels); /* number of element data bytes */ |
||
1004 | } |
||
1005 | |||
1006 | /******************************************************************************* |
||
1007 | Function: |
||
1008 | void WF_CAGetChannelList(UINT8 *p_channelList, UINT8 *p_numChannels) |
||
1009 | |||
1010 | Summary: |
||
1011 | Gets the channel list. |
||
1012 | |||
1013 | Description: |
||
1014 | Gets the Channel List used by the Connection Algorithm. |
||
1015 | |||
1016 | Precondition: |
||
1017 | MACInit must be called first. |
||
1018 | |||
1019 | Parameters: |
||
1020 | p_channelList -- pointer to where channel list will be returned |
||
1021 | p_numChannels -- pointer to where number of channels in list will be |
||
1022 | returned |
||
1023 | |||
1024 | Returns: |
||
1025 | None. |
||
1026 | |||
1027 | Remarks: |
||
1028 | None. |
||
1029 | *****************************************************************************/ |
||
1030 | void WF_CAGetChannelList(UINT8 *p_channelList, UINT8 *p_numChannels) |
||
1031 | { |
||
1032 | tCAElementResponseHdr mgmtHdr; |
||
1033 | |||
1034 | /* send request, wait for mgmt response, do not read and do not free up response buffer */ |
||
1035 | LowLevel_CAGetElement(WF_CA_ELEMENT_CHANNEL_LIST, /* Element ID */ |
||
1036 | NULL, /* do not read */ |
||
1037 | 0, /* do not read */ |
||
1038 | FALSE); /* do not read, do not free mgmt buffer */ |
||
1039 | |||
1040 | /* at this point, management response is mounted and ready to be read */ |
||
1041 | |||
1042 | /* read managment header */ |
||
1043 | RawRead(RAW_RX_ID, 0, sizeof(tCAElementResponseHdr), (UINT8 *)&mgmtHdr); |
||
1044 | |||
1045 | /* extract data length (which will be channel list length) */ |
||
1046 | *p_numChannels = mgmtHdr.elementDataLength; |
||
1047 | |||
1048 | RawRead(RAW_RX_ID, sizeof(tCAElementResponseHdr), *p_numChannels, p_channelList); |
||
1049 | } |
||
1050 | |||
1051 | /******************************************************************************* |
||
1052 | Function: |
||
1053 | void WF_CASetListenInterval(UINT16 listenInterval) |
||
1054 | |||
1055 | Summary: |
||
1056 | Sets the listen interval. |
||
1057 | |||
1058 | Description: |
||
1059 | Sets the listen interval used by the Connection Algorithm. This value is |
||
1060 | measured in 100ms intervals, the default beacon period of APs. |
||
1061 | |||
1062 | <table> |
||
1063 | Value Description |
||
1064 | ----- ----------- |
||
1065 | 1 MRF24WB0M wakes up every 100ms to receive buffered messages. |
||
1066 | 2 MRF24WB0M wakes up every 200ms to receive buffered messages. |
||
1067 | ... ... |
||
1068 | 65535 MRF24WB0M wakes up every 6535.5 seconds (~109 minutes) to |
||
1069 | receive buffered messages. |
||
1070 | </table> |
||
1071 | |||
1072 | Precondition: |
||
1073 | MACInit must be called first. Only used when PS Poll mode is enabled. |
||
1074 | |||
1075 | Parameters: |
||
1076 | listenInterval -- Number of 100ms intervals between instances when |
||
1077 | the MRF24WB0M wakes up to receive buffered messages |
||
1078 | from the network. |
||
1079 | |||
1080 | Returns: |
||
1081 | None. |
||
1082 | |||
1083 | Remarks: |
||
1084 | None. |
||
1085 | *****************************************************************************/ |
||
1086 | void WF_CASetListenInterval(UINT16 listenInterval) |
||
1087 | { |
||
1088 | /* correct endianness before sending message */ |
||
1089 | listenInterval = HSTOWFS(listenInterval); |
||
1090 | |||
1091 | LowLevel_CASetElement(WF_CA_ELEMENT_LISTEN_INTERVAL, /* Element ID */ |
||
1092 | (UINT8 *)&listenInterval, /* pointer to element data */ |
||
1093 | sizeof(listenInterval)); /* number of element data bytes */ |
||
1094 | } |
||
1095 | |||
1096 | /******************************************************************************* |
||
1097 | Function: |
||
1098 | void WF_CAGetListenInterval(UINT16 *p_listenInterval) |
||
1099 | |||
1100 | Summary: |
||
1101 | Gets the listen interval. |
||
1102 | |||
1103 | Description: |
||
1104 | Gets the Listen Interval used by the Connection Algorithm. This value is |
||
1105 | measured in 100ms intervals, the default beacon period of APs. |
||
1106 | |||
1107 | <table> |
||
1108 | Value Description |
||
1109 | ----- ----------- |
||
1110 | 1 MRF24WB0M wakes up every 100ms to receive buffered messages. |
||
1111 | 2 MRF24WB0M wakes up every 200ms to receive buffered messages. |
||
1112 | ... ... |
||
1113 | 65535 MRF24WB0M wakes up every 6535.5 seconds (~109 minutes) to |
||
1114 | receive buffered messages. |
||
1115 | </table> |
||
1116 | |||
1117 | Precondition: |
||
1118 | MACInit must be called first. Only used when PS Poll mode is enabled. |
||
1119 | |||
1120 | Parameters: |
||
1121 | p_listenInterval -- pointer to where listen interval is returned |
||
1122 | |||
1123 | Returns: |
||
1124 | None. |
||
1125 | |||
1126 | Remarks: |
||
1127 | None. |
||
1128 | *****************************************************************************/ |
||
1129 | void WF_CAGetListenInterval(UINT16 *p_listenInterval) |
||
1130 | { |
||
1131 | LowLevel_CAGetElement(WF_CA_ELEMENT_LISTEN_INTERVAL, /* Element ID */ |
||
1132 | (UINT8 *)p_listenInterval, /* pointer to element data */ |
||
1133 | sizeof(UINT16), /* number of element data bytes */ |
||
1134 | TRUE); /* read data, free buffer */ |
||
1135 | |||
1136 | /* fix endianness before returning value */ |
||
1137 | *p_listenInterval = WFSTOHS(*p_listenInterval); |
||
1138 | } |
||
1139 | |||
1140 | /******************************************************************************* |
||
1141 | Function: |
||
1142 | void WF_CASetBeaconTimeout(UINT8 beaconTimeout) |
||
1143 | |||
1144 | Summary: |
||
1145 | Sets the beacon timeout value. |
||
1146 | |||
1147 | Description: |
||
1148 | Sets the Beacon Timeout used by the Connection Algorithm. |
||
1149 | |||
1150 | <table> |
||
1151 | Value Description |
||
1152 | ----- ----------- |
||
1153 | |||
1154 | not be notified of this event. |
||
1155 | 1-255 Number of beacons missed before disconnect event occurs and |
||
1156 | beaconTimeoutAction occurs. If enabled, host will receive |
||
1157 | an event message indicating connection temporarily or |
||
1158 | permanently lost, and if retrying, a connection successful |
||
1159 | event. |
||
1160 | </table> |
||
1161 | |||
1162 | Precondition: |
||
1163 | MACInit must be called first. |
||
1164 | |||
1165 | Parameters: |
||
1166 | beaconTimeout - Number of beacons that can be missed before the action in |
||
1167 | beaconTimeoutAction is taken. |
||
1168 | |||
1169 | Returns: |
||
1170 | None. |
||
1171 | |||
1172 | Remarks: |
||
1173 | None. |
||
1174 | *****************************************************************************/ |
||
1175 | void WF_CASetBeaconTimeout(UINT8 beaconTimeout) |
||
1176 | { |
||
1177 | LowLevel_CASetElement(WF_CA_ELEMENT_BEACON_TIMEOUT, /* Element ID */ |
||
1178 | &beaconTimeout, /* pointer to element data */ |
||
1179 | sizeof(beaconTimeout)); /* number of element data bytes */ |
||
1180 | } |
||
1181 | |||
1182 | /******************************************************************************* |
||
1183 | Function: |
||
1184 | void WF_CAGetBeaconTimeout(UINT8 *p_beaconTimeout) |
||
1185 | |||
1186 | Summary: |
||
1187 | Reads the beacon timeout value. |
||
1188 | |||
1189 | Description: |
||
1190 | Gets the Beacon Timeout used by the Connection Algorithm. |
||
1191 | |||
1192 | <table> |
||
1193 | Value Description |
||
1194 | ----- ----------- |
||
1195 | |||
1196 | not be notified of this event. |
||
1197 | 1-255 Number of beacons missed before disconnect event occurs and |
||
1198 | beaconTimeoutAction occurs. If enabled, host will receive |
||
1199 | an event message indicating connection temporarily or |
||
1200 | permanently lost, and if retrying, a connection successful |
||
1201 | event. |
||
1202 | </table> |
||
1203 | |||
1204 | Precondition: |
||
1205 | MACInit must be called first. |
||
1206 | |||
1207 | Parameters: |
||
1208 | p_beaconTimeout -- pointer where beacon timeout value is written |
||
1209 | |||
1210 | Returns: |
||
1211 | None. |
||
1212 | |||
1213 | Remarks: |
||
1214 | None. |
||
1215 | *****************************************************************************/ |
||
1216 | void WF_CAGetBeaconTimeout(UINT8 *p_beaconTimeout) |
||
1217 | { |
||
1218 | LowLevel_CAGetElement(WF_CA_ELEMENT_BEACON_TIMEOUT, /* Element ID */ |
||
1219 | p_beaconTimeout, /* pointer to element data */ |
||
1220 | 1, /* number of element data bytes */ |
||
1221 | TRUE); /* read data, free buffer */ |
||
1222 | } |
||
1223 | |||
1224 | /******************************************************************************* |
||
1225 | Function: |
||
1226 | static void SetEventNotificationMask(UINT8 eventNotificationBitMask) |
||
1227 | |||
1228 | Summary: |
||
1229 | Sets the event notification mask. |
||
1230 | |||
1231 | Description: |
||
1232 | Sets the event notification mask for the Connection Algorithm. Allowable |
||
1233 | values are: |
||
1234 | |||
1235 | <table> |
||
1236 | Value Event |
||
1237 | ----- ----- |
||
1238 | 0x01 WF_NOTIFY_CONNECTION_ATTEMPT_SUCCESSFUL |
||
1239 | 0x02 WF_NOTIFY_CONNECTION_ATTEMPT_FAILED |
||
1240 | 0x04 WF_NOTIFY_CONNECTION_TEMPORARILY_LOST |
||
1241 | 0x08 WF_NOTIFY_CONNECTION_PERMANENTLY_LOST |
||
1242 | 0x10 WF_NOTIFY_CONNECTION_REESTABLISHED |
||
1243 | 0x1f WF_NOTIFY_ALL_EVENTS |
||
1244 | </table> |
||
1245 | |||
1246 | Precondition: |
||
1247 | MACInit must be called first. |
||
1248 | |||
1249 | Parameters: |
||
1250 | eventNotificationBitMask - Bit mask defining which events the host will be |
||
1251 | notified of. |
||
1252 | |||
1253 | Returns: |
||
1254 | None. |
||
1255 | |||
1256 | Remarks: |
||
1257 | None. |
||
1258 | *****************************************************************************/ |
||
1259 | static void SetEventNotificationMask(UINT8 eventNotificationBitMask) |
||
1260 | { |
||
1261 | g_EventNotificationAction = eventNotificationBitMask; |
||
1262 | } |
||
1263 | |||
1264 | /******************************************************************************* |
||
1265 | Function: |
||
1266 | UINT8 GetEventNotificationMask(void) |
||
1267 | |||
1268 | Summary: |
||
1269 | Gets the event notification mask. |
||
1270 | |||
1271 | Description: |
||
1272 | Gets the event notification mask for the Connection Algorithm. Retruned |
||
1273 | values are: |
||
1274 | |||
1275 | <table> |
||
1276 | Value Event |
||
1277 | ----- ----- |
||
1278 | 0x01 WF_NOTIFY_CONNECTION_ATTEMPT_SUCCESSFUL |
||
1279 | 0x02 WF_NOTIFY_CONNECTION_ATTEMPT_FAILED |
||
1280 | 0x04 WF_NOTIFY_CONNECTION_TEMPORARILY_LOST |
||
1281 | 0x08 WF_NOTIFY_CONNECTION_PERMANENTLY_LOST |
||
1282 | 0x10 WF_NOTIFY_CONNECTION_REESTABLISHED |
||
1283 | 0x1f WF_NOTIFY_ALL_EVENTS |
||
1284 | </table> |
||
1285 | |||
1286 | Precondition: |
||
1287 | MACInit must be called first. |
||
1288 | |||
1289 | Parameters: |
||
1290 | None. |
||
1291 | |||
1292 | Returns: |
||
1293 | A UINT8 of the event notification bit mask. |
||
1294 | |||
1295 | Remarks: |
||
1296 | None. |
||
1297 | *****************************************************************************/ |
||
1298 | UINT8 GetEventNotificationMask(void) |
||
1299 | { |
||
1300 | return g_EventNotificationAction; |
||
1301 | } |
||
1302 | #endif /* WF_USE_INDIVIDUAL_SET_GETS */ |
||
1303 | |||
1304 | /******************************************************************************* |
||
1305 | Function: |
||
1306 | static void LowLevel_CASetElement(UINT8 elementId, |
||
1307 | UINT8 *p_elementData, |
||
1308 | UINT8 elementDataLength) |
||
1309 | |||
1310 | Summary: |
||
1311 | Set an element of the connection algorithm on the MRF24WB0M. |
||
1312 | |||
1313 | Description: |
||
1314 | Low-level function to send the appropriate management message to the |
||
1315 | MRF24WB0M to set the Connection Algorithm element. |
||
1316 | |||
1317 | Precondition: |
||
1318 | MACInit must be called first. |
||
1319 | |||
1320 | Parameters: |
||
1321 | elementId -- element that is being set |
||
1322 | p_elementData -- pointer to element data |
||
1323 | elementDataLength -- number of bytes pointed to by p_elementData |
||
1324 | |||
1325 | Returns: |
||
1326 | None. |
||
1327 | |||
1328 | Remarks: |
||
1329 | All Connection Algorithm 'Set Element' functions call this function |
||
1330 | to construct the management message. The caller must fix up any endian |
||
1331 | issues prior to calling this function. |
||
1332 | *****************************************************************************/ |
||
1333 | static void LowLevel_CASetElement(UINT8 elementId, |
||
1334 | UINT8 *p_elementData, |
||
1335 | UINT8 elementDataLength) |
||
1336 | { |
||
1337 | UINT8 hdrBuf[4]; |
||
1338 | |||
1339 | hdrBuf[0] = WF_MGMT_REQUEST_TYPE; /* indicate this is a mgmt msg */ |
||
1340 | hdrBuf[1] = WF_CA_SET_ELEMENT_SUBTYPE; /* mgmt request subtype */ |
||
1341 | hdrBuf[2] = elementId; /* Element ID */ |
||
1342 | hdrBuf[3] = elementDataLength; /* number of bytes of element data */ |
||
1343 | |||
1344 | SendMgmtMsg(hdrBuf, |
||
1345 | sizeof(hdrBuf), |
||
1346 | p_elementData, |
||
1347 | elementDataLength); |
||
1348 | |||
1349 | /* wait for mgmt response, free after it comes in, don't need data bytes */ |
||
1350 | WaitForMgmtResponse(WF_CA_SET_ELEMENT_SUBTYPE, FREE_MGMT_BUFFER); |
||
1351 | } |
||
1352 | |||
1353 | /******************************************************************************* |
||
1354 | Function: |
||
1355 | static void LowLevel_CAGetElement(UINT8 elementId, |
||
1356 | UINT8 *p_elementData, |
||
1357 | UINT8 elementDataLength, |
||
1358 | UINT8 dataReadAction) |
||
1359 | |||
1360 | Summary: |
||
1361 | Get an element of the connection algorithm on the MRF24WB0M. |
||
1362 | |||
1363 | Description: |
||
1364 | Low-level function to send the appropriate management message to the |
||
1365 | MRF24WB0M to get the Connection Algorithm element. |
||
1366 | |||
1367 | Precondition: |
||
1368 | MACInit must be called first. |
||
1369 | |||
1370 | Parameters: |
||
1371 | elementId -- element that is being read |
||
1372 | p_elementData -- pointer to where element data will be written |
||
1373 | elementDataLength -- number of element data bytes that will be read |
||
1374 | dataReadAction -- If TRUE then read data per paramters and free mgmt response buffer. |
||
1375 | If FALSE then return after response received, do not read any data as the |
||
1376 | caller will do that, and don't free buffer, as caller will do that as well. |
||
1377 | |||
1378 | Returns: |
||
1379 | None. |
||
1380 | |||
1381 | Remarks: |
||
1382 | All Connection Algorithm 'Get Element' functions call this function to |
||
1383 | construct the management message. The caller must fix up any endian issues |
||
1384 | after getting the data from this function. |
||
1385 | *****************************************************************************/ |
||
1386 | static void LowLevel_CAGetElement(UINT8 elementId, |
||
1387 | UINT8 *p_elementData, |
||
1388 | UINT8 elementDataLength, |
||
1389 | UINT8 dataReadAction) /* TRUE or FALSE */ |
||
1390 | { |
||
1391 | UINT8 hdrBuf[4]; |
||
1392 | |||
1393 | hdrBuf[0] = WF_MGMT_REQUEST_TYPE; /* indicate this is a mgmt msg */ |
||
1394 | hdrBuf[1] = WF_CA_GET_ELEMENT_SUBTYPE; /* mgmt request subtype */ |
||
1395 | hdrBuf[2] = elementId; /* Element ID */ |
||
1396 | hdrBuf[3] = 0; /* not used */ |
||
1397 | |||
1398 | SendMgmtMsg(hdrBuf, |
||
1399 | sizeof(hdrBuf), |
||
1400 | NULL, |
||
1401 | 0); |
||
1402 | |||
1403 | if (dataReadAction == (UINT8)TRUE) |
||
1404 | { |
||
1405 | /* wait for mgmt response, read desired data, and then free response buffer */ |
||
1406 | WaitForMgmtResponseAndReadData(WF_CA_GET_ELEMENT_SUBTYPE, |
||
1407 | elementDataLength, /* num data bytes to read */ |
||
1408 | sizeof(tCAElementResponseHdr), /* index of first byte of element data */ |
||
1409 | p_elementData); /* where to write element data */ |
||
1410 | } |
||
1411 | else |
||
1412 | { |
||
1413 | /* wait for mgmt response, don't read any data bytes, do not release mgmt buffer */ |
||
1414 | WaitForMgmtResponse(WF_CA_GET_ELEMENT_SUBTYPE, DO_NOT_FREE_MGMT_BUFFER); |
||
1415 | } |
||
1416 | } |
||
1417 | |||
1418 | #if defined(WF_CM_DEBUG) |
||
1419 | static void LowLevel_CMInfo(UINT8 infoId, |
||
1420 | UINT8 *p_infoData, |
||
1421 | UINT8 infoDataLength, |
||
1422 | UINT8 dataReadAction) /* TRUE or FALSE */ |
||
1423 | { |
||
1424 | UINT8 hdrBuf[4]; |
||
1425 | |||
1426 | hdrBuf[0] = WF_MGMT_REQUEST_TYPE; /* indicate this is a mgmt msg */ |
||
1427 | hdrBuf[1] = WF_CM_INFO_SUBTYPE; /* mgmt request subtype */ |
||
1428 | hdrBuf[2] = infoId; /* info ID */ |
||
1429 | hdrBuf[3] = 0; /* not used */ |
||
1430 | |||
1431 | SendMgmtMsg(hdrBuf, |
||
1432 | sizeof(hdrBuf), |
||
1433 | NULL, |
||
1434 | 0); |
||
1435 | |||
1436 | if (dataReadAction == (UINT8)TRUE) |
||
1437 | { |
||
1438 | /* wait for mgmt response, read desired data, and then free response buffer */ |
||
1439 | WaitForMgmtResponseAndReadData(WF_CM_INFO_SUBTYPE, |
||
1440 | infoDataLength, /* num data bytes to read */ |
||
1441 | sizeof(tCMInfoResponseHdr), /* index of first byte of info data */ |
||
1442 | p_infoData); /* where to write info data */ |
||
1443 | } |
||
1444 | else |
||
1445 | { |
||
1446 | /* wait for mgmt response, don't read any data bytes, do not release mgmt buffer */ |
||
1447 | WaitForMgmtResponse(WF_CM_INFO_SUBTYPE, DO_NOT_FREE_MGMT_BUFFER); |
||
1448 | } |
||
1449 | } |
||
1450 | |||
1451 | void WF_CMInfoGetFSMStats(tWFCMInfoFSMStats *p_info) |
||
1452 | { |
||
1453 | LowLevel_CMInfo(WF_CM_INFO_GET_FSM_STATS, /* info ID */ |
||
1454 | (UINT8 *)p_info, /* pointer to info data */ |
||
1455 | sizeof(tWFCMInfoFSMStats), /* num data bytes */ |
||
1456 | TRUE); /* read data, free buffer */ |
||
1457 | } |
||
1458 | #endif /* WF_CM_DEBUG */ |
||
1459 | |||
1460 | #endif /* WF_CS_TRIS */ |
||
1461 |
Powered by WebSVN v2.8.3