'-------------------------------------------------------------------------------
'              NM7010A Network Module Modifikasi Oleh Dedy Hidayat
'-------------------------------------------------------------------------------
$regfile = "m8535.dat"                                      ' Menjelaskan jenis microcontroller yang digunakan
 
$prog , &HA4 , &HD9,
$crystal = 4000000                                          ' Menentukan jumlah crystal frequency yang digunakan
$baud = 19200                                               ' Mengunakan baud rate
$hwstack = 32                                               ' default use 32 for the hardware stack
$swstack = 10                                               ' default use 10 for the SW stack
$framesize = 40                                             ' default use 40 for the frame space
 
 
Const Sock_stream = $01                                     ' Tcp
Const Sel_recv = 2
 
'socket status
Const Sock_closed = $00                                     ' Status Of Connection Closed
 
Const Sock_established = $06                                ' Status Of Tcp Connection Established
Const Sock_close_wait = $07                                 ' Status Of Closing Tcp Connection
 
Config Pind.4 = Output                                      ' reset NM7010A module
Set Portd.4
Reset Portd.4
Waitms 12
 
Set Portd.4
Config Portb.0 = Output
Config Portb.1 = Output
 
Config Portb.2 = Output
Config Portb.3 = Output
 
Config Porta.0 = Output
Config Porta.1 = Output
 
Enable Interrupts
' Atutrlah MAC & IP address, SubMask, Gateway to appropriate to your network setting
' From computer connected to the network, type //192.168.1.8/index.htm at the Internet Explorer window
Config Tcpip = Int0 , Mac = 12.128.12.34.56.78 , Ip = 10.10.10.2 , Submask = 255.255.255.0 , Gateway = 10.10.10.1 , Localport = 1000 , Tx = $55 , Rx = $55 , Twi = &H80
 
'dim used variables
Dim S As String * 200 , Shtml As String * 15 , Sheader As String * 30
Dim Tempw As Word
Dim I As Byte , P1 As Byte , P2 As Byte
 
Do
   Tempw = Socketstat(0 , 0)                                ' get status
   If Tempw = Sock_established Then
      Tempw = Socketstat(0 , Sel_recv)                      ' get received bytes
      If Tempw > 0 Then                                     ' if there is something received
         Do
            Tempw = Tcpread(0 , S)                          ' read a line
            If Left(s , 3) = "GET" Then
               Gosub Page
            End If
         Loop Until S = ""                                  ' wait until we get an empty line
         Tempw = Tcpwrite(0 , "HTTP/1.0 200 OK{013}{010}")  ' send ok
         Gosub Stuur                                        ' GET or HEAD or POST feedback so send it
         Closesocket 0                                      ' close the connection
      End If
   Elseif Tempw = Sock_close_wait Then
      Closesocket 0                                         ' we need to close
   Elseif Tempw = Sock_closed Then
      I = Getsocket(0 , Sock_stream , 80 , 0)               ' get a new socket
      Socketlisten 0                                        ' listen
   End If
Loop
End
 
'get html page out of data
Page:
   P1 = Instr(s , " ")                                      ' find first space
   P1 = P1 + 1                                              ' 4
   P2 = Instr(p1 , S , " ")                                 ' find second space
   P2 = P2 - P1
   Shtml = Mid(s , P1 , P2)                                 ' dont use too long page names
   Shtml = Lcase(shtml)                                     ' make lower case
Return
 
'send data
Stuur:
   Dim Wsize As Word , Ihitcounter As Integer
   Tempw = Tcpwrite(0 , "Content-Type: text/html{013}{010}")
   If Shtml = "/index.htm" Then                             ' data from eeprom
      S = "<html><head><title>Innovative Electronics</title></head><body><p><b>NM7010A test<br></b>by IE team<br><br>Hits : " + Str(ihitcounter) + "</p></body></html>"
      Incr Ihitcounter                                      ' increase hitcounter
      Wsize = Len(s)                                        ' size of body
      Sheader = "Content-Length: " + Str(wsize) + "{013}{010}"
      Tempw = Tcpwritestr(0 , Sheader , 255)                ' add additional CR and LF
      Tempw = Tcpwrite(0 , S , Wsize)                       ' send body
   End If
   Shtml = ""
Return

GroG

11 years ago

You've just dumped a bunch of visual basic on a page without a direct question about it.  Why?  What does this have to do with your previous question?