## 6 Application of Proposed Architecture  
The reference architecture proposed in Section 5 can be suitable for some IoT scenarios. We selected automatic ticketing as a case to discuss how the proposed architecture can be adapted to the IoT scenarios. Passengers can purchase and validate public transport tickets in various ways, for instance, through an app solution on the passenger's smartphone, contactless payment cards, the transport provider's own card solutions, or buying tickets with cash. In all of these solutions, the passenger needs to do something. Instead, imagine that ticketing automatically happens when passengers are inside the bus or tram without them having to perform any action. Passengers do not need to think about purchasing/validating tickets or the best price option when they want to travel by public transport when ticketing takes place automatically. Faster boarding, no cash handling, and possibly increasing customer satisfaction, as well as discovering customer behavioral patterns on public transport companies, are just a few of the advantages that automatic mobile ticketing solutions can offer [149; 150]. The challenge is how, with high accuracy, to determine whether travelers are inside or outside of a public transport and which kind of public transportation travelers are taking. Inferring the user's state is necessary to detect the mode of transport of a commuter and to enable automated ticketing. Mobile sensor data combined with the reference sensor data of a transport vehicle can be utilized to detect the activity of a person [151; 152; 153] or to derive the transportation mode [154; 155; 156; 157]. In particular, contextual data, e.g., the location and start time of a journey, can be utilized to reveal significant journeys of passengers [158; 159; 160; 161; 162; 163]. This can be achieved by the collection of movement data of a traveler using sensors of the traveler's smartphone in combination with external data sources such as existing bluetooth low energy (BLE)-enabled beacons [164]. BLE technology is the most popular approach to achieving automatic ticketing [165; 166; 167; 168]. By employing BLE, it is possible to completely eliminate the traveler's action during check-in and check-out. The traveler's smartphone communicates with either a BLE-enabled on-board device or a device located at a bus stop for seamless check-in/check-out [166; 167; 168; 169]. In these solutions, an application residing on the traveler's smartphone triggers a check-in or check-out event when the traveler enters or leaves the proximity of a BLE beacon. Other common solutions mostly rely on GPS or cellular network coordinates to locate the traveler; however, these solutions are not viable for automatic ticketing. The accurate in-vehicle presence of the traveler is critical for accurate automatic check-in/check-out [165]. It is challenging to establish whether the traveler is indeed inside the public transport vehicle or is located outside somewhere next to the public transport vehicle using GPS technology. Moreover, a GPS is associated with high energy consumption compared with sensor data, such as a gyroscope, magnetometer, or accelerometer [170], and a GPS also depends on an unobstructed view of satellites, which may be difficult to achieve in urban public transportation infrastructure. Therefore, it is less suitable for the real-time in-vehicle presence detection of people. In addition, a GPS provides only static position information and does not capture the constantly changing environment that a passenger is experiencing during travel. Thus, merely considering location data to monitor passengers is inadequate and can be improved by incorporating contextual information from mobile sensors [171]. In our scenario, a group of passengers travels using several modes of public transportation, such as a bus, train, metro, tram, and city boat, within a middle-sized Scandinavian city.