How to get AP's IP address
How to get AP's IP address
Postby ftdiyun » Mon Jul 25, 2016 10:05 am
Hi,
When the ESP8266 acting as a station, and connected to an AP, how can user know the AP's IP address? I went through the API docuement "2c-esp8266_non_os_sdk_api_reference_cn", I didn't find a proper API to do this. Can you provide some hints or solution to get AP's IP address? Thanks.
When the ESP8266 acting as a station, and connected to an AP, how can user know the AP's IP address? I went through the API docuement "2c-esp8266_non_os_sdk_api_reference_cn", I didn't find a proper API to do this. Can you provide some hints or solution to get AP's IP address? Thanks.
Re: How to get AP's IP address
Postby akouz » Mon Jul 25, 2016 12:37 pm
Use command AT+CIFSR
For example, I've got the following replies (bold text) to that command:
+CIFSR:APIP,"192.168.4.1" - AP address
+CIFSR:APMAC,"1a:fe:34:fe:89:8d" - AP MAC
+CIFSR:STAIP,"192.168.1.104" - station address
+CIFSR:STAMAC,"18:fe:34:fe:89:8d" - station MAC
For example, I've got the following replies (bold text) to that command:
+CIFSR:APIP,"192.168.4.1" - AP address
+CIFSR:APMAC,"1a:fe:34:fe:89:8d" - AP MAC
+CIFSR:STAIP,"192.168.1.104" - station address
+CIFSR:STAMAC,"18:fe:34:fe:89:8d" - station MAC
Re: How to get AP's IP address
Postby ftdiyun » Mon Jul 25, 2016 4:58 pm
Hi,
Thanks for your reply. I tried this using the latest AT firmware, but there is no information about AP's IP. Please check the information as below:
AT+CIFSR
+CIFSR:STAIP,"192.168.1.5"
+CIFSR:STAMAC,"18:fe:34:a6:01:a9"
OK
at+GMR
AT version:1.3.0.0(Jul 14 2016 18:54:01)
SDK version:2.0.0(656edbf)
compile time:Jul 22 2016 12:02:54
OK
Thanks for your reply. I tried this using the latest AT firmware, but there is no information about AP's IP. Please check the information as below:
AT+CIFSR
+CIFSR:STAIP,"192.168.1.5"
+CIFSR:STAMAC,"18:fe:34:a6:01:a9"
OK
at+GMR
AT version:1.3.0.0(Jul 14 2016 18:54:01)
SDK version:2.0.0(656edbf)
compile time:Jul 22 2016 12:02:54
OK
Re: How to get AP's IP address
Postby Her Mary » Mon Jul 25, 2016 8:52 pm
The gateway should be the AP's IP address if DHCP is enabled. WiFi event "EVENT_STAMODE_GOT_IP" after registered callback by wifi_set_event_handler_cb.
AT command may be : AT+CIPSTA_CUR?
AT command may be : AT+CIPSTA_CUR?
Re: How to get AP's IP address
Postby akouz » Tue Jul 26, 2016 7:10 am
ftdiyun wrote:I tried this using the latest AT firmware, but there is no information about AP's IP
Perhaps you forgotten to enable AP by AT+CWMODE_CUR. Use either AT+CWMODE_CUR=2 or AT+CWMODE_CUR=3. Here is my initialisation sequence:
AT+CWMODE_CUR=3
AT+CWJAP_CUR="xxx","xxx"
AT+CIPMUX=1
AT+CIPSERVER=1,1300
After that I can query IP addresses:
AT+CIFSR
Re: How to get AP's IP address
Postby ftdiyun » Tue Jul 26, 2016 9:21 am
Hi akouz,
AT+CWMODE_CUR=3, means "softAP + station mode", the AP's IP address is the module its own SoftAP's address. It's not the gateway's IP address. Under this mode, "AT+CIFSR" commands do print-out its own SoftAP's address IP address, but not the gateway's IP address.
I am using "AT+CWMODE_CUR=1", means "station mode" only. Under this mode, "AT+CIFSR" commands doesn't print-out the connected AP's IP address (or gateway address).
The output message of command "AT+CIFSR" is not consistent for different mode.
AT+CWMODE_CUR=3, means "softAP + station mode", the AP's IP address is the module its own SoftAP's address. It's not the gateway's IP address. Under this mode, "AT+CIFSR" commands do print-out its own SoftAP's address IP address, but not the gateway's IP address.
I am using "AT+CWMODE_CUR=1", means "station mode" only. Under this mode, "AT+CIFSR" commands doesn't print-out the connected AP's IP address (or gateway address).
The output message of command "AT+CIFSR" is not consistent for different mode.
Who is online
Users browsing this forum: No registered users and 189 guests
Login
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
Latest SDK
Documentation
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!
- All times are UTC+08:00
- Top
- Delete all board cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. We are the manufacturer of ESP8266EX.