Sunday, September 6, 2009

Android emulator + external GSM modem

Recently, I am working on this issue 'Use GTA02 GSM Passthrough mode as external Android GSM modem' and the goal is to use Beagle board as a platform. Since we are still using cupcake in beagle board, I choose to use Android emulator with latest donut in the beginning. When we have donut image in beagle board, i will switch it on that time.

In Android emulator, it would use a qemud socket as GSM modem and it can simulate GSM network. Like camp to GSM base station (Android 3G :P), receive incoming call, dial out a phone call, has a simulated SIM Card, send SMS messages....etc. In my previous article about tracing RIL, I tried to run two emulators and made a phone call to each other. It's pretty fun, coz it can simulate real GSM network.

But it's still a fake one, not real GSM network, it doesn't camp to the nearby network like your mobile does. Therefore..... I changed few lines and made Android emulator to run an external GSM modem. Here is my experiment!



rild: allow it to use other GSM device in qemu

diff --git a/rild/rild.c b/rild/rild.c
index 14a6ea9..bd91314 100644
--- a/rild/rild.c
+++ b/rild/rild.c
@@ -161,7 +161,7 @@ int main(int argc, char **argv)
}
close(fd);

- if (strstr(buffer, "android.qemud=") != NULL)
+ if (strstr(buffer, "android.qemud=") == NULL)
{
/* the qemud daemon is launched after rild, so
* give it some time to create its GSM socket


Modify rild lib argument and change device name

diff --git a/target/board/generic/system.prop b/target/board/generic/system.prop
index f2424c9..1b84596 100644
--- a/target/board/generic/system.prop
+++ b/target/board/generic/system.prop
@@ -3,4 +3,4 @@
#

rild.libpath=/system/lib/libreference-ril.so
-rild.libargs=-d /dev/ttyS0
+rild.libargs=-d /dev/ttyS2


GTA02 NEO phone

erin@daydreamer:~$ sudo ifconfig usb0 192.168.0.200
erin@daydreamer:~$ ssh root@192.168.0.202
root@om-gta02:~# echo 1 > /sys/devices/platform/neo1973-pm-gsm.0/power_on
root@om-gta02:~# echo ate1 | ./tickminicom
root@om-gta02:~# nc -l -p 4270 < /dev/ttySAC0 > /dev/ttySAC0 &

PS. tickminicom is here

Running pty in host machine

# ./pty 192.168.0.202 4270

PS.1 where is pty? how do I know it? it's from Thomas! I was co-working with him about gsmd and dialer UI in 2007.

Running emulator with serial port option

erin@daydreamer:~/android/mydroid_emu/out$ ./host/linux-x86/bin/emulator -system ./target/product/generic/system.img -sysdir ./target/product/generic/system -data ./target/product/generic/userdata.img -kernel ../prebuilt/android-arm/kernel/kernel-qemu -ramdisk ./target/product/generic/ramdisk.img -qemu -serial /dev/pts/2


Cannot receive any incoming call
I was stuck on this case and it would send hangup command to any incoming calls without any notification UI. I found this issue is a known one and we can set 'Settings.Secure.DEVICE_PROVISIONED' to 1. Then no problem now.

What it can do now?
* Camp to GSM network
* Dial out a phone call
* Receive an incoming call
* Send SMS
* Receive SMS

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.