next up previous contents
Next: The cricketdaemon.clientlib.Callback Class Up: Clientlib API Previous: Clientlib API   Contents


The cricketdaemon.clientlib.ServerBroker Class

The ServerBroker class implements the following public methods:

public ServerBroker() 
public ServerBroker(String addr, int portNum)

These are constructors for ServerBroker. The default constructor attempts to connect to the CricketDaemon running on the localhost via port 5001. Otherwise, the IP address of the host running CricketDaemon and the port it binds to may be specified through the addr and portNum parameters via the alternate constructor.

public boolean clearBeaconTable()
public boolean clearBeaconTableEntry(String space, int id)
public boolean setBeaconTableEntry(String space, int id, 
				    double x, double y, double z)

CricketDaemon implements a beacon table that maps a uniquely-identified beacon to an arbitrary coordinate value. By default, the beacon table is empty and CricketDaemon uses coordinate values advertised by the beacon if it cannot find a matching entry in the beacon table. But if a beacon does not advertise its coordinates and it has no entry in the beacon table, the distance measurements from it will not be used to compute the position coordinates of the listener.

The *BeaconTable* methods manipulate the beacon table. A beacon is uniquely identified by its space and id values.4.1 As the name of the methods suggests, the clearBeaconTable method clears the entire beacon table, clearBeaconTableEntry method clears an entry for a specific beacon and setBeaconTableEntry maps a beacon with space and id to coordinates (x, y, z).

The return boolean value indicates whether the command succeeded (true) or failed (false).

public boolean setPositionAggressive(boolean v)

By default, CricketDaemon uses the mode distance value collected from each beacon within its history window (see FILTER_WINDOW_MS in Section 3.4) to compute the position coordinates of the listener. When this method is invoked with v=true, CricketDaemon will use only the last measurement taken from each beacon heard in the history window to compute the position of the listener. This will reduce the latency of position tracking at the expense of using unfiltered distance estimates to compute the location of the listener.

The return boolean value indicates whether the command succeeded (true) or failed (false).

public synchronized void register(Callback c, BitSet fieldMask)
public synchronized void deRegister(Callback c, BitSet fieldMask)

These methods registers/deregisters a callback object with the ServerBroker, where c is a callback object that implements the Callback interface and fieldMask specifies the type(s) of location update that should trigger a callback. Table 4.4.1 lists the available callback type bits.


Table 4.1: Callback types.
TYPE DEFINITION
ALL selects all types
SPACE current spatial location
DEVICECOORD current position coordinates
BEACONSHEARDLIST set of beacons heard in history window
BEACONSTAT distance measurement to a beacon
POSERR exceptions in position computation


By default, all distance/coordinate values are in centimeter units, unless the unit is changed via the Serial Port API described in Section 2.2.

The POSERR type bit requires further explanation. ServerBroker invokes the callback handler method (see next section) with the POSERR bit set when the position solver in CricketDaemon cannot solve the listener's position. In the current implementation, the position solver requires at least 3 beacons to be within the listener's range and at least 3 of those beacons need to have sufficiently low standard deviations among the distance samples collected in the current history window (see STDDEV_TOLERANCE_CM in Section 3.4). If either of these conditions are not met, the callback handler will receive a callback with POSERR value set in the callback mask.

public void run()
public void start()

All applications should call either the run() or the start() method to start the callback loop in ServerBroker. The run() method blocks while start() forks a new thread to run the callback loop.


next up previous contents
Next: The cricketdaemon.clientlib.Callback Class Up: Clientlib API Previous: Clientlib API   Contents
Michel Goraczko 2004-12-02