# A Visitor Assistance System Based on LoRa for Nature Forest Parks
## 5 The Proposed Visitor Assistance System
### Protocol and Application
Groups are created without the need for visitor intervention. Upon the receipt of 30 beacons generated by the same terminal within 30 minutes, group formation or inclusion in an existing group is initiated. The terminals involved then proceed on leader election using messages sent using SF7. This message contains the terminal ID and an estimate of the time for the battery to be exhausted. The leader will be the terminal with the longest expected battery life. Ties are broken based on the highest terminal ID. Once the group is formed, both the leader and other group participants have the same set of sighting records. The group stays synchronized by the leader beacon, identified by the group ID. The group ID consists of the leader ID and the group flag (GF) field. One who is not a group leader will have the GF field with zero value. The leader GF will have value 1. Figure 12: Communication in an emergency situation. Only the leader will send beacons and exchange sighting records with other contacting terminals. In this way, the other participants in the group save battery since the supply current in transmit mode is ten times greater than in receive mode, as shown by the values described in Table 1. There is no need for the leader to replicate data received from a terminal outside the group to the other participants, as everyone listens to the broadcast for the group ID. This way, every terminal in the group keeps the same sighting record set. If the leader's beacon is not received for an interval longer than 10 minutes, a new leader election begins. If during the election, the terminal does not receive messages from other terminals, it is assumed that it is no longer part of any group and the person is moving alone. If the leader's battery charge falls below a pre-established threshold, the device stops sending beacons forcing a new election. Communication within groups is done using SF7, which provides the smallest radio range, as its members are always close. This way a higher baud rate can be used while reducing the consumption and the chances of interfering with other communications. Sending beacons, either by a terminal traveling alone or by a group leader, is done using SF12. The communication between terminal and totem (Figure 11) is also asynchronous and started by beacon reception, following a similar handshake with the choice of an SF for a record sending channel. Nevertheless, the totems advertise their coordinates every five seconds since totems have no power or storage constraints, differently from mobile terminals. On the other hand, it is important to increase the probability that a device entering a totem area will be able to communicate. Totems also record the presence of mobile terminals. The totems inform which trail the visitor is on: typically, there may be different trails inside a natural park. A prediction is then made of when the visitor will pass the next totem of this same trail. This prediction is refined by accumulating records about each visitor and by estimating their average travel speed. Ideally, totems should be located at least at the entrances and junctions of trails, as well as places with specific hazards such as waterfalls and caves. In Section 5.3, we have proposed an optimization model for the positioning of totems considering risks and other specific requirements of each spot that was mapped as a point of interest by the administration of the natural park. In Figure 11, terminal A, which passes through the totem coverage area, receives a beacon. The terminal updates its coordinates data, notifies its identification, and requests the transmission of the records saved in its memory to the totem, using a specific SF. Upon receiving the acceptance, it then forwards all the records of its memory and waits for confirmation by the totem via an ACK. Upon receiving the ACK, the mobile terminal empties its memory. This message contains the number of records received by the totem. If it is not the same number of records sent by the terminal, all of these are re-sent.