Code Monkey home page Code Monkey logo

purple-box's Introduction

Purple Box

Purple Box is scalable serverless platform that gathers and monitors sensordata. To send data to the purple box you need a client device, such as an Android phone.

Usage example

Receiving data in a web client

<script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
<script src="http://code.jquery.com/jquery-1.11.1.js"></script>
<script>
const socket = io().connect('http://your.url.here.com/3000');
$(document).ready(function () {
  socket.on('your_app_id', function (msg1) {
    let dataEntry = JSON.stringify(msg1) + "<br>";
    $(".json-dump").append(dataEntry);
  });
});
</script>
<html>
<head>
<title>JSON Dump</title>
</head>
 <body>
  <div class="json-dump">
  </div>
 </body>
</html>

Sending JSON-data

class AsyncT extends AsyncTask<Void, Void, Void> {

    @Override
    protected Void doInBackground(Void... voids) {
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost post = new HttpPost("http://your.url.here.com:80");
        post.addHeader("Content-Type", "application/json; charset=UTF-8");

        try {
            JSONObject jsonobj = new JSONObject();
            jsonobj.put("msg", "all good!”);

            StringEntity se = new StringEntity(jsonobj.toString());
            Log.e("mainToPost", "mainToPost" + jsonobj.toString());
            post.setEntity(se);

            // Execute HTTP Post Request
            HttpResponse response = httpclient.execute(post);

        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}

Accepted JSON key-value pairs with example values

“Appid”:”VisitorCounter”
"Devid":"1"
"TimeStamp":"24.12.2016 12:00:00"
“Location”: 
	“Coordinates” : [62.123, 21.512]
	“Speed”:”10m/s”
	“Heading”:”123”
	“Altitude”:”123”
“Audio”:
	“MaxDecibel”:”70db”
“MotionSensor”:
	“Acceleration”:”[9.8, 1.1, 0.2]”
	“Stepcounter”:”123”
“Device”:
	“Battery”:”43”
	“Msg”:"all good!”
	“Storage”:”10/32gb”

##Purple Box App Purple Box App

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.