Simulating WiFi device in android emulator with mac80211_hwsim kernel module - android

I am looking to simulate an additional WiFi device in a rooted android emulator (to simulate a device my company makes). So far I have found the linux kernel module, mac80211_hwsim, which seems like it would help me create virtual networks like this. I believe this is also the mechanism that the emulator uses to create its fake wifi network already. I have found /vendor/bin/mac80211_create_radios which seems to allow me to access that module (to create more channels / radios which appear in ip link show as wlan*).
If this is in fact the right way forward, once I create some more channels for that kernel module, I want to be able to connect to a program on my local computer after connected to this other WiFi network (similar to how 10.0.2.2 maps to the host computer). (this looks helpful with the redir command)
Does this sound reasonable and does anyone have some tips going forward? It's been challenging to find information that is relevant to Android in this area.
Some relevant files for how I believe the emulator does this:
/vendor/bin/init.wifi.sh
/vendor/bin/init.ranchu-net.sh
/vendor/bin/mac80211_create_radios
/vendor/etc/simulated_hostapd.conf

Related

Access Modem - Android Device (Nexus 5)

Device : Google Nexus 5 (Un-rooted)
Host Machine : Window 7
I want to Access Android Device as a Modem (using COM or Modem Port) and eventually pass AT Commands using HyperTerminal/Teraterm.
So after connecting the device to a Windows Box, The Device gets detected under Device Manager, but doesn't show any COM Port (other than the default COM0).
On right click and update driver, It shows it cannot find drivers.
I have tried the following options, but no luck with any.
Tried this on a rooted Nexus 5, but doesn't expose which /dev/smdX to use. Tried all combinations, didn't work.
Tried the Google USB Drivers from the Google Android's Website. No changes.
From here. I Installed drivers from LG Electronics, No changes in COM Port.
Universal Naked Driver helped me get to ADB Shell interface, but
thats not what I want.
In all of the Above procedure USB Debugging was enabled (Just saying).
I also heard the phone has to put into Modem mode to fire AT Commands.
If so, How do I do that ?
Or Is this a device driver Issue ?
Conclusion:
I want to access the Modem of the Android Device and fire AT Commands to it.
Could you please tell what am I missing ?
Any help on this would be really appreciated.
It's difficult to give an exact answer to this question, because it depends on how the manufacturer has implemented the device drivers. Unfortunately, there is a lot of information that isn't in the public domain.
It is possible, that the manufacturer has implemented some code to convert the device to a modem. Doing this yourself is device-specific, and proprietary. You might be able to get hold of a converter, for example bundled with the manufacturer's dashboard application for the PC, if such a thing exists.
Some devices don't expose the modem port at all. They may be visible as a network adapter, or as an always-connected LAN connection. If the device is visible as a network adapter, then you can access it via Windows Mobile Broadband API, or via MBIM for some newer devices.
To check if the device is visible as a network adapter, and get information about it, open a cmd box and type
netsh mbn show interfaces
Windows Mobile Broadband API doesn't give as many details as a good AT command set, but performs basically the same functions. MBIM is an industry standard interface with similar functionality, available on the Windows 8+ desktop via the Mobile Broadband DeviceServices API, for devices that support it.
If the device shows as an always-on LAN connection, there is probably a proprietary, high level interface for mobile functionality.
Driver behaviour can differ for different operating systems. If you have the chance to try the device on Windows Vista, 7 and 8, you may see different behaviour.

how to run wifi peer to peer application in android emulator..?

