Added the channel and frequency options

master
root 2012-10-21 12:27:53 -07:00
parent 12959f2641
commit 916d34d938
2 changed files with 30 additions and 1 deletions

View File

@ -14,6 +14,21 @@ class ToorChatProtocol():
self.device.RFxmit(msg.to_string()) self.device.RFxmit(msg.to_string())
return msg return msg
def change_channel(self, channel):
''' This is used to change the channel that the user operates in '''
self.device.setChannel(int(channel))
if channel != int
return None
else
return channel
def change_frequency(self, frequency):
''' This is used to change the frequency that the user operates in '''
self.device.setFreq(int(change_frequency))
if frequency != int
return None
else
return frequency
@classmethod @classmethod
def parse_message(cls, raw_message): def parse_message(cls, raw_message):
message = ToorChatMessage() message = ToorChatMessage()

View File

@ -34,6 +34,8 @@ class Visualizer():
self.protocol = ToorChatProtocol(self.badge) self.protocol = ToorChatProtocol(self.badge)
self.message_queue = [] self.message_queue = []
self.user = None self.user = None
self.channel = None
self.frequency = None
#This when set to True will kill the thread #This when set to True will kill the thread
self.exit = False self.exit = False
@ -54,7 +56,7 @@ class Visualizer():
self.last_message_index = 0 self.last_message_index = 0
while True: while True:
self.screen_max_y, self.screen_max_x = self.screen.getmaxyx() self.screen_max_y, self.screen_max_x = self.screen.getmaxyx()
self.screen.addstr(0, 1, "[S] Send Message [U] Set User Name") self.screen.addstr(0, 1, "[S] Send Message [U] Set User Name [C] Set Channel [F] Set Frequency")
self.__add_message_to_screen__() self.__add_message_to_screen__()
entry = self.screen.getch() entry = self.screen.getch()
if entry == curses.KEY_RESIZE: if entry == curses.KEY_RESIZE:
@ -72,6 +74,18 @@ class Visualizer():
self.user = user_input[:USER_NAME_SIZE] self.user = user_input[:USER_NAME_SIZE]
self.screen.nodelay(1) self.screen.nodelay(1)
self.screen.addstr(1,1," "*(self.screen_max_x-3)) self.screen.addstr(1,1," "*(self.screen_max_x-3))
if entry == ord('c'):
self.screen.nodelay(0)
user_input = self.screen.getstr(1, 1, 60)
self.channel = self.protocol.change_channel(user_input)
self.screen.nodelay(1)
self.screen.addstr(1,1," "*(self.screen_max_x-3))
if entry == ord('f'):
self.screen.nodelay(0)
user_input = self.screen.getstr(1, 1, 60)
self.frequency = self.protocol.change_frequency(user_input)
self.screen.nodelay(1)
self.screen.addstr(1,1," "*(self.screen_max_x-3))
except KeyboardInterrupt: except KeyboardInterrupt:
self.exit = True self.exit = True