From Swordfish Wiki

SwordfishUser: W5500

Updated with TCP socket connection - February 28, 2015

Updated with PING functionality - March 27, 2015 (see at bottom)

This library allow the use of the WIZnet / WIZ550io in Swordfish that mount W5500 ethernet chip. The W5500 has within it all the logic related to the TCP client / server and responds to the ping without special drivers, can enable wake on lan feature and it is for this reason that lends itself to be used quickly and without a great deal of memory. Compared to his older brother W5100 (for which you will find the SF library here) has far fewer pins, a simple buffer management (no more fraction) allowing direct access to the memory in a sequential manner and more available sockets.

You can download Swordfish library modules here: W5500-Library

This library is compatible with this hardware also

Hardware specifications

In particular, I have used through a module sold by the same WIZnet called WIZ550io that mounts over chip and ethernet connector with all necessary circuitry. The module has two connectors strips with 1x6 pin and 1x8 pins.

Works with 3.3V only although would be driven with signals up to 5V tolerance. I made an home made PCB and have attached schematics and PCB.

You can download Eagle project here

Internal W5500 specifications

The module in question is a new born in WIZNET and soon take the place of his older brother since its specifications and its cost are definitely their attacks, as the brother the only flaw it has is the lack of natives DHCP and DNS for which you must write the missing driver .. WIZnet provides extensive documentation about it and they should make porting from C ++.

Based on what has been done for the Firewing home made ethernet shield I did include the initialization and all that allows you to use this module as a server as I allow its use as a server / client TCP and UDP as it is.

Surely the use of W5500 with PIC18 is an advantage because compared to the W5100 version with this chip you can avoid allocating the receive buffer. In the main program with options you can also disable DNS and/or DHCP freely for more memory.

The W5500 has a total memory of 16K transmission and 16K reception RAM and has 8 independent sockets on which you can make simultaneous connections. The memories are adaptable to the needs, and you can predefine the amount of memory allocation for the TX and RX for every socket in steps of 1K. The routine that sets the memory is the SysMemInit in the module W5500-Regs.BAS that uses as default the values contained in two array in the module W5500-Config.BAS and you have to call a reset of the device and so you need to re-insert network parameters (refer to SetDHCPNetwork() in W5500-DHCP module and of course at the datasheet of the device).

Modules in library zip file

ModuleDescription
W5500.basMain module with public aliases to other module
W5500-Config.basNetwork and memory default configuration like MAC address and IP,GW,DNS
W5500-Consts.basDevice constants like regs and memory definitions
W5500-DHCP.basDHCP module with DHCHTask main sub
W5500-DNS.basDNS module with DNSResolve main sub, the DNS uses global Dns_Addr for DNS server IP address when USE_DHCP=False
W5500-Ping.basIPRAW mode ping module (27/3/2015)
W5500-Regs.basModule responsible of device regs setting
W5500-RX.basAll sync and async RX functions
W5500-SOAP.basRoutines for the creation of response and parameters extraction from SOAP request
W5500-Socket.basRoutines for socket management
W5100-TX.basAll sync and async TX functions
W5100-Utils.basSW transposition of C++ arrays management

If you do not use DHCP the settings affecting fixed ip address, subnet mask and gw are set in the module "W5500-Config.bas" that however can be overridden and this module is not part of the zip and must be created into project folder. The default tcp port cTCP_PORT is set in "W5500-Consts.bas" and as default is the port 80. This port is used only and exclusively by the examples which I reported below and is not used in another way by the modules contained in the zip.

W5500-Config.bas

Create this module in a file called W5500-Config.bas in the folder where have created the two sample programs.

{
*****************************************************************************
*  Name    : W5500-Config.BAS                                               *
*  Author  : Coccoliso                                                      *
*  Notice  : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS]              *
*          : All Rights Reserved                                            *
*  Date    : 02/11/2014                                                     *
*  Version : 1.0                                                            *
*  Notes   :                                                                *
*          :                                                                *
*****************************************************************************
}
Module W5500_Config

Public Const
    cMac_Addr(6) As Byte = ($00,$0E,$35,$73,$9F,$EF),
    cIp_Addr(4)  As Byte = (192,168,1,9),
    cSub_Mask(4) As Byte = (255,255,255,0),
    cGtw_Addr(4) As Byte = (192,168,1,200),
    cDns_Addr(4) As Byte = (192,168,1,200)

