[Firebug-cvs] firebug/project/java/src/org/firebug DBLogger.java,1.13,1.14 SensorPacket.java,1.5,1.6
Brought to you by:
doolin
From: <che...@us...> - 2003-05-22 03:06:28
|
Update of /cvsroot/firebug/firebug/project/java/src/org/firebug In directory sc8-pr-cvs1:/tmp/cvs-serv20558 Modified Files: DBLogger.java SensorPacket.java Log Message: filter out the non-data packet Index: DBLogger.java =================================================================== RCS file: /cvsroot/firebug/firebug/project/java/src/org/firebug/DBLogger.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** DBLogger.java 21 May 2003 23:51:51 -0000 1.13 --- DBLogger.java 22 May 2003 03:06:25 -0000 1.14 *************** *** 40,44 **** //float temp = (float)(72.0 + (3*rand.nextGaussian())); //return temp; ! float basetemp=(float)(packet[12]*256+packet[11]); //float temp=TestDBLogger.getRandomTemp(basetemp); return basetemp; //temp; --- 40,44 ---- //float temp = (float)(72.0 + (3*rand.nextGaussian())); //return temp; ! float basetemp=(float)((long)packet[12]*256+(long)packet[11]); //float temp=TestDBLogger.getRandomTemp(basetemp); return basetemp; //temp; *************** *** 66,69 **** --- 66,85 ---- } + private int get_packet_type(byte [] packet) { + + return (int)packet[2]; + } + + private void print_packet_raw(byte [] packet) { + + //int size = packet.size; + + for (int i = 0; i < 15; i++) { + System.out.print(packet[i] + " "); + } + System.out.println("\n"); + } + + /** Put everything in print for now. */ *************** *** 87,95 **** float baro_pres = getBaroPres(packet); try { ResultSet rs; Statement stmt = conn.createStatement(); ! String updatequery = "UPDATE current " + "SET time=" + time + ", " --- 103,131 ---- float baro_pres = getBaroPres(packet); + if (get_packet_type(packet) != 1){ + dbh.return_connection(conn); + return; + } + + + if ( get_packet_type(packet) == 1 && + packet[7] == -1) { + dbh.return_connection(conn); + return; + } + + print_packet_raw(packet); + + //base station ID is 1; + if (mote_id == 1) { + dbh.return_connection(conn); + return; + } + try { ResultSet rs; Statement stmt = conn.createStatement(); ! String updatequery = "UPDATE current " + "SET time=" + time + ", " *************** *** 161,187 **** * example packets to be fed into the DBLogger class. */ ! //class TestDBLogger { /** "test" is the _only_public_method_ in this * class. */ ! // public static boolean test(DBLogger dbl) { ! /* ! byte [] packet = {0x7e,0,0x0a,0x7d,0x1a, ! 0x01,0x01, ! 0x01,0x02,0x03, ! 0x01, //mote_id ! 0x12,0x67, //temp ! 0x37,0x2d, //rel_hum ! 0x4a,0x22 //baro ! }; ! dbl.print(packet); ! return false; } ! */ ! // getRandomID, getRandomTime, getRandomRelHum, etc. /** All of the following methods are private --- 197,231 ---- * example packets to be fed into the DBLogger class. */ ! class TestDBLogger { /** "test" is the _only_public_method_ in this * class. */ ! public static boolean test(DBLogger dbl) { ! ! byte mote_id = (byte)0xff; ! ! byte [] packet = {0x7e, //header ! 0x0, //header ! 0x0a, //packet type ! 0x7d, //header ! 0x1a, //header ! 0x01, //routing ! 0x01, //routing ! 0x01, //routing ! 0x02, //routing ! 0x03, //routing ! mote_id, ! 0x12,0x67, //temp ! 0x37,0x2d, //rel_hum ! 0x4a,0x22 //baro ! }; ! dbl.print(packet); ! return false; } ! /** All of the following methods are private *************** *** 189,193 **** * class. */ ! /* private static int getRandomID(int baseID) { --- 233,237 ---- * class. */ ! private static int getRandomID(int baseID) { *************** *** 217,219 **** } - */ --- 261,262 ---- Index: SensorPacket.java =================================================================== RCS file: /cvsroot/firebug/firebug/project/java/src/org/firebug/SensorPacket.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SensorPacket.java 21 May 2003 22:32:23 -0000 1.5 --- SensorPacket.java 22 May 2003 03:06:25 -0000 1.6 *************** *** 84,88 **** s += " [="+Long.toString((long)tempF)+" Fahrenheit Degree]\n"; */ ! if (packet[2]==1 && packet[5]!=1){ s += " [MoteID="+Long.toString(packet[10])+ "]\n"; //Humidity --- 84,88 ---- s += " [="+Long.toString((long)tempF)+" Fahrenheit Degree]\n"; */ ! if (packet[2]==1 && packet[7]!=-1 && packet[10]!=1){ s += " [MoteID="+Long.toString(packet[10])+ "]\n"; //Humidity |