当前位置:网站首页>Serial port to WiFi module communication
Serial port to WiFi module communication
2022-07-01 08:33:00 【Hardware head teacher】
Serial port to WIFI Module communication
One : The method of using the downloader !( Strongly recommend )
There is a downloader that directly changes the corresponding server domain name 、 Router account , Just the password
1:TCP signal communication
server_addr = "192.168.1.101" -- You can also write the domain name of the server directly
server_port = 8080 -- Port number
ap_ssid = "mywifi" -- Router account
ap_passwd = "abc123" -- Router password
-- To configure USB Working in virtual serial mode , This call print() Function will be printed out in the computer serial terminal
--LIB_UsbConfig("CDC")
-- Enabling system 10 The millisecond timer starts to work
--LIB_10msTimerConfig("ENABLE")
-- Set up Wifi Module occupancy TX0、RX0、D5 Pin ,TCP Client Pattern
-- Router account :mywifi Router password :abc123, The server ip:192.168.1.101 Port number :8080
-- Heartbeat packet interval time 0 second ( Don't use the heartbeat mechanism ).
-- Get... Somewhere in the code WIFI Module unique ID Number
--ID_Str=LIB_GetSysUniID()
LIB_IntWifiTcpConfig(ap_ssid,ap_passwd,server_addr,server_port,0)
-- To configure Uart0 The baud rate of serial port is 115200
LIB_Uart0Config("BAUDRATE_115200")
-- Start the big cycle
while(GC(1) == true)
do
recv_flag,uart_recv_tab = LIB_Uart0Recv()
if recv_flag == 1 then
LIB_IntWifiTcpSend(uart_recv_tab)
end
recv_flag,wifi_recv_tab = LIB_IntWifiTcpRecv()
if recv_flag == 1 then
LIB_Uart0Send(wifi_recv_tab)
end
end
2:UDP signal communication
target_addr = "192.168.1.101" -- You can also write the domain name of the server directly , such as "www.shineblink.com" etc.
target_port = 8080
ap_ssid = "mywifi" -- Router account
ap_passwd = "abc123" -- Router password
-- Set up esp8266 Wifi Module occupancy TX0、RX0、D5 Pin ,UDP Pattern , port 1112
-- Router account :mywifi Router password :abc123,UDP Opposite end to be connected IP:192.168.1.101 Port number :8080
-- Heartbeat packet interval time 0 second ( Don't use the heartbeat mechanism ). If you need to use it, please use it in ApiDoc Refer to the document for LIB_WifiUdpConfig Functional p7 Detailed introduction of parameters
LIB_IntWifiUdpConfig(ap_ssid,ap_passwd,target_addr,target_port,0)
LIB_Uart0Config("BAUDRATE_115200")
-- Start the big cycle
while(GC(1) == true)
do
recv_flag,uart_recv_tab = LIB_Uart0Recv()
if recv_flag == 1 then
LIB_IntWifiUdpSend(uart_recv_tab)
end
recv_flag,wifi_recv_tab = LIB_IntWifiUdpRecv()
if recv_flag == 1 then
LIB_Uart0Send(wifi_recv_tab)
end
end
边栏推荐
猜你喜欢

SPL-安装与基本使用(二)

CPU設計實戰-第四章實踐任務一簡單CPU參考設計調試

【Redis】一气呵成,带你了解Redis安装与连接

SPL Introduction (I)

Agrometeorological environment monitoring system

基于Gazebo的无人机管道检测

Use threejs simple Web3D effect

Connect timed out of database connection
![[dynamic planning] p1020 missile interception (variant of the longest increasing subsequence)](/img/3e/75a1152f9cdf63c6779fdadec702a0.jpg)
[dynamic planning] p1020 missile interception (variant of the longest increasing subsequence)

【华为机试真题详解】判断字符串子序列【2022 Q1 Q2 | 200分】
随机推荐
Thread safety analysis of [concurrent programming JUC] variables
[untitled]
Leetcode T39: 组合总和
Provincial election + noi part I dynamic planning DP
Redis publish subscription
How to use OKR as the leadership framework of marketing department
How to recruit Taobao anchor suitable for your own store
SPL installation and basic use (II)
Anddroid 文本合成语音TTS实现
Leetcode T40: 组合总和II
shardingSphere
Intelligent water conservancy solution
Download jackson codehaus. org jar - downloading jackson. codehaus. org jar
Anddroid text to speech TTS implementation
Luogu p3799 demon dream stick
网关gateway-88
Mavros sends a custom topic message to Px4
Agrometeorological environment monitoring system
基于Gazebo的无人机管道检测
Codeworks round 803 (Div. 2) VP supplement