diff --git a/libtoorchat.py b/libtoorchat.py index a2b9e58..8f78733 100644 --- a/libtoorchat.py +++ b/libtoorchat.py @@ -6,10 +6,10 @@ class ToorChatProtocol(): self.PACKET_END = "\xFF\xBE\xEF\xFF" self.device = device - def send_message(cls, message = "", user = None): + def send_message(self, message = "", user = None): ''' This is used to send a simple message over the toorchat protocol ''' msg = ToorChatMessage(message, user) - self.device.RFxmit(msg) + self.device.RFxmit(msg.to_string()) @classmethod def get_packet_start(cls): @@ -32,6 +32,9 @@ class ToorChatMessage(): self.data = message self.end = ToorChatProtocol.get_packet_end() + def get_random_xid(self): + return "44444444" + def __str__(self): return self.start + self.xid + self.user + self.data + self.end diff --git a/recv_loop.py b/recv_loop.py new file mode 100644 index 0000000..afab15b --- /dev/null +++ b/recv_loop.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +import sys +from rflib import * +import rflib.chipcon_nic as rfnic +import atexit +from libtoorchat import * + +def banner(): + print "******** ToorChat [v 0.1] ********" + +def main(): + banner() + badge = RfCat(idx=0) + badge.setModeRX() + protocol = ToorChatProtocol(badge) + while True: + try: + msg, timestamp = badge.RFrecv() + print msg + except ChipconUsbTimeoutException: + pass + + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/toorchat.py b/toorchat.py index ce904c4..fa8de13 100755 --- a/toorchat.py +++ b/toorchat.py @@ -16,10 +16,10 @@ def main(): protocol = ToorChatProtocol(badge) while True: try: - msg, timestamp = badge.RFrecv() - print "enter a message" - # send = input("Enter a message") - # protocol.send_message(send) + # msg, timestamp = badge.RFrecv() + # print "enter a message" + send = raw_input("Enter a message") + protocol.send_message(send) except ChipconUsbTimeoutException: pass