Launching ofono with SIM800

From ZeroPhone
Jump to: navigation, search

Compiling ofono in Raspbian

git clone git://git.kernel.org/pub/scm/network/ofono/ofono.git
cd ofono
apt install automake build-essential libtool libglib-2.0-dev libglib-2.0 libglib2.0-dev libdbus-1-dev libudev-dev mobile-broadband-provider-info
# remove -Wno-error-cast=align and ‘-Wno-format-truncation’ from makefile
./bootstrap-configure
make

Adding an udev rule to point to the modem's UART

echo "KERNEL==\"ttyAMA0\", ENV{OFONO_DRIVER}=\"sim900\""| sudo tee /etc/udev/rules.d/00-ofono.rules

Starting ofonod in debug mode

./src/ofonod -n -d 'plugins/*'
[...]
ofonod[5102]: plugins/udevng.c:add_serial_device() Device is missing required OFONO_DRIVER property
ofonod[5102]: plugins/udevng.c:create_modem() /sys/devices/platform/soc/20201000.serial/tty/ttyAMA0
ofonod[5102]: plugins/udevng.c:create_modem() driver=sim900
ofonod[5102]: plugins/sim900.c:sim900_probe() 0x1fba88
ofonod[5102]: plugins/dun_gw_bluez5.c:modem_watch() modem: 0x1fba88, added: 1
ofonod[5102]: plugins/hfp_ag_bluez5.c:modem_watch() modem: 0x1fba88, added: 1
ofonod[5102]: plugins/smart-messaging.c:modem_watch() modem: 0x1fba88, added: 1
ofonod[5102]: plugins/push-notification.c:modem_watch() modem: 0x1fba88, added: 1
ofonod[5102]: plugins/hfp_hf_bluez5.c:connect_handler() Registering External Profile handler ...
ofonod[5102]: plugins/bluez5.c:bt_register_profile() Bluetooth: Registering 0000111e-0000-1000-8000-00805f9b34fb (hfp_hf) profile
ofonod[5102]: plugins/bluez5.c:profile_register_cb()

Listing detected modems

python2 ./list-modems 
[ /sim900_0 ]
    Features = 
    Emergency = 0
    Powered = 0
    Lockdown = 0
    Interfaces = 
    Online = 0
    Type = hardware

[ /stktest ]
    Features = 
    Emergency = 0
    Powered = 0
    Lockdown = 0
    Interfaces = 
    Online = 0
    Type = test

More about ofono install

# get ELL (Embedded Linux Library), must be in same folder as ofono: ell, ofono
git clone git://git.kernel.org/pub/scm/libs/ell/ell.git
# get ofono, follow README
git clone git://git.kernel.org/pub/scm/network/ofono/ofono.git
# build
cd ofono
sudo apt-get update
sudo apt-get upgrade
sudo apt install automake build-essential libtool libglib2.0-dev libdbus-1-dev libudev-dev mobile-broadband-provider-info
cp acinclude.m4 acinclude.m4-was
# comment lines 25,26 in acinclude.m4:
# CFLAGS="$CFLAGS -Wcast-align"
# CFLAGS="$CFLAGS -Wno-format-truncation"
# or use: ./bootstrap-configure --disable-maintainer-mode
./bootstrap-configure
make

Debug mode

# after that may use ofono in debug mode (no need to run 'make install' to play with ofono):
sudo systemctl stop zpui.service # just in case
# switch UART to ofono
echo 500 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio500/direction
echo 0 > /sys/class/gpio/gpio500/value
cat /sys/class/gpio/gpio500/value 
# may use ttyAMA0 with screen or minicom to test simple AT commands, like:
ATI - get module name
AT+CMEE=2 - set verbose errors
AT+CCID - get SIM card number
AT+CBC - get battery status
AT+COPS? - check that you are connected to network
AT+CSQ - check signal strength
# Debugging ofono AT commands:
# Need to have a good power (2A peaks) - use battery, if use power from USB, SIM800L may switch off unexpectedly.
sudo OFONO_AT_DEBUG=1 ./src/ofonod -nd
# in other console (a valid SIM need to be inserted in SIM800L)
sudo python2 ./test/enable-modem
sudo python2 ./test/dial-number '+nnnxxxyyyaabb'