Beispiel #1
0
	def _connect(self):
		self.connecting = True
		try:
			self.pebble = Pebble(self.pebbleId, True, False, self.locationSource)
			self.pebble.register_endpoint("MUSIC_CONTROL", self.musicControl)
		except LightBluePebbleError, e:
			self.signals.onMessage.emit("Unable to connect to Pebble", str(e))
			self.connecting = False
			return
Beispiel #2
0
 def player_shoot(self, mouse_click):
     vector_direction = (mouse_click[0] - self.player.get_location()[0],
                         mouse_click[1] - self.player.get_location()[1])
     if vector_direction != (0, 0):
         self.pebbles.append(
             Pebble(vector_direction, self.player.get_location()))
Beispiel #3
0
class Rockwatch(dbus.service.Object):


	def __init__(self, parent = None):
		super(Rockwatch, self).__init__(parent)
		self.app = QApplication(sys.argv)
		self.app.setApplicationName("Rockwatch")
		self.pebble = None
		self.locationSource = Location.QGeoPositionInfoSource.createDefaultSource(self.app)
		self.signals = Signals()
		self.lastCheck = QDateTime()
		self.stopped = True
		self.paused = False
		self.connecting = False
		self.firmwareUpdated = False
		self.artist = "Unknown Artist"
		self.album = "Unknown Album"
		self.track = "Unknown Track"
		self.view = QDeclarativeView()
		self.view.setSource("/opt/rockwatch/qml/Main.qml")
		self.rootObject = self.view.rootObject()
		self.rootObject.openFile("Menu.qml")
		self.rootObject.quit.connect(self.quit)
		self.rootObject.ping.connect(self.ping)
		self.rootObject.firmwareCheck.connect(self.firmwareCheck)
		self.rootObject.upgradeFirmware.connect(self.upgradeFirmware)
		self.rootObject.watchfaceSelected.connect(self.installApp)
		self.rootObject.getAppList.connect(self.getAppList)
		self.rootObject.setTime.connect(self.setTime)
		self.rootObject.deleteApp.connect(self.deleteApp)
		self.appListModel = AppListModel()
		self.context = self.view.rootContext()
		self.context.setContextProperty('appListModel', self.appListModel)
		self.signals.onDoneWorking.connect(self.doneWorking)
		self.signals.onConnect.connect(self.connect)
		self.signals.onConnected.connect(self.connected)
		self.signals.onMessage.connect(self.message)
		self.signals.onNewFirmwareAvailable.connect(self.newFirmwareAvailable)
		self.view.showFullScreen()
		self.mutex = threading.Lock()
		self.timer = QTimer(self.app)
		self.app.connect(self.timer, SIGNAL("timeout()"), self.checkConnection)
		self.timer.start(30000)
		QTimer.singleShot(0, self.findPebble)
		sys.exit(self.app.exec_())


	def findPebble(self):
		self.connecting = True
		sysbus = dbus.SystemBus()
		manager = dbus.Interface(sysbus.get_object('org.bluez', '/'), 'org.bluez.Manager')
		adapterPath = manager.DefaultAdapter()
		adapter = dbus.Interface(sysbus.get_object('org.bluez', adapterPath), 'org.bluez.Adapter')
		self.pebbleId = None
		for devicePath in adapter.ListDevices():
			device = dbus.Interface(sysbus.get_object('org.bluez', devicePath),'org.bluez.Device')
			deviceProperties = device.GetProperties()
			name = deviceProperties['Name']
			if name.lower()[:6] == "pebble":
				self.pebbleId = deviceProperties['Address']
				self.connect()
				break
		if self.pebbleId == None:
			self.connecting = False
			self.message("Couldn't find Pebble", "Sorry! I couldn't find your Pebble. Please ensure that it has been paired with your N9 and that its name begins with 'Pebble'", True)


	def doneWorking(self):
		self.rootObject.stopWorking()


	def message(self, title, message, quitAfter = False):
		self.rootObject.showMessage(title, message, quitAfter)

	
	def connect(self):
		self.rootObject.startWorking()
		thread = threading.Thread(target=self._connect)
		thread.start()


	def checkConnection(self):
		self.mutex.acquire()
		if not self.pebble or not self.pebble.is_alive():
			if self.connecting and not self.firmwareUpdated:
				self.signals.onMessage.emit("Unable to connect to Pebble", "Check that your phone's bluetooth is switched on and that your Pebble is nearby.")
			self.findPebble() # Try to reconnect
		self.mutex.release()


	def _connect(self):
		self.connecting = True
		try:
			self.pebble = Pebble(self.pebbleId, True, False, self.locationSource)
			self.pebble.register_endpoint("MUSIC_CONTROL", self.musicControl)
		except LightBluePebbleError, e:
			self.signals.onMessage.emit("Unable to connect to Pebble", str(e))
			self.connecting = False
			return

		# Enable HTTPebble bridge
		self.pebble.install_bridge(httpebble.HTTPebble)

		dbus_main_loop = dbus.glib.DBusGMainLoop(set_as_default=True)
		self.bus = dbus.SessionBus(dbus_main_loop)

		# Setup our own DBUS service
		bus_name = dbus.service.BusName("com.mikeasoft.rockwatch", bus=self.bus)
		dbus.service.Object.__init__(self, object_path="/rockwatch", bus_name=bus_name)

		# Register rockwatchnotification as a notificationsink
		notificationmanager = dbus.Interface(self.bus.get_object('com.meego.core.MNotificationManager', '/notificationsinkmanager'), 'com.meego.core.MNotificationManager')
		notificationmanager.registerSink("com.mikeasoft.notificationsink", "/notificationsink")

		# If MeeGo multimedia framework has already been started,
		# we need to connect to it
		self.mafwIfaceChanged()

		self.bus.add_signal_receiver(self.mafwIfaceChanged, dbus_interface="org.freedesktop.DBus", signal_name="NameOwnerChanged", arg0=self.MAFW_GST_RENDERER)
		self.bus.add_signal_receiver(self.metadataChanged, dbus_interface="com.nokia.mafw.renderer", signal_name="metadata_changed")
		self.bus.add_signal_receiver(self.stateChanged, dbus_interface="com.nokia.mafw.renderer", signal_name="state_changed")

		self.firmwareUpdated = False
		self.signals.onConnected.emit()
