#!/usr/bin/python
import sys
import dbus

def main():
    bus = dbus.SystemBus()
    gsm_device_obj = bus.get_object("org.freesmartphone.ogsmd", "/org/freesmartphone/GSM/Device")
    gsm_network_iface = dbus.Interface(gsm_device_obj, 'org.freesmartphone.GSM.Network')
    try:
        status = gsm_network_iface.GetStatus()
        code = str(status["code"])
        mcc = int(code[:3])
        mnc = int(code[3:])
        lac = int(status["lac"], 16)
        cid = int(status["cid"], 16)
        print("%s %s %s %s" % (mcc, mnc, lac, cid))
    except:
        sys.exit(1)

main()


