public static void main(String[] args) throws Exception { String source = null; if (args.length == 2) { if (!args[0].equals("-comm")) { usage(); System.exit(1); } source = args[1]; } else if (args.length != 0) { usage(); System.exit(1); } PhoenixSource phoenix; if (source == null) { phoenix = BuildSource.makePhoenix(PrintStreamMessenger.err); } else { phoenix = BuildSource.makePhoenix(source, PrintStreamMessenger.err); } MoteIF mif = new MoteIF(phoenix); TestSerial serial = new TestSerial(mif); serial.sendPackets(); }
static void help() { System.out.println(""); System.out.println("Usage: java RawLogger [options] "); System.out.println(" [options] are:"); System.out.println(" -h, --help Display this message."); System.out.println(" --logging Enable Logging."); System.out.println(" Required options (source). "); System.out.println(" And (url, user, pass, tablename). "); System.out.println(" --display Display Packets."); System.out.println(" Required options (source). "); System.out.println(" --createtable Create a table."); System.out.println( " Required options (url, user, pass, tablename)."); System.out.println(" --droptable Drop a table."); System.out.println( " Required options (url, user, pass, tablename)."); System.out.println(" --cleartable Clear a table."); System.out.println( " Required options (url, user, pass, tablename)."); System.out.println(" --duration Summary of Experiement Duration."); System.out.println( " Required options (url, user, pass, tablename)."); System.out.println(" --reset Reseting EPRB and the attached mote "); System.out.println(" Required options (source). "); System.out.println(" --tablename=<name> Specify sql tablename "); System.out.println(" --url=<ip/dbname> JDBC URL. eg: localhost/rsc."); System.out.println(" --user=<user> User of the database."); System.out.println(" --pass=<password> Password of the database."); System.out.println(" --source=<type> Standard TinyOS Source"); System.out.println(" serial@COM1:platform"); System.out.println(" network@HOSTNAME:PORTNUMBER"); System.out.println(" sf@HOSTNAME:PORTNUMBER"); System.out.println(""); System.exit(-1); }
public static void duration() { connectDb(); String sql = "select min(time), max(time), count(*) from " + tablename + ";"; try { ResultSet rs = query.executeQuery(sql); rs.next(); int numCols = rs.getMetaData().getColumnCount(); String minTime = rs.getString(1); String maxTime = rs.getString(2); String numPackets = rs.getString(3); System.out.println( "Experiment " + tablename + "\n\tfrom: " + minTime + "\n\tto: " + maxTime + "\n\tpackets: " + numPackets); } catch (SQLException e) { System.out.println("SQL Exception: " + e); System.exit(1); } }
public AntiTheftGui() { try { guiInit(); /* Setup communication with the mote and request a messageReceived callback when an AlertMsg is received */ mote = new MoteIF(this); mote.registerListener(new AlertMsg(), this); } catch (Exception e) { e.printStackTrace(); System.exit(2); } }
static void connectDb() { // before: localhost/rsc sqlURL = "jdbc:postgresql://" + sqlURL; // after: "jdbc:postgresql://localhost/rsc"; // "jdbc:postgresql://webbie.berkeley.intel-research.net/rsc" try { Class.forName("org.postgresql.Driver"); } catch (ClassNotFoundException cnfe) { System.out.println("Couldn't find the driver!"); System.out.println("Let's print a stack trace, and exit."); System.exit(1); } Connection connection = null; try { connection = DriverManager.getConnection(sqlURL, sqlUser, sqlPassword); query = connection.createStatement(); } catch (SQLException se) { System.out.println("Couldn't connect: " + se); System.exit(1); } }
public static void clearTable() { connectDb(); String sql = "delete from " + tablename + ";"; try { query.executeUpdate(sql); } catch (SQLException e) { System.out.println("SQL Exception: " + e); System.exit(1); } System.out.println("Table Cleared Successfully"); }
public static void main(String[] args) throws Exception { String source = ""; if (args.length == 2) { if (!args[0].equals("-comm")) { usage(); System.exit(1); } source = args[1]; } else { usage(); System.exit(1); } PhoenixSource phoenix; if (source == null) { phoenix = BuildSource.makePhoenix(PrintStreamMessenger.err); } else { phoenix = BuildSource.makePhoenix(source, PrintStreamMessenger.err); } System.out.print(phoenix); MoteIF mif = new MoteIF(phoenix); PrintfClient client = new PrintfClient(mif); }
public static void reset() { // network@ip:10002 String address = source.substring(8, source.length() - 6); try { Socket server = new Socket(address, 9999); DataOutputStream out = new DataOutputStream(server.getOutputStream()); out.writeBytes("\r\n"); out.flush(); out.writeBytes("9\r\n"); out.flush(); } catch (Exception e) { System.out.println("Sorry I can't reset the device fro some reason: " + e); System.exit(1); } System.out.println("Issued reset command to " + address); }
public static void main(String[] args) { String motePort = null; String outputFile = null; for (int i = 0; i < args.length; i++) { if (args[i].equals("-comm")) { motePort = args[++i]; System.out.println("Using mote port: " + motePort); } else if (args[i].equals("-file")) { outputFile = args[++i]; System.out.println("Saving data to: " + outputFile); } else { usage(); System.exit(1); } } RadioSignalMeter meter = new RadioSignalMeter(motePort, outputFile); }
public void messageReceived(int to, Message message) { long t = System.currentTimeMillis(); // System.out.print("" + t + ": "); // System.out.println(message); MessageProcessor messageProcessor = new MessageProcessor((SerialMsg) message, t); JSONObject json = messageProcessor.getJSON(); client.sendCollectionJSON(json); JSONObject processingJson = messageProcessor.getCouchJSON(); client.sendProcessingJSON(processingJson); fireStatus[messageProcessor.nodeToSensorID()] = messageProcessor.getFire(); if (fireStatus[0] || fireStatus[1] || fireStatus[2]) { client.sendFireRepresentation(fireStatus); } }
public static void createTable() { connectDb(); String dataField = ""; for (int i = 0; i < AM_HEADER_LENGTH + TOSH_DATA_LENGTH + CRC_LENGTH; i++) { dataField = dataField + ", " + "b" + Integer.toString(i) + " smallint"; } String sql = "create table " + tablename + " (time timestamp without time zone, packetid serial" + dataField; sql += ", primary key (packetid) );"; try { query.executeUpdate(sql); } catch (SQLException e) { System.out.println("SQL Exception: " + e); System.exit(1); } System.out.println("Initialise Table Successfully"); }
public static void main(String[] args) throws Exception { String source = null; Vector v = new Vector(); if (args.length > 0) { for (int i = 0; i < args.length; i++) { if (args[i].equals("-comm")) { source = args[++i]; } else { String className = args[i]; try { Class c = Class.forName(className); Object packet = c.newInstance(); Message msg = (Message) packet; if (msg.amType() < 0) { System.err.println(className + " does not have an AM type - ignored"); } else { v.addElement(msg); } } catch (Exception e) { System.err.println(e); } } } } else if (args.length != 0) { usage(); System.exit(1); } MsgReader mr = new MsgReader(source); Enumeration msgs = v.elements(); while (msgs.hasMoreElements()) { Message m = (Message) msgs.nextElement(); mr.addMsgType(m); } mr.start(); }