Skip to content

Transfer Data Between Serial And Tcp

swt edited this page Aug 2, 2017 · 3 revisions

Tunnel To Transfer Data Between Serial And Tcp

Tunnel Descraption

Http Command Introduction

This function is used Uart1, and the uart1 baudrate is 115200, and tcp port is 5005 by default,but you can change them through http command, in Access Point mode, ip address: 192.168.230.1

  • Open Tunnel
	http://192.168.230.1:9999/server.command?command=open_tunnel
  • Close Tunnel
	http://192.168.230.1:9999/server.command?command=close_tunnel
  • Tunnel Port

get port
	http://192.168.230.1:9999/server.command?command=tunnel&get_port

set port

such as change port to 6006

	http://192.168.230.1:9999/server.command?command=tunnel&set_port&value=6006
  • Tunnel Baudrate

get baudrate

	http://192.168.230.1:9999/server.command?command=tunnel&get_baudrate

set baudrate

such as change baudrate to 9600

	http://192.168.230.1:9999/server.command?command=tunnel&set_baudrate&value=9600

Uart Introduction

Here Used Uart1

Baudrate: 9600 19200 38400 57600 115200 230400

Uart Protocol

Uart Protocol Table

Note: A packet of data should be less than 1024 Bytes

Name Bits Value Discription
Id 2 Bytes 0xAA 0xAA \
Command Type 1 Byte 0x00 0x00: Set Command
0x01: Get Command
Command 2 Bytes 0x00 0x00 0x00 0x00: Open Tunnel
0x00 0x01: Close Tunnel
0x00 0x02: Send Data
Status 1 Byte 0x00 Open/Close Tunnel Through Uart, it will return:
0x00: OK
0x01: Fail
Parity 2 Bytes 0x00 0x00 0x00 0x00: none
Length 2 Bytes 0x00 0x00 Don't Send Data,value=0x00 0x00
Send Data,Value Depends On Data
Data 2 Bytes \ Depends On Length

Uart Protocol Command

  • Open Tunnel
	0xAA 0xAA 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
  • Close Tunnel
	0xAA 0xAA 0x00 0x00 0x01 0x00 0x00 0x00 0x00 0x00
  • Send Data
	0xAA 0xAA 0x00 0x00 0x02 0x00 0x00 0x00 0x00 0x05 0x14 0xE0 0xFA 0x96 0xCB

To Use Tunnel

Step 1 To Download Tools For Test

Step 2 Prepare Before Open Tunnel

  1. Power on the WisCore module, and then connect the wireless "WisCore_macaddr".
  2. Open UartAssist, and connect it, the same to setup console through serial

  1. Before open tunnel, set/get port/baudrate

By default, the baudrate is 115200, port is 5005, and you can get the params through http command

if you want to get the params,input the url,and it will returns a value, value="port/baudrate"

Get Baudrate

Get Port

if you want to change the params,input the url,and it will returns a value, if value=0,set port/baudrate success

Set Baudrate

Set Port

Step 3 To Opne Tunnel

Through Http Command

input the url,and it will return a value, if value=0,open tunnel success

Through Uart Command

input uart command, if open success, it will return the correct command

IF OK, GO ON PLEASE!

Step 4 Connect NetAssist Tool

If open tunnel success, please connect NetAssist:

  1. Protocol: Tcp Client
  2. Local host addr: your computer's IP
  3. Remote host adr: module's IP

Step 5 Send Data Between Serial And Tcp

Then, you can send data in NetAssist: just send data in UartAssist: packet header + data

Note: A packet of data should be less than 1024 Bytes

Step 6 Close Tunnel

Through Http Command

input the url,and it will return a value, if value=0,close tunnel success.

Through Uart Command

input uart command, if close success, it will return the correct command