1296
|
1 from twisted.internet.defer import Deferred
|
|
2 from twisted.protocols.stateful import StatefulProtocol, StringIO
|
|
3 from twisted.protocols.policies import TimeoutMixin
|
|
4
|
|
5
|
|
6 class InsteonProtocol(StatefulProtocol, TimeoutMixin):
|
|
7 def getInitialState(self):
|
|
8 return (self.surprise, 1)
|
|
9
|
|
10 def surprise(self, bytes):
|
|
11 print "received %r" % bytes
|
|
12
|
|
13
|
|
14
|
|
15 def getImInfo(self):
|
|
16 msg = map(ord, self._send("\x60", 6))
|
|
17 def imInfoBack(
|
|
18 self._sful_data = (imInfoBack, , StringIO(), 0
|
|
19
|
|
20
|
|
21 d = Deferred()
|
|
22 return d
|
|
23 return {'id' : "%02X%02X%02X" % (msg[0], msg[1], msg[2]),
|
|
24 'deviceCategory' : msg[3],
|
|
25 'deviceSubcategory' : msg[4],
|
|
26 'firmwareRevision': msg[5]}
|