A Smart Parking System Based On Mini PC Platform and Mobile Application For Parking Space Detection
A Smart Parking System Based On Mini PC Platform and Mobile Application For Parking Space Detection
Research Article
A Smart Parking System Based on Mini PC Platform and Mobile
Application for Parking Space Detection
Received 24 June 2020; Revised 25 September 2020; Accepted 9 October 2020; Published 26 October 2020
Copyright © 2020 Vladimir Sobeslav and Josef Horalek. This is an open access article distributed under the Creative Commons
Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is
properly cited.
Car parking is a major problem in urban areas in developed and also in developing countries. The growing number of vehicles
creates a problem with parking spaces mainly in the city center and the surrounding streets. The local authorities have to react with
regulations, and the current situation is unpleasant for many citizens. Therefore, the aim of this article is to propose a complex
outdoor smart parking lot system based on the mini PC platform with the pilot implementation, which would provide a solution
for the aforementioned problem. Current outdoor car park management is dependent on human personnel keeping track of the
available parking lots or a sensor-based system that monitors the availability of each car. The proposed solution utilizes a modern
IoT approach and technologies such as mini PC platform, sensors, and IQRF. When compared to a specialized and expensive
system, it is a solution that is cost-effective and has the potential in its expansion and integration with other IoT services.
cloud using mini PC (Raspberry Pi) deployed on the parking in [7] and the spread of the networks’ usage is discussed in
lot. The authors describe the use of Raspberry Pi GPIO pins, [8, 9].
to which 26 sensors can be connected. The number can be
increased even further using a suitable multiplexor. This 3. The Proposed System Architecture
solution utilizes an IBM MQTT server, to which the
Raspberry sends data from the sensors via MQTT messages. The aim of the proposed parking system is a complex and
The user communicates with the system via a mobile app economic system for detection of free parking spaces on an
written in Apache Cordova, which communicates with the outdoor parking lot, which is based on the mini PC
server with messages in the JSON format. The user can use platform. The system partially handles the problems with
the mobile app to see the number of the free spots on the undisciplined drivers who would use the parking lot
parking lot, make a reservation of a parking space, and pay without the respective authorization. This is provided by
the parking fee. In [2], besides the general architecture, the using the automatic gate system at the parking lot entrance.
authors focus on using Elliptic Curve Cryptography (ECC) Because of the budget requirements, the variant where the
as an attractive alternative to the conventional public key parked vehicles would be detected via ultrasound or infra-
cryptography such as RSA. Interesting algorithms employed sensors has been abandoned, and therefore, the proposed
in the contemporary smart parking systems are presented in solution discusses the variant using magnetometric sensors
[3]. Finally, an overall overview of the approaches and so- connected to a mesh network. In regular intervals, the mini
lutions is provided by [4]. PC checks whether the individual parking spaces are oc-
Another topic covered by this article is the optimization cupied and stores the data in a real-time database. The
of the logic and IoT approaches used to find and navigate to driver is then informed via the mobile app for Android, and
the parking space itself. Tsai et al.[5] describe the use of a so they have current information about the numbers of
mobile app and Internet of Things (IoT) technology in the available parking spaces on the selected parking lot. The
parking system: the process of finding a parking lot, parking availability can be checked either manually or automati-
space reservation, and indoor navigation inside the parking cally using the Geofencing service. The user is also able to
lot. Another topic is finding the suitable algorithm to cal- book a parking space for 60 minutes. If they do not arrive at
culate the priority for recommending a specific parking lot the parking lot during this time, the reservation is auto-
based on the distance of the driver from the parking lot, matically canceled.
number of free parking spaces, and the parking fee, with the The proposed solution enables opening the parking lot
preferences being set up by the user. After selecting the gate directly from the mobile app by adding an entry into the
parking lot, the driver has an opportunity to book the real-time database. After the entry is added, the mini PC
parking space via the app. For the calculation of the distance performs the corresponding steps. To check the presence of
from the parking lot and the navigation, the app uses GPS the driver (their smartphone, to be precise) on the parking
coordinates acquired from the Google API. Detection of the lot, the mobile app compares the GPS coordinates before
presence of the vehicle on the parking space is realized via an registering the vehicle as present on the parking lot. If the
ultrasound sensor and transferred to the server via a WiFi distance between the smartphone and the parking lot is
module. The described solution is designated mainly for higher than a given limit, the access is denied. Thanks to this
indoor parking lots, with the indoor navigation provided by solution, there is no necessity for use of an RFID chip, and to
iBeacon Bluetooth transmitters. The presence of the driver make use of the parking lot, a smartphone with the installed
on the parking lot is detected by an RFID chip. The matter of app and connection to the Internet should suffice. The
parking specifically on the side of the roads is discussed in identification of the smartphone is performed using a unique
[6]. It describes the detection of the roadside parking spaces 64-bit number, ANDROID ID. The general model of the
using sensors placed on the vehicle on the passenger’s side. proposed solution is depicted in Figure 1.
These sensors are placed on public transport vehicles, taxis,
or sometimes on the vehicles of the volunteers who fre-
quently pass through the marked measured areas. 3.1. Functional Diagram of the Proposed Solution. The mobile
The system uses an ultrasound detector to detect the app monitors the entry in the database with the number of
parked vehicles and empty spots along the road in con- empty spots. On every change, the state of the notification
junction with the GPS system, and by using Map Matching icon on the app’s main screen is changed. After tapping this
(which compares the detected spots with the map), a map icon, the current occupancy of the individual parking spaces
of available parking spaces is continuously generated and is loaded from the database, and it is displayed on the
is distributed to the users via the mobile app or a website. smartphone screen. By tapping on the respective icon on the
According to the performed measuring, to map the same main screen, navigation to the parking lot is started. Using
number of the parking spaces, mobile sensors are more Google API, the application starts navigation on Google
efficient than sensors placed directly on the parking Maps. More detailed information is described in Section 5.
spaces. The success rate of the detection was between 76 To enable the automatic notifications about parking lots in
and 94 percent, depending on the accuracy of the GPS proximity and the number of available parking spaces, the
system. application uses Geofencing service, which is described in
In the hereby presented complex solution, IQRF net- Section 5.2.
works are utilized. Their communication system is discussed The following diagrams describe two main functions:
Mobile Information Systems 3
IQRF
IQRF
Displaying the available spots at the parking lot and 4. IQRF Communication Platform
their current occupancy (Figure 2)
Turning on the automatic notification about available From the principle of the intelligent parking system pro-
parking lot (Figure 3) posal, it is necessary for the system itself to be able to detect
whether the respective physical spot is occupied or not, and
The following diagram (Figure 4) describes the logical it must also be connected to the suitable network so it can
steps required for opening the parking lot gate. First, the communicate with the central mini PC. For this purpose,
application checks the database of the parked vehicles to IQRF technology has been chosen [10].
determine whether the vehicle is entering or leaving the IQRF is a platform suitable for wireless data transfer,
parking lot. which utilizes wireless data transfer, using the frequencies of
When entering the parking lot, it is also checked whether 868 MHz and 433 MHz for the communication. The IQRF
there are available spots or if the driver who is sending a platform makes use of special transceivers that reciprocally
request to open the gate has a reservation saved in the interchange the data. The IQRF transceivers are known to
database. If everything is in order, the distance from the have a very low consumption rate (12.3 mA during com-
parking lot is checked to prevent an unintentional or de- munication and 380 nA in sleep mode), and thanks to the
liberate gate closure at higher distance from the parking lot. supported MESH topology, communication at relatively
If any condition is not met, the driver receives information long distance is possible. These parameters appear to be an
about the parking lot unavailability. Otherwise, the gate ideal solution for the IoT technologies. The wireless IQRF
opens, and the arriving vehicle is added to the parking lot’s network uses the IQMEST protocol [11, 12], which uses the
database. At the same time, the driver’s reservation validity is principle that in any given area, and there are always at least
checked and deleted from the database if invalid. When two IQRF transceivers within the transmission reach. The
leaving the parking lot, the system opens the exit gate and maximum distance between two communicating trans-
deletes the record of the vehicle from the parking lot’s ceivers is around 500 meters in space without obstacles. The
database. transceivers transmit in synchronization, so they do not
The realization of the reservation process is depicted in interrupt each other during the transmission. The com-
Figure 5. During an attempt at making a reservation, the munication is governed by a coordinator, which sends the
system first checks whether the vehicle is not currently data, transceivers in the reach receive the data, during their
located at the parking lot and that its ID does not have a time-slot send the data further, and this way the data
reservation created already. Then, the available spots are gradually spread through the whole network. Thanks to this
checked. If all the conditions are met, a reservation entry is principle, the whole network is very reliable and has a high
made in the parking lot’s database. Otherwise, the app success rate of the data transmission. Because of the du-
informs the driver that the reservation cannot be made. plicate paths between individual transceivers, the data reach
Duration of the reservation is limited to 60 minutes. For their destination even if multiple communication paths are
this reason, in 1-minute intervals, the mini PC on the disrupted at the same time. The principle is depicted in
parking lot checks the database if any reservation has Figure 7, where the coordinator C sends the data for the
exceeded this limit. If this occurs, the entry is deleted from transceiver N2. The communication paths that are inter-
the database. rupted, e.g., by signal disruption, are represented by the red
On the general communication schema (Figure 6), you crosses. The data reach their destination, as the green arrows
can see that the common storage for the whole system is a suggest, via the transceivers N1, N3, and N4.
Firebase database. The communication between the database
and the mini PC is procured via TCP/IP protocol. The
communication between the database and the mobile app 4.1. DPA Protocol. Every transceiver has a hardware profile
uses mobile network data transfers and the communication (HWP). Assigning a HWP to the transceivers enables their
between the mini PC and the individual sensors is procured control via messages with DPA (direct peripheral access)
by the IQRF technology described in Chapter 3. protocol [13]. Because of this protocol, it is possible to build
4 Mobile Information Systems
Figure 2: Functional diagram to show the number of available parking spaces and their current occupancy.
Automatic
detection by
geofencing
No
Command to start
automatic parking Launch services Parking in
detection within Geofencing the vicinity
range
Mobile apps
Yes
View notification of
available car park
with free space
Figure 3: Functional diagram to trigger the automatic notification of available car parking.
a network comprised of up to 240 transceivers, and the respective command. Using the DPA handler, it is also
transceivers can be controlled by sending the data in the possible to expand the set of the HW groups described
specific format (Table 1). above, and thus it enables the filtering of control message for
NADR (node address) has the address 0x00 for the the groups of peripheries of the respective type.
coordinator and 0x01–0xEF for the other transceivers and
PNUM (peripheral number) 0x03 EEPROM, 0x08 SPI, 0x0C
4.3. FRC. Fast response command (FRC) is a special co-
UART, etc. PCMD (peripheral command) is designated only
ordinator DPA periphery, which enables sending a com-
by the type of the used periphery; HWPID (hardware profile
mand that can be processed by all the transceivers in the
ID) uniquely determines the functionality of the periphery
network. The moment the transceiver processes the com-
device. If 0xFFFF number is used, the command is executed
mand, it stores the response on the specific position in the
on any HW profile. PDATA (peripheral data) is an optional
message and it passes through the whole network along with
56-byte field for additional command parameters.
the data and collects the responses of individual transceivers.
If we need to get the same information from all the
4.2. Custom DPA Handler. For creating the own logic of the transceivers, which is, in our case, the input from a detector
transceiver, custom DPA handler is used, i.e., it uses code about the presence of a vehicle on a parking space, the use of
written in C, which can be used to define custom user FRC is very practical as it is not necessary to send indi-
periphery and set up its behavior during received a DPA vidually to every transceiver, but sending one command is
command with this periphery’s ID and the ID of the enough. This positively affects not only the amount of the
Mobile Information Systems 5
Mobile apps
Firebase
Read data from
the database
Car in the Opening the
Yes
parking lot? barrier
Deleting a
vehicle record
No from the parking
database
Firebase
Free places?
Reservation?
Yes
No Finding the distance
from the GPS car
park
NO
Firebase
Information about
the inability to
Y make a reservation N
e o
s
Read from
database Car in the
Booking parking lot?
order Is there a No Free place?
Firebase
reservation?
Mobile apps
Write a
reservation to
the database Yes
Firebase
GPRS, EDGE,
LTE ..
TCP/IP IQRF
Firebase
Mobile apps Mini PC Sensor set
N5 N2
After programming all the transceivers and inserting
N3 them into the DK-EVAL-04A testing modules or alterna-
tively by connecting custom modules that would need to be
C adjusted according to the transceiver connection schema
(Figure 9), for the transceiver to be powered by the right
N1 N4 voltage and have accessible RESET and bonding buttons, by
connecting the coordinator into the CK–USB–04K pro-
Figure 7: Principle of IQRF communication between coordinator grammer, an IQRF network can be created.
C and N2 transceiver. If a red LED is blinking after connecting the power source, it
means that no previous bonding is stored in the memory.
Otherwise, it is necessary to manually unbond by pressing the
transferred data but also time needed to get a response. The reset and the user buttons on the testing module and then
FRC command is sent via the DPA protocol (Table 2). releasing the reset button. After a green LED blinks, the user
User data item is not required by all the FRC commands, button must be released at once. For erasing the data about
and if not used, it must be replaced by a 2-byte value of 00.00. bonding from the coordinator, IQMESH Network Manager,
SEND command can be replaced by the SEND selective which is a part of the IQRF IDE program, must be used. To do
(0x02) command, which makes it possible to send the so, press the “Clear All Bonds” button. Afterwards, by pressing
command only to the chosen transceivers, which are defined the “Bond” button, the coordinator start searching for a new
in the data field between ID and user data entries. node, and in the frame of ten seconds, the bonding must be
The selected transceivers can be specified through 30- confirmed by pressing the user button on the respective testing
byte binary information. In IQRF network, there can be the module. By repeating this procedure, all the nodes must be
maximum of 240 transceivers, which corresponds to 30 bonded with the coordinator. At the time of the bonding, all the
bytes, i.e., 240 bits. If the respective bit has a value of 1, the nodes must be in the communication reach of the coordinator.
command will be sent to the corresponding transceiver. After the bonding is finished and the respective nodes are placed
Otherwise (the value of 0), the transceiver will not be in- on their final positions, by clicking the “Discovery” button in
cluded into processing of the command. IQMESH Network Manager, the IQMESH network topology is
For the initial configuration of the transceivers and for created. It can be viewed in the “MapView” tab (Figure 10).
the creation of the IQRF network, it is necessary to use
CK–USB–04K programmer and IQRF IDE development
interface. It is also necessary to get hardware profiles for the 4.4. IQRF Gateway. The created IQRF network requires a
coordinator and the individual nodes. gateway for transmitting the data to the database/cloud via
Into the newly created project, the author must add the the Internet. For the purposes of the best compatibility and
HW profiles and the DPA custom handler for FRC com- technical support, a one-board computer UpBoard has been
mand for detecting the state of the sensors on the parking used as it, in comparison to Raspberry Pi, offers a micro-
spaces. The HW profiles belong to plug-ins section and the processor with better performance in Intel Atom, as well as
DPA custom handler to source section. Considering the higher memory capacity, and does not require an OS to be
fact that the inserted DPA handler is in the format of the installed on an external memory card, which can pose po-
source file written in C, this file must be compiled to ∗ hex tential problems in conjunction with the mechanical con-
format so it can be uploaded to the transceiver. After ® ™
nector. UpBoard is also used in Intel RealSense Robotic
Development Kit and has the following characteristics:
inserting the first transceiver into the programmer and
connecting it to a USB port of a PC, in the “Project”
window in the “TR Configuration” section, the configu- ® ™
Intel Atom x5-Z8350 SoC
Onboard DDR3L Memory up to 4 GB
ration settings for the inserted transceiver can be opened.
For all the communicating transceivers, it is necessary to set Onboard eMMC Storage up to 64 GB
the same communication channel (typically 52) in the “OS” Gigabit LAN × 1, USB 2.0 × 4, USB 3.0 × 1, HDMI × 1
tab. Next, in the “HWP” section, the option to process the 5V DC-in
FRC commands for the coordinator and use of custom
40 pin GPIO × 1
DPA handler for every node must be enabled. In the
“Security” tab, a password and communication encryption DSI/eDP × 1
can be set up (Figure 8). MIPI-CSI × 1
Mobile Information Systems 7
10
6
8
MCP73831MC Ref.
USB 5
1 VIN 1 3 VBAT 3.3V 4
VIN VBAT LDO C1 C5
2 2 4 JP1 3
F1 C2 C6
SW2
3 SN035-16 2
6 C3 C7
LED3 GND +
4 5 9 1
Accu LED2 C4 C8
5 8 3.6V 9
SIM 7
XC3 IC1
XC1
SW1
LED1
mobile app but also the mini PC via NodeRED. For greater for the gate to open is stored in reservationID item. This ID is
clarity, individual program flows are split into individual then compared to the records in reservations, and if a valid
IQRF_Request tabs. The commands are sent to the IQRF reservation is found, it is deleted. After the time delay, the
network, IQRF_Response processes the responses from the reservationID item is reset by ResetReservID.
IQRF network, Firebase communicates with the Firebase The second flow starts with the GateID node, which
database, Gate operates the entrance and exit gate, and continuously checks the database for changes in the gateID
Reservations maintains the user reservations. item. Into this item, the mobile app saves the ID of the
smartphone registered on the parking lot (it has a record in
carInPark) and sends a request to open the exit gate. The
5.3. IQRF_Request. The program flow IQRF_Request program continues with the link to IQRF_Request, where it
(Figure 12) uses program nodes on the lies 2 through 5, opens the exit gate via the GateExitOpen node. After a time
which send the requests to open or close the entrance or exit delay for the vehicle to pass through, the gate is closed again
gate. The requests come from other tabs via the connections via the link to GateExitClose. The flow continues with
(grey arrows at the beginning of the lines). loading the CarInPark items from the database and coverts
Individual requests are realized via custom functions them to the JSON format. These data are passed to the
written in JavaScript. That is the DPA command for the FirebaseConvert function (code: finding and passing the
IQRF network (code: create a request for an IQRF network). item ID for deletion), which, from the smartphone ID stored
Because of the physical absence of a gate, for the tuning in GlobalContext, searches for a record in the database and
purposes of the app, the commands were simulated by turn deletes the record via the DeleteValue node. The last step of
on or off a red LED on the IQRF coordinator (entry gate) the program is the gateID item reset.
and a green LED (exit gate). In practice, the LED would be
replaced by a digital output that would send the command to
the gate. 5.5. Reservations. In the case of this flow, a division into two
var data � { parts has been done too (Figure 14). Every minute, the first
part checks the reservation length, and in case of exceeding
type: “raw”,
the time limit, the reservation is removed. The other part
request: { checks the reservations of the drivers entering the parking
nadr: “0x0000”, lot, and if such an entry exists, it is deleted.
pnum: “0x06”, Every minute, the inject node loads the reservations from
the database and converts them to JSON. The data are passed
pcmd: “0x01”,
by the FirebaseConvert (code: check out booking timeout)
hwpid: “0xFFFF”, function, which checks the length of every reservation and in
pdata: “”, case of exceeding the time limit and passes the respective
}, reservation for deletion. If a reservation that should be
deleted is found, the switch continues with the second path.
timeout: 1000 Otherwise, it continues with the first path, where the pro-
} gram ends.
msg.payload � data; var response � msg.payload;
return msg; var data � “”;
var nic � 1;
5.4. Gate. For the communication itself and its procure- var data1 � response.split(“{”).toString();
ment, the gate is a key component of the whole architecture.
The gate process flow is split into two parts. The first part var l � data1.length;
controls the entry gate, and the other controls the exit gate for(i�0;i<l;i++){
(Figure 13). var s � data1.substring(i, i + 1);
The first flow begins with the Gate node, which is, in fact,
if(s �� “\””){}
a listener that watches the Gate item in the database. It
follows with the switch on the value of 1 (opens the gate) and else if(s �� “{”){}
continues with the second path to the GateEntranceOpen else if(s �� “}”){}
node. The next node is a time delay for the vehicle to pass else {data � data + s;}
(sensors for the detection of a vehicle in the gate space are its
}
part) and then the flow continues with the link to Gate-
EntranceClose and sets the value of the gate item in the var allmsg � data.split(“,−”);
database to 0. In that case, the switch ensures that the gate l � allmsg.length;
does not open again after the value in the database is for(i�1;i<l;i++){
changed when the value of 0 is added, and so it takes the path
var data1 � allmsg[i].split(“:”);
1, to which no other program node is connected. After
opening the entry gate, the ID of the smartphone that asked var fh � parseInt(data1[4]);
10 Mobile Information Systems
Gateentranceclose
Gateexitopen
Gateexitclose
Delay 10s
DeleteValue
GlobalContext Ready
GateIDUpdate
Ready
1 Reservations Json
Ready
@Override
public void onDataChange(@NonNull DataSnap-
shot dataSnapshot) {
places � dataSnapshot.getValue().toString();
int pl � Integer.parseInt(places);
int cr � (int) (pl − countRes);
Fplaces.setText(String.valueOf(cr));
}
@Override
public void onCancelled(@NonNull DatabaseError
Figure 15: Notification after entering geofence.
databaseError) {
places � “Error”;
}
Searching for a place and displaying it on the map });
Navigation with the selected means of transport (car,
bicycle, and walking) On every change of the available parking spaces, the method
above (code: setting the listener to change the number of free
Displaying the panorama view in Google Street View parking spaces) sets the textView value on the main activity via
service the setText method, so the button always contains the current
To run the map, it is first necessary to create an “Intent” number of available spaces on the parking lot. When tapping
object and specify the mode in which the map will be this button, a new activity is run. It contains listView, which
opened. Intent contains a special string (URI), which ac- informs the driver about current occupancy of the individual
curately specifies the requested action. After creating the parking spaces on the parking lot. The same activity is run also
Intent, the activity gets started by the startActivity() method. upon entering the parking lot after the request to open the entry
As you can see in the following code (code: create Intent and gate, so the driver has an overview of the available spaces. For
run Map Activity), Intent is created via URI, which defines this purpose, the app uses, similarly to the previous case, the data
the type of the action as navigation to a set GPS coordinate. stored in the database, whose changes are monitored by the
Subsequently, the Intent is injected with a packet to secure listener. The data about the occupancy of the individual spaces
that is processed by Google Maps. are stored in the database via NodeRED in the form of a string
“0000110100110010”, which contains sixteen bits: “1” or “0”. If
public void startNavigationButtonHandler(View view) the given position has the value of “1”, it means that the space is
{ occupied. Otherwise, the space is available. The getOccupancy()
Uri gmmIntentUri � Uri.parse(“google.navigation: method (code: filling a text field based on database data) in this
q � 50.475367, 16.179489”); activity fills the OCCUPANCY[] array with the values “FREE”
Intent mapIntent � new Intent(Intent.ACTION_- or “OCCUPIED”.
VIEW, gmmIntentUri); public void getOccupancy(){
mapIntent.setPack- for(int i�0;i < 8;i++){
age(“com.google.android.apps.maps”) ;
System.out.println(places.substring(i, i + 1));
startActivity(mapIntent);
if(places.substring(i, i + 1).equals(“0”)){OCCU-
}
PANCY[i] � “FREE”;}
if(places.substring(i, i + 1).equals(“1”)){OCCU-
5.9. Information about the Parking Lot Occupancy. The in- PANCY[i] � “OCCUPIED”;}
formation about number of available and occupied parking if(places.substring(i + 8, i + 9).equals(“0”)){OC-
space is saved by NodeRED into the Firebase database, and in CUPANCY[i + 8] � “FREE”;}
the Android app, the instance of the database is created: if(places.substring(i + 8, i + 9).equals(“1”)){OC-
FirebaseDatabase database � FirebaseDatabase.getInstance(), CUPANCY[i + 8] � “OCCUPIED”;}
along with the references for its individual items: Data-
baseReference myRef. . . � database.getReference(“parkings/ NUMBERS[i] � i + 1;
parking1/. . .. . .. . .”). This is followed by the listener per- }
forming the corresponding actions every time a value changes }
in any of the values it is monitoring.
Afterwards, these values are in the adapter using listView
public void readFreePlaces(){ passed to individual textView (code: filling text boxes and
myRefFplaces.addValueEventListener(new Val- setting font color based on content), as is shown in the image
ueEventListener() { (Figure 16).
Mobile Information Systems 13
public View getView(int i, View view, ViewGroup androidID–unique 64-bit number generated by the
viewGroup) { Android OS
view- time–the time when the reservation is created
� getLayoutInflater().inflate(R.layout.customlayout,
Before creating a reservation, based on the Android ID, the
null);
app checks whether the user is already saved in the database
TextView (has a valid reservation or is already on the parking lot) (Sample
tvNumbers � view.findViewById(R.id.tvNumbers); 14) and if there are any spaces available for reservation on the
TextView parking lot (number of free spaces—number of valid reser-
tvOccupancy � view.findViewById(R.id.tvOccupancy); vations). If a reservation is possible, it asks the database for a
TextView tvOccu- new item id: id � myRefRes.push().getKey(). It then creates a
pancy1 � view.findViewById(R.id.tvOccupancy1) ; new instance of the Reservation class: myRe-
fRes.child(id).setValue(reservations; and finally, this newly
tvNumbers.setText(String.valueOf(NUMBERS
created instance is stored in the database (Figure 17): myRe-
[i]));
fRes.child(id).setValue(reservations) (code: determining the
tvOccupancy.setText(String.valueOf(OCCU- status of a user’s reservation).
PANCY[i]));
public void onDataChange(DataSnapshot snapshot) {
tvOccupancy1.setText(String.valueOf(OCCU-
PANCY[i+8])); countRes � snapshot.getChildrenCount();
if(OCCUPANCY[i].equals(“FREE”)){tvOccu- updateCountReservation();
pancy.setTextColor(Color.parseColor(“#00ff00”));} resIndicator � false;
if(OCCUPANCY[i].equals(“OCCUPIED”)){tvOccu- for (DataSnapshot postSnapshot: snapshot.getCh-
pancy.setTextColor(Color.parseColor(“#ff0000”));} ildren()) {
if(OCCUPANCY[i+8].equals(“FREE”)){tvOccu- Reservation
pancy1.setTextColor(Color.parseColor(“#00ff00”));} post � postSnapshot.getValue(Reservation.class);
if(OCCUPANCY[i+8].equals(“OCCUPIED”)){tvOc- String resCheck � post.getAndroidID();
cupancy1.setTextColor(Color.parseColor(“#ff0000”));} if(resCheck.equals(androidID)){resIn-
return view; dicator � true;}
} }
} }
The state of the reservations is regularly monitored also
by the mini PC via NodeRED, and if the time limit for the
5.10. Creating a Parking Space Reservation. Every driver can
reservation is exceeded, it is automatically removed from the
make one short-term reservation of one parking space. For
database. The reservation is removed also if a driver with a
this purpose, the app uses the Reservation.java class, which
valid reservation arrives on the parking lot and sends a
has three attributes:
request to open the entry gate. The procedure for removing
id–item ID generated by the Firebase database the reservation from the database is described later.
14 Mobile Information Systems
Parkings
Reservations
Parking1
-LYY5_Y2ueZ33fHK2Zq8
CarInPark
References
[1] A. Khanna and R. Anand, “IoT based smart parking system,”
in Proceedings of International Conference on Internet of
Things and Applications (IOTA), pp. 266–270, Pune, India,
January 2016.