用oFono操作Openmoko手机

Neo FreeRunner是Openmoko公司设计生产的手机,它从硬件到软件都是开放的,主要面向的是开发者而不是终端用户。目前FreeRunner已经十几种不同的发行版,其中包括Android,SHR,Debian,Qt Extended,Gentoo等等。大家可以从Openmoko的官网上找到更多信息。(见Resource)
neo_freerunner
Neophysis是FreeRunner上第一个采用oFono的发行版。即使不用Neophysis,也很容易在FreeRunner上用oFono来控制modem。FreeRunner采用的是TI的calypso modem,据说是一款功能很完善的modem。
连接FreeRunner
1. 用USB线连接FreeRunner。
2. 在host PC上能够看到eth1或者usb1 interface.
3. sudo ifconfig eth1 192.168.0.200
4. ping 192.168.0.202。 这是FreeRunner默认的ip地址。应该能ping通。
5. 在本地的/etc/network/interfaces中加入以下config,设置ip forwarding.
auto eth1
iface eth1 inet static
    address 192.168.0.200
    netmask 255.255.255.0
    up iptables -A POSTROUTING -t nat -s 192.168.0.0/24 -j MASQUERADE
    up echo 1 > /proc/sys/net/ipv4/ip_forward
    down iptables -D POSTROUTING -t nat -s 192.168.0.0/24 -j MASQUERADE
    down echo 0 > /proc/sys/net/ipv4/ip_forward
设置FreeRunner
1.  ssh [email protected]。应该能直接登陆到FreeRunner上。
2.  修改/etc/network/interfaces。需要把替换成你所在的DNS server地址。
auto usb0                                     
iface usb0 inet static                        
    address 192.168.0.202                 
    netmask 255.255.255.0                 
    network 192.168.0.0                   
    up route add default gw 192.168.0.200 metric 8
    up echo domain sh.intel.com > /etc/resolv.conf
    up echo search sh.intel.com >> /etc/resolv.conf
    up echo nameserver >> /etc/resolv.conf
    down route del default gw 192.168.0.200 metric 8
3. 如果需要设http代理的话:
export http_proxy=http://proxy_server:proxy_port/
4. 创建4个脚本。
  1. alloc.sh
    dbus-send --system --print-reply --type=method_call --dest=org.freesmartphone.omuxerd /org/freesmartphone/GSM/Muxer org.freesmartphone.GSM.MUX.AllocChannel string:"1" int32:0
  2. power_on.sh
    stty -F /dev/ttySAC0 -echo
    echo "1" > /sys/bus/platform/devices/neo1973-pm-gsm.0/power_on
  3. reset_modem.sh
    stty -F /dev/ttySAC0 -crtscts
    echo "0" > /sys/bus/platform/devices/neo1973-pm-gsm.0/power_on
    stty -F /dev/ttySAC0 -echo
    echo "1" > /sys/bus/platform/devices/neo1973-pm-gsm.0/power_on
    启动oFono
    有两种启动oFono的办法。
    1. 在Linux Host上启动oFono,通过nc重定向Slave的输入输出到Host上面。nc是一个可以把tty串口输入重定向到TCP/IP端口的程序。以下主要介绍的是这种方法。
    2. 在FreeRunner上直接运行oFono。你需要从Openmoko网站上下载交叉编译环境。但大致思路还是一样的。
    在Host上控制oFono
    1. 在FreeRunner上,需要先停止已有的Telephony服务。在SHR OS上,它默认是使用fso-ogsmd和TI calypso modem通信的。
    root@om-gta02 ~ $ /etc/init.d/frameworkd stop
    2. 运行alloc.sh从Mux server上创建一个新的channel
    root@om-gta02 ~ $ ./alloc.sh
    method return sender=:1.22 -> dest=:1.27 reply_serial=2
       string "/dev/pts/1"
       int32 1
    3. 重定向输入和输出到2000端口上
    nc -l -p 2000 < /dev/pts/1 > /dev/pts/1
    4. 在Linux host上就可以通过Telenet访问,并看到“AT-Command Interpreter ready”。
    xxx@xxx:~/obexd$ telnet 192.168.0.202 2000
    Trying 192.168.0.202...
    Connected to 192.168.0.202.
    Escape character is '^]'.
    AT-Command Interpreter ready
    AT
    OK
    5. 修改/usr/local/etc/ofono/modem.conf
    [freerunner]
    Driver=phonesim
    Address=192.168.0.202
    Port=2000
    Modem=calypso
6. sudo src/ofonod -nd '*'
7. ofono/test/enable-modem /freerunner
8. ofono/test/online-modem /freerunner
9. ofono/test/create-context cmnet
10. ofono/test/activiate-context
Resource
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章