I am trying to develop an wifi peer to peer application in android(4.+).
The problem here is how to test it.
I tried to run that application in android emulator. there was no option to configure wifi in the settings menu, i also tired to enable wifi using the dev tools application form the emulator but it didn't work, And through all my googling over 3 days and i found that Android emulator is not supported the Wifi.
So i opted for androidx86 4.0eeepc using virtual box and tired to add devices both wifi and bluetooth (my app uses both bluetooth and wifi) but only bluetooth device got added and it did not work. But my virtual box detected the wifi and bluetooth devices. I just couldnt get them work with the virtual machine.
I tried everything like manually adding the addresses using terminal emulator app in androidx86 and used netcfg through the android commandline but neither of them worked.
Please suggest and guide me on the correct path to run these kind of applications that use wifi and bluetooth in android.
Thanks in advance.
First, be sure you enabled WiFi Direct in the Android settings for the two virtualbox instances:
Settings --> Wireless & Networks --> More... --> Wi-Fi direct
It has been stated as working once that hurdle was overcome, and I'm sure many have experienced the same...just be sure to enable wifi direct
I would have tried exactly what you've already tried by naturally moving from the emulator to the androidx86 project. Although unreliable, I'd recommend looking at and finagling this, if you haven't yet seen it: Android: Simulate WiFi in the emulator? and How to disable/enable network, switch to Wifi in Android emulator? most likely wouldn't have full out success but may be enough to let you know that it works or would work.
As far as testing WiFi-Direct/WiFiP2P without you yourself having a device/s, I would recommend:
Trying out some of the fiddling as mentioned above. And read through tons of logs.
You could always crowd source it to friends, or release an apk on a forum for a small group of testers.
Of course, both of those options are not ideal, seamless, or fast. So, I'd definitely hope you get VirtualBox VMs of AndroidX86 4.0 running as it should once you check that setting and pair up the WiFi APs :-)
A near future solution:
This might be something to look into in near future.
Real devices are hosted by Samsung and screens are streamed to your PC.
http://developer.samsung.com/remoteTestLab.do
According to an email responded by samsung, which I sent to them earlier.
They only have 2 devices (Galaxy Nexus) running on Android v4.0 at the moment.
Unfortunately they are not physically close to each other. (One in Korea, One in Poland)
But they are planning to upgrade existing Galaxy S2 to v4.0.
Because recently Samsung have released v4.0 upgrade for S2.
Once they done that, there will be plenty of v4.0 phones.
And you can ask them which 2 phones are physically close so you can test Wifi Direct.
--------------------------- EDIT ---------------------------------
There are plenty of ICS devices there now, which you can test P2P.
Check with them which 2 are physically near to each other.
Per the docs:
Each instance of the emulator runs behind a virtual router/firewall
service that isolates it from your development machine's network
interfaces and settings and from the internet.
You have to use Network Redirection, as described in the Developer Docs. In essence, you forward specific ports using ADB. Therefore you cannot test certain things like broadcast messages.
I have tried doing what you are trying to do, and-- while I won't say it is impossible (anything is possible in computing with enough time, money, and persistence)-- I wasted a lot of time on it. You cannot treat the Android emulator as a normal network peer-to-peer device. As far as I have been able to find, it is a fork of QEMU, and that is just how the QEMU emulator is implemented.
QEMU itself does support TUN/TAP bridging, but I was never able to get it working with the Android emulator. If you want to go that route, you may want to investigate running Android in the QEMU emulator, rather than in the SDK's emulator (I see you are already trying a similar approach with VirtualBox).
Unfortunately the best way to test a peer-to-peer networking program in Android is with physical devices at this time-- unless your app can suffice with the port forwarding method.
See Also: Issue 26:Emulated Androids should be able to communicate via TCP, and Google
(Repeating here my answer elsewhere.)
In theory, linux (the kernel underlying android) has mac80211_hwsim driver, which simulates WiFi. It can be used to set up several WiFi devices (an acces point, and another WiFi device, and so on), which would make up a WiFi network.
It's useful for testing WiFi programs under linux. Possibly, even under user-mode linux or other isolated virtual "boxes" with linux.
In theory, this driver could be used for tests in the android systems where you don't have a real WiFi device (or don't want to use it), and also in some kind of android emulators. Perhaps, one can manage to use this driver in android-x86, or--for testing--in android-x86 run in VirtualBox.

Android App and Communications via USB

