espressif / esp-hosted

Hosted Solution (Linux/MCU) with ESP32 (Wi-Fi + BT + BLE)
Other
707 stars 169 forks source link

Can not get ip #40

Open donny681 opened 3 years ago

donny681 commented 3 years ago

I use esp32 spi interface to connect to rpi.The esp32 connected wifi sucessfully,but it cannot get ip from dhcp.

`

pi@raspberrypi:~/esp-hosted/host/linux/host_control/python_support $ python station_connect.py 'AC2100' 'wifiwifi' station MAC address bc:dd:c2:d1:b3:10 Connected to AC2100 sudo ifconfig ethsta0 down sudo ifconfig ethsta0 hw ether bc:dd:c2:d1:b3:10 sudo ifconfig ethsta0 up Killed old client process sudo dhclient ethsta0 -r Internet Systems Consortium DHCP Client 4.4.1 Copyright 2004-2018 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/ethsta0/bc:dd:c2:d1:b3:10 Sending on LPF/ethsta0/bc:dd:c2:d1:b3:10 Sending on Socket/fallback DHCPDISCOVER on ethsta0 to 255.255.255.255 port 67 interval 6 DHCPDISCOVER on ethsta0 to 255.255.255.255 port 67 interval 8 DHCPDISCOVER on ethsta0 to 255.255.255.255 port 67 interval 14 DHCPDISCOVER on ethsta0 to 255.255.255.255 port 67 interval 20 DHCPDISCOVER on ethsta0 to 255.255.255.255 port 67 interval 11 DHCPDISCOVER on ethsta0 to 255.255.255.255 port 67 interval 2 No DHCPOFFERS received. No working leases in persistent database - sleeping. sudo dhclient ethsta0 -v Success in setting AP config pi@raspberrypi:~/esp-hosted/host/linux/host_control/python_support $ ifcofnig -bash: ifcofnig: command not found pi@raspberrypi:~/esp-hosted/host/linux/host_control/python_support $ ifconfig enxb827eb7d1286: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.0.121 netmask 255.255.255.0 broadcast 192.168.0.255 inet6 fe80::b0df:5751:a4f9:6bda prefixlen 64 scopeid 0x20 ether b8:27:eb:7d:12:86 txqueuelen 1000 (Ethernet) RX packets 3779 bytes 367614 (358.9 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1874 bytes 247806 (241.9 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

ethap0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 169.254.221.117 netmask 255.255.0.0 broadcast 169.254.255.255 inet6 fe80::4f12:90f2:618a:5c3c prefixlen 64 scopeid 0x20 ether bc:dd:c2:d1:b3:11 txqueuelen 1000 (Ethernet) RX packets 608 bytes 100491 (98.1 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 113 bytes 22440 (21.9 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

ethsta0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 169.254.246.62 netmask 255.255.0.0 broadcast 169.254.255.255 inet6 fe80::f4ce:cda0:201f:45b9 prefixlen 64 scopeid 0x20 ether bc:dd:c2:d1:b3:10 txqueuelen 1000 (Ethernet) RX packets 644 bytes 127307 (124.3 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 285 bytes 50627 (49.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 1000 (Local Loopback) RX packets 4 bytes 1128 (1.1 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 4 bytes 1128 (1.1 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

wlan0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 ether b8:27:eb:28:47:d3 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

pi@raspberrypi:~/esp-hosted/host/linux/host_control/python_support $ dhclient -s 192.168.1.20 RTNETLINK answers: Operation not permitted RTNETLINK answers: Operation not permitted RTNETLINK answers: Operation not permitted RTNETLINK answers: Operation not permitted pi@raspberrypi:~/esp-hosted/host/linux/host_control/python_support $ sudo dhclient -s 192.168.1.20 ^C pi@raspberrypi:~/esp-hosted/host/linux/host_control/python_support $ sudo dhclient -s 192.168.1.20 -v Internet Systems Consortium DHCP Client 4.4.1 Copyright 2004-2018 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/ethap0/bc:dd:c2:d1:b3:11 Sending on LPF/ethap0/bc:dd:c2:d1:b3:11 Listening on LPF/ethsta0/bc:dd:c2:d1:b3:10 Sending on LPF/ethsta0/bc:dd:c2:d1:b3:10 Listening on LPF/wlan0/b8:27:eb:28:47:d3 Sending on LPF/wlan0/b8:27:eb:28:47:d3 Listening on LPF/enxb827eb7d1286/b8:27:eb:7d:12:86 Sending on LPF/enxb827eb7d1286/b8:27:eb:7d:12:86 Sending on Socket/fallback DHCPDISCOVER on ethap0 to 192.168.1.20 port 67 interval 7 DHCPDISCOVER on ethsta0 to 192.168.1.20 port 67 interval 8 DHCPDISCOVER on wlan0 to 192.168.1.20 port 67 interval 3 DHCPREQUEST for 192.168.0.121 on enxb827eb7d1286 to 192.168.1.20 port 67 DHCPDISCOVER on wlan0 to 192.168.1.20 port 67 interval 4 DHCPDISCOVER on wlan0 to 192.168.1.20 port 67 interval 6 DHCPDISCOVER on ethap0 to 192.168.1.20 port 67 interval 8 DHCPREQUEST for 192.168.0.121 on enxb827eb7d1286 to 192.168.1.20 port 67 DHCPDISCOVER on ethsta0 to 192.168.1.20 port 67 interval 15 DHCPDISCOVER on wlan0 to 192.168.1.20 port 67 interval 15 DHCPDISCOVER on ethap0 to 192.168.1.20 port 67 interval 15 DHCPDISCOVER on enxb827eb7d1286 to 192.168.1.20 port 67 interval 4 DHCPDISCOVER on enxb827eb7d1286 to 192.168.1.20 port 67 interval 6 DHCPDISCOVER on ethsta0 to 192.168.1.20 port 67 interval 19 DHCPDISCOVER on wlan0 to 192.168.1.20 port 67 interval 17 DHCPDISCOVER on enxb827eb7d1286 to 192.168.1.20 port 67 interval 11 DHCPDISCOVER on ethap0 to 192.168.1.20 port 67 interval 7 ^C pi@raspberrypi:~/esp-hosted/host/linux/host_control/python_support $ ^C pi@raspberrypi:~/esp-hosted/host/linux/host_control/python_support $ sudo dhclient ethsta0 -s 192.168.1.20 -v Internet Systems Consortium DHCP Client 4.4.1 Copyright 2004-2018 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/ethsta0/bc:dd:c2:d1:b3:10 Sending on LPF/ethsta0/bc:dd:c2:d1:b3:10 Sending on Socket/fallback DHCPDISCOVER on ethsta0 to 192.168.1.20 port 67 interval 8 DHCPDISCOVER on ethsta0 to 192.168.1.20 port 67 interval 17 DHCPDISCOVER on ethsta0 to 192.168.1.20 port 67 interval 14 DHCPDISCOVER on ethsta0 to 192.168.1.20 port 67 interval 14 DHCPDISCOVER on ethsta0 to 192.168.1.20 port 67 interval 8 No DHCPOFFERS received. No working leases in persistent database - sleeping. pi@raspberrypi:~/esp-hosted/host/linux/host_control/python_support $

`

I (906986) wifi:mode : null I (906986) slave_commands: station d6:02:ea:c5:c8:f2 leave, AID=1 I (906986) slave_commands: softap stop handler stop I (906996) slave_commands: softap stopped data ready I (926596) wifi:mode : sta (bc:dd:c2:d1:b3:10) I (926596) slave_commands: Station mode set in scan handler I (928196) slave_commands: Total APs scanned = 14 I (928196) slave_commands: Details of AP no 0 I (928196) slave_commands: SSID AC2100 I (928196) slave_commands: RSSI -33 I (928196) slave_commands: Channel 1 I (928206) slave_commands: BSSID 1c:fa:68:b9:99:ca I (928206) slave_commands: Auth mode 3

I (928216) slave_commands: Details of AP no 1 I (928216) slave_commands: SSID Ziroom-13A02 I (928226) slave_commands: RSSI -53 I (928226) slave_commands: Channel 11 I (928236) slave_commands: BSSID 80:ea:07:36:94:b4 I (928236) slave_commands: Auth mode 4

I (928246) slave_commands: Details of AP no 2 I (928246) slave_commands: SSID ChinaNet-ApfA I (928256) slave_commands: RSSI -57 I (928256) slave_commands: Channel 6 I (928266) slave_commands: BSSID 00:bd:82:25:f0:6e I (928266) slave_commands: Auth mode 4

I (928276) slave_commands: Details of AP no 3 I (928276) slave_commands: SSID HHT_200_1_97243 I (928286) slave_commands: RSSI -63 I (928286) slave_commands: Channel 11 I (928296) slave_commands: BSSID d8:b0:4c:b9:fb:20 I (928296) slave_commands: Auth mode 3

I (928306) slave_commands: Details of AP no 4 I (928306) slave_commands: SSID ABO1000 I (928316) slave_commands: RSSI -68 I (928316) slave_commands: Channel 3 I (928326) slave_commands: BSSID fc:37:2b:fd:1c:73 I (928326) slave_commands: Auth mode 4

I (928336) slave_commands: Details of AP no 5 I (928336) slave_commands: SSID Aa123456 I (928346) slave_commands: RSSI -70 I (928346) slave_commands: Channel 6 I (928356) slave_commands: BSSID f8:2f:65:df:d9:44 I (928356) slave_commands: Auth mode 4

I (928366) slave_commands: Details of AP no 6 I (928366) slave_commands: SSID abohome I (928376) slave_commands: RSSI -82 I (928376) slave_commands: Channel 10 I (928376) slave_commands: BSSID 08:36:c9:92:33:39 I (928386) slave_commands: Auth mode 3

I (928386) slave_commands: Details of AP no 7 I (928396) slave_commands: SSID JUL4LN_HiLink I (928396) slave_commands: RSSI -85 I (928406) slave_commands: Channel 6 I (928406) slave_commands: BSSID 68:a0:3e:bc:63:70 I (928416) slave_commands: Auth mode 3

I (928416) slave_commands: Details of AP no 8 I (928426) slave_commands: SSID DYR I (928426) slave_commands: RSSI -86 I (928436) slave_commands: Channel 1 I (928436) slave_commands: BSSID c8:5b:a0:e8:05:52 I (928446) slave_commands: Auth mode 4

I (928446) slave_commands: Details of AP no 9 I (928456) slave_commands: SSID Redmi_A875 I (928456) slave_commands: RSSI -86 I (928466) slave_commands: Channel 11 I (928466) slave_commands: BSSID 8c:de:f9:77:99:a0 I (928476) slave_commands: Auth mode 4

I (928476) slave_commands: Details of AP no 10 I (928486) slave_commands: SSID eason I (928486) slave_commands: RSSI -89 I (928496) slave_commands: Channel 1 I (928496) slave_commands: BSSID 48:0e:ec:75:46:ee I (928506) slave_commands: Auth mode 4

I (928506) slave_commands: Details of AP no 11 I (928516) slave_commands: SSID abohome I (928516) slave_commands: RSSI -91 I (928516) slave_commands: Channel 10 I (928526) slave_commands: BSSID 0e:36:c9:92:2b:81 I (928536) slave_commands: Auth mode 3

I (928536) slave_commands: Details of AP no 12 I (928536) slave_commands: SSID 1702华为路由 I (928546) slave_commands: RSSI -91 I (928546) slave_commands: Channel 11 I (928556) slave_commands: BSSID 74:45:2d:88:ae:64 I (928556) slave_commands: Auth mode 4

I (928566) slave_commands: Details of AP no 13 I (928566) slave_commands: SSID libo I (928576) slave_commands: RSSI -94 I (928576) slave_commands: Channel 9 I (928586) slave_commands: BSSID d8:32:14:5f:10:58 I (928586) slave_commands: Auth mode 4

data ready I (982926) slave_commands: Get station mac address I (982926) slave_commands: mac [bc:dd:c2:d1:b3:10] data ready I (982926) slave_commands: station mode set I (983056) wifi:new:<11,2>, old:<1,0>, ap:<255,255>, sta:<11,2>, prof:1 I (984036) wifi:state: init -> auth (b0) I (984046) wifi:state: auth -> assoc (0) I (984046) wifi:state: assoc -> run (10) I (987256) wifi:connected with Ziroom-13A02, aid = 1, channel 11, 40D, bssid = 80:ea:07:36:94:b4 I (987256) wifi:security: WPA2-PSK, phy: bgn, rssi: -48 I (987266) wifi:pm start, type: 1

I (987266) wifi:AP's beacon interval = 102400 us, DTIM period = 1 I (987276) slave_commands: Connected to AP I (987276) slave_commands: connected to ap SSID:'Ziroom-13A02', password:'4001001111' data ready I (1338856) slave_commands: Get station mac address I (1338856) slave_commands: mac [bc:dd:c2:d1:b3:10] data ready I (1338866) slave_commands: Disconnecting from previously connected AP I (1338866) wifi:state: run -> init (0) I (1338876) wifi:pm stop, total sleep time: 315850937 us / 351606871 us

I (1338876) wifi:new:<11,0>, old:<11,2>, ap:<255,255>, sta:<11,2>, prof:1 I (1338886) slave_commands: station mode set I (1339016) wifi:new:<1,1>, old:<11,0>, ap:<255,255>, sta:<1,1>, prof:1 I (1339986) wifi:state: init -> auth (b0) I (1339996) wifi:state: auth -> assoc (0) I (1339996) wifi:state: assoc -> run (10) I (1340616) wifi:connected with AC2100, aid = 3, channel 1, 40U, bssid = 1c:fa:68:b9:99:ca I (1340616) wifi:security: WPA2-PSK, phy: bgn, rssi: -25 I (1340616) wifi:pm start, type: 1

I (1340626) slave_commands: Connected to AP I (1340626) slave_commands: connected to ap SSID:'AC2100', password:'wifiwifi' I (1340646) wifi:AP's beacon interval = 102400 us, DTIM period = 1

` Could you tell me the reason why rpi can not get ip address from DHCP?

mantriyogesh commented 3 years ago

Hello Divter,

Thank you for your query but DHCP is not under the scope of this project.

Anyway I would suggest you to check your dhcp configuration, /etc/network/interfaces or similar script used for network configuration. I would also suggect to check dhcp server logs if you are unsure what happening.

Alternatively to localize dhcp issue, I would suggest to set up static ip first. If that is working, dhcp problem can be debugged further.

donny681 commented 3 years ago

Yes,if I set up static ip and it works.But I want to know the reason why rpi can not get wifi ip?How to fix it ? @mantriyogesh

mantriyogesh commented 2 years ago

Sorry, this went out of focus. Were you able to get it working @donny681 ?