Giter Club home page Giter Club logo

src-test's Introduction

SRC Privacy Server

This git repo gives you a sample code to interact with ISABELA API. There are two sample codes:

  • Built to Visual Studio Community and available in the master branch.
  • Built to the linux and gcc compiler and available on the linux-gcc branch.

Linux-GCC

Install on Ubuntu

  1. Download the code:
git clone https://github.com/jmSfernandes/SRC-Test.git
  1. Checkout to the linux branch:
git checkout linux-gcc
  1. Install all the missing libraries with apt-get (gcc,clang,libtool,autoconf,automake), see the instructions

  2. Run the following commands in json-c path:

   sh autogen.sh
   ./configure
   make
   make install (need sudo)
   make check
  1. Install libcurl:
   sudo apt-get install libcurl4-gnutls-dev
  1. Add the library to the environment variables:
   export LD_RUN_PATH=/usr/local/lib
   export LD_LIBRARY_PATH=/usr/local/lib/
  1. Compile the application using gcc:
   gcc main.c -o main -lcurl -ljson-c

Visual Studio

If you want to run the code, with all the libraries already installed and pre-compiled, you need to install the Visual Studio Community 2013 (V120 Build tools).

If you want to create the example from scracth in another IDE, the following libraries need to be installed:

The data is retrieved by invoking an HTTP GET, and a JSON array object is retrieved by the API (with the data from the students). The privacy server will act as an anonymisation server, protecting the privacy of the students. The clients that interact with the privacy server will be able to retrieve their own data (the student ID will act as a token that gives access to individual data). When retrieved other student's data, the proxy will anonymize the data to the clients.

Understanding the code

  1. Create a JSON object to store the JSON data
   struct json_object *jobj_array, *jobj_obj;
  1. Get the student data from the ISABELA API
   jobj_array = get_student_data();
  1. Get individual fields from the array of data (e.g., location)
   arraylen = json_object_array_length(jobj_array);
   for (i = 0; i < arraylen; i++) {
   	jobj_obj = json_object_array_get_idx(jobj_array, i);
   	jobj_object_location = json_object_object_get(jobj_obj, "location");
   	printf("location=%s\n", json_object_get_string(jobj_object_location));
   }

The fields available in the ISABELA API are:

  • id: student ID code (check your ID in the ISABELA Android settings);
  • activity: student activity (Exercise,Sleeping,Classes,Tilting,Walking,In vehicle,Unknown,Still);
  • accelerometer: an array of values from the accelerometer, with the x,y,z values for several events, the t attribute corresponds to the timestamp of the event;
  • ble: scan of the ble devices;
  • bluetooth: scan of the bluetooth devices;
  • gyroscope: scan of the gyroscope values, with the x,y,z values for several events, the t attribute corresponds to the timestamp of the event;
  • location: student location (University, House, Other);
  • callsduration: duration of calls made in the last 5 seconds;
  • callsmade: number of calls made in the last 5 seconds;
  • callsmissed: number of calls missed in the last 5 seconds;
  • callsreceived: number of calls received in the last 5 seconds;
  • department: name of the department (DEI);
  • smsreceived: number of sms received in the last 5 seconds;
  • smssent: number of sms sent in the last 5 seconds;
  • wifi: scan of the available Access Points(APs), in the form of Json Object where the keys are the mac address of the APs and the values are the strength of the signal (RSSI);
  • timestamp: datetime in the format of ISO8601 corresponding to the date and time at which the event was recorded;

To use this example from outside, the URL of the request need to be changed from the interal IP address to the DNS address (socialiteorion2.dei.uc.pt)

//From this:
   curl_easy_setopt(hnd, CURLOPT_URL, "http://10.3.4.75:9014/v2/entities?options=keyValues&type=student&limit=1000");
   
//To this:
   curl_easy_setopt(hnd, CURLOPT_URL, "http://socialiteorion2.dei.uc.pt:9014/v2/entities?options=keyValues&type=student&limit=1000");

src-test's People

Contributors

dgraposo avatar jmsfernandes avatar

Watchers

James Cloos avatar

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.