HW Construction
WizFi360 for Access Point + Raspberry Pi Pico (Gateway application) + W5500 for Ethernet + Serial Interface(Log and Command)
Details on W5500 and WizFi360 PIN Connection
TDX and RDX jumpers from the WizFi to send UART data to the UART W5500-EVB-Pico pins.
WizFi360 Pin Map
W5500 EVB Pico Pin Map
https://docs.wiznet.io/Product/iEthernet/W5500/w5500-evb-pico
Test: TCP Client Application
Mobile phone's TCP Client Test application is used for Server Test.
Normally client try to connect server and server accepted client's connection request. And client send data and receive ACK response.
Test: Serial AT Command and Response
You can see Command(Request) and Response Access Point and Station.
Test: AWS IoT Result
Server(WizFi360) transfer client data to ethernet(W5500) to send AWS IoT Cloud. AWS normally subscribe client data by MQTT.
Result: Serial Logs
Details on how Ethernet and WiFi to run.
Hello World
## ETHNET MQTT Demo ##
## WIFI TCP Demo ##
## Activate WiFi ##
Driver_WiFix.Initialize() and PowerControl(ARM_POWER_FULL)
[eric]::USART Serial: --> AT_Cmd_CurrentMode= 0, 3 is softAp + Station
[eric] AT_Parse_IP_1(): 192.168.36.1.0
[eric] AT_Parse_IP_1(): 192.168.36.1.0
[eric] AT_Parse_IP_1(): 255.255.255.0.0
[eric] AT_Parse_MAC_1(): 2:8:DC:59:5F:E4:C0
[eric] AT_Parse_IP_1(): 192.168.36.2.0
[eric] AT_Parse_IP_1(): 192.168.36.101.120
[eric] LoadOptions()--> AT_Cmd_CurrentMode: AP
## ETHERNET_MQTT_thread ###
## WIZ CHIP READY ###
DHCP client running
[eric] > STATE_DHCP_INIT
> Send DHCP_DISCOVER
[eric] AT_Parse_IP_1(): 8.8.8.8.165
[eric] AT_Parse_IP_1(): 0.0.0.0.8
[eric] AP ARM_WIFI_IP_DNS1/2
[eric]::WiFi SetOption succeeded!
[eric] SoftAP + station
[eric] Setup ssid and pass
[eric] AT_Cmd_ConfigureAP() OK
[eric] Setup access point MAC
[eric] Set network parameters (ip, netmask, gateway)
[eric] AT_Cmd_DHCP:set SoftAP and enable DHCP set=0U, mode=1
[eric] Configure DHCP lease
[eric] WiFi Activated = 0
Server Socket is 0: iotSocketCreate() success
------------------------------------------------------
# iotSocketBind() client bind success #
### Server Socket = 0
### Server Socket at WIFI_DRIVER= 0
### Local IP = 0.0.0.0
### Server IP setting = 192.168.36.1
### Remote IP = 0.0.0.0
### Socket State = 0
### Connect(Link) ID = 0
------------------------------------------------------
Setup_TCPServer_Socket() success
DHCP message : 192.168.0.1(67) 548 received.
[eric] > STATE_DHCP_DISCOVER
> Receive DHCP_OFFER
> Send DHCP_REQUEST
[eric] ARM_WIFI_SocketListen(): CMD_CIPSERVERMAXCONN
[eric] ARM_WIFI_SocketListen(): CMD_CIPSERVER
[eric] ARM_WIFI_SocketListen(): Server successfully created, SOCKET_STATE_SERVER
[eric] ARM_WIFI_SocketListen(): backlog is 1
[eric] ARM_WIFI_SocketListen(): change socket state, SOCKET_STATE_LISTEN
[eric] ARM_WIFI_SocketListen(): backlog is 2
[eric] ARM_WIFI_SocketListen(): change socket state, SOCKET_STATE_LISTEN
[eric] ARM_WIFI_SocketListen(): backlog is 3
[eric] ARM_WIFI_SocketListen(): change socket state, SOCKET_STATE_LISTEN
[eric] ARM_WIFI_SocketListen(): backlog is 4
[eric] ARM_WIFI_SocketListen(): change socket state, SOCKET_STATE_LISTEN
------------------------------------------------------
# Waiting Accept_TCP_Connection() #
Socket backlog = 255
Socket[backlog].state = 0 [3=Listen, 4=ConnectReq, 5=Connected]
Socket[ 0 ].state = 8 [3=Listen, 4=ConnectReq, 5=Connected]
Socket[ 1 ].state = 3 [3=Listen, 4=ConnectReq, 5=Connected]
Socket[ 2 ].state = 3 [3=Listen, 4=ConnectReq, 5=Connected]
Socket[ 3 ].state = 3 [3=Listen, 4=ConnectReq, 5=Connected]
Socket[ 4 ].state = 3 [3=Listen, 4=ConnectReq, 5=Connected]
### Server Socket = 0
### Socket Backlog = 1
### Server Socket at WIFI_DRIVER= 0
### Local IP = 0.0.0.0
### Server IP setting = 192.168.36.1
### Remote IP = 0.0.0.0
### Connect(Link) ID = 0
------------------------------------------------------
Accept_TCP_Connection() wait someone connect: backlog is 1
ARM_WIFI_SocketAccept() Loop for waiting client
ARM_WIFI_SocketAccept() No connection to accept
ARM_WIFI_SocketAccept(): WiFi_Wait(), until Someone Connects
DHCP message : 192.168.0.1(67) 548 received.
[eric] > STATE_DHCP_REQUEST
> Receive DHCP_ACK
> Check leased IP - OK
====================================================================================================
W5500 network configuration : DHCP
MAC : 00:08:DC:12:34:56
IP : 192.168.0.13
Subnet Mask : 255.255.255.0
Gateway : 192.168.0.1
DNS : 8.8.8.8
====================================================================================================
DHCP leased time : 10 seconds
[eric] > STATE_DHCP_LEASED
- DNS: [a36anwbdj0b0kz-ats.iot.ap-northeast-2.amazonaws.com] Get Server IP - 3.38.230.221
ok! mbedtls_x509_crt_parse returned -0x0 while parsing root cert
ok! mbedtls_ssl_set_hostname returned 0
ok! mbedtls_x509_crt_parse returned -0x0 while parsing device cert
ok! mbedtls_pk_parse_key returned -0x0 while parsing private key
Root CA verify option 2
ok! mbedtls_ssl_conf_own_cert returned 0
SSL initialization is success
Performing the SSL/TLS handshake...
ok
[ Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256 ]
SSL connection is success
MQTT initialization is success
MQTT connection is success
MQTT subscription is success
[eric] > STATE_DHCP_LEASED
> Maintains the IP address
> Send DHCP_REQUEST
Received SUBACK: PacketID=1
DHCP message : 192.168.0.1(67) 548 received.
.
.
.
[eric] > STATE_DHCP_REREQUEST
[eric] > STATE_DHCP_LEASED
> Maintains the IP address
> Send DHCP_REQUEST
[eric] AT_NOTIFY_STATION_DISCONNECTED:AT_Resp_StaMac(mac) = B6:7E:0:51:F4:DA
.
.
.
[eric] AT_NOTIFY_STATION_CONNECTED:AT_Resp_StaMac(mac) = B6:7E:0:51:F4:DA
[eric] Mac Copy is [B6:7E:0:51:F4:DA]
[eric] AT_Notify(): pCtrl->cb_event (ARM_WIFI_EVENT_AP_CONNECT, mac)
DHCP message : 192.168.0.1(67) 548 received.
[eric] > STATE_DHCP_REREQUEST
[eric] At_Notify: AT_NOTIFY_CONNECTION_OPEN
[eric] At_Notify: SOCKET_STATE_SERVER: put connection on the backlog
[eric] At_Notify: SOCKET_STATE_SERVER: the backlog is 1
Socket[1].state = 3 [3=Listen, 4=ConnectReq, 5=Connected, 8=Server]
[eric] At_Notify: SOCKET_STATE_SERVER: SOCKET_STATE_CONNECTED
[eric] At_Notify: osEventFlagsSet(WIFI_WAIT_CONN_ACCEPT)
ARM_WIFI_SocketAccept(): WiFi_Wait() end, Someone Connects
ARM_WIFI_SocketAccept() Loop for waiting client
ARM_WIFI_SocketAccept() Socket[1].state == SOCKET_STATE_CONNECTED
[eric] AT_Parse_IP_1(): 192.168.36.100.54
------------------------------------------------------
# Accept_TCP_Connection() client connection success #
### Socket Backlog = 1
Socket[backlog].state = 5 [3=Listen, 4=ConnectReq, 5=Connected]
Socket[ 0 ].state = 8 [3=Listen, 4=ConnectReq, 5=Connected]
Socket[ 1 ].state = 5 [3=Listen, 4=ConnectReq, 5=Connected]
Socket[ 2 ].state = 3 [3=Listen, 4=ConnectReq, 5=Connected]
Socket[ 3 ].state = 3 [3=Listen, 4=ConnectReq, 5=Connected]
Socket[ 4 ].state = 3 [3=Listen, 4=ConnectReq, 5=Connected]
### Server Socket = 0
### Server Socket at WIFI_DRIVER= 0
### Local IP = 192.168.36.1
### Server IP setting = 192.168.36.1
### Remote IP = 192.168.36.100
### Connect(Link) ID = 0
------------------------------------------------------
Accept_TCP_Connection(): clientSockd is 1
thread create ThreadClient():clientSockd is 1
Handle_TCP_Client
[eric] > STATE_DHCP_LEASED
> Maintains the IP address
> Send DHCP_REQUEST
[eric] ### AT_Parser_Execute:AT_STATE_RECV_DATA ###
[eric] ### AT_Parser_Execute:AT_STATE_RECV_DATA ###
[eric] # mqtt_buf # {"message":"Hello, IOT World!", "publish message":"123345"}
MQTT pulishing is success
PUBLISH OK
DHCP message : 192.168.0.1(67) 548 received.
[eric] > STATE_DHCP_REREQUEST
[eric] > STATE_DHCP_LEASED
> Maintains the IP address
> Send DHCP_REQUEST
DHCP message : 192.168.0.1(67) 548 received.
[eric] > STATE_DHCP_REREQUEST
[eric] ### AT_Parser_Execute:AT_STATE_RECV_DATA ###
[eric] # mqtt_buf # {"message":"Hello, IOT World!", "publish message":"123345"}
MQTT pulishing is success
PUBLISH OK
[eric] > STATE_DHCP_LEASED
> Maintains the IP address
> Send DHCP_REQUEST
DHCP message : 192.168.0.1(67) 548 received.
[eric] > STATE_DHCP_REREQUEST
[eric] AT_Resp_IPD()
[eric] ### AT_Parser_Execute:AT_STATE_RECV_DATA ###
[eric] # mqtt_buf # {"message":"Hello, IOT World!", "publish message":"123345"}
MQTT pulishing is success
PUBLISH OK
.
.
.
[eric] > STATE_DHCP_LEASED
> Maintains the IP address
> Send DHCP_REQUEST
DHCP message : 192.168.0.1(67) 548 received.
[eric] > parseDHCPMSG(), type=5
[eric] > STATE_DHCP_REREQUEST
[eric] > STATE_DHCP_LEASED
> Maintains the IP address
> Send DHCP_REQUEST
[eric] At_Notify: AT_NOTIFY_CONNECTION_CLOSED
[eric] At_Notify: ConnId_Free (conn_id): 0
[eric] At_Notify: change to Socket[1].conn_id: 0
[eric] At_Notify:(else SOCKET_INVALID) Socket[1].state: 3
[eric] At_Notify: WIFI_WAIT_CONN_CLOSE(n): 1
iotSocketRecv() failed
End of ThreadClient()
osThreadNew(ThreadClient()) Failed
Server: iotSocketListen() doesn't exist, ret = -3
------------------------------------------------------
# Waiting Accept_TCP_Connection() #
Socket backlog = 255
Socket[backlog].state = 0 [3=Listen, 4=ConnectReq, 5=Connected]
Socket[ 0 ].state = 8 [3=Listen, 4=ConnectReq, 5=Connected]
Socket[ 1 ].state = 3 [3=Listen, 4=ConnectReq, 5=Connected]
Socket[ 2 ].state = 3 [3=Listen, 4=ConnectReq, 5=Connected]
Socket[ 3 ].state = 3 [3=Listen, 4=ConnectReq, 5=Connected]
Socket[ 4 ].state = 3 [3=Listen, 4=ConnectReq, 5=Connected]
### Server Socket = 0
### Socket Backlog = 1
### Server Socket at WIFI_DRIVER= 0
### Local IP = 0.0.0.0
### Server IP setting = 192.168.36.1
### Remote IP = 0.0.0.0
### Connect(Link) ID = 0
------------------------------------------------------
Accept_TCP_Connection() wait someone connect: backlog is 1
[eric] ## osFlagsError: WiFi_Thread() ##
ARM_WIFI_SocketAccept() Loop for waiting client
ARM_WIFI_SocketAccept() No connection to accept
ARM_WIFI_SocketAccept(): WiFi_Wait(), until Someone Connects
DHCP message : 192.168.0.1(67) 548 received.
.
.
.
[eric] AT_NOTIFY_STATION_CONNECTED:AT_Resp_StaMac(mac) = B6:7E:0:51:F4:DA
[eric] Mac Copy is [B6:7E:0:51:F4:DA]
[eric] AT_Notify(): pCtrl->cb_event (ARM_WIFI_EVENT_AP_CONNECT, mac)
.
.
.
[eric] At_Notify: AT_NOTIFY_CONNECTION_OPEN
[eric] At_Notify: SOCKET_STATE_SERVER: put connection on the backlog
[eric] At_Notify: SOCKET_STATE_SERVER: the backlog is 1
Socket[1].state = 3 [3=Listen, 4=ConnectReq, 5=Connected, 8=Server]
[eric] At_Notify: SOCKET_STATE_SERVER: SOCKET_STATE_CONNECTED
[eric] At_Notify: osEventFlagsSet(WIFI_WAIT_CONN_ACCEPT)
ARM_WIFI_SocketAccept(): WiFi_Wait() end, Someone Connects
ARM_WIFI_SocketAccept() Loop for waiting client
ARM_WIFI_SocketAccept() Socket[1].state == SOCKET_STATE_CONNECTED
[eric] AT_Parse_IP_1(): 192.168.36.100.54
------------------------------------------------------
# Accept_TCP_Connection() client connection success #
### Socket Backlog = 1
Socket[backlog].state = 5 [3=Listen, 4=ConnectReq, 5=Connected]
Socket[ 0 ].state = 8 [3=Listen, 4=ConnectReq, 5=Connected]
Socket[ 1 ].state = 5 [3=Listen, 4=ConnectReq, 5=Connected]
Socket[ 2 ].state = 3 [3=Listen, 4=ConnectReq, 5=Connected]
Socket[ 3 ].state = 3 [3=Listen, 4=ConnectReq, 5=Connected]
Socket[ 4 ].state = 3 [3=Listen, 4=ConnectReq, 5=Connected]
### Server Socket = 0
### Server Socket at WIFI_DRIVER= 0
### Local IP = 192.168.36.1
### Server IP setting = 192.168.36.1
### Remote IP = 192.168.36.100
### Connect(Link) ID = 0
------------------------------------------------------
Accept_TCP_Connection(): clientSockd is 1
thread create ThreadClient():clientSockd is 1
Handle_TCP_Client
Comments