Android Open Source - Look Nodo Wifi






From Project

Back to project page Look.

License

The source code is released under:

====================== LOOK! LICENSING TERMS ====================== look! is licensed under the BSD 3-Clause (also known as "BSD New" or "BSD Simplified"), as follows: Copyright (c) 2010-2012, Look...

If you think the Android project Look listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
*-----------------------------------------------------------------------------
* Copyright (c) 2012, Look! Development Team
* All rights reserved./*from   w w w .  j  a  v a2s. co  m*/
*
* Distributed under the terms of the BSD Simplified License.
*
* The full license is in the LICENSE file, distributed with this software.
*-----------------------------------------------------------------------------
*/
package es.ucm.look.locationProviderWifi.wifi;

import java.util.ArrayList;

/**
 * Mantains information of an Access Point
 * 
 * @author Jorge Creixell Rojo
 * 
 */
public class NodoWifi implements Comparable<Object> {
  
  /**
   * MAX signal level - MIN signal level
   */
  public static final int MAX_DIF = 100;

  /**
   * MAC address of the access point.
   */
  private String bssid;
  
  /**
   * Signal level of the access point
   */
  private int level;
  
  /**
   * id number of the access point
   */
  private int id;

  /**
   * Parameterized contructor.
   * @param bssid
   *       MAC address of the access point
   * @param level
   *       Signal level
   * @param id
   *       Id nunmber
   */
  public NodoWifi(String bssid, int level, int id) {
    this.bssid = bssid;
    this.level = level;
    this.id = id;
    
  }

  /**
   * Returns MAC address of the access point
   * @return MAC address
   */
  public String getBssid() {
    return bssid;
  }

  /**
   * Returns signal level of the access point
   * @return signal level
   */
  public int getLevel() {
    return level;
  }
  
  /**
   * Returns access point information as a string
   * @return String representing AP information
   */
  public String toString() {
    return ("Nodo: " + bssid + " " + level + " " + id);
  }
  
  
  
  /**
   * Compares the current AP signal with another and returns the similarity level between them.
   * @param signal
   *       Signal level of the other AP.
   * @return Similarity between signals
   */
  //de 1 a 100, grado de similitud en la se?al recibida
  //signal1 en formato de 1 a 35
  public int getSignalSimilarity(int signal) {
    int signal1 = java.lang.Math.abs(level);//WifiManager.calculateSignalLevel(level,35);
    int signal2 = java.lang.Math.abs(signal);//WifiManager.calculateSignalLevel(signal,35);
    
    int dif = java.lang.Math.abs(signal2-signal1);
    int similarity = MAX_DIF-dif;
    
    int result = (Math.round(((similarity/10))));

    return result;
  }

  /**
   * Returns the id number of the access point
   * @return id number
   */
  public int getId() {
    return id;
  }
  
  /**
   * Returns the id number of the access point as a string
   * @return id number as a string
   */
  public String getKey() {
    return (Integer.toString(id));
  }
  
  /**
   * Calculates the average signal of a list of signal values
   * @param l
   *       List of signal levels
   * @return mean of the signal levels
   */
  public static int averageLevel(ArrayList<Integer> l) {
    int sum = 0;
    for (int i =0; i < l.size(); i++) {
      sum += l.get(i);
    }
    return (sum/l.size());
  }
  
  /**
   * Calculates the maximum signal of a list of signal values
   * @param l
   *       List of signal levels
   * @return maximum value
   */
  public static int maxLevel(ArrayList<Integer> l) {
    int max = -100;
    for (int i =0; i < l.size(); i++) {
      if (l.get(i) > max) {
        max = l.get(i);
      }
    }
    return (max);
  }
  
  
  /**
   * Compares two nodes by signal level
   * @param o
   *       Node to compare with the current
   * @return 0 if equals, -1 if current node lower, 1 if current node higher
   */
  @Override
  public int compareTo(Object o) {
    int result = 0;
    NodoWifi nodo = (NodoWifi)o;
    if (nodo.level == this.level)
      result = 0;
    else if (this.level > nodo.level)
      result = 1;
    else
      result = -1;
    
    return result;
    
  }

}




Java Source Code List