Beispiel #4
0
 pebble.initMultiPart(url)
 print
 print
 pebble.putPart(url, DataPool.getData(13), 1)
 print
 print
 pebble.putPart(url, DataPool.getData(26), 2)
 print
 print
 pebble.listMultiPars(url)
 print
 print
 pebble.listParts(url)
 print
 print
 pebble.completeMultiPart(url)
 print
 print
 pebble.listMultiPars(url)
 print
 print
 pebble.listParts(url)
 print
 print
 p = Pebble(pebbleId)
 print "*" * 40
 print p.head(url)
 print "*" * 40
 print p.get(url)
 #testPebbleNew("/pebble_0001/pebble_XXXX_00000001", url)
 #data = pebble.get(url, 0, True)
Beispiel #5
0
 pebble.initMultiPart(url)
 print 
 print 
 pebble.putPart(url,DataPool.getData(13),1 )
 print 
 print     
 pebble.putPart(url,DataPool.getData(26),2)
 print 
 print 
 pebble.listMultiPars(url)
 print 
 print 
 pebble.listParts(url)
 print 
 print 
 pebble.completeMultiPart(url)
 print 
 print 
 pebble.listMultiPars(url)
 print 
 print 
 pebble.listParts(url)    
 print 
 print 
 p = Pebble(pebbleId)
 print "*"*40
 print p.head(url)
 print "*"*40
 print p.get(url)
 #testPebbleNew("/pebble_0001/pebble_XXXX_00000001", url)
 #data = pebble.get(url, 0, True)