Public Const
    cHOST_NAME  = "WIZ550IO"

Public Const
    SOCK_TX_SIZES(8) As Byte = (2,2,2,2,2,2,2,2),    
    SOCK_RX_SIZES(8) As Byte = (2,2,2,2,2,2,2,2)    

HTTP Server Sample

Here's an example of use with DHCP request, DNS resolution and a simple web server that responds to the "/index.html" and is able to recognize the HTTP verb and act as a result.

{
*****************************************************************************
*  Name    : W5500-HTTP-Server.BAS                                          *
*  Author  : Coccoliso                                                      *
*  Notice  : Copyright (c) 2014                                             *
*          : All Rights Reserved                                            *
*  Date    : 30/01/2015                                                     *
*  Version : 2.0                                                            *
*  Notes   : All 8 sockets can be used for a multi socket server            *
*          :                                                                *
*****************************************************************************
}
Device = 18f2682
Clock = 40

#option WIZ_DHCP_DEBUG  = true
#option WIZ_DNS_DEBUG   = false

#option USE_DHCP = true
#option USE_DNS  = false
#option WIZ_SCS_PIN = PORTC.0
#option WIZ_RST_PIN = PORTC.1  

Include "Config_NOWDT"
Include "W5500-Consts"
Include "W5500-Utils"
Include "W5500"

Include "usart"
Include "convert"
Include "string"


#if USE_DNS
    Include "W5500-DNSConsts"
    Dim dnsRes As DNS_INFO
#endif

