unsigned int SPI_Ethernet_UserTCP(unsigned char *remoteHost, unsigned int remotePort, unsigned int localPort, unsigned int reqLength, TEthPktFlags *flags) { unsigned int len; // my reply length if(localPort != 8080) return(0); // I listen only to web request on port 80
// get 10 first bytes only of the request, the rest does not matter here for(len = 0 ; len < 15 ; len++) getRequest[len] = SPI_Ethernet_getByte(); getRequest[len] = 0;
if(memcmp(getRequest, "GET /", 5)) return(0); // only GET method if(!memcmp(getRequest+11, 112, 3)) //web'ten 112 gelirge g değişkenin 1 yap diyorum.
len = SPI_Ethernet_putConstString(httpHeader); // HTTP header len += SPI_Ethernet_putConstString(httpMimeTypeHTML); // with HTML MIME type len += SPI_Ethernet_putString(indexPage); // HTML page first part //len += SPI_Ethernet_putString(indexPage2); return len; // return to the library with the number of bytes to transmit } unsigned int SPI_Ethernet_UserUDP(unsigned char *remoteHost, unsigned int remotePort, unsigned int destPort, unsigned int reqLength, TEthPktFlags *flags)
{ return 0; // back to the library with the length of the UDP reply }
void main() { UART1_Init(300); Delay_ms(100); ADCON1 |= 0x0F ; // Analog Girişler Kapalı CMCON |= 0x07 ; // Komparatörler TRISA=0XFF; //PORTA GİRİŞ TRISB=0xFF; //PORTB GİRİŞ TRISB.RB0=0; TRISC.RC6=0; //// TX BACAĞI ÇIKIŞ TRISD=0XFF; //PORTD GİRİŞ TRISC.RC2=1; //RC2 GİRİŞ //TRISE.RE0=1; //RE0 GİRİŞ PORTB=0X00; PORTA=0X00; PORTC.RC2=0; PORTD=0x00; // starts ENC28J60 with: reset bit on PORTC.F0, CS bit on PORTC.F1, // my MAC & IP address, full duplex SPI1_Init(); // full duplex, CRC + MAC Unicast + MAC Broadcast filtering SPI_Ethernet_Init(myMacAddr, myIpAddr, Spi_Ethernet_FULLDUPLEX) ;
// dhcp will not be used here, so use preconfigured addresses SPI_Ethernet_confNetwork(ipMask, gwIpAddr, dnsIpAddr);