A collision and avoidance detection system.
-
The main thread is responsible for synchronizing the android application. During the initialization the application asks for permissions. The android version used for the development was the Android 7 thus permissions must be asked runtime. Using the
getMacAddress()
method the topic at which the android client will be subscribed is initialized. At this point the main activity boots the mqtt client and defines a number ofOnClickListeners
to buttons. The application's interface also includes asettings
button that opens a new layout. This layout contains three buttons to solely grant permissions from the user and an interface for text input. Lastly there is an option to exit the application. -
The main thread's context is passed as an argument to the
AndroidMqttClient
constructor. Even though the client is a non-activity class by using the above method it can produce messages in the application's interface. The constructor of a handler is then called and the MainLooper of the UIThread is passed as an argument. This way the main thread can queue runnables that are about to be executed. The new mqtt client can now connect to the broker and subscribe to the topic that is defined by the mac address of the android terminal. When the subscription is completed a timer starts adding runnables to the queue. One runnable will be added per 2 seconds. This time period value is called "Data Intervals" and can be set in the settings interface of the application. The mqtt client through the context of the main activity and using the methodgetAssets()
sends random files (from the training set) towards the edge server. Using aByteArrayOutputStream
and aByteBuffer
the client sends the name of the file, the mac address of the android terminal itself, the data of the randomly chosen csv file, and theFILE
identifier to the edge server. In case the android mqtt client disconnects from the broker the timer stops and no data is transmitted. Lastly, the client tries to reconnect by calling theAndroidMqttClient
constructor. -
- For the android mqtt client implementation libraries org.eclipse.paho.client.mqttv3 and org.eclipse.paho.android.service were used.
- For the android interface library com.android.support was used and the testing framework junit.
- For the gps tracking implementation com.google.android.gms library was used.
-
The backhaul server initially is responsible for developing the training set of the model which will later be sent to the edge server. The entropy is calculated for each channel in each csv file in the directory Training Set. The entropy values along with the experiment's name "Eyes Closed" or "Eyes Opened" are then copied in the file training_set.csv. When all experiments are processed the file is ready to be sent to the edge server. For the
DataExtraction
implementation library MIToolboxJava was used and the JavaSDK. -
After the training_set.csv file is created the backhaul server boots the websocket server and waits for the edge server to connect. Using the annotation
@OnWebSocketConnect
the backhaul server is informed about incoming connections and using@OnWebSocketMessage
it receives client messages. When the backhaul server receives the "Hello Backhaul Server" message from the edge server it sends the contents of the training_set.csv file. When the edge server disconnects from the websocket the backhaul server is informed through the@OnWebSocketClose
and terminates the websocket server. For the websocket client implementation jetty-runner-9.4.6.v20170531 library was used along with the JavaSDK. - Following the websocket connection and the training_set.csv file upload, the backhaul server initializes the connection to the database. The connection is achieved using the jdbc driver and by using the correct username, password, and database URL. For the jdbc driver implementation mysql-connector-java-8.0.13.jar library was used along with the JavaSDK.
-
DatabaseElement
Class: This class defines 4 public String variables and a constructor with a String input argument. During the object's instantiation the input String is split into 4 substrings assigned to the 4 public String variables.DatabaseConnection
Class: This class oversees the connection to the SQL database and defines 3 static String variables and a subclassconnect
. It connects to the database and dumps theDatabaseElement
Strings in it.
-
Initialy the edge server must connect to the backhaul server and download the training_set.csv file. When the websocket server is ready the edge server connects as a client using the "ws://localhost:8080"
URI
. When the connection to the websocket server is completed the edge server sends a simple "Hello Backhaul Server" message, downloads the training_set.csv data using the annotationOnWebSocketMessage
and stores the data in a new file. Then the edge server closes the session and sends to the backhaul server aStatusCode
and a termination message. For the websocket client implementation jetty-runner-9.4.6.v20170531 library was used along with the JavaSDK.