|
2009-12-14
, 21:07
|
|
Posts: 4,274 |
Thanked: 5,358 times |
Joined on Sep 2007
@ Looking at y'all and sighing
|
#2
|
|
2009-12-14
, 21:13
|
|
Posts: 516 |
Thanked: 643 times |
Joined on Oct 2009
@ Denmark/Poland
|
#3
|
The Following 3 Users Say Thank You to hopbeat For This Useful Post: | ||
|
2009-12-14
, 21:36
|
Posts: 486 |
Thanked: 154 times |
Joined on Sep 2009
@ New York City
|
#4
|
|
2009-12-14
, 22:18
|
Posts: 486 |
Thanked: 154 times |
Joined on Sep 2009
@ New York City
|
#5
|
@hypnotik:
and here you have an example of using DBus in Python (this one is for WLAN scanning):
http://slexy.org/view/s25h3to4Rr
|
2009-12-14
, 22:44
|
Posts: 486 |
Thanked: 154 times |
Joined on Sep 2009
@ New York City
|
#6
|
from dbus.glib import * import gobject import dbus import array loop=None def scan_results(*args): loop.quit() if __name__ == "__main__": #mandatory to receive dbus signal loop=gobject.MainLoop() bus = dbus.SystemBus() wlancond = bus.get_object('com.nokia.phone.net', '/com/nokia/phone/net') request = dbus.Interface(wlancond, 'Phone.Net') bus.add_signal_receiver(scan_results, dbus_interface="Phone.Net.get_registration_status", signal_name="get_registration_status") request.get_cell_id(dbus.Int32(4), dbus.ByteArray([]), dbus.Int32(2)) loop.run()
ERROR:dbus.proxies:Introspect error on :1.16:/com/nokia/phone/net: dbus.exceptions.DBusException: rpc.Error: object /com/nokia/phone/net doesn't have interface org.freedesktop.DBus.Introspectable Traceback (most recent call last): File "test2.py", line 31, in <module> request.get_cell_id(dbus.Int32(4), dbus.ByteArray([]), dbus.Int32(2)) File "/usr/lib/pymodules/python2.5/dbus/proxies.py", line 68, in __call__ return self._proxy_method(*args, **keywords) File "/usr/lib/pymodules/python2.5/dbus/proxies.py", line 140, in __call__ **keywords) File "/usr/lib/pymodules/python2.5/dbus/connection.py", line 622, in call_blocking message, timeout) dbus.exceptions.DBusException: rpc.Error: can't find method Phone.Net::get_cell_id
|
2009-12-14
, 23:30
|
|
Posts: 4,274 |
Thanked: 5,358 times |
Joined on Sep 2007
@ Looking at y'all and sighing
|
#7
|
#include <glib.h> #include <dbus/dbus-glib.h> #define PHONE_NET_DBUS_NAME "com.nokia.phone.net" #define PHONE_NET_DBUS_IFACE "Phone.Net" #define PHONE_NET_DBUS_PATH "/com/nokia/phone/net" #define PHONE_NET_REGISTRATION_METHOD "get_registration_status" guint get_cell_id (void) { DBusGConnection *connection; DBusGProxy *proxy; GError *error = NULL; guchar status, network_type, supported_services; guint lac, cell_id, operator_code, country_code; gint net_err; g_type_init(); connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error); if (!connection) { g_printerr("Failed to open connection to system bus: %s\n", error->message); g_clear_error(&error); return 0; } proxy = dbus_g_proxy_new_for_name(connection, PHONE_NET_DBUS_NAME, PHONE_NET_DBUS_PATH, PHONE_NET_DBUS_IFACE); if (!dbus_g_proxy_call(proxy, PHONE_NET_REGISTRATION_METHOD, &error, G_TYPE_INVALID, G_TYPE_UCHAR, &status, G_TYPE_UINT, &lac, G_TYPE_UINT, &cell_id, G_TYPE_UINT, &operator_code, G_TYPE_UINT, &country_code, G_TYPE_UCHAR, &network_type, G_TYPE_UCHAR, &supported_services, G_TYPE_INT, &net_err, G_TYPE_INVALID)) { if (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION) g_printerr("Caught remote method exception %s: %s", dbus_g_error_get_name(error), error->message); else g_printerr("Failed to call method: %s\n", error->message); g_clear_error(&error); return 0; } g_object_unref(proxy); dbus_g_connection_unref(connection); return cell_id; }
from ctypes import * weed = CDLL("/sdk/weed.so") crack = weed.get_cell_id(None) print "%d" % crack
The Following User Says Thank You to qwerty12 For This Useful Post: | ||
|
2009-12-15
, 09:07
|
Posts: 2,802 |
Thanked: 4,491 times |
Joined on Nov 2007
|
#8
|
#!/usr/bin/env python import sys import traceback import gobject import dbus import dbus.mainloop.glib def cell_signal_handler(*args): print "%s,%s,%s" % (args[4], args[3], args[2]) if __name__ == '__main__': dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) bus = dbus.SystemBus() bus.add_signal_receiver(cell_signal_handler, dbus_interface = "Phone.Net", signal_name = "registration_status_change") bus.add_signal_receiver(cell_signal_handler, dbus_interface = "Phone.Net", signal_name = "cell_info_change") loop = gobject.MainLoop() loop.run()
|
2009-12-15
, 09:26
|
|
Posts: 445 |
Thanked: 572 times |
Joined on Oct 2009
@ Oxford
|
#9
|
The Following 2 Users Say Thank You to ewan For This Useful Post: | ||
|
2009-12-15
, 09:50
|
Posts: 432 |
Thanked: 645 times |
Joined on Mar 2009
|
#10
|
I don't know for sure, but I was under the impression that the built-in liblocation would do this for you, rather than it needing to be implemented in each app - is that not the case?
The Following User Says Thank You to danielwilms For This Useful Post: | ||
Tags |
cell id, location, n900, python |
|
I want to be able to use this value to query an open cell database to get a rough location of the user (for when indoors/gps not working, etc)
thanks.
barriosquare - maemo/n900 foursquare app - get it now from extras-devel
My technology blog posts
follow me on twitter