Logo Search packages:      
Sourcecode: telepathy-blue version File versions

test.py

import tpblue.ltihooks, gtk
from tpblue.sms import SmsController
import btctl
SERIAL_PORT_SVCLASS_ID = 0x1101

def create_sms_controller(bt_addr, bt_chan):
      c=SmsController(bt_addr, bt_chan)

      def sms_received(controller, message):
            print 'SMS Received', message

      def disconnected(controller):
            print 'Disconnected'
            gtk.main_quit()
      
      c.connect('sms-received', sms_received)
      c.connect('disconnected', disconnected)
      return c

def discovered_service(controller, bt_addr, bt_name, clsid, bt_channel):
      print 'Service:', bt_addr, bt_name, clsid, bt_channel
      if clsid == SERIAL_PORT_SVCLASS_ID:
            c=create_sms_controller (bt_addr, bt_channel)
            if c.connect_bt():
                  c.send_sms ("+46762322367", "Hello World     !")

def status_change(c, status):
      print 'New status:', status

def add_device(c, dev):
      print 'New device:', dev

def device_name(c, dev, name):
      print 'New device:', dev, name
      
ctl=btctl.Controller("hci0")
ctl.connect ("add-device-service",discovered_service)
ctl.connect ("status-change", status_change)
ctl.connect ("add-device", add_device)
ctl.connect ("device-name", device_name)
    
#print 'Starting discovery'
#ctl.discover_devices ();
c=create_sms_controller("00:16:20:80:9D:05", 2)
if c.connect_bt():
      #c.send_sms ("+46762322367", "Hello World     ")
      pass
gtk.main()


#     controller = gnomebt_controller_new ();
#     g_message ("Trying to connect to BT device");
#     rfcomm_device = gnomebt_controller_connect_rfcomm_port_by_service (controller, BTADDR, SERIAL_PORT_SVCLASS_ID);
#     if (rfcomm_device < 0)
#     {
#           g_message ("Unable to connect to device");
#           g_object_unref(controller);
#           return;
#     }
#     rfcomm_device_path = g_strdup_printf ("/dev/rfcomm%d", rfcomm_device);
#
#     /* FIXME: boo*/
#     sleep(1);

Generated by  Doxygen 1.6.0   Back to index