projects/positioning/backend/src/main/java/io/v/positioning/BluetoothProximityServlet.java
/**
     * Processes a POST request to save nearby devices scanned using Bluetooth
     *
     * @param req  The servlet request that includes JSONObject with properties to be saved
     * @param resp The servlet response informing a user if the request was successful or not
     */
Processes a POST request to save nearby devices scanned using Bluetooth
@param req  The servlet request that includes JSONObject with properties to be saved
@param resp The servlet response informing a user if the request was successful or not
Processes a POST request to save nearby devices scanned using Bluetooth @param req The servlet request that includes JSONObject with properties to be saved @param resp The servlet response informing a user if the request was successful or not
@Override
    public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        resp.setContentType("text/plain");
        BufferedReader br = req.getReader();
        try {
            JSONObject jo = new JSONObject(br.readLine());
            DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
            Entity entity = new Entity("bluetooth");
            entity.setProperty("androidId", jo.get("androidId"));
            entity.setProperty("myMacAddress", jo.get("myMacAddress"));
            entity.setProperty("remoteName", jo.get("remoteName"));
            entity.setProperty("remoteAddress", jo.get("remoteAddress"));
            entity.setProperty("remoteRssi", jo.get("remoteRssi"));
            entity.setProperty("deviceTime", jo.get("deviceTime"));
            entity.setProperty("serverTime", System.currentTimeMillis());
            datastore.put(entity);
            resp.getWriter().println("New bluetooth device added.");
        } catch (Exception e) {
            resp.getWriter().println("Recording failed. " + e);
        }
    }
@ Override public void doPost ( HttpServletRequest req , HttpServletResponse resp ) throws IOException { resp . setContentType ( "text/plain" ) ; BufferedReader br = req . getReader ( ) ; try { JSONObject jo = new JSONObject ( br . readLine ( ) ) ; DatastoreService datastore = DatastoreServiceFactory . getDatastoreService ( ) ; Entity entity = new Entity ( "bluetooth" ) ; entity . setProperty ( "androidId" , jo . get ( "androidId" ) ) ; entity . setProperty ( "myMacAddress" , jo . get ( "myMacAddress" ) ) ; entity . setProperty ( "remoteName" , jo . get ( "remoteName" ) ) ; entity . setProperty ( "remoteAddress" , jo . get ( "remoteAddress" ) ) ; entity . setProperty ( "remoteRssi" , jo . get ( "remoteRssi" ) ) ; entity . setProperty ( "deviceTime" , jo . get ( "deviceTime" ) ) ; entity . setProperty ( "serverTime" , System . currentTimeMillis ( ) ) ; datastore . put ( entity ) ; resp . getWriter ( ) . println ( "New bluetooth device added." ) ; } catch ( Exception e ) { resp . getWriter ( ) . println ( "Recording failed. " + e ) ; } }
Processes a POST request to save nearby devices scanned using Bluetooth
 @param req  The servlet request that includes JSONObject with properties to be saved
 @param resp The servlet response informing a user if the request was successful or not
Processes a POST request to save nearby devices scanned using Bluetooth @param req The servlet request that includes JSONObject with properties to be saved @param resp The servlet response informing a user if the request was successful or not