Private Sub ConfigDisplay()
    USART.Write(#13,#10)
    USART.Write("MAC Address ",SARtoString(),#13,#10)
    USART.Write("IP Address  ",SIPRtoString(),#13,#10)
    USART.Write("Subnet Mask ",SUBRtoString(),#13,#10)
    USART.Write("Gateway     ",GARtoString(),#13,#10)
    USART.Write("DNS Address ",AddrToString(@Dns_Addr),#13,#10)
    USART.Write(#13,#10)    
End Sub

#if USE_DHCP
Sub OnUpdate()
    ConfigDisplay()
End Sub

Sub OnConflict()
End Sub
#endif

// ##################################################################################

// ##################################################################################

Dim sockstat    As Byte 
Dim sockreg     As Byte
Dim rsize       As Word
Dim charcount   As Word
Dim writecount  As Word
Dim iGet        As Integer
Dim iEnd        As Integer
Dim iPost       As Integer
Dim iInc        As Integer
Dim sResp       As String

USART.SetBaudrate(br115200)

#if USE_DHCP = true
    USART.Write("Now find the DHCP server.. ",13,10)    
    DHCPSetEvents(@OnUpdate, @OnConflict)
    If DHCPTask(3) = false Then
        USART.Write("DHCP error, so must set static parms.. ",13,10)
        ConfigDisplay()
    End If    
#else
    USART.Write("Using static config.. ",13,10)    
    ConfigDisplay()
#endif

DelayMS(1000)

#if USE_DNS
    USART.Write("DNSResolving for www.google.com ... ")
    dnsRes = DNSResolve("www.google.com")
    If dnsRes.STATUS = cRC_NO_ERROR Then
        USART.Write(AddrToString(@dnsRes.IPAddr.Byt),13,10)
    Else
        USART.Write("unable to resolve (ERR=",DecToStr(dnsRes.STATUS),")",13,10)    
    End If
#endif
USART.Write(13,10)
USART.Write("Open a browser on http://" + SIPRtoString() + " for test it.",13,10)

sockstat = 0
sockreg = 1
writecount = 0
charcount = 0
While true
    sockstat=ReadSocketReg(sockreg, rSn_SR)
    Select sockstat
    Case cSOCK_CLOSED
        If Socket(sockreg, cSn_MR_TCP, TCP_PORT, 0) Then 
            If Not Listen(sockreg) Then
                DelayMS(1)
            End If
        End If
    Case cSOCK_ESTABLISHED       
        rsize = W5500.DataAvailable(sockreg)
        If rsize > 0 Then
            SockTimeoutEnable(sockreg)

{  
    A GET REQUEST Header is like this .. 

    GET /index.html HTTP/1.1
    Host: xxx.xxx.xxx.xxx
    Keep-Alive: timeout=15
    Connection: Keep-Alive
    X-Forwarded-For: 192.168.10.1
    .. then I search for "Connection:"
    Other types are xml tagged. 
}

            If SeekToken(sockreg,0, "Connection:")<>-1 Then
                iGet = SeekToken(sockreg,0, "GET /")
                iPost = SeekToken(sockreg, 0, "POST /")
                If iGet<>-1 Then
                    iEnd = SeekToken(sockreg, iGet, " HTTP/")
                ElseIf iPost<>-1 Then
                    iEnd = SeekToken(sockreg, iPost, " HTTP/")
                End If

{
    I received a new request, 
    In any case I have to answer with an
    HTML page then prepare it.   
}

                ASyncTXBufferInit(sockreg)                                                         
                PutInTXBuffer(sockreg,("HTTP/1.1 200 OK" + #13 + #10))
                PutInTXBuffer(sockreg,("Content-Type: text/html" + #13 + #10 + #13 + #10),false)
                PutInTXBuffer(sockreg,"<html><body>",false)

                If iGet<>-1 Then                
                    If (iEnd - iGet)<>5 Then
{
    I received a GET request, 
    now look if is index.html 
    page.   
}
                        sResp = ""
                        ExtractRXBuffer(sockreg,@sResp, iGet + 5, iEnd - iGet -5,true)
                        If sResp<>"index.html" Then
                            USART.Write("For now only index.html is recognized as homepage",13,10)
                            PutInTXBuffer(sockreg,"<h1>Sorry</h1>",false)    
                            PutInTXBuffer(sockreg,("<h2>Before you can download the page " +#34) ,false)    
                            PutInTXBuffer(sockreg, sResp,false)
                            PutInTXBuffer(sockreg,(#34 + " I think that you have to create it ..</h2>"),false)    
                            PutInTXBuffer(sockreg,"<h2>Please specify ",false)
                            PutInTXBuffer(sockreg,(#34 + "index.html" + #34 + " to get it!</h2>"),false)    
                        Else
                            USART.Write("Ok for index.html",13,10)
                            PutInTXBuffer(sockreg,("<form name=" + #34 + "myform" + #34),false)
                            PutInTXBuffer(sockreg,(" action=" + #34 + "index.html" + #34),false)
                            PutInTXBuffer(sockreg,(" method=" + #34 + "POST" + #34 + ">"),false)    
                            PutInTXBuffer(sockreg,"<br><br>",false)
                            PutInTXBuffer(sockreg,("<input type=" + #34 + "text" + #34),false)
                            PutInTXBuffer(sockreg,(" size=" + #34 + "25" + #34),false)
                            PutInTXBuffer(sockreg,(" name=incoming value=" + #34 + #34 + ">"),false)
                            PutInTXBuffer(sockreg,("<br><input type=" + #34 + "submit" + #34),false)
                            PutInTXBuffer(sockreg,(" value=" + #34 + " SEND TEXT " + #34 + "><br>"),false)
                            PutInTXBuffer(sockreg,"</form>",false)
                        End If                    
                    Else
                        PutInTXBuffer(sockreg,("<h2>Please specify " ),false)
                        PutInTXBuffer(sockreg,(#34 + "index.html" + #34 ),false)
                        PutInTXBuffer(sockreg,(" to get it!</h2>"),false)    
                    End If
                EndIf

                If iPost<>-1 Then
                    If (iEnd - iPost)<>5 Then
{
    I received a POST request, 
    now look if is index.html 
    page.   
}
                        sResp = ""
                        ExtractRXBuffer(sockreg,@sResp, iPost + 5, iEnd - iPost -5,true)
                        If sResp<>"index.html" Then
{
    you pressed ENTER in a previous sended
    index.html page and then try the 
    parameter passed that was 'incoming=' 
    in returned request with POST verb
}                        
                            iInc = SeekToken(sockreg, iPost, "incoming=") 
                            If iInc <>-1 Then
                                sResp = ""
                                ExtractRXBuffer(sockreg,@sResp, iInc + 9, 0, true)
                                USART.Write("The POST value is ",sResp,13,10)
                                PutInTXBuffer(sockreg,"<h2>Here you can take value posted ... ",false)
                                PutInTXBuffer(sockreg, sResp + " </h2>",false)                        
                            End If
                        End If
                    End If
                End If
{
    Whatever happened to end up 
    close the HTML response page 
    and its socket
}
                ReleaseRXBuffer(sockreg)
                PutInTXBuffer(sockreg,"</body></html>",false)

                ASyncTXBufferSend(sockreg)                                    
                Disconnect(sockreg)                   
                SockTimeoutDisable(sockreg)

            End If            
        End If              
    Case cSOCK_FIN_WAIT,
         cSOCK_CLOSING,
         cSOCK_TIME_WAIT,
         cSOCK_CLOSE_WAIT,
         cSOCK_LAST_ACK

        Close(sockreg)
    End Select

    If SockTimeout(sockreg) Then
        Disconnect(sockreg) 
        SockTimeoutDisable(sockreg)
    End If

End While

I want to point out the use of the send buffer:

  ASyncTXBufferInit(sockreg)                                                         
  PutInTXBuffer(sockreg,("HTTP/1.1 200 OK" + #13 + #10),false)
  ...
  ASyncTXBufferSend(sockreg)                                                    

ASyncTXBufferInit storing the pointers of transmission buffer and after a series of entries communicate to the W5500 to forward the content and all internal memory pointers movements are under control of W5500. The third "false" in PutInTXBuffer parameter tells the device to not process the buffer and do not close the transmission until next ASyncTXBufferSend().

SOAP 1.1 Web Service Sample

Use as a web service instead imposes many standards and the amount of memory MCU does not allow the use of a wsdl downloaded at the time and so you need to create it in another way .. I have implemented a SOAP ws 1.1 in VS2010 already used in the example of Swordfish and W5100 and Firewing and W5500 then re-imported into the client program during development allows me to do without it when using the embedded web server. An example of the result of this import/generation make by VisualStudio tool you can find directly in the project folder of the client \VS2010 \WindowsApplication1\Service References\ServiceReference1 that stores a copy of the generated WSDL named "Service1.wsdl", open it, this is how the web service should return as result of a "?WSDL" client request. Use of this generation method is simple. Emulate the web service response with a custom "as like" web service then the client application, when a wsdl is request for generate the recv class, you point to in-solution web service.. you're done and do not need new reload it until wsdl updates. One thing you must remember is to change the url in the client app before using the application because end point is the original ws windows url.

The purpose of the application is to show in the first case how to send a request to the web service in which it took a command and a parameter and obtain a Boolean value, and in a second case which the application call the web service for message state consisting of a class ( an object ) of composite type.

Simple test application is "WindowsApplication1.exe" from \VS2010\WindowsApplication1\bin\Debug folder. You can open the source with VisualStudio loading "WebService1.sln" solution file from \VS2010 folder that opens in the solution also the client project.

You can download SOAP Client VB.NET example here: VB.NET SOAP Client

This is VS2010 VB.NET class named Service1.asmx used in example:

Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel

<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class Service1
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function Status() As Response
        Dim a As New Response()
        a.ListaAttese.Add(10)
        a.ListaAttese.Add(1)
        a.ListaAttese.Add(2)
        Return a
    End Function

    <WebMethod()> _
    Public Function Command(cCommand As Byte, cParm As Byte) As Boolean
        Return True
    End Function

End Class

The response class ( composite object ) than contains returned values: four integers two boolean and two variable size arrays of integer.

Imports System.Collections.Generic
Imports System.Runtime.Serialization

<Serializable()> _
Public Class Response
    Public Property PointsNum As Integer
    Public Property Chiamate As Integer
    Public Property InAttesa As Integer
    Public Property Visore As Integer
    Public Property Buzzer As Boolean
    Public Property Flash As Boolean
    Public Property ListaChiamate As New List(Of Integer)
    Public Property ListaAttese As New List(Of Integer)

    Public Sub New()
    End Sub
End Class

This is the "PIC side" source that receives, interprets and returns to the windows client app the class above:

{
*****************************************************************************
*  Name    : W5500-SOAP-Server.BAS                                          *
*  Author  : Coccoliso                                                      *
*  Notice  : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS]              *
*          : All Rights Reserved                                            *
*  Date    : 30/01/2015                                                     *
*  Version : 2.0                                                            *
*  Notes   : All 8 sockets can used for multi socket SOAP server            *
*          :                                                                *
*****************************************************************************
}
Device = 18f2682
Clock = 40

#option WIZ_DHCP_DEBUG  = false
#option WIZ_DNS_DEBUG   = false
#option WIZ_NTP_DEBUG   = false


#option USE_DHCP = true
#option USE_DNS  = true
#option WIZ_SCS_PIN = PORTC.0
#option WIZ_RST_PIN = PORTC.1  

Include "Config_NOWDT"
Include "usart"
Include "convert"
Include "string"
Include "W5500-Consts"
Include "W5500-Utils"
Include "W5500"
Include "W5500-SOAP"

#if USE_DNS
    Include "W5500-DNSConsts"
    Dim dnsRes As DNS_INFO
#endif

Private Sub ConfigDisplay()
    USART.Write(#13,#10)
    USART.Write("MAC Address ",SARtoString(),#13,#10)
    USART.Write("IP Address  ",SIPRtoString(),#13,#10)
    USART.Write("Subnet Mask ",SUBRtoString(),#13,#10)
    USART.Write("Gateway     ",GARtoString(),#13,#10)
    USART.Write("DNS Address ",AddrToString(@Dns_Addr),#13,#10)
    USART.Write(#13,#10)    
End Sub

#if USE_DHCP
Sub OnUpdate()
    ConfigDisplay()
End Sub

Sub OnConflict()
End Sub
#endif


// ########################################################################################################################

// ########################################################################################################################

Dim sockstat As Byte 
Dim sockreg As Byte
Dim rsize As Word
Dim iMethod As Integer
Dim cCommand As Integer
Dim cParm As Integer

USART.SetBaudrate(br115200)

sockstat = 0

USART.Write("Initialized",13,10)

#if USE_DHCP = true
    USART.Write("Now find the DHCP server.. ",13,10)    
    DHCPSetEvents(@OnUpdate, @OnConflict)
    If DHCPTask(3) = false Then
        USART.Write("DHCP error, so must set static parms.. ",13,10)
        ConfigDisplay()
    End If    
#else
    ConfigDisplay()
#endif

DelayMS(1000)

#if USE_DNS
    USART.Write("DNSResolving for www.google.com ... ")
    dnsRes = DNSResolve("www.google.com")
    If dnsRes.Status = cRC_NO_ERROR Then
        USART.Write(AddrToString(@dnsRes.IPAddr.Byt),13,10)
    Else
        USART.Write("unable to resolve (ERR=",DecToStr(dnsRes.Status),")",13,10)    
    End If
#endif

USART.Write("Now you can launch SOAP client program.",#13,#10)
USART.Write("SOAP Testing.. ",#13,#10)
sockreg = 0

While true
    For sockreg= 0 To 7
        sockstat=ReadSocketReg(sockreg, rSn_SR)
        Select sockstat
        Case cSOCK_CLOSED
            If Socket(sockreg, cSn_MR_TCP, TCP_PORT, 0) Then 
                If Not Listen(sockreg) Then
                    DelayMS(1)
                End If
            End If
        Case cSOCK_ESTABLISHED       
            rsize = W5500.DataAvailable(sockreg)
            If rsize > 0 Then
                SockTimeoutEnable(sockreg)
    {
        Remember that the SOAP module works directly 
        on the receive buffer and can be used on only 
        one socket at a time because it keeps the 
        socket number in a static variable which is set 
        through the CheckEnvelope() function. 
    }            
                If CheckEnvelope(sockreg) Then
                    If CheckMethod(sockreg, "Command", iMethod) Then
    {
        Client send a Command method
        request so check cCommand 
        as integer parameter
    }                
                        If GetValue(sockreg, iMethod,"cCommand",cCommand) Then
                            USART.Write("cCommand=",DecToStr(cCommand),#13,#10)
                        Else
                            USART.Write("cCommand=","INVALID",#13,#10)
                        End If                   
    {
        now check cParm as integer 
        parameter
    }                
                        If GetValue(sockreg, iMethod, "cParm",cParm) Then
                            USART.Write("cParm=",DecToStr(cParm),#13,#10)
                        Else
                            USART.Write("cParm=","INVALID",#13,#10)
                        End If
                        W5500.ReleaseRXBuffer(sockreg)
    {
        Command method wants as answer 
        a single Boolean value 
        so create the response with
        single boolean result
    }                                   
                        W5500_SOAP.Initialize(sockreg, "Command")
                        W5500_SOAP.WriteResult(sockreg, true)
                        W5500_SOAP.Finalize(sockreg)
                        Disconnect(sockreg)                   
                        SockTimeoutDisable(sockreg)
                    End If

                    If CheckMethod(sockreg, "Status", iMethod) Then
                        W5500.ReleaseRXBuffer(sockreg)
    {
        Client send a Status method
        request without parameters 
        but want a complex object
        as response
    }                
                        W5500_SOAP.Initialize(sockreg, "Status")
    {
        Prepare four integer values
    }                    
                        W5500_SOAP.WriteElement(sockreg, "PointsNum",0)
                        W5500_SOAP.WriteElement(sockreg, "Chiamate",0)
                        W5500_SOAP.WriteElement(sockreg, "InAttesa",0)
                        W5500_SOAP.WriteElement(sockreg, "Visore",0)
    {
        Prepare two boolean values
    }                    
                        W5500_SOAP.WriteElement(sockreg, "Buzzer", false)
                        W5500_SOAP.WriteElement(sockreg, "Flash", false)
    {
        Now prepare a ListOf(integer) 
        named ListaChiamate
    }

                        W5500_SOAP.WriteElementOpen(sockreg, "ListaChiamate")
                        W5500_SOAP.WriteItem(sockreg,0)
                        W5500_SOAP.WriteItem(sockreg,1)
                        W5500_SOAP.WriteItem(sockreg,2)
                        W5500_SOAP.WriteItem(sockreg,3)
                        W5500_SOAP.WriteElementClose(sockreg, "ListaChiamate")
    {
        Now prepare a ListOf(integer) 
        named ListaAttese
    }
                        W5500_SOAP.WriteElementOpen(sockreg, "ListaAttese")
                        W5500_SOAP.WriteItem(sockreg, 5)
                        W5500_SOAP.WriteElementClose(sockreg, "ListaAttese")
                        W5500_SOAP.Finalize(sockreg)
                        Disconnect(sockreg)                   
                        SockTimeoutDisable(sockreg)
                    End If
                End If
            End If              
        Case cSOCK_FIN_WAIT,
             cSOCK_CLOSING,
             cSOCK_TIME_WAIT,
             cSOCK_CLOSE_WAIT,
             cSOCK_LAST_ACK
            Close(sockreg)
        End Select

        If SockTimeout(sockreg) Then
            Close(sockreg) 
            SockTimeoutDisable(sockreg)
        End If    
    Next
End While

Examples of SOAP 1.1 communication

This is the request that the client sends to the web service when requesting the Command method:

<?xml version="1.0" encoding="utf-16"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <Command xmlns="http://tempuri.org/">
      <cCommand>0</cCommand>
      <cParm>0</cParm>
    </Command>
  </soap:Body>
</soap:Envelope>

This is the PIC response at the Command method request:

ResponseCode: 200 (OK)
Content-Type:text/xml; charset=utf-8

<?xml version="1.0" encoding="utf-16"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <CommandResponse xmlns="http://tempuri.org/">
      <CommandResult>true</CommandResult>
    </CommandResponse>
  </soap:Body>
</soap:Envelope>

This is the request that the client sends to the web service when requesting the Status method:

<?xml version="1.0" encoding="utf-16"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <Status xmlns="http://tempuri.org/" />
  </soap:Body>
</soap:Envelope>

This is the PIC response at the Status method request:

ResponseCode: 200 (OK)
Content-Type:text/xml; charset=utf-8

<?xml version="1.0" encoding="utf-16"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <StatusResponse xmlns="http://tempuri.org/">
      <StatusResult>
        <PointsNum>0</PointsNum>
        <Chiamate>0</Chiamate>
        <InAttesa>0</InAttesa>
        <Visore>0</Visore>
        <Buzzer>false</Buzzer>
        <Flash>false</Flash>
        <ListaChiamate />
        <ListaAttese>
          <int>10</int>
          <int>1</int>
          <int>2</int>
        </ListaAttese>
      </StatusResult>
    </StatusResponse>
  </soap:Body>
</soap:Envelope>

Swordfish W5500 library modules : W5500-Library

Eagle PCB project : Eagle project

SOAP VB.NET Client: VB.NET SOAP Client

Updated with TCP socket connection - February 28, 2015

Added routines to allow a TCP client connection and increase the local port at the last use, avoiding the connection timeout on the server side socket eventually left open earlier.

Updated with PING functionality - March 27, 2015

Here you will find PING functionality test program.

{
*****************************************************************************
*  Name    : W5500-Test-Ping.BAS                                            *
*  Author  : Coccoliso                                                      *
*  Notice  : Copyright (c) 2015                                             *
*          : All Rights Reserved                                            *
*  Date    : 27/03/2015                                                     *
*  Version : 1.0                                                            *
*  Notes   :                                                                *
*          :                                                                *
*****************************************************************************
}
Device = 18f2682
Clock = 40

#option WIZ_DHCP_DEBUG  = true
#option WIZ_DNS_DEBUG   = false
#option WIZ_PING_DEBUG  = false
#option WIZ_PING_DISPLAY = true

#option USE_DHCP = true
#option USE_DNS  = false
#option USE_PING = true
#option WIZ_SCS_PIN = PORTC.0
#option WIZ_RST_PIN = PORTC.1  

Include "Config_NOWDT"
Include "W5500-Consts"
Include "W5500-Utils"
Include "W5500"

Include "usart"
Include "convert"
Include "string"


#if USE_DNS
    Include "W5500-DNSConsts"
    Dim dnsRes As DNS_INFO
#endif

Private Sub ConfigDisplay()
    USART.Write(#13,#10)
    USART.Write("MAC Address ",SARtoString(),#13,#10)
    USART.Write("IP Address  ",SIPRtoString(),#13,#10)
    USART.Write("Subnet Mask ",SUBRtoString(),#13,#10)
    USART.Write("Gateway     ",GARtoString(),#13,#10)
    USART.Write("DNS Address ",AddrToString(@Dns_Addr),#13,#10)
    USART.Write(#13,#10)    
End Sub

#if USE_DHCP
Sub OnUpdate()
    ConfigDisplay()
End Sub

Sub OnConflict()
End Sub
#endif

Private Function SetAddress(a,b,c,d As Byte, RAMAddr As Word) As Word  
    result = RAMAddr
    Save(FSR2)
    FSR2 = RAMAddr
    POSTINC2 = a
    POSTINC2 = b
    POSTINC2 = c
    INDF2 = d
    Restore            
End Function

// ##################################################################################

// ##################################################################################

Dim PingAddr(4)   As Byte
USART.SetBaudrate(br115200)

#if USE_DHCP = true
    USART.Write("Now find the DHCP server.. ",13,10)    
    DHCPSetEvents(@OnUpdate, @OnConflict)
    If DHCPTask(3) = false Then
        USART.Write("DHCP error, so must set static parms.. ",13,10)
        ConfigDisplay()
    End If    
#else
    USART.Write("Using static config.. ",13,10)    
    ConfigDisplay()
#endif

DelayMS(1000)

#if USE_DNS
    USART.Write("DNSResolving for www.google.com ... ")
    dnsRes = DNSResolve("www.google.com")
    If dnsRes.STATUS = cRC_NO_ERROR Then
        USART.Write(AddrToString(@dnsRes.IPAddr.Byt),13,10)
    Else
        USART.Write("unable to resolve (ERR=",DecToStr(dnsRes.STATUS),")",13,10)    
    End If
#endif
USART.Write(13,10)
USART.Write("My IP is ",SIPRtoString(),13,10)


SetAddress(192,168,1,50,@PingAddr) ' <-- CHANGE YOUR REQ.PING ADDRESS 

USART.Write("Now call PingAuto()..",13,10)
PingAuto(@PingAddr)
USART.Write("Now call PingCount() with 10 pings on Socket 0 ..",13,10)
PingCount(0,10,@PingAddr)
USART.Write("That is all!",13,10)
While true
End While
Retrieved from https://www.sfcompiler.co.uk/wiki/pmwiki.php?n=SwordfishUser.W5500
Page last modified on March 31, 2015, at 09:54 AM