I am working on a project that requires knowing the bluetooth or wifi MAC adresses of local IOS devices but whenever the IOS device is not in the settings screen for bluetooth, the device is not discoverable. This is a problem because the program needs to scan all local IOS devices no matter if the settings screen is open. I am considering switching to using wifi mac addresses if there is a way to extract them when not being connected to the same network or even on a network at all just in the same area. It wouldn't need to be long-range only find some sort of always-broadcasting unique identifier short distances (I know IP adresses can change so I avoided using them) that can be found without being connected to a certain wifi or being discoverable on bluetooth. Is there a solution that would work with python and IOS? Thanks for any responses in advance!
Related
I'm struggling with some kind of connection problem.
Here's the problem that I wanted to resolve
What I want to do is getting video streaming data from a IP camera (RTSP)
The IP camera is attached to the router which has access to the internet
I want to connect to this IP camera from remote computer.
IP cam --- Router --- Internet --- My computer
I know that I can do this by setting port forwarding option of the router.
However, I cannot set the option because the router is not mine, which means I cannot access to the router's admininstration server (192.168.0.1)
I'm trying to figure out this issue by connecting a small edge computer (e.g., raspberry pi) to the router's subnetwork and send streaming data to my computer through the Internet.
IP cam --------- Router --- Internet --- My computer
minicomputer ---
It's certain that the minicomputer can access to my computer through ssh, so I think It's possible to use the minicom as a proxy.
What is the best the way to get the IP camera's streaming in my circumstance?
Please help.
I think a good idea would be to use a VPN. Install a VPN-Server (openvpn, wireguard, etc...) on your minicomputer in the same network as your camera. Than connect to your vpn from your computer. Now you should be able to access the camera.
I have a few ideas how to view the camera stream, depending how you would normaly access it.
If it is a software to connect to the camera, install a desktop-environment on your minicomputer and connect to it via VNC (more or less a linux equivalent to rdp on windows) or RDP. Then open the software and view your stream. It could be a bit laggy because it has to be transmitted two times (camera -> minipc -> your pc)
If you can access the stream via a url, you could setup a webserver (nginx or apache2) on your minicomputer and build a small html website, that displays the stream. This should be more perfomant than the first solution, but involves a bit more tinkering. If you should decide to use this solution, I should have an example HTML-Page somewhere. Just let me know and i will try to find it and share it.
Depending on how you setup your VPN-Server maybe you can connect to your Camera directly via it's IP. To do that, your VPN-Server has to do some routing between the subnets.
I know these are just some Ideas from the top of my head, but I hope I can help a bit. If you have more questions or I didn't explain it in a way it is understandable, feel free to ask again.
I have an embedded system on which I can connect to internet. This embedded system must send sensor data to PC client.
I put a socket client using python on my PC. I put a socket server ( using C++ language on the embedded system because you can only use C++ ).
I can succesfully connect from my PC to the embedded system using the sockets and send and recieve whatever I want.
Now, the problem is I use local IP to connect to the system and both of them must be connected to the same Wifi router.
In the real application, I won't know where the embedded system is in the world. I need to get to it through internet, because it will be connectet to internet through 4g.
My question is, how can I connect to it through internet, if the embedded system is connected to internet using 4G?
Thank you
Realistically in typical situations, neither a PC nor an embedded device hanging off a 4g modem will likely have (or should be allowed) to have externally routable addresses.
What this practically means is that you need to bounce your traffic through a mutually visible relay in the cloud.
One very common way of doing that for IoT devices (which is basically to say, connected embedded devices) is to use MQTT. You'll find support in one form or another for most computing platforms with any sort of IP networking capability.
Of course there are many other schemes, too - you can do something with a RESTful API, or websockets (perhaps as an alternate mode of an MQTT broker), or various proprietary IoT solutions offered by the big cloud platforms.
It's also going to be really key that you wrap the traffic in SSL, so you'll need support for that in your embedded device, too. And you'll have to think about which CA certs you package, and what you do about time given its formal requirement as an input to SSL validation.
I think your problem is more easily solved if you reverse the roles of your embedded system and PC. If you are communicating to a device using IP protocols across cellular networks, it is much easier to have the device connect to a server on the PC rather than the other way around. Some networks/cellular modems do not allow server sockets and in any case, the IP address is usually dynamically allocated and therefore difficult to know. By having the device connect to a server, it "knows" the domain name (or IP address) and port to which it should make the connection. You just have to make sure that there is indeed a server program running at that host bound to some agreed upon port number. You can wake up the device to form the connection based on a number of criteria, e.g. time or amount of collected data, etc.
At work, I'm connected to both an internal internet service (through wifi) and an ethernet cable for external internet access. The wifi connection is the only way to connect to our internal databases or systems, but ethernet is what I need for internet browsing. Currently, by default I'm on the ethernet cable, but when I need to connect to our internal databases, I have to unplug the ethernet cable or go into my settings to change the service order to specifically use wifi (unplugging is much quicker).
Is there any way to specify in python to specifically use the non-default wifi connection when connecting to my sql server?
Python can't determine how to connect to IPs, that is in the domain of the operating system, at a lower level than Python cares about. You have to convince your OS to do it. Note that, because of this, the method is necessarily OS-specific, so nothing in this answer will work on anything other than Mac OS X.
I am not 100% sure, but I think you can do it so that OS handles the situation automatically. Try this:
Know the IP address of your database (e.g. 192.168.1.1)
Find out what the connection is called (probably Wi-Fi):
networksetup -listallnetworkservices
Find the gateway that is taking you there (e.g. 192.168.1.254) and its subnet mask (eg. 255.255.255.0):
networksetup -getinfo Wi-Fi
Set up a route so that your Mac OS will know to use that gateway for that address. This is kernel-level stuff so you need superuser access:
sudo networksetup -setadditionalroutes Wi-Fi 192.168.1.1 255.255.255.0 192.168.1.254
If I am correct, you can now browse the web using your normal connection, and use the ethernet Wi-Fi to connect to your database, automatically without you having to do anything further.
Another way to do this, closer to the way you asked it, is to create two different locations, with different service order; then you can switch between them programmatically using
networksetup -switchtolocation MyLovelyDatabase
You can get back to the default using
networksetup -switchtolocation Automatic
You can do this method from Python using subprocess.
I was wondering if there is a way to detect, from a python script, if the computer is connected to the internet using a tethered cell phone?
I have a Python script which runs a bunch of network measurement tests. Ideally, depending on the type of network the client is using (ethernet, wifi, LTE, ...) the tests should change. The challenge is how to get this information from the python client, with out asking the user to provide it. Especially detect tethering.
Normally not - from the computer's prospective the tethered cell phone is simply just another wifi router/provider.
You might be able to detect some of the phone carrier networks from the traceroute info to some known servers (DNS names or even IP address ranges of network nodes - they don't change that often).
If you have control over the phone tethering you could also theoretically use the phone's wifi SSID (or even IP address ranges) to identify tethering via individual/specific phones (not 100% reliable either unless you know that you can't get those parameters from other sources).
In case anyone is interested, what I ended up doing was keeping the phone connected to my machine and used ADB to get this info. The command I run is:
adb shell dumpsys netstats
This is also a useful link.
I'm connecting a several identical USB-MIDI devices and talking to them using Python and pyportmidi. I have noticed that when I run my code on Linux, occasionally the MIDI ports of the devices are enumerated in a different order, so I send messages to the wrong devices. As the devices do not have unique identifiers, I am told that I should identify them by which USB port they are connected to.
Is there any way to retrieve this information? My app will run on Linux, but Mac OS support is useful for development.
It's annoying because they usually enumerate in a sensible order - the first device in the hub is the first device in portmidi, but sometimes they don't - usually the first 2 devices are switched. I have to physically move the devices without unplugging to fix them.
lsusb should do the trick. All devices and their respective hubs are listed there.