# Towards an Indoor Gunshot Detection and Notification System Using Deep Learning
## 3 Materials and Methods
### Firmware
#### 3.2.2 Central Server Software  
The software implements an SQL database. The database tables, their fields, and their relationships are shown in Figure 6. In Figure 6, the primary key of each table is marked using a key sign on the left side of the field name; and the lines indicate relationships between a primary key field at the left and a foreign key field at the right. The user_tbl table contains the customer or the user information such as name, address, email, and phone. The user's smartphone's Android ID [61] is used as the unique UserID. One user can have several smartphones and each smartphone app is treated as a separate user. To send notifications to the user's smartphone in the event of a gunshot, the Firebase Cloud Messaging (FCM) registration token [62] is stored in this table in the FCMID field. A unique Android ID and a unique FCM registration token are generated for each user when the person installs the smartphone app. The device_tbl table contains the device information. As discussed in Section 3.2.1. in Firmware the Bluetooth MAC address is used as the unique device serial number and it is stored in the DeviceSN field. The location information of the device such as latitude and longitude, address, floor, and room are stored in this table so that emergency responders can quickly go to the place where the gunshot is detected. Users can assign a nickname to the device and it is stored in the Name field. The local IP of the device is stored in the IP field. The user_device_tbl connects the users and the devices. One user can have multiple devices installed, such as in several rooms in a building. One device can have multiple users, such as each family member in a home. Thus, there could be a many-to-many relationship between users and devices. Each row of this table connects a user with a device using the UserID and DeviceSN namely. The ID field of this table is an autoincrement primary key field. The er_tbl table contains a list of emergency responder's information such as ERID, FCMID, name, address, email, and phone. Similar to the user table, ERID stores the Android ID, and the FCMID stores the FCM registration token. The event_data_tbl table contains information on each gunshot event such as the serial number of the device where the gunshot is detected, date, time, and location information of the device. This table keeps track of all the gunshot events and can be used for querying data. Data Processing in TCP Server  
The central server implements a Transmission Control Protocol (TCP) server [63] and listens at port 8050. Connecting the gunshot detector devices or smartphones to this server necessitates a stable public IP address and an accessible port. The router's public IP, provided by the Internet service provider (ISP), typically remains constant and serves as the fixed public IP. To facilitate the transmission of incoming data packets from the Internet to our custom TCP server port, we set a static local IP for the server computer and configure port forwarding [64] on the router. Additionally, the port number is opened in the Firewall settings [65]. The TCP server receives user and device configuration data, emergency responder configuration data from smartphones; and gunshot notification data from gunshot detector devices. The first byte of the data indicates whether it is user and device configuration data, emergency responder configuration data, or gunshot notification data. The handling of these three kinds of data is briefly described below. User and device configuration data: The user and device configuration data string contains: each field value of the user_tbl; the total number of devices; and each field value of the device_tbl for each device. Each field value is separated by a vertical line character, \(|\), instead of a comma because a comma could be part of the 'address' field of a user. When the data arrive at the server: the data are parsed, saved in variables, and stored in the  
Figure 6: Tables, fields, and relationships of the database.