Last active
October 31, 2018 13:52
-
-
Save kylekyle/4b74de259a094d0890e02e3488f07712 to your computer and use it in GitHub Desktop.
An rfcat script to replay an RF relay remote on 315 MHZ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python2.7 | |
import time | |
import rflib | |
import bitstring | |
rfcat = rflib.RfCat() | |
# center frequency | |
rfcat.setFreq(314955000) | |
# AM On/Off Keying | |
rfcat.setMdmModulation(rflib.MOD_ASK_OOK) | |
# in audacity, out biggest pulse is about | |
# 10 samples wide in a 44000 Hz wavefile | |
pulse_width = 10.0 | |
sample_rate = 48000.0 | |
# set the baudrate | |
rfcat.setMdmDRate(1.0/(pulse_width/sample_rate)) | |
# charge the laser! | |
rfcat.setMaxPower() | |
on = '1001011111010111' | |
off = '1001011111100111' | |
while True: | |
for data in [on, off]: | |
# PCM | |
# 1 0 0 1 0 1 1 1 | |
# 1000 1110 1110 1000 1110 1000 1000 1000 | |
modulated = ''.join(['1000' if bit == '1' else '1110' for bit in data]) | |
packet = bitstring.BitArray(bin=(modulated)).tobytes() | |
for _ in range(12): | |
rfcat.RFxmit(packet, repeat=1) | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment