# An Interactive Real-Time Locating System Based on Bluetooth Low-Energy Beacon Network +
## 3 System Design
### Flow of Operations  
In this subsection we describe the flow of operations of our system. When the Mesh Beacons are powered on, they periodically broadcast beacon messages over the advertising channel, just like ordinary beacon devices do. Moreover, our Mesh Beacons also listen to the messages carrying users' presence state from the Mobile Apps at the same time. In the following, we illustrate the flow of operations when a smartphone user with our Mobile App enters the communication range of our Bluetooth beacon network.  
1. When the Mobile App discovers a beacon message from a certain Mesh Beacon, it locates itself based on the Major/Minor values embedded in the message. In our design, the Mobile App directly looks up a built-in location table to resolve the Major/Minor values, so the name of the detected location can be shown on the user interface immediately.
2. Once the locating process has completed, the Mobile App composes the presence message containing the encrypted user ID and the detected Major/Minor values, and then broadcasts the presence message. The objective of broadcasting the presence message is to inform the backend system that this specific user has shown up at a particular location.
3. As soon as any Mesh Beacon hears the presence message, it uses the managed-flood-based approach to rebroadcast the presence message. The purpose of rebroadcasting the presence message is to relay it to the Mesh Router. The managed-flood-based approach can make sure that once a specific presence message has been broadcasted by a Mesh Beacon, the Mesh Beacon will not rebroadcast it again.
4. When the Mesh Router hears the presence message originated from a certain Mobile App, it uploads the content in the presence message to the Application Server. Meanwhile, it sends an acknowledgement message back to the Mobile App by broadcast.
5. When any Mesh Beacon hears the acknowledgement message, it rebroadcasts the message by using the managed-flood-based approach again. The purpose of rebroadcasting the acknowledgement message is to relay it to the Mobile App.  
Figure 1: System architecture.  
6. (Continue from item 4) When the Application Server receives the presence state from the Mesh Router, it forwards the presence state to the Cloud Database. In the Cloud Database we are able to see the locating history for all the mobile users.
7. When the acknowledgement message from the Mesh Router has been received at the Mobile App, the Mobile App displays a welcome message indicating that the backend system is aware of the user's presence.  
The sequence diagram in Figure 2 shows an example of the flow of operations, where the labeled numbers correspond to the 7 items described above. In this example, there are three Mesh Beacons on the transmission path between the Mobile App and the Mesh Router. From the diagram, we can see how the interactivity between the mobile user and the backend system is achieved. From the users' perspective, they are able to receive more than the basic locating service. Benefiting from interacting with the backend system over a single Bluetooth beacon network, they can enjoy personalized services without having to connect to the Internet. From the system operators' perspective, they are able to detect the presence of specific users at particular locations, and then offer personalized services to them. With the presence state stored in the Cloud Database, the system operators can also track and analyze user behaviors using the users' real-time and past locations.