CROSS-REFERENCE TO RELATED APPLICATIONS 
       [0001]    This application claims the benefit of U.S. Provisional Patent Application Ser. No. 61/157,379 entitled “Range-based wireless alarm system” filed Mar. 4, 2009, the disclosure thereof incorporated by reference herein in its entirety. 
     
    
     FIELD OF THE INVENTION 
       [0002]    The present invention relates generally to wireless local area network (WLAN) systems and more particularly relates to a method for a range-based alarm system utilizing the computed distances between a reference device and other devices as the trigger mechanism for alarm. 
       BACKGROUND 
       [0003]    Wireless interfaces are utilized ubiquitously in a variety of devices from cell phones to hand held devices to laptop computers to routers that connect to the internet via a hardwire, Ethernet cable. These interfaces are typically wireless local area network (WLAN) interfaces. At present time, these interfaces are mostly used for transferring data, exchanging music or video files between two devices. 
         [0004]    It is desirable to utilize these WLAN interfaces for other applications such as security and telemetry. The fact that the signals transmitted from such devices are traveling in the air at the speed of light C (C=300,000 km/s). Therefore, the distance between two WLAN devices can be computed fairly accurately if the time it takes for the signal to be transmitted from one device to reach the other device is known. The accuracy of the computed distance depends largely on the following factors:
       a. The accuracy of the clocks being used at the transmitter and receiver to record the time the signal is transmitted from the transmitter and the time the signal is received the receiver.   b. Assuming that the clocks running at the transmitter and receiver are very accurate, these clocks need to be synchronized so that the time the signal takes to travel from the transmitter to the receiver can be calculated by subtracting the time the receiver receives the signal from the time the signal is transmitted from the source.   c. Due to reflection of the signal from objects that are situated in between the transmitter and receiver, the signal may be reflected off many objects before getting to the receiver. The receiver usually locks into the strongest path to retrieve the signal. If the strongest path is not the direct path between the transmitter and receiver, it may arrive at the receiver a fraction of the time later than the signal that would have been arrived via the direct path. In this invention, this effect is considered minimal.       
 
       SUMMARY OF THE INVENTION 
       [0008]    The invention describes methods and apparatus for forming ranged-based wireless alarm systems that rely on the computed distances between two or more WLAN devices to trigger alarms. Accordingly, a system and method in accordance with the present invention enables a smart phone, handheld, laptop, router or the like, which is equipped with a WLAN interface, to monitor the distance between itself and one or more WLAN devices and raise an alarm if the computed distance is greater than a preset value. Other aspects and advantages of the present invention will become apparent from the following detailed description, taken in conjunction with the accompanying drawings, which illustrate by way of example the principles of the invention. 
         [0009]    The invention enables people to maintain contact from one designated person to one or more persons in public places such as shopping malls, beaches, parks, ski slopes and at events such as festivals, outdoor concerts, and public gatherings. An alarm is raised when any contact is lost or when the distance between the designated person to any person in the group exceeds the preset distance. 
         [0010]    The invention can also be used to monitor or display distances from a fixed, stationary device to objects such as cars, bicycles, people and animals that are equipped with WLAN interlaces within the operating range of WLAN, typically varied from 300 meters to 1000 meters. An alarm is raised if any of the measured distances exceeds a preset value. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0011]      FIG. 1A  is a block diagram of an embodiment of a range-based wireless alarm system in accordance with the invention, wherein the devices shown are all mobile or handheld devices. 
           [0012]      FIG. 1B  is a block diagram of an embodiment of a range-based wireless alarm system in accordance with the invention, wherein the controlling device is installed at a fixed location and other devices are mobile devices. 
           [0013]      FIG. 2  shows a flow chart describing the procedure to activate and arm a range-based alarm between the controlling device and another device, which is called tracking device, in accordance with the invention. 
           [0014]      FIG. 3  shows the procedure to synchronize the time clocks of the controlling device and a tracking device in accordance with the invention, wherein both devices are mobile devices. 
           [0015]      FIG. 4  shows the time sync procedure between the controlling device and a tracking device in accordance with the invention, wherein the controlling device is installed at a fixed location and the tracking device is a mobile device. 
           [0016]      FIG. 5  shows the steps involved in the computation of the distance between the controlling device and a tracking device in accordance with the invention. 
       
    
    
     DETAILED DESCRIPTION 
       [0017]    In one embodiment, the invention enables a group of mobile and handheld users to form a ranged-based alarm system ( FIG. 1A ) using their WLAN interfaces. For example, a family doing shopping at a mall can use their cell phones that are equipped with WLAN interfaces to make sure that all members in the family stays within a reasonable distance to the mom or dad. 
         [0018]    Following the procedure shown in  FIG. 2 , the first step is to select one of the mobile devices to be the controlling device. The second step is to select the Maximum Distance Value for the controlling device to operate. This value is also known as the range. This is the maximum distance that the tracking devices are allowed to be located from the controlling device without triggering an alarm. The third step is to synchronize the internal time of the tracking device to the internal time of the controlling device ( FIG. 3 ). 
         [0019]    The time sync procedure is activated by placing the controlling device physically close to a tracking device and press the time-sync button on the controlling device first, followed by pressing the time-sync button on a tracking device within a few seconds. On smart phones or handheld devices, the time-sync buttons can be replaced by a code, usually consists of two or more digits. The code is first entered into the device that is chosen to be the controlling device, and then users of other devices enter the same code on their devices within a few seconds after. 
         [0020]    Continue with  FIG. 3 , the tracking device sends a request to the controlling device for time sync, the controlling device responds with a number of time-sync data packets, each packet includes a time stamp that indicates the time the packet is transmitted from the controlling device. The tracking device extracts the time stamp from the incoming packet and overwrites its internal time with the received time stamp. This process is repeated until that last time-sync packet is received. The number of time-sync packets transmitted from the controlling device can vary from 1 to n. In most situations, one time-sync packet would be sufficient. The repeated transmission of the time-sync packets is designed to minimize the processing delay at the receivers. 
         [0021]    Continued with  FIG. 3 , the last time-sync packet includes a special code. The tracking device recognizes the last time-sync packet, then sends a confirmation packet to the controlling device with a time stamp. The controlling device receives the confirmation packet, extracts the time stamp and compares it with its internal time. If the time stamp received is faster than its internal time, it subtracts its internal time from the received time stamp to come up with a time adjustment (TA) that will be used to subtract from the time stamps received from this tracking device. On the other hand, if the time stamp received is slower than its internal time, it subtracts the received time stamp from its internal time to come up with a time adjustment (TA) that will be used to add to the time stamps received from this tracking device. 
         [0022]    Finally, the controlling device sends an acknowledgement of time-sync completion to the tracking device. Both devices provide indications to the users that the time-sync has been successful and the alarm is activated for the tracking device. 
         [0023]    Continued with  FIG. 2 , after the controlling device and the tracking device successfully performed the time-sync procedure, at regular interval, the controlling device initiates the procedure to compute the distance between itself and the tracking device as shown in  FIG. 5 . The controlling device issues a request for distance measurement to the tracking device, which in turns responds with a number of time-sync packets. The number of time-sync packets transmitted from the tracking device can vary from 1 to n. In most situations, one time-sync packet would be sufficient. The repeated transmission of the time-sync packets is designed to minimize the processing delay at the receiver and alleviate the effect on signal reflection as discussed in the Background section. The controlling device extracts the time stamps from the incoming packets coming from the tracking device and computes the time for the packet to travel from the tracking device to the controlling device according to the following equation: 
         [0000]      TT=IT−TS+/−TA       Where TT=travel time, IT is the internal time of the controlling device, TS is the received time stamp, and TA is the time adjustment for this tracking device as previously calculated.   Depending on the number of packets received, TT is computed for each received packet, then the average travel time (AT) is derived by the following equation:         
         [0000]      AT=sum(TTs)/no. of packets received 
         [0026]    Finally, the distance between the controlling device is 
         [0000]      Computed distance=AT(sec)×300,000 km/sec       If the accuracy of the clocks used on both of the controlling and tracking devices is in order of a nanosecond, then each nanosecond is equivalent to a distance of 0.3 meter or 0.98 foot.         
         [0028]    The controlling device checks if the value of the computed distance is less than or equal to the maximum distance value, then it will move on to compute the distance of the next tracking device. If the value of the computed distance is more than the maximum distance value, it raises an alarm indicating that this tracking device has exceeded the maximum distance value. 
         [0029]    If the procedure of  FIG. 2  does not complete successfully, the controlling device will abandon the computational procedure and will return to perform the distance measurement at the next interval. If the second attempt still does not complete successfully, the controlling device raises an alarm indicating that it has encountered communication with the tracking device. 
         [0030]    On a tracking device, if it does not receive any request for distance measurement for a period of time that exceeds two regular intervals, it will raise a local alarm on the tracking device indicating that it has lost communication with the controlling device. 
         [0031]      FIG. 1B  is a block diagram of another embodiment of a range-based wireless alarm system in accordance with the invention, wherein the controlling device is installed at a fixed location and other devices are mobile devices. For examples, the controlling device is installed on the wall of a hotel or a residential home for the purpose of tracking people, automobiles, animals and devices such as laptop, cell phones that are all equipped with WLAN interfaces. Pushing the button on the controlling device to activate the time-sync procedure may not be practical. Instead, the time sync procedure can be triggered by a remote control or by a command that is sent via a cable connected to the Ethernet port of the controlling device. After the time-sync command is received, the controlling device of  FIG. 1B  operates the same way as the controlling device of  FIG. 1A .
A range-based alarm system comprised of a controlling device and a plurality of portable, handheld devices communicating over a wireless local area network (WLAN); wherein the controlling device frequently computes the distance between itself and the plurality of portable, handheld devices and raises an audible or visual alarm when one of the computed distances exceeds its programmed operating range. An audible or visual alarm is also triggered on any of a plurality of portable, handheld devices when it has lost communication with the controlling device or when instructed by the controlling device.