add intertechno 32 support

This commit is contained in:
S. Seegel 2018-02-08 00:07:24 +01:00
parent aaf8b43ac3
commit a93b8e5bb3
4 changed files with 89 additions and 41 deletions

View file

@ -1,6 +1,9 @@
#!/usr/bin/env python2.7 #!/usr/bin/env python2.7
import rfm69
from rfm69 import Rfm69
import xx2262 import xx2262
import it32
import sys import sys
import re import re
@ -15,44 +18,72 @@ def encodeBits(val, num, pol, inv):
return result return result
def usage(): def usage():
print "usage: intertechno <HOUSECODE A-P> <GROUP 1-4> <CHANNEL 1-4> on|off" #12-digit code 12 * ['0' | '1' | 'f'] print "usage:"
print "Example: intertechno A 1 1 on" print "intertechno <HOUSECODE A-P> <GROUP 1-4> <CHANNEL 1-4> on|off" #12-digit code 12 * ['0' | '1' | 'f']
print "OR"
print "intertechno <26 bit address> <1 goup bit> <4 bit unit> on|off"
print "Examples:"
print "intertechno A 1 1 on"
print "interttechno 11110000111100001111000010 0 1110 on"
sys.exit(1) sys.exit(1)
if len(sys.argv) != 5: if __name__ == "__main__":
usage() import sys
cmd = ""
data = None
for i in range(1, len(sys.argv)):
cmd += " " + sys.argv[i]
cmd = cmd.strip()
daatarate = None
itstr = '' if re.match('^[01]{32}$', cmd) is not None:
data = it32.MakeFrame(cmd, 5)
datarate = 4
if re.match('[A-P]$', sys.argv[1]) is None: if re.match('^[01]{26} [01] [01]{4} (on|off)$', cmd) is not None:
print "Invalid housecode" tmp = cmd[0:26] + cmd[27]
usage() if cmd[-2:] == 'on':
tmp += '1'
else:
tmp += '0'
tmp += cmd[29:33]
data = it32.MakeFrame(tmp, 5)
datarate = 1/275E-6/1000
housecode = ord(sys.argv[1][0]) - ord('A') if re.match('^[A-P] [1-4] [1-4] (on|off)$', cmd) is not None:
itstr += encodeBits(housecode, 4, '0', False) housecode = ord(cmd[0]) - ord('A')
itstr = ''
itstr += encodeBits(housecode, 4, '0', False)
if re.match('[1-4]$', sys.argv[3]) is None: ch = ord(cmd[2]) - ord('1')
print "Invalid channel" itstr += encodeBits(ch, 2, '0', False)
usage()
ch = ord(sys.argv[3][0]) - ord('1') group = ord(cmd[4]) - ord('1')
itstr += encodeBits(ch, 2, '0', False) itstr += encodeBits(group, 2, '0', False)
if re.match('[1-4]$', sys.argv[2]) is None: itstr += '0F'
print "Invalid group"
usage()
group = ord(sys.argv[2][0]) - ord('1') if cmd[-2:] == 'on':
itstr += encodeBits(group, 2, '0', False) itstr += 'FF'
else:
itstr += '0F' itstr += 'F0'
if sys.argv[4] == 'on':
itstr += 'FF'
else:
itstr += 'F0'
print "Sending", itstr data = xx2262.MakeFrame(itstr, 5)
datarate = 2.66666666
data = xx2262.MakeFrame(itstr, 8) if re.match('^[01Ff]{12}$', cmd) is not None:
xx2262.rfm.SendPacket(data) data = xx2262.MakeFrame(cmd, 5)
datarate = 2.66666666
if data is not None:
rfm = Rfm69()
rfm.SetParams(
Freq = 433.92,
Datarate = datarate, #2.666666,
TXPower = 13,
ModulationType = rfm69.OOK,
SyncPattern = []
)
rfm.SendPacket(data)
else:
usage()

10
it32.py Normal file
View file

@ -0,0 +1,10 @@
def MakeFrame(code, rep):
data = [0x08, 0x00] #sync
for c in code:
if c == '0':
data.append(0xA0)
elif c == '1':
data.append(0x82)
data += [0x80, 0x00, 0x00, 0x00, 0x00]
return data * rep

View file

@ -156,7 +156,7 @@ class Rfm69:
config[RegOokPeak] = 0x40 config[RegOokPeak] = 0x40
config[RegOokAvg] = 0x80 config[RegOokAvg] = 0x80
config[RegOokFix] = 0x06 config[RegOokFix] = 0x06
config[RegAfcFei] = 0x10 config[RegAfcFei] = 1<<3 | 1<<2
config[RegAfcMsb] = 0x00 config[RegAfcMsb] = 0x00
config[RegAfcLsb] = 0x00 config[RegAfcLsb] = 0x00
config[RegFeiMsb] = 0x00 config[RegFeiMsb] = 0x00
@ -362,7 +362,13 @@ class Rfm69:
result = [] result = []
for x in range(length): for x in range(length):
result.append(self.ReadReg(RegFifo)) result.append(self.ReadReg(RegFifo))
afc = self.ReadReg(RegAfcMsb) << 8
afc = afc | self.ReadReg(RegAfcLsb)
if afc >= 0x8000:
afc = afc - 0x10000
self.__SetMode(MODE_STDBY) self.__SetMode(MODE_STDBY)
return (result, rssi) return (result, rssi, afc)

View file

@ -4,15 +4,6 @@ from rfm69 import Rfm69
import rfm69 import rfm69
import re import re
rfm = Rfm69()
rfm.SetParams(
Freq = 433.92,
Datarate = 2.666666,
TXPower = 13,
ModulationType = rfm69.OOK,
SyncPattern = []
)
#Frame generation #Frame generation
def MakeFrame(code, rep): def MakeFrame(code, rep):
data = [0x80, 0x00, 0x00, 0x00] #sync data = [0x80, 0x00, 0x00, 0x00] #sync
@ -44,4 +35,14 @@ if __name__ == "__main__":
usage() usage()
data = MakeFrame(sys.argv[1], 5) data = MakeFrame(sys.argv[1], 5)
rfm = Rfm69()
rfm.SetParams(
Freq = 433.92,
Datarate = 2.666666,
TXPower = 13,
ModulationType = rfm69.OOK,
SyncPattern = []
)
rfm.SendPacket(data) rfm.SendPacket(data)