es.ucm.look.ar.LookAR.java
es.ucm.look.ar.Preview.java
es.ucm.look.ar.ar2D.AR2D.java
es.ucm.look.ar.ar2D.Drawable2D.java
es.ucm.look.ar.ar2D.HUDElement.java
es.ucm.look.ar.ar2D.drawables.Circle2D.java
es.ucm.look.ar.ar2D.drawables.Image2D.java
es.ucm.look.ar.ar2D.drawables.Text2D.java
es.ucm.look.ar.ar3D.Drawable3D.java
es.ucm.look.ar.ar3D.Renderer3D.java
es.ucm.look.ar.ar3D.core.Color4.java
es.ucm.look.ar.ar3D.core.TextureFactory.java
es.ucm.look.ar.ar3D.core.camera.Camera3D.java
es.ucm.look.ar.ar3D.core.camera.OrientedCamera.java
es.ucm.look.ar.ar3D.core.drawables.DrawablesDataBase.java
es.ucm.look.ar.ar3D.core.drawables.Entity3D.java
es.ucm.look.ar.ar3D.core.drawables.Mesh3D.java
es.ucm.look.ar.ar3D.core.drawables.primitives.CirclePrimitive.java
es.ucm.look.ar.ar3D.core.drawables.primitives.Cube.java
es.ucm.look.ar.ar3D.core.drawables.primitives.Grid.java
es.ucm.look.ar.ar3D.core.drawables.primitives.LinePrimitive.java
es.ucm.look.ar.ar3D.core.drawables.primitives.LinesLoopPrimitive.java
es.ucm.look.ar.ar3D.core.drawables.primitives.ObjMesh3D.java
es.ucm.look.ar.ar3D.core.drawables.primitives.PointPrimitive.java
es.ucm.look.ar.ar3D.core.drawables.primitives.Ring.java
es.ucm.look.ar.ar3D.core.drawables.primitives.SquarePrimitive.java
es.ucm.look.ar.ar3D.core.drawables.primitives.TrianglePrimitive.java
es.ucm.look.ar.ar3D.core.drawables.primitives.extra.ImagePrimitive.java
es.ucm.look.ar.ar3D.parser.MeshObjParser.java
es.ucm.look.ar.hud.ActionListener.java
es.ucm.look.ar.hud.BasicHud.java
es.ucm.look.ar.hud.Button.java
es.ucm.look.ar.hud.HUD.java
es.ucm.look.ar.listeners.CameraListener.java
es.ucm.look.ar.listeners.TouchListener.java
es.ucm.look.ar.math.collision.Armature.java
es.ucm.look.ar.math.collision.SphericalArmature.java
es.ucm.look.ar.math.collision.SquareArmature.java
es.ucm.look.ar.math.collision.debug.DebugArmature.java
es.ucm.look.ar.math.collision.debug.SphericalDebugArmature.java
es.ucm.look.ar.math.collision.debug.SquareDebugArmature.java
es.ucm.look.ar.math.geom.Matrix3.java
es.ucm.look.ar.math.geom.Plane.java
es.ucm.look.ar.math.geom.Point2.java
es.ucm.look.ar.math.geom.Point3.java
es.ucm.look.ar.math.geom.Ray.java
es.ucm.look.ar.math.geom.Triangle.java
es.ucm.look.ar.math.geom.Vector3.java
es.ucm.look.ar.util.CameraParametersHelper.java
es.ucm.look.ar.util.DeviceOrientation.java
es.ucm.look.ar.util.LookARUtil.java
es.ucm.look.ar.util.PositionTimerTask.java
es.ucm.look.data.EntityData.java
es.ucm.look.data.LookData.java
es.ucm.look.data.WorldEntityFactory.java
es.ucm.look.data.WorldEntity.java
es.ucm.look.data.World.java
es.ucm.look.data.filesManager.LookFilesManager.java
es.ucm.look.data.interfaces.DataGetter.java
es.ucm.look.data.interfaces.DataHandler.java
es.ucm.look.data.interfaces.DataSetter.java
es.ucm.look.data.local.BasicDataHandler.java
es.ucm.look.data.local.DBDataHandler.java
es.ucm.look.data.local.contentprovider.LookContentProvider.java
es.ucm.look.data.local.contentprovider.sql.LookSQLContentProvider.java
es.ucm.look.data.local.contentprovider.sql.LookSQLHelper.java
es.ucm.look.data.remote.ConfigNet.java
es.ucm.look.data.remote.LookProperties.java
es.ucm.look.data.remote.RemoteDBHandler.java
es.ucm.look.data.remote.restful.LookService.java
es.ucm.look.data.remote.restful.RestMethod.java
es.ucm.look.data.remote.restful.ServiceManager.java
es.ucm.look.location.LocationManager.java
es.ucm.look.locationProvider.DeviceSensor.java
es.ucm.look.locationProvider.InertialNavigationSystem.java
es.ucm.look.locationProvider.LocationProvider.java
es.ucm.look.locationProvider.Motion.java
es.ucm.look.locationProvider.Positioning.java
es.ucm.look.locationProvider.Util.java
es.ucm.look.locationProviderWifi.Cliente.java
es.ucm.look.locationProviderWifi.WifiLocation.java
es.ucm.look.locationProviderWifi.WifiService.java
es.ucm.look.locationProviderWifi.util.DateUtils.java
es.ucm.look.locationProviderWifi.util.DeviceReader.java
es.ucm.look.locationProviderWifi.util.DeviceWriter.java
es.ucm.look.locationProviderWifi.wifi.Lugar.java
es.ucm.look.locationProviderWifi.wifi.Lugares.java
es.ucm.look.locationProviderWifi.wifi.NodoWifi.java
es.ucm.look.locationProvider.map.Mapa.java
es.ucm.look.locationProvider.test.java