def de(self,tlg): if tlg == 'de': print(":de") # return the next state if sys.platform == 'esp8266': roger.roger() return State.CALLSIGN return State.DE
def byede(self,tlg): if tlg == 'de': print(":de") if sys.platform == 'esp8266': roger.roger() # return the next state return State.BYECALL return State.BYEDE
def reportde(self,tlg): if tlg == 'de': print(":de") # return the next state if sys.platform == 'esp8266': roger.roger() return State.REPORTCALL return State.REPORTDE
def bye73(self,tlg): if tlg == '73': print(":73") # return the next state if sys.platform == 'esp8266': roger.roger() return State.BYEDE return State.BYE73
def byerr(self,tlg): if tlg == 'rr': print(":rr") if sys.platform == 'esp8266': roger.roger() # return the next state return State.BYETU return State.BYERR
def byetu(self,tlg): if tlg == 'tu': print(":tu") if sys.platform == 'esp8266': roger.roger() # return the next state return State.BYE73 return State.BYETU
def report(self,tlg): if len(tlg) >= 3: if self.check_rst(tlg): self.tmplist.append(tlg) print(':'+tlg) if len(self.tmplist) >= self.numberofcq: # return the next state if sys.platform == 'esp8266': roger.roger() return State.REPORTDE return State.REPORT
def callsign(self,tlg): if len(tlg) >= self.lencall: if len(self.callsignlist) == 0: print(':'+tlg) self.callsignlist.append(tlg) elif tlg == self.callsignlist[0]: print(':'+tlg) self.callsignlist.append(tlg) if len(self.callsignlist) >= self.numberofcq: # return the next state if sys.platform == 'esp8266': roger.roger() return State.K return State.CALLSIGN
def cq(self,tlg): if tlg == 'cq': print(":cq") self.cqlist.append(tlg) if tlg == 'sota': print(":sota") self.sota = 1 self.sotalist.append(tlg) if self.sota == 1: if len(self.cqlist) >= self.numberofcq and len(self.sotalist) >= self.numberofcq: if sys.platform == 'esp8266': roger.roger() return State.DE return State.CQ elif len(self.cqlist) >= self.numberofcq: if sys.platform == 'esp8266': roger.roger() return State.DE return State.CQ
def byeee(self,tlg): if tlg == 'ee': print(":ee") if sys.platform == 'esp8266': roger.roger() return State.END return State.BYEEE
def byecall(self,tlg): if tlg == self.callsignlist[0]: print(':'+str(self.callsignlist[0])) if sys.platform == 'esp8266': roger.roger() return State.BYEEE return State.BYECALL
def ourcallsign(self,tlg): if tlg == self.urcallsign: print(':'+str(self.urcallsign)) if sys.platform == 'esp8266': roger.roger() return State.UR return State.OURCALLSIGN
def reportk(self,tlg): if tlg == 'k': print(":k") if sys.platform == 'esp8266': roger.roger() return State.REPORTCHASE return State.REPORTK
def reportcall(self,tlg): if tlg == self.callsignlist[0]: print(':'+str(self.callsignlist[0])) if sys.platform == 'esp8266': roger.roger() return State.REPORTK return State.REPORTCALL
def rst(self,tlg): if tlg == 'rst': print(':rst') if sys.platform == 'esp8266': roger.roger() return State.REPORT return State.RST
def ur(self,tlg): if tlg == 'ur': print(':ur') if sys.platform == 'esp8266': roger.roger() return State.RST return State.UR
def main(): if sys.platform == 'esp8266': roger.roger() rc = 0 state = State.CQ while True: payload, client_address = sock.recvfrom(64) b = bytearray(payload) hexstr = binascii.hexlify(b) morsecode = translator.mopptotxt(hexstr) tlg = morsecode.strip() # print ('From: ', end ='') # print( client_address) # print('Text: ', end ='') log('<'+morsecode+'>') # call the designated function and update the state # <sk> break and go to end if morsecode.strip() == '<sk>': print(':<sk> bye') state = State.END state = qso.run_func(state,tlg) log('state: '+str(state)) if state == State.CHASE: qso.urcallsign = callsign.get_call() # Chaser calls activator # VK3XAS/P de VK3BQ VK3BQ VK3BQ K sendmoppstr(client_address, qso.callsignlist[0]) sendmoppstr(client_address, 'de') sendmoppstr(client_address, qso.urcallsign) sendmoppstr(client_address, qso.urcallsign) sendmoppstr(client_address, qso.urcallsign) sendmoppstr(client_address, 'k') state = State.OURCALLSIGN #Chaser confirms receipt of his report and gives one to activator # R R UR RST 559 559 de VK3BQ K if state == State.REPORTCHASE: sendmoppstr(client_address, 'r') sendmoppstr(client_address, 'r') sendmoppstr(client_address, 'ur') sendmoppstr(client_address, 'rst') rst = callsign.get_rst() sendmoppstr(client_address,rst ) sendmoppstr(client_address,rst ) sendmoppstr(client_address,rst ) sendmoppstr(client_address, 'de') sendmoppstr(client_address, qso.urcallsign) sendmoppstr(client_address, 'k') state = State.BYERR # Chaser may then send 73 if state == State.END: sendmoppstr(client_address, '73') if sys.platform == 'esp8266': roger.roger() if sys.platform == 'esp8266': roger.roger() state = State.CQ
def k(self,tlg): if tlg == 'k': print(":k") if sys.platform == 'esp8266': roger.roger() return State.CHASE return State.K