# Situational Awareness: Mapping Interference Sources in Real-Time Using a Smartphone App
## 3 NGeneApp: An Android-Based Real Time RFI Detector for Smartphones
### General Overview of the Development Work  
Portability, compatibility, and flexibility are the three key drivers for the choice of the target smartphone used to develop NGeneApp. Among all the OSs currently available in the market place, Android OS grants the highest level of flexibility and portability. Since Android is an open platform based on the Linux kernel, developers can even access the file system if they have root permission; furthermore, the massive number of Android devices with several hardware capabilities and featuresis an advantage in terms of development support and tools stability. On the other side, the hardware compatibility with respect to the original source code is highly desired to ease the porting procedure. From all these considerations and after a scouting the market, to compare different solutions in terms of performance, power consumption and price, the Samsung Galaxy S6 has been selected as target smartphone: it features a 64-bit Exynos 7 Octa 7420 system-on-chip, which consists of a Quad Core 2.1 GHz Cortex-A57 and a Quad Core 1.5 GHz Cortex-A53. The choice of the ARM family as processor architecture allows the full portability of the Single-Instruction Multiple-Data (SIMD) NEON instructions exploited by the original source code to satisfy real-time requirements. The entire development work was performed on a laptop PC, running Windows 10 OS, using Android Studio, which is the official Integrated Development Environment (IDE) for building app on Android devices.  
Although based on the Linux kernel, Android OS shows one main difference compared to most of desktop Linux distributions: the default factory configuration does not grant root access to the OS. NGeneApp, on the contrary, requires administrator privilege in order to read raw samples coming from the USB-based FE through libusb library functions calls. Thus, the 'rooting' procedure was the first necessary step in the development chain. The second step of the porting procedure was the compilation of the original code on the target platform: the native code can be called in Android application through the Java Native Interface (JNI); Android Studio provides the Native Development Kit (NDK) toolset to compile C and C++ code into a native library and packs it into an Android Package Kit (APK) using Gradle, the IDE's integrated build system. After the resolution of some libusb compatibility issues, the porting of the whole native code (ANSI-C and assembly) was accomplished. At this point, the two functionalities that distinguish NGeneApp have been implemented in the form of two additional software modules: the remote server communication and the RFI detection. The communication between NGeneApp and the server is established by using the TCP/IP protocol via network sockets. NGeneApp acts as a client, sending the request to the server every five seconds until the connection is established. After the communication initialization, NGeneApp sends a data message to the control server every second. The connection with the server, which is actually a PC located at ISMB premises, is set up through the smartphone data uplink, exploiting both Wi-Fi and the cellular network, i.e., mainly 4G Global System for Mobile Communication (GSM). The detailed description of the adopted RFI algorithms, coded in ANSI-C, is deferred to Section 4. The next two sections describe respectively the high-level architecture of NGeneApp including the list of main functionalities, and the smartphone-dependent optimizations implemented to fully exploit the hardware resources.