Peer-To-Peer connection via WiFi - android-wifi

Is it possible ?
Peer-To-Peer connection via WiFi (same Access Point) , how would multiple devices talk on this layer.
Any API available or sources that can be looked into ?
Thanks
Yogurt

The Wi-Fi Alliance on Monday announced that its direct peer-to-peer networking version of WiFi, called WiFi Direct, is now available on several new WiFi devices. The Alliance is also announcing that it has begun the process of certifying devices for WiFi Direct compatibility.

Try researching the state of Bonjour / Avahi / Zeroconf on android. I'm seeing some pages that indicate people have made some progress for certain purposes but nothing like a generic howto or ready to use library.

Unless you know the IP address assigned to the other peer already, you'd have to somehow have devices inform other devices that they exist.
Are these devices definitely going to be on the same subnet? If so you can try messing around with having the devices send out 'broadcast' packets. I have no idea if the Android API lets actual applications receive these though.
The more reliable approach would probably be to run some centralised server somewhere that devices register with when they go online, and give their IP address when they register. Then they can query that server for which other devices are nearby and what their IP addresses are. If this is to be a central server out on the wider internet, then it means that unfortunately that the device discovery part isn't peer to peer - there is some privacy implication. Another thing if this is a central server is that you'll have to design the querying process to cope with NAT so that querying for other devices on your local network is restricted to the right network, but that you also get their IP address.

Related

UDP broadcast search from a webpage

I have some devices which provide small webserver applications for users to access from their phone or laptop using a browser or thin client. All that the thin client does is a UDP broadcast to find devices on the local network and then connect a browser to the device(s) when found - or notify when no devices are found after a timeout.
Would it be possible to implement this thin client as a webpage served from a known host, so that the users' device wouldn't need any software installed beyond a browser and a link to the known host? The webpage would broadcast some UDP packets and wait for (appropriate) responses from any devices on the local network, if/when device responses are received present a list of devices to connect to, so the user can just select from a list, instead of having to determine the device addresses and type them in for themselves or install and use the thin client.
I can see how this sort of thing might be abused, and therefore made difficult or impossible by browsers, but no more than so many other technologies that are currently wide open for use...
Any help getting started with this kind of solution would be appreciated, thanks!
Unfortunately, this can't be done directly. I think it would be really great if there were some sort of "local peer" API to enable simple WebRTC connections without going through servers, but this doesn't exist.
You do have some options:
Write a browser extensionThis needs to call some native code to shuffle your data around, but it can work.
Deploy a server on the networkThe server can do all the initial connection/negotiation.

Codename one wi-fi detection

Im working with "Codename one" (Android developer) and I would like to know how can I detect if the phone has wi-fi activated or not. In this way, I can decide store data locally, and transmit it only when WI-FI is active. Otherwise, if I want to send pictures, without WI-FI, could be very expensive.
As a related question, do I have to setup some kind of cron or similar (in my code) in order to ask to my device if the WI-FI has been turned on?
Thank you very much for your help.
Kindly regards,
Gustavo
Normally to detect network you will need to use a check of whether you can connect to a specific server since a WiFi might be an airport wifi or something where you aren't authorized to connect outside. This will make it seem like wifi is connected but won't really work.
We have an APN API that allows you to detect the connection type (wifi/3g etc.) but it only works on Android/Blackberry and thus won't work (at this time) on iOS etc. Look at NetworkManager specifically: isAPSupported, getCurrentAccessPoint, getAPType.

What's the appropriate strategy to remotely assign static IP addresses to a bunch of embedded devices in an un-managed network

My company is currently developping an embedded device running uClinux.
Those devices are supposed to be deployed in both un-managed and managed networks.
We are looking for the best strategy to assign static IP addresses (and subnet masks) to those devices (from a Windows computer on the network) when no DHCP (or BOOTP) server is available and save those values to a configuration file in the device.
This strategy shall avoid the usage of ssh, telnet or any similar interface.
The device would be set with a factory default IP address and netmask (i.e. something like 192.168.1.1). Ideally, the strategy woudl also enable us to activate or de-activate DHCP support in those devices. The MAC addresses of the devices would be known information available that could be used in any kind of tool running on a Windows computer.
Does anyone know if any standard way of doing such a thing does exists? Any recommendation ensuring possible future portability on other platform than uClinux is welcome. A combination of standard Busybox tools or uCLinux available tools would be ideal.
Thanks in advance,
Francois
I think the best strategy is to use Zeroconf, which in embedded linux can be achieved with Avahi. The idea is that the device automatically assigns an IPv4 or IPv6 address to itself and resolves conflicts of addresses if necessary.
Devices can be discovered on the network and you can access them even if you have services running on the board. The best strategy is to have an IP alias on the network card with the zeroconf address and on the main interface you put the address you prefer

How can I communicate mobile with PC browser?

I want to make an HTML5 game that can be controlled with mobile. So how to communicate between mobile and browser on PC?
I think of the following ways:
Bluetooth This may be the most easy way to use. But I searched and found that Chrome made bluetooth API proposal last year but is now available only on Chrome dev, which means I cannot make the game popular for everyone.
WiFi I don't know how to set up a host on browser using WiFi information. If so, I can then connect my mobile to WiFi. This is considered to be faster than web socket since it's local network.
Web Socket There're a lot of information about how to use this. But as this use WAN, it is considered to be slower and is my last choice.
So, does anyone know how to achieve this with the former 2 ways?

wifi videostreaming from laptop to device

trying to create a program that works as following .video is captured by web cam of laptop and it is streamed to android phone using wifi .According to the video displayed, user types some messages and sents back to laptop simultaneously.
googled and found that making an ad-hoc wireless network will work,but forum
discussions says its not supported by android.want my app to work from 2.2 onwards
Which Socket communication protocol (UDP or TCP) protocol should be used to stream video?
Since want to implement two way communication, which one must be the server (laptop or mobile device)
Please guide me how to implement this
use connectify or any virtual router to get connected to your android phone.so app can be connected with your laptop or desktop.
go for UDP its fast and recover data even if it's lost and also use a proper data streaming strategy or a protocol.
According to your application design , i will recommend you to make your laptop work as a server. Also it would be best if you choose to use threading in both application and recommend your app to act as server or client as it's required shows more robustness..!