wind_energy wrote:
Rudi, can you see what i`m doing wrong?
Hi Pawel,
1)
If you use UDP as protokoll
you do not need to set a Server
Server you only create if you use "TCP"
then you must connect the client with AT+CIPSTART="TCP"....
so the command on SoftAP + Station mode
is not need.
2)
edit: ( UDP-> TCP )
If you only connect one Client to the "TCP SERVER"
you do not need to multiple connection AT+CIPMUX=1
you can use single connection AT+CIPMUX=0
if you use UDP and you want connect more as one Client
you can use multiple connection AT+CIPMUX=1 and you have then ID too,
but you do not really need to do this, you have from each "client" the ip
so you can send to the ip from each "client" or Softap/"server"
if you use on each UDP device the same port
this is no problem too, because you have from each UDP device the ip
if you want to send to more as one UDP device
you can send broadcast messages too
if you want to start more as one UDP services on an UDP device
you can use multiple connection AT+CIPMUX ( it is recommend )
so you can make on ID more as one UDP at one UDP device
ID1 UDP ADC Service
ID2 UDP PWM Service
ID3 TCP HTTPServer Service
and so on
3)
you can not connect by "UDP" to a "TCP" Server
4)
in UDP it is not need for multiple connection ( but you can use it if you want/need)
5)
Use DHCP if you want to set IP auto
You can set IP static too
see example:
Station: AT+CIPSTA
SoftAP: AT+CIPAP
wind_energy wrote:
SoftAP + Station mode
Code: Select all
AT+CWMODE=3
OK
AT
OK
AT+CWSAP?
+CWSAP:"ESP_2CB220","",1,0
OK
AT+CIFSR
+CIFSR:APIP,"192.168.4.1"
+CIFSR:APMAC,"1a:fe:34:2c:b2:20"
+CIFSR:STAIP,"0.0.0.0"
+CIFSR:STAMAC,"18:fe:34:2c:b2:20"
OK
// NOT NEED see (2) if you use Single connection in UDP
// AT+CIPMUX=1
OK
// NOT NEED see (1) if you use "UDP"
// AT+CIPSERVER=1,909
OK
the rest of SoftAP is ok.
now Station:
see comments in the "at code"..
wind_energy wrote:
Station mode
Code: Select all
AT+CWMODE=1
OK
AT+CWLAP
+CWLAP:(0,"ESP_2CB220",-9,"1a:fe:34:2c:b2:20",1)
OK
// ** the first will you inform that you have no ip get...cause you are not connected with the SoftAP..
AT+CIFSR
+CIFSR:STAIP,"0.0.0.0"
+CIFSR:STAMAC,"18:fe:34:2c:d8:d0"
OK
AT+CWJAP="ESP_2CB220","",
OK
// if you get an OK for join in the AP
// then usually the next try to get local IP must be possitive..
// you can try to check if your SoftAP DHCP is switch on
// you can try to check if your Client DHCP is switch on
AT+CIFSR
+CIFSR:STAIP,"0.0.0.0"
+CIFSR:STAMAC,"18:fe:34:2c:d8:d0"
OK
AT+CIPSTATUS
STATUS:2
OK
AT+CIPMUX=1
// you do not need a second server ;-)
// if you want send bidirektional you can use one server
// the server has a local port example 909
// the client has a local port this is auto done by the client..
// ..
OK
// not need..
// AT+CIPSERVER=1,909
OK
// now comes the "big" mistake
// you have start on Station AP a "TCP" server with AT+CIPSERVER=1,909
// and you try now with your client to connect the "TCP" server with an "UDP" protokoll
AT+CIPSTART="UDP","192.168.4.1",909
Link typ ERROR
try this if you want use UDP
-----------------------------------
on SoftAP + Station ESP32 Modul
Your Port: 909
on Station ESP32 Modul
Your Port: 808 ( you can use 909 too, but here only for better see what is going on )
on each "close" the port would be change, so you can do:
You want not change the ports in next time, so you can use the "parameter" 0,
The Parameter comes later here, only just in time for your eyes.
// SoftAP + Station
AT+CWMODE=3
// DHCP on for SoftAP
// each connected Client will get auto an IP
AT+CWDHCP=3
// Check Your SoftAP
// ok...
AT+CWSAP?
+CWSAP:"ESP_2CB220","",1,0
// Change and Set Your SoftAP with encryption und hidden SSID
// <ssid>,<pwd>,<channel>,<encryption>,<maxconn>,<ssidhidden>
AT+CWSAP="pawelnetwork","not4uPassort",1,4,10,1
// you can check your ips
// ok...
AT+CIFSR
+CIFSR:APIP,"192.168.4.1"
+CIFSR:APMAC,"1a:fe:34:2c:b2:20"
+CIFSR:STAIP,"0.0.0.0"
+CIFSR:STAMAC,"18:fe:34:2c:b2:20"
OK
// now remember you, SoftAP/SVR port (909) , Station/Client Port (808) and UDP
// so simple start a "UDP" network on your StationAP, local port is 909, and remote(client side) port will be 808
// the ip address you must use from the client, usually StationAP is 192.168.4.1 and the client becomes 192.168.4.2
// you must check it
// the last parameter is "do not change the ports after close, and reconnect"
// note: in UDP you must give the first port parameter for the remote, the second is for local
// so for SoftAP (909) is valid
AT+CIPSTART="UDP","192.168.4.2",808,909,0
// your "UDP" (server) network is ready on StationAP side
// **********
// now Station
// Station Mode ..
AT+CWMODE=1
// join to SoftAP
AT+CWJAP="pawelnetwork","not4uPassort"
// you can check your client IP
// usually comes the next after the SoftAP Ip ( 192.168.4.1 ...192.168.4.2 ...192.168.4.3 and so on )
AT+CIFSR
+CIFSR:STAIP,"192.168.4.2"
+CIFSR:STAMAC,"18:fe:34:2c:d8:d0"
// set up your client for the "UDP" network
// now remember you, SoftAP/SVR port (909) , Station/Client Port (808) and UDP
// so simple start a "UDP" network on your Sation (client), local port is 808, and remote(SoftAP, "Server" side) port will be 908
// the ip address you must use from the SoftAP, usually is 192.168.4.1 ..
// you must check it
// the last parameter is "do not change the ports after close, and reconnect"
// and here same
// note: in UDP you must give the first port parameter for the remote, the second is for local
// so for Station (808) is valid
AT+CIPSTART="UDP","192.168.4.1",909,808,0
// your "UDP" (server) network is ready on Station ( client ) side
// now you can start
// if you want start first to try one message to the other so try on SoftAP
// you use single connection so set it:
AT+CIPMUX=0
// now send 7 chars
AT+CIPSEND=7
hello_1
// now you have send from SoftAP to the Station, you must see on Station Terminal your message
// now send from Station to SoftAP
// single connection
AT+CIPMUX=0
// now send 7 chars
AT+CIPSEND=7
hello_2
// now you have send from Station to the SoftAP, you must see on SoftAP Terminal your message
- mode_0.png (27.34 KiB) Viewed 14679 times
// edit typo: no -> now
// now start transparent mode on each side
// each character you send from one you will see in the other
// SoftAP
AT+CIPMODE=1
// Station
AT+CIPMODE=1
// SoftAP
// now push your data to Station bidirectional
// each char you put you send to the connected esp
// Station
// now push your data to SoftAP bidirectional
// each char you put you send to the connected esp
// you stop the transmission by sending "+++"
// you must do this without delays and spaces and CR and LF
Code: Select all
esp_at_port_write_data( (uint8_t *) "+++", strlen("+++"));
// if you want to start your transmission again
// so select transparent 1 mode or normal mode 0
// AT+CIPMODE=1
// or
// AT*CIPMODE=0
// if you want close the "UDP" network
// SoftAP
AT+CIPCLOSE
// Station
AT+CIPCLOSE
- mode_1.png (19.32 KiB) Viewed 14679 times
question if you have , write here
let me know how you get on
best wishes
rudi