Ok, so I have researched this somewhat and am not encouraged, but I'm going to ask anyway, and be specific about what I'm trying to do. Maybe it will help!
I have a custom board with DaVinci processor with USB 2.0 OTG controller on it. I have it configured as a host with an attached hub and various peripherals. This processor runs Monta Vista Linux (MVL) 4.0 with 2.6.18 based kernel. This custom board some video processing and streaming.
I also have a Moto Droid. I can attach the phone as a USB device to my DaVinci system and MVL will enumerate the phone, but obviously doesn't know which driver to use. That I can fix.
So what I would ideally like to do is be able to have a data connection between my board and the phone, and use the phone with a custom app, as a configuration tool (initially). I'm thinking RNDIS would be wonderful, but I don't know if Android supports that on the USB port. Then my custom app would establish a connection over the USB to a server on my custom board.
Can anyone attest to what Android DOES support over USB, besides adb and flash file system?
Any other suggestions are welcome, although please don't tell me "Bluetooth", it doesn't have bandwidth for video, which is a future goal.
Thanks!
For small amounts of data, you could look at Working Android with Arduino, which points at Microbridge (http://code.google.com/p/microbridge/) or you could also look at IOIO (http://ytai-mer.blogspot.com/2011/04/meet-ioio-io-for-android.html).
For things like video, adb port forward (http://developer.android.com/guide/developing/tools/adb.html#forwardports) could be you friend (assuming you have the networking stack on MVL all setup and adb configured). You can basically set up port tunnels for TCP over USB and shift reasonably large amounts of data over the link. One end of the connection (probably the android device) runs a TCP/HTTP server, and the custom board opens connections to communicate. This works reasonably well, you set up a thread running adb devices to detect the plugging in of the Droid device, run adb port forward to set up the port forward, then open your sockets and you're good to go.
Is using 802.11 an option for you on the Davinci board? E.g. either via a Wifi USB dongle or through wired ethernet to an AP? If so, that would seem to be an easier route to communicate with Android than trying to go through USB. Or are your video resolution and compression requirements more than what you'd expect to realistically get through 802.11?

Android phone usb

I want to make a remote control for my tv using my android phone. I plan to connect my external infrared device to the phone via usb. An application on the phone should do the processing and send out commands to the infrared device via usb. Is it possible to explicitly access the phone's usb interface from the application to send/receive data? The data will just be short binary strings. In one instance, the phone should be the host and in the other instance, the phone should be a client.
For this to be possible, I believe you will need a USB host driver for your phone. While these drivers are available for some devices (see link), you'll need to have root access to install them, and it won't be easy. For instance, here's a description of how to install a USB host driver for the Nexus One.
Given how few devices support USB host, there seems to be very little documentation one how one would actually go about accessing a specific USB device. The second link above, to the Nexus One driver, provides some sparse details. Beyond that I can only assume that you'd need to write your own driver for the specific device, which would probably be similar to standard Linux USB driver development. This XDA thread (started by the author of the N1 USB host driver) is probably the best source of information you'll find.
Unfortunately the short answer is that what you want to do will be very difficult, and you certainly won't be able to distribute your work easily if you do manage it. Good luck!

USB Android I/O

Is it possible to access the USB port on Android phones? (Droid X for example)
Here is my usage case:
Have a USB device attached to the Android phone. The phone listens for data on this USB device. (The USB device is connected to a USB->RS-232 converter that has I/O attached to it)
This would be slick if possible. Does anyone know if this is possible?
Would be slick, yup. Not possible though. There's a feature request for it: http://code.google.com/p/android/issues/detail?id=738
Actually it is possible on a lot of the phones if you are able to install a new kernel with a USB host driver and rig up a custom cabling scheme to provide usb bus power to the device as the phone won't. A few phones even shipped with this capability already live.
I don't know if the Droid X specifically ships with this already, can have it added (if you are able to flash kernels), could have it added but no one has written the host driver yet, or is missing the hardware capability.
You also would need to enable the appropriate usb serial converter device driver (identified by experimenting with the device on a desktop linux box), but that's probably already in the kernel sources and just needs to be selected in the config. You may also need to create a device file for the /dev/ttyUSB0 or whatever and give it permissions appropriate to the application that wants to access it. (This requires root, but if you can reflash the kernel, you can get root)
If you want to pursue this, search the android kernel google group for posts about USB host mode.
One serious downside to putting the USB into host mode is that you loose the adb interface into the phone, which makes working on your projects hard. You'll probably need to either build an adapter for the low voltage debug serial port if there is one (as on G1, mytouch, etc) so you can get a console shell (or just use that instead of USB to talk to your peripheral) or at a minimum set up an ssh and sftp server on the wifi.
Since you want serial anyway, another option people have used is to get a bluetooth-to-serial module from an outfit such as sparkfun.
A bluetooth to serial adapter might solv your problems.
You can find one at https://www.sparkfun.com/products/582. Boards from other companies are also available for example on ebay.

Categories

Resources