127 GET-
@@ -1,127 +0,0 @@
HTTP/1.1 200 OK
Date: Thu, 12 Mar 2015 13:32:34 GMT
Server: Apache
X-Powered-By: PHP/5.4.4
Set-Cookie: PHPSESSID=lk4qktvk4l2gndfp6fpd8t0v44; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 7395
Connection: close
Content-Type: text/html


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>The ACme Project</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="menu">
<ul>
<li class="active"><a href="index.php" accesskey="1" title="">Home</a></li>
<li><a href="display.php" accesskey="2" title="">Display</a></li>
<li><a href="mypage.php" accesskey="3" title="">My Page</a></li>
<li><a href="update.php" accesskey="4" title="">Update</a></li>
<li><a href="register.php" accesskey="5" title="">Register</a></li>
<li><a href="about.php" accesskey="6" title="">About</a></li>
</ul>
</div>
<!-- end #menu -->
<div id="header">
<!--
<h1>ACme Project</h1>
<h2>ACme Wireless Meter and Controller</h2>
-->
</div>

<!-- end #header -->
<div id="wrapper">
<div id="content">
<div id="posts">

<div class="post">
<h2 class="title">ACme: Berkeley Wireless AC Meter/Switch</h2>
<div class="story">
<p><center>
<img src="images/acme_frontpage.jpg" height=300 alt="ACme node" />
</center>
</p>
<p>
ACme is an open source hardware and software platform that enables wireless energy/power measurement and control of AC devices.
The ACme node (pictured on the left) fills the gap between inexpensive LCD watt-meters (e.g. Kill-A-Watt) and expensive networked enterprise energy monitors.
<!-- ACme uses the ADE7753 energy monitor chip for energy and power measurements, the SHARP solid-state relay for power switching, and the Berkeley EPIC wireless module for communication. -->
The ACme network (pictured on the right) is an IPv6 based mesh network that enables direct IP communication with individual ACme nodes.
For more information about the ACme platform, please click <strong><a href="about.php">here</a></strong>.
For a quickstart guide to developing for ACme, please click <strong><a href="acme_quickstart.pdf">here</a></strong>.
</p>
</div>

</div>
</div>
<!-- end #posts -->
<div id="links">
<div class="post">
<h2 class="title">Quick Start</h2>
<div class="story">
<ul>
<li><a href="display.php">ACme Dashboard</a></li>
<li><a href="about.php">ACme Info</a></li>
</ul>
</div>
</div>
<br>

<div class="post">
<h2 class="title">Login</h2><div class="story"><p>Login here for a personalized view</p><form action="mypage.php" method="post">Username: <br /><input type="text" name="username" /><br />Password: <br /><input type="password" name="password" /><br /><br><input type="submit" value="Login" /><br>*login is not necessary to view </p><input type="hidden" name="inorout" value="login"></form><form action="register.php" method="post"><input type="submit" value="Register"></form>

</div>


</div>
<br />
<br>

<div class="post">
<h2 class="title">Affiliations</h2>
<div class="story">
<br>
<ul><center>
<li><a href="http://webs.cs.berkeley.edu"><img src="images/webs.jpg" width=200 alt="WEBS" border=0 /></a></li>
<li><a href="http://local.cs.berkeley.edu"><img src="images/local.jpg" width=160 alt="LoCal" border=0 /></a></li>
<li><a href="http://www.nsf.gov"><img src="images/nsf1.gif" width=100 alt="LoCal" border=0 /></a></li>
<li><a href="http://www.berkeley.edu"><img src="images/berkeley.gif" width=100 alt="LoCal" border=0 /></a></li>
</center>
</ul>
</div>
</div>
<br>


<!--
<ul>
<li>
<h2>Registered Motes</h2>
<ul>
<li><a href="#">301</a></li><li><a href="#">302</a></li><li><a href="#">303</a></li><li><a href="#">304</a></li><li><a href="#">305</a></li><li><a href="#">306</a></li><li><a href="#">307</a></li><li><a href="#">308</a></li><li><a href="#">309</a></li><li><a href="#">310</a></li><li><a href="#">311</a></li><li><a href="#">312</a></li><li><a href="#">313</a></li><li><a href="#">314</a></li><li><a href="#">315</a></li><li><a href="#">316</a></li><li><a href="#">317</a></li><li><a href="#">318</a></li><li><a href="#">319</a></li><li><a href="#">320</a></li><li><a href="#">321</a></li><li><a href="#">322</a></li><li><a href="#">323</a></li><li><a href="#">324</a></li><li><a href="#">325</a></li><li><a href="#">326</a></li><li><a href="#">327</a></li><li><a href="#">328</a></li><li><a href="#">329</a></li><li><a href="#">330</a></li><li><a href="#">331</a></li><li><a href="#">332</a></li><li><a href="#">333</a></li><li><a href="#">334</a></li><li><a href="#">335</a></li><li><a href="#">336</a></li><li><a href="#">337</a></li><li><a href="#">338</a></li><li><a href="#">339</a></li><li><a href="#">340</a></li><li><a href="#">341</a></li><li><a href="#">342</a></li><li><a href="#">343</a></li><li><a href="#">344</a></li><li><a href="#">345</a></li><li><a href="#">346</a></li><li><a href="#">347</a></li><li><a href="#">348</a></li><li><a href="#">349</a></li><li><a href="#">350</a></li><li><a href="#">351</a></li><li><a href="#">352</a></li><li><a href="#">353</a></li><li><a href="#">354</a></li><li><a href="#">355</a></li><li><a href="#">356</a></li><li><a href="#">357</a></li><li><a href="#">358</a></li><li><a href="#">359</a></li><li><a href="#">360</a></li><li><a href="#">361</a></li><li><a href="#">362</a></li><li><a href="#">363</a></li><li><a href="#">364</a></li><li><a href="#">365</a></li><li><a href="#">366</a></li><li><a href="#">367</a></li><li><a href="#">368</a></li><li><a href="#">369</a></li><li><a href="#">370</a></li><li><a href="#">371</a></li><li><a href="#">372</a></li><li><a href="#">373</a></li><li><a href="#">374</a></li><li><a href="#">375</a></li><li><a href="#">376</a></li><li><a href="#">377</a></li><li><a href="#">378</a></li><li><a href="#">379</a></li><li><a href="#">380</a></li><li><a href="#">381</a></li><li><a href="#">382</a></li><li><a href="#">383</a></li><li><a href="#">384</a></li><li><a href="#">385</a></li><li><a href="#">386</a></li><li><a href="#">387</a></li><li><a href="#">388</a></li><li><a href="#">389</a></li><li><a href="#">390</a></li><li><a href="#">391</a></li><li><a href="#">392</a></li><li><a href="#">393</a></li><li><a href="#">394</a></li><li><a href="#">395</a></li><li><a href="#">396</a></li><li><a href="#">397</a></li> </ul>
</li>
</ul>
-->
</div>
<!-- end #links -->
<div style="clear: both;">&nbsp;</div>
</div>
</div>
<!-- end #content -->
<div id="footer">
<p id="legal">
Could not connect: Connection refused
BIN -31.3 KB GET-images-webs.jpg
Deleted file not rendered

This file was deleted.

BIN +15.7 KB out.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN +14.8 KB out.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN +50.4 KB out.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,117 @@
import java.io.*;
import java.net.*;
import java.util.*;
import java.nio.*;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;

import org.jsoup.Jsoup;
import org.jsoup.parser.Parser;
import org.jsoup.nodes.Element;
import org.jsoup.nodes.Node;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.TextNode;
import org.jsoup.select.Elements;

import java.text.*;

import javax.imageio.ImageIO;

import java.awt.image.BufferedImage;

public class ConnectionHandler implements Runnable {
Socket client;
String clientSentence;
String totalMessage;
String command;
String URI;
String version;
String code;

public ConnectionHandler(Socket socket){
client = socket;
}

@Override
public void run(){
while(true) {
// Create inputstream (convenient data reader) to this host.
BufferedReader inFromClient;
try {
inFromClient = new BufferedReader(new InputStreamReader (client.getInputStream()));
// Create outputstream (convenient data writer) to this host.
DataOutputStream outToClient = new DataOutputStream(client.getOutputStream());
String clientSentence;
String totalMessage = "";
// Read text from the client, make it uppercase and write it back.
clientSentence = inFromClient.readLine();
while (clientSentence.length()>0){
totalMessage = totalMessage + clientSentence + "\r\n";
clientSentence = inFromClient.readLine();

} ;
getArguments(totalMessage);
System.out.println("Received: " + totalMessage);
if (command.equals("GET")){
System.out.println("binnen");
System.out.println(getCommand());
outToClient.writeBytes(getCommand());
}

String capsSentence = totalMessage.toUpperCase() + '\n';
//outToClient.writeBytes(capsSentence);
System.out.println("command: "+ command);}
catch (IOException e) {
e.printStackTrace();
}
}

}

private String getCommand() {
String returnMessage;
File f = new File("Server/"+URI);

if(f.exists() && !f.isDirectory()) {
code = "200 OK";
}
else{
code = "404 BAD REQUEST";
}
returnMessage = version + code;
returnMessage = returnMessage.replace("\r\n", " ");
String extra = extraMessage(f);
returnMessage = returnMessage + "\r\n" + extra;
return returnMessage;
}

private String extraMessage(File file) {
Date date = new Date();
Locale locale = new Locale("en");
SimpleDateFormat ft =
new SimpleDateFormat ("E',' dd MM yyyy hh:mm:ss zzz",locale);
ft.setTimeZone(TimeZone.getTimeZone("GMT"));
Path path = FileSystems.getDefault().getPath("Server",URI);
String type = "";
try {
type = Files.probeContentType(path);
} catch (IOException e) {
e.printStackTrace();
}
return "Date: " + ft.format(date) + "\r\n" + "Content-Type: " + type + "\r\n" + "Content-Length: " + file.length();
}

private void getArguments(String totalMessage) {
String[] arguments = totalMessage.split(" ");
command = arguments[0];
URI = arguments[1];
if (URI.equals("/")){
URI = "Index.html";
}
System.out.println("uri:"+ URI);
version = arguments[2];

}

}
@@ -20,15 +20,15 @@ public class HTTPClient {

public static void main(String[] args) throws IOException{
Socket s = new Socket();
String host = "www.tinyos.net";
String host = "localhost";
PrintWriter s_out = null;
BufferedReader s_in = null;
//String command = args[0];
String command = "GET";
//String URI = args[1];
String URI = "/images/webs.jpg";
String URI = "/";
//int port = Integer.parseInt(args[2]);
int port = 80;
int port = 6789;
//String version = args[3];
String version = "1.0";
System.out.println("Before try");
@@ -18,29 +18,16 @@ public static void main(String argv[]) throws Exception
{
// Create server (incoming) socket on port 6789.
ServerSocket welcomeSocket = new ServerSocket(6789);

// Wait for a connection to be made to the server socket.
while(true)
{
// Create a 'real' socket from the Server socket.
Socket connectionSocket = welcomeSocket.accept();
Runnable connectionHandler = new ConnectionHandler(connectionSocket);
new Thread(connectionHandler).start();

// Create inputstream (convenient data reader) to this host.
BufferedReader inFromClient = new BufferedReader(new InputStreamReader (connectionSocket.getInputStream()));

// Create outputstream (convenient data writer) to this host.
DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream());
String clientSentence;
String totalMessage = "";
// Read text from the client, make it uppercase and write it back.
do{
clientSentence = inFromClient.readLine();
totalMessage = totalMessage + clientSentence + "\r\n";
} while (clientSentence.length()>0);
System.out.println("Received: " + totalMessage);
String capsSentence = clientSentence.toUpperCase() + '\n';
outToClient.writeBytes(capsSentence);
System.out.println("Sent: "+ capsSentence);
}
}

} // End of main method.

@@ -64,11 +64,13 @@ private void extractImage(String img) throws IOException {
System.out.println(response);
}
try {
System.out.println("YES");
image = ImageIO.read(s_in);

ImageIO.write(image, "jpg",new File("out.jpg"));
ImageIO.write(image, "gif",new File("out.gif"));
ImageIO.write(image, "png",new File("out.png"));
String fileName = img;
System.out.println(fileName);
ImageIO.write(image, "jpg",new File(fileName + ".jpg"));
ImageIO.write(image, "gif",new File(fileName +".gif"));
ImageIO.write(image, "png",new File(fileName +".png"));

} catch (IOException e) {
e.printStackTrace();