# Towards an Indoor Gunshot Detection and Notification System Using Deep Learning
## 3 Materials and Methods
### Firmware
#### 3.2.3 Smartphone App  
Two smartphone apps are developed for the Android platform: for users and emergency responders. These apps contain a settings window where the user's or emergency responder's information, as shown in user_tbl and er_tbl namely in Figure 6, can be entered. The UserID and the ERID, which are the unique Android IDs [61] of the smartphones, and the FCMID, which is the FCM registration token [62], are assigned automatically without manual input.  
The main difference between these two apps is that the user app contains options for configuring their devices, whereas the emergency responder app does not contain options for device configuration as they are not users of any device. The setting window contains a custom list view that shows the list of devices the user has. New devices can be added and existing devices can be edited or removed from here. The properties of these devices, as shown in device_tbl in Figure 6, can be updated by selecting the device. To make the device location input process easier: the smartphone can be placed near the device, and the GPS location and address information can be retrieved automatically using the GeoLocation [69] library. The Wi-Fi configuration of the device, as discussed in Section 3.2.1 in Firmware, is implemented with GUI in the app. It contains a window where nearby Bluetooth devices can be searched and connections can be made. The device must be paired with the smartphone before connection. After connecting: the Bluetooth MAC address is assigned as the DeviceSN, the list of available Wi-Fi SSIDs is retrieved from the device and shown in the app, and the user can choose the desired SSID and provide a password--as discussed in Section 3.2.1 in Firmware. When the app leaves the setting window: the smartphone connects with the central server using the Internet as a client and sends the configuration data using a socket that updates the database in the server.  
Once the Wi-Fi of the device is configured, the smartphone app obtains the local IP of the device. Using the local IP and the HTTP server port of the device, the gunshot sounds recorded in the device can be accessed and played from the smartphone.  
The first screen of these apps contains a list of gunshot events showing the device name and serial number; its location; and the date and time of the event. These apps are registered in the FCM [70] dashboard for receiving push notifications. In this application, there is a background service called FirebaseMessaging [71]. When this service receives a push notification message from Firebase Cloud Messaging (FCM), it triggers a callback function. Subsequently, the app performs several actions, including adding the received message to a list, saving the list to a file, generating a smartphone notification, and updating the list view on the screen. If the user clicks on any item in the list view, the application opens Google Maps, setting the destination to the gunshot detector device's current location. This feature enables the user or an emergency responder to navigate to the site promptly.