played around with different inputs to change the temperature display
[goodfet] / client / goodfet.zigduino
1 #!/usr/bin/env python
2 #GoodFET zigduino client
3 #forked from code by neighbor Travis Goodspeed by bx
4
5 import sys, binascii, os, array, time, glob
6
7 from GoodFETatmel128 import GoodFETatmel128rfa1
8 from intelhex import IntelHex;
9
10
11 def printpacket(packet):
12     s="";
13     i=0;
14     for foo in packet:
15         i=i+1;
16         if i>client.packetlen: break;
17         s="%s %02x" % (s,ord(foo));
18     print "%s" % s;
19
20
21 mskbstring="";
22 oldseq=-1;
23
24 #def printconfig():
25 #    print "Encoding %s" % client.RF_getenc();
26 #    print "Freq    %10i MHz" % (client.RF_getfreq()/10**6);
27 #    print "Rate    %10i kbps" % (client.RF_getrate()/1000);
28 #    print "PacketLen %02i bytes" % client.RF_getpacketlen();
29 #    #print "MacLen    %2i bytes" % client.RF_getmaclen();
30 #    print "SMAC  0x%010x" % client.RF_getsmac();
31 #    print "TMAC  0x%010x" % client.RF_gettmac();
32
33
34 if(len(sys.argv)==1):
35     print "Usage: %s verb [objects]\n" % sys.argv[0];
36     #print "%s info" % sys.argv[0];
37     print "%s sniff [channel]\n\tSniffs packets." % sys.argv[0];
38     print "%s beaconreq [channel]\n\tSends out beacons requests" % sys.argv[0];
39     sys.exit();
40
41 #Initialize FET and set baud rate
42 client=GoodFETatmel128rfa1()
43 #client.verbose = True
44 client.serInit()
45
46 #if(sys.argv[1ce]=="info"):
47 #    printconfig();
48
49 if(sys.argv[1]=="sniff"):
50     client.RF_setup()
51     if len(sys.argv)>2:
52         print "Set channel to %s" % sys.argv[2];
53         client.RF_setchannel(int(sys.argv[2]));
54     #Now we're ready to get packets.
55
56     while 1:
57         packet=None;
58         while packet==None:
59             packet=client.RF_rxpacket();
60             time.sleep(0.4)
61         printpacket(packet);
62         sys.stdout.flush();
63
64 if (sys.argv[1]=="beaconreq"):
65     client.RF_setup()
66     if len(sys.argv)>2:
67         print "Set channel to %s" % sys.argv[2];
68         client.RF_setchannel(int(sys.argv[2]));
69     packet="\x03\x08\x46\xff\xff\xff\xff\x07\x13\x33"
70     while 1:
71         client.RX_txpacket(packet)
72         time.sleep(1)