wifi.sta.setip({ ip = "192.168.0.111", netmask = "255.255.255.0",gateway = "192.168.0.1"})
with above we can set static IP,
but by mistake if someone enters the netmask/gateway/ip a digit or to wrong (eg:netmask = "255.255.2.0" ) we have no way of detecting. only way is to
by re entering correctly
rebooting
(How to clear static IP configuration and start DHCP)
so it would be nice if we can detect the status somehow like with wifi.sta.status() do.
How to clear static IP configuration and start DHCP
wifi.sta.clearconfig()
Clears the currently saved WiFi station configuration, erasing it from
the flash. May be useful for certain factory-reset scenarios
Not sure if this also deletes the ip but you can probably just set the ip to "0.0.0.0" befor you reconnect.
Related
I need your help because I don't understand what's going on. I have 2 esp8266 , one in AP mode and the second in station mode.
When I connect the ESP in station mode to my box, it's ok.
On the other hand when I use this code to connect to the other ESP in AP mode with a fixed IP, the ESP remains in the while loop
import network
from time import sleep
def config_wifi():
ip = '192.168.144.3'
subnet = '255.255.255.0'
gateway = '192.168.144.1'
dns = '8.8.8.8'
ssid = 'MicroPython-AP'
password = '123456789'
ap=network.WLAN(network.AP_IF)
ap.active(False)
ap.disconnect()
print(ap.status()) # return None
sleep(2)
sta=network.WLAN(network.STA_IF)
sta.active(True)
sta.disconnect() # for ESP8266
sta.connect(ssid,password)
print(sta.status())# return 1001 : CONNEXION
sleep(2)
while (sta.isconnected()==False):
print(sta.isconnected())
sta.ifconfig((ip,subnet,gateway,dns))
ip=sta.ifconfig()[0]
print('Connected',ip)
return ip
def run():
config_wifi()
run()
Following my tests, I used an ESP32 Lolin with this program and I have the same result, ie False in the while loop.
The first status gives me None and the second 1001. Searching on different forums, 1001 means Connexion.
Status indicates that there is connection, on the other hand the while loop gives False
I do not understand Do you have an idea?
Server.set_addr (sv, addr)
I can not understand what the method takes as input.
It would seem that Server.get_addr(sv) returns ip:port - so you also need to pass ip:port, but no. This does not work.
The documentation reads:
See the documentation for the control socket for more information on the string format.
Well, I saw that you need to transfer the ip port: port (example: 127.0.0.1 port 80). But that doesn't work either.
The only thing that works is pass only ip (example: 127.0.0.1).
The question is how to change the port?
Code sample: (if not work - no have any entry in log)
-- work
-- log entry: changed its IP from 1.1.1.1 to 2.2.2.2 by Lua script.
local newAdr = backendServer.ip
server:set_addr(newAdr)
-- not work
local newAdr = backendServer.port
server:set_addr(newAdr)
-- not work
local newAdr = backendServer.ip .. ":" .. backendServer.port
server:set_addr(newAdr)
-- not work
local newAdr = backendServer.ip .. " " .. backendServer.port
server:set_addr(newAdr)
-- not work
local newAdr = backendServer.ip .. " port " .. backendServer.port
server:set_addr(newAdr)
Update: As of HAProxy 2.2dev7, this functionality has now been merged: set_addr takes an additional optional parameter to specify a new port.
It's not currently possible to do that via Lua. A look through HAProxy's source code reveals that set_addr calls hlua_server_set_addr, which calls server_parse_addr_change_request, which calls update_server_addr, which only updates the address and not the port. Contrast this with the management socket's set server, which calls cli_parse_set_server, which calls update_server_addr_port, which does update the port too.
However, there are two pieces of good news:
Since the management socket can do it, you can use it as a workaround.
It would be very simple to modify HAProxy's Lua interface to support updating the port, since all the logic is already there. I sent a patch that does so to their mailing list.
Running one of the Lslidar(16 Channels) on the Embeded board(ROS development environments) is not a problem.
This is because you can use the default IP and ports.
But I plan to run two at the same time, and I want to use values other than the default values of ports and IP..
For example, you can use ports like 2368 and 2369.
I need a reference to refer to how to change the port value and IP value...
Help Plz...
Here is code from lsLidar driver from ROS Wiki:
bool LslidarC16Driver::loadParameters() {
//pnh.param("frame_id", frame_id, std::string("lslidar"));
pnh.param("lidar_ip", lidar_ip_string, std::string("192.168.1.222"));
pnh.param<int>("device_port", UDP_PORT_NUMBER,2368);
pnh.param<bool>("add_multicast", add_multicast, false);
pnh.param("group_ip", group_ip_string, std::string("234.2.3.2"));
inet_aton(lidar_ip_string.c_str(), &lidar_ip);
ROS_INFO_STREAM("Opening UDP socket: address " << lidar_ip_string);
if(add_multicast) ROS_INFO_STREAM("Opening UDP socket: group_address " << group_ip_string);
ROS_INFO_STREAM("Opening UDP socket: port " << UDP_PORT_NUMBER);
return true;
}
As you can see there is a place where you can change port and IP. For two devices I'd advise you to modify the original driver. All source code is available on https://github.com/tongsky723/lslidar_C16
Clone it to you workspace and create additional functionality for two LiDARs.
I'm trying to connect to an RN42, module through python. When the RN42 pairs with W10 it creates two virtual COM ports(outgoing and incoming). I need to connect to the outgoing port.
I'm trying to do this automatically. I've tried:
import serial
import serial.tools.list_ports as port_lst
ports = list(port_lst.comports())
bluetooth_ports = []
for p in ports:
if 'Bluetooth' in p.description:
bluetooth_ports += [p.device]
bluetooth_com = serial.Serial(bluetooth_ports[0],115200)
I thought that the first port was usually the outgoing one, but I've paired the module to another computer, and this didn't apply (the second port was the outgoing one). Is there a way to find out the direction of the COM ports?
Thanks!!!
Although this is an antique question, I have been searching for the answer to this for some time myself and since I finally figured it out I wanted others to be able to find the answer. With help from a blog entry at in the hand and its accompanying gist:
The trick is to acquire the hwid using pySerial, then parse the address. The incoming port in a pair has an address of zero and the outgoing port has a nonzero address. Here is some ugly Python code that decodes it:
import serial.tools.list_ports
cp=serial.tools.list_ports.comports()
for p in cp:
if "BTHENUM" in p.hwid:
start_of_address=p.hwid.rfind("&")
end_of_address=p.hwid.rfind("_")
address=p.hwid[start_of_address+1:end_of_address]
if int(address,16)==0:
port_type="incoming"
else:
port_type="outgoing"
print(p.hwid)
print(p.name, address, port_type)
And the output:
BTHENUM\{00001101-0000-1000-8000-00805F9B34FB}_LOCALMFG&0000\7&CC47540&0&000000000000_000000A8
COM4 000000000000 incoming
BTHENUM\{00001101-0000-1000-8000-00805F9B34FB}_LOCALMFG&0002\7&CC47540&0&209BA5420081_C00000000
COM5 209BA5420081 outgoing
I need to Write a Wireshark display filter to meet the following requirements.
All traffic from host 192.168.12.44 to host 192.168.12.1
I believe it is just
ip.src_host = 192.168.12.44 && ip.dst_host 192.168.12.1
or
ip.src== 192.168.12.44 && ip.dst==192.168.12.1
I'm just not sure which syntax is correct. Can anyone offer any tips/advice? I tried this on two different IPs that i can actually test yet they seem to offer different results, so I'm not sure which one I need.
ip.src & ip.dst are for IP adresses while ip.src_host & ip.dst_host are for their DNS names. Suppose an IP with the address 192.168.1.1 has a corresponding DNS name of mydns.mysite.com. Assuming you have enabled Resolve Network Address under View --> Name Resolution, then ip.src_host will filter mydns.mysite.com while when not enabled ip.src will filter 192.168.1.1
Please refer to this link for more information.