| Line No. | Rev | Author | Line |
|---|---|---|---|
| 1 | 32 | kaklik | /********************************************************************* |
| 2 | * |
||
| 3 | * Zero Confiruation (Zeroconf) Helper |
||
| 4 | * Module for Microchip TCP/IP Stack |
||
| 5 | * |
||
| 6 | ********************************************************************* |
||
| 7 | * FileName: ZeroconfHelper.h |
||
| 8 | * Dependencies: ZeroconfLinkLocal, ZeroconfMulticastDNS |
||
| 9 | * Processor: PIC24F, PIC24H, dsPIC30F, dsPIC33F, PIC32 |
||
| 10 | * Compiler: Microchip C32 v1.05 or higher |
||
| 11 | * Microchip C30 v3.12 or higher |
||
| 12 | * Company: Microchip Technology, Inc. |
||
| 13 | * |
||
| 14 | * Software License Agreement |
||
| 15 | * |
||
| 16 | * Copyright (C) 2009-2010 Microchip Technology Inc. All rights |
||
| 17 | * reserved. |
||
| 18 | * |
||
| 19 | * Microchip licenses to you the right to use, modify, copy, and |
||
| 20 | * distribute: |
||
| 21 | * (i) the Software when embedded on a Microchip microcontroller or |
||
| 22 | * digital signal controller product ("Device") which is |
||
| 23 | * integrated into Licensee's product; or |
||
| 24 | * (ii) ONLY the Software driver source files ENC28J60.c, ENC28J60.h, |
||
| 25 | * ENCX24J600.c and ENCX24J600.h ported to a non-Microchip device |
||
| 26 | * used in conjunction with a Microchip ethernet controller for |
||
| 27 | * the sole purpose of interfacing with the ethernet controller. |
||
| 28 | * |
||
| 29 | * You should refer to the license agreement accompanying this |
||
| 30 | * Software for additional information regarding your rights and |
||
| 31 | * obligations. |
||
| 32 | * |
||
| 33 | * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT |
||
| 34 | * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT |
||
| 35 | * LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A |
||
| 36 | * PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
||
| 37 | * MICROCHIP BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR |
||
| 38 | * CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF |
||
| 39 | * PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS |
||
| 40 | * BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE |
||
| 41 | * THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER |
||
| 42 | * SIMILAR COSTS, WHETHER ASSERTED ON THE BASIS OF CONTRACT, TORT |
||
| 43 | * (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR OTHERWISE. |
||
| 44 | * |
||
| 45 | * |
||
| 46 | * Author Date Comment |
||
| 47 | *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
| 48 | * Pradeep Reddy 01 Mar 2009 Initial |
||
| 49 | * Brad Rex 05 Apr 2010 Updated for MRF24WB0M. |
||
| 50 | ********************************************************************/ |
||
| 51 | #define __Zeroconf_Helper_C |
||
| 52 | |||
| 53 | #include "TCPIP Stack/TCPIP.h" |
||
| 54 | |||
| 55 | #if defined(STACK_USE_ZEROCONF_LINK_LOCAL) || defined(STACK_USE_ZEROCONF_MDNS_SD) |
||
| 56 | |||
| 57 | #include "TCPIP Stack/ZeroconfHelper.h" |
||
| 58 | |||
| 59 | BYTE zeroconf_dbg_level = 3; // All levels of debug info are printed. |
||
| 60 | |||
| 61 | #if defined(NEED_TO_DEFINE_zeroconf_dbg_msg) |
||
| 62 | |||
| 63 | char zeroconf_dbg_msg[ZEROCONF_DBG_MSG_SIZE]; |
||
| 64 | |||
| 65 | #endif |
||
| 66 | |||
| 67 | #if defined(INFO_ZCLL) |
||
| 68 | void info_zcll_print(char * msg) |
||
| 69 | { |
||
| 70 | if (zeroconf_dbg_level >= 1) |
||
| 71 | putsUART(msg); |
||
| 72 | } |
||
| 73 | #endif |
||
| 74 | |||
| 75 | #if defined(DEBUG_ZCLL) |
||
| 76 | void debug_zcll_print(char * msg) |
||
| 77 | { |
||
| 78 | if (zeroconf_dbg_level >= 2) |
||
| 79 | putsUART(msg); |
||
| 80 | } |
||
| 81 | #endif |
||
| 82 | |||
| 83 | #if defined(INFO_MDNS) |
||
| 84 | void info_mdns_print(char * msg) |
||
| 85 | { |
||
| 86 | if (zeroconf_dbg_level >= 1) |
||
| 87 | putsUART(msg); |
||
| 88 | } |
||
| 89 | #endif |
||
| 90 | |||
| 91 | #if defined(DEBUG_MDNS) |
||
| 92 | void debug_mdns_print(char * msg) |
||
| 93 | { |
||
| 94 | if (zeroconf_dbg_level >= 2) |
||
| 95 | putsUART(msg); |
||
| 96 | } |
||
| 97 | #endif |
||
| 98 | |||
| 99 | /* |
||
| 100 | The calling convention is: |
||
| 101 | |||
| 102 | static TICK event_time = 0; |
||
| 103 | static TICK random_delay = 0; |
||
| 104 | static BYTE time_recorded = 0; |
||
| 105 | |||
| 106 | switch ( zgzc_wait_for(&random_delay, &event_time, &time_recorded) ) |
||
| 107 | { |
||
| 108 | case ZGZC_STARTED_WAITING: |
||
| 109 | |||
| 110 | # Set random_delay value; |
||
| 111 | |||
| 112 | // Intentional fall-through |
||
| 113 | |||
| 114 | case ZGZC_KEEP_WAITING: |
||
| 115 | |||
| 116 | // Not Completed the delay proposed |
||
| 117 | return; |
||
| 118 | } |
||
| 119 | |||
| 120 | // Completed the delay required |
||
| 121 | |||
| 122 | # Do the scheduled work; |
||
| 123 | */ |
||
| 124 | |||
| 125 | BYTE zgzc_wait_for(DWORD *pTicksToWait, DWORD *pStartingTickTime, BYTE *pWaitingHasStarted) |
||
| 126 | { |
||
| 127 | if ( !(*pWaitingHasStarted) ) |
||
| 128 | { |
||
| 129 | // start a new waiting period |
||
| 130 | *pStartingTickTime = TickGet(); // The time we started the waiting. |
||
| 131 | *pWaitingHasStarted = 1; // To indicate that the timer has started. |
||
| 132 | |||
| 133 | return ZGZC_STARTED_WAITING; |
||
| 134 | } |
||
| 135 | |||
| 136 | if( (TickGet() - *pStartingTickTime) < (*pTicksToWait) ) |
||
| 137 | { |
||
| 138 | /* Not Completed the delay proposed */ |
||
| 139 | return ZGZC_KEEP_WAITING; |
||
| 140 | } |
||
| 141 | |||
| 142 | // We have completed the required waiting. |
||
| 143 | |||
| 144 | *pStartingTickTime = 0 ; /* Reset starting time. Not really necessary. */ |
||
| 145 | *pWaitingHasStarted = 0; /* Reset timer */ |
||
| 146 | |||
| 147 | return ZGZC_DONE_WAITING; |
||
| 148 | } |
||
| 149 | |||
| 150 | #endif // (STACK_USE_ZEROCONF_LINK_LOCAL) || defined(STACK_USE_ZEROCONF_MDNS_SD) |
Powered by WebSVN v2.8.3