Turning Point patches.
authortravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Mon, 5 Jul 2010 15:16:38 +0000 (15:16 +0000)
committertravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Mon, 5 Jul 2010 15:16:38 +0000 (15:16 +0000)
git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@653 12e2690d-a6be-4b82-a7b7-67c4a43b65c8

client/GoodFETNRF.py
client/goodfet.nrf

index 6d07171..6afd934 100644 (file)
@@ -145,6 +145,19 @@ class GoodFETNRF(GoodFET):
             self.writecmd(self.NRFAPP,0x82,0,None); #Flush
             self.poke(0x07,0x40);#clear bit.
         return None;
+    def RF_txpacket(self,payload):
+        """Transmit a packet.  Untested."""
+        if self.peek(0x07) & 0x40:
+            #Packet has arrived.
+            self.writecmd(self.NRFAPP,0x81,0,None); #RX Packet
+            data=self.data;
+            self.poke(0x07,0x40);#clear bit.
+            return data;
+        elif self.peek(0x07)==0:
+            self.writecmd(self.NRFAPP,0x83,0,None); #Flush
+            self.poke(0x07,0x40);#clear bit.
+        return None;
+
     def RF_carrier(self):
         """Hold a carrier wave on the present frequency."""
         # Set CONT_WAVE, PLL_LOCK, and 0dBm in RF_SETUP            
index 3e76205..4abf8a4 100755 (executable)
@@ -46,9 +46,13 @@ if(len(sys.argv)==1):
     print "%s test" % sys.argv[0];
     print "%s regs" % sys.argv[0];
     print "%s pyregs" % sys.argv[0];
+
     print "%s sniff\n\tSniffs packets by current config." % sys.argv[0];
     print "%s sniffob\n\tSniffs OpenBeacon traffic." % sys.argv[0];
     print "%s snifftp\n\tSniffs Tunrning Point Clicker traffic." % sys.argv[0];
+
+    print "%s hosttp\n\tHosts Tunrning Point Clicker traffic." % sys.argv[0];
+
     print "%s carrier [freq]\n\tHolds a carrier on [freq] Hz." % sys.argv[0];
     sys.exit();
 
@@ -189,6 +193,38 @@ if(sys.argv[1]=="snifftp"):
         printpacket(packet);
         sys.stdout.flush();
 
+if(sys.argv[1]=="hosttp"):
+    client.poke(0x00,0x00); #Stop nRF
+    client.poke(0x01,0x00); #Disable Shockburst
+    client.poke(0x02,0x01); #Set RX Pipe 0
+    
+    chan=0x29;
+
+    client.RF_setfreq((2400+chan) * 10**6);
+    client.poke(0x06,0x00); #1Mbps
+    client.poke(0x07,0x78); #Reset status register
+    
+    client.RF_setmaclen(3); # SETUP_AW for 3-byte addresses.
+    client.RF_setsmac(0x123456);
+    client.RF_setpacketlen(4);
+    
+    #Power radio, prime for RX, two-byte checksum.
+    client.poke(0x00,0x70|0x03|0x04|0x08);
+    
+    print "Listening as %010x on %i MHz" % (client.RF_getsmac(),
+                                           client.RF_getfreq()/10**6);
+    #Now we're ready to get packets.
+    while 1:
+        packet=None;
+        while packet==None:
+            packet=client.RF_rxpacket();
+        mac=((ord(packet[0])<<16)+
+             (ord(packet[1])<<8)+
+             ord(packet[2]));
+        key=packet[3];
+        print "%c from %06x" % (key,mac);
+        sys.stdout.flush();
+
 if(sys.argv[1]=="sniff"):
     #client.poke(0x00,0x00); #Stop nRF
     client.poke(0x07,0x78); #Reset status register