'--Send_sd_data.inc
'*******************************************************************************
' send data from SD Card
'*******************************************************************************
Sub Sd_html()
Local Fl As Long
Local Wsize As Word
Select Case Filetype
Case 9 : Tempw = Tcpwrite(i , "Content-Type: image/gif{013}{010}")
Case 12 : Tempw = Tcpwrite(i , "Content-Type: image/jpeg{013}{010}")
Case 2 : Tempw = Tcpwrite(i , "Content-Type: application/x-javascript{013}{010}")
Case 14 : Tempw = Tcpwrite(i , "text/css{013}{010}")
Case Else : Tempw = Tcpwrite(i , "Content-Type: text/html{013}{010}")
End Select
Print "Ext=" ; Ext
Print "send " ; Shtml ; " on Sock= " ; I
Call Activate_sdcard()
Fl = Filelen(shtml)
Call Activate_wiz812
#if Cdebug
Print "size :" ; Fl
#endif
Locate 1 , 1
Lcd "Size>" ; Fl
Buffer = "Content-Length: " + Str(fl) + "{013}{010}"
Tempw = Tcpwritestr(i , Buffer , 900) ' add additional CR and LF
Call Activate_sdcard()
Open Shtml For Binary As #4
Do
Call Activate_sdcard()
If Fl > 900 Then 'send 128 Byte
Get #4 , Buf(1) , , 900
Fl = Fl - 900 : Wsize = 900
Else
Get #4 , Buf(1) , , Fl 'send the rest
Wsize = Fl : Fl = 0
End If
Call Activate_wiz812
Tempw = Tcpwrite(i , Buf(1) , Wsize) ' write data
If Tempw <> Wsize Then
Print Tempw ; " - " ; Wsize ; " written : error" 'when error
Exit Do
End If
Loop Until Fl = 0
Close #4
Buffer = ""
End Sub
|