-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds CSV logging for GSM, CDMA, UMTS, NR, Bluetooth, and GNSS
- Loading branch information
1 parent
a38f0bd
commit f59f2aa
Showing
19 changed files
with
986 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...rksurvey/src/main/java/com/craxiom/networksurvey/constants/csv/BluetoothCsvConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.craxiom.networksurvey.constants.csv; | ||
|
||
/** | ||
* The constants associated with the Bluetooth CSV file headers. | ||
* <p> | ||
* The constants in this class are intended to match the constants defined in the | ||
* <a href="https://messaging.networksurvey.app/">Network Survey Messaging API</a>. | ||
*/ | ||
public class BluetoothCsvConstants extends SurveyCsvConstants | ||
{ | ||
private BluetoothCsvConstants() | ||
{ | ||
} | ||
|
||
public static final String SOURCE_ADDRESS = "sourceAddress"; | ||
public static final String DESTINATION_ADDRESS = "destinationAddress"; | ||
public static final String SIGNAL_STRENGTH = "signalStrength"; | ||
public static final String TX_POWER = "txPower"; | ||
public static final String TECHNOLOGY = "technology"; | ||
public static final String SUPPORTED_TECHNOLOGIES = "supportedTechnologies"; | ||
public static final String OTA_DEVICE_NAME = "otaDeviceName"; | ||
public static final String CHANNEL = "channel"; | ||
} |
23 changes: 23 additions & 0 deletions
23
networksurvey/src/main/java/com/craxiom/networksurvey/constants/csv/CdmaCsvConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.craxiom.networksurvey.constants.csv; | ||
|
||
/** | ||
* The constants associated with the CDMA CSV file headers. | ||
* <p> | ||
* The constants in this class are intended to match the constants defined in the | ||
* <a href="https://messaging.networksurvey.app/">Network Survey Messaging API</a>. | ||
*/ | ||
public class CdmaCsvConstants extends CellularCsvConstants | ||
{ | ||
private CdmaCsvConstants() | ||
{ | ||
} | ||
|
||
public static final String SID = "sid"; | ||
public static final String NID = "nid"; | ||
public static final String ZONE = "zone"; | ||
public static final String BSID = "bsid"; | ||
public static final String CHANNEL = "channel"; | ||
public static final String PN_OFFSET = "pnOffset"; | ||
public static final String SIGNAL_STRENGTH = "signalStrength"; | ||
public static final String ECIO = "ecio"; | ||
} |
30 changes: 30 additions & 0 deletions
30
networksurvey/src/main/java/com/craxiom/networksurvey/constants/csv/GnssCsvConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.craxiom.networksurvey.constants.csv; | ||
|
||
/** | ||
* The constants associated with the GNSS CSV file headers. | ||
* <p> | ||
* The constants in this class are intended to match the constants defined in the | ||
* <a href="https://messaging.networksurvey.app/">Network Survey Messaging API</a>. | ||
*/ | ||
public class GnssCsvConstants extends SurveyCsvConstants | ||
{ | ||
private GnssCsvConstants() | ||
{ | ||
} | ||
|
||
public static final String GROUP_NUMBER = "groupNumber"; | ||
|
||
public static final String CONSTELLATION = "constellation"; | ||
public static final String SPACE_VEHICLE_ID = "spaceVehicleId"; | ||
public static final String CARRIER_FREQ_HZ = "carrierFreqHz"; | ||
public static final String CLOCK_OFFSET = "clockOffset"; | ||
public static final String USED_IN_SOLUTION = "usedInSolution"; | ||
public static final String UNDULATION_M = "undulationM"; | ||
public static final String LATITUDE_STD_DEV_M = "latitudeStdDevM"; | ||
public static final String LONGITUDE_STD_DEV_M = "longitudeStdDevM"; | ||
public static final String ALTITUDE_STD_DEV_M = "altitudeStdDevM"; | ||
public static final String AGC_DB = "agcDb"; | ||
public static final String CN0_DB_HZ = "cn0DbHz"; | ||
public static final String HDOP = "hdop"; | ||
public static final String VDOP = "vdop"; | ||
} |
23 changes: 23 additions & 0 deletions
23
networksurvey/src/main/java/com/craxiom/networksurvey/constants/csv/GsmCsvConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.craxiom.networksurvey.constants.csv; | ||
|
||
/** | ||
* The constants associated with the GSM CSV file headers. | ||
* <p> | ||
* The constants in this class are intended to match the constants defined in the | ||
* <a href="https://messaging.networksurvey.app/">Network Survey Messaging API</a>. | ||
*/ | ||
public class GsmCsvConstants extends CellularCsvConstants | ||
{ | ||
private GsmCsvConstants() | ||
{ | ||
} | ||
|
||
public static final String MCC = "mcc"; | ||
public static final String MNC = "mnc"; | ||
public static final String LAC = "lac"; | ||
public static final String CI = "ci"; | ||
public static final String ARFCN = "arfcn"; | ||
public static final String BSIC = "bsic"; | ||
public static final String SIGNAL_STRENGTH = "signalStrength"; | ||
public static final String TA = "ta"; | ||
} |
28 changes: 28 additions & 0 deletions
28
networksurvey/src/main/java/com/craxiom/networksurvey/constants/csv/NrCsvConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.craxiom.networksurvey.constants.csv; | ||
|
||
/** | ||
* The constants associated with the 5G NR CSV file headers. | ||
* <p> | ||
* The constants in this class are intended to match the constants defined in the | ||
* <a href="https://messaging.networksurvey.app/">Network Survey Messaging API</a>. | ||
*/ | ||
public class NrCsvConstants extends CellularCsvConstants | ||
{ | ||
private NrCsvConstants() | ||
{ | ||
} | ||
|
||
public static final String MCC = "mcc"; | ||
public static final String MNC = "mnc"; | ||
public static final String TAC = "tac"; | ||
public static final String NCI = "nci"; | ||
public static final String NARFCN = "narfcn"; | ||
public static final String PCI = "pci"; | ||
public static final String SS_RSRP = "ssRsrp"; | ||
public static final String SS_RSRQ = "ssRsrq"; | ||
public static final String SS_SINR = "ssSinr"; | ||
public static final String CSI_RSRP = "csiRsrp"; | ||
public static final String CSI_RSRQ = "csiRsrq"; | ||
public static final String CSI_SINR = "csiSinr"; | ||
public static final String TA = "ta"; | ||
} |
24 changes: 24 additions & 0 deletions
24
networksurvey/src/main/java/com/craxiom/networksurvey/constants/csv/UmtsCsvConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.craxiom.networksurvey.constants.csv; | ||
|
||
/** | ||
* The constants associated with the UMTS CSV file headers. | ||
* <p> | ||
* The constants in this class are intended to match the constants defined in the | ||
* <a href="https://messaging.networksurvey.app/">Network Survey Messaging API</a>. | ||
*/ | ||
public class UmtsCsvConstants extends CellularCsvConstants | ||
{ | ||
private UmtsCsvConstants() | ||
{ | ||
} | ||
|
||
public static final String MCC = "mcc"; | ||
public static final String MNC = "mnc"; | ||
public static final String LAC = "lac"; | ||
public static final String CID = "cid"; | ||
public static final String UARFCN = "uarfcn"; | ||
public static final String PSC = "psc"; | ||
public static final String RSCP = "rscp"; | ||
public static final String ECNO = "ecno"; | ||
public static final String SIGNAL_STRENGTH = "signalStrength"; | ||
} |
122 changes: 122 additions & 0 deletions
122
networksurvey/src/main/java/com/craxiom/networksurvey/logging/BluetoothCsvLogger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
package com.craxiom.networksurvey.logging; | ||
|
||
import static com.craxiom.networksurvey.constants.csv.BluetoothCsvConstants.ACCURACY; | ||
import static com.craxiom.networksurvey.constants.csv.BluetoothCsvConstants.ALTITUDE; | ||
import static com.craxiom.networksurvey.constants.csv.BluetoothCsvConstants.CHANNEL; | ||
import static com.craxiom.networksurvey.constants.csv.BluetoothCsvConstants.DESTINATION_ADDRESS; | ||
import static com.craxiom.networksurvey.constants.csv.BluetoothCsvConstants.DEVICE_TIME; | ||
import static com.craxiom.networksurvey.constants.csv.BluetoothCsvConstants.LATITUDE; | ||
import static com.craxiom.networksurvey.constants.csv.BluetoothCsvConstants.LONGITUDE; | ||
import static com.craxiom.networksurvey.constants.csv.BluetoothCsvConstants.MISSION_ID; | ||
import static com.craxiom.networksurvey.constants.csv.BluetoothCsvConstants.OTA_DEVICE_NAME; | ||
import static com.craxiom.networksurvey.constants.csv.BluetoothCsvConstants.RECORD_NUMBER; | ||
import static com.craxiom.networksurvey.constants.csv.BluetoothCsvConstants.SIGNAL_STRENGTH; | ||
import static com.craxiom.networksurvey.constants.csv.BluetoothCsvConstants.SOURCE_ADDRESS; | ||
import static com.craxiom.networksurvey.constants.csv.BluetoothCsvConstants.SPEED; | ||
import static com.craxiom.networksurvey.constants.csv.BluetoothCsvConstants.SUPPORTED_TECHNOLOGIES; | ||
import static com.craxiom.networksurvey.constants.csv.BluetoothCsvConstants.TECHNOLOGY; | ||
import static com.craxiom.networksurvey.constants.csv.BluetoothCsvConstants.TX_POWER; | ||
|
||
import android.os.Looper; | ||
|
||
import com.craxiom.messaging.BluetoothRecord; | ||
import com.craxiom.messaging.BluetoothRecordData; | ||
import com.craxiom.messaging.bluetooth.SupportedTechnologies; | ||
import com.craxiom.messaging.bluetooth.Technology; | ||
import com.craxiom.networksurvey.constants.NetworkSurveyConstants; | ||
import com.craxiom.networksurvey.listeners.IBluetoothSurveyRecordListener; | ||
import com.craxiom.networksurvey.services.NetworkSurveyService; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import timber.log.Timber; | ||
|
||
/** | ||
* Responsible for taking in Bluetooth survey records and logging them to a CSV file. | ||
*/ | ||
public class BluetoothCsvLogger extends CsvRecordLogger implements IBluetoothSurveyRecordListener | ||
{ | ||
public BluetoothCsvLogger(NetworkSurveyService networkSurveyService, Looper serviceLooper) | ||
{ | ||
super(networkSurveyService, serviceLooper, NetworkSurveyConstants.CSV_LOG_DIRECTORY_NAME, | ||
NetworkSurveyConstants.BLUETOOTH_FILE_NAME_PREFIX, true); | ||
} | ||
|
||
@Override | ||
String[] getHeaders() | ||
{ | ||
return new String[]{DEVICE_TIME, LATITUDE, LONGITUDE, ALTITUDE, SPEED, ACCURACY, | ||
MISSION_ID, RECORD_NUMBER, | ||
SOURCE_ADDRESS, DESTINATION_ADDRESS, SIGNAL_STRENGTH, TX_POWER, TECHNOLOGY, | ||
SUPPORTED_TECHNOLOGIES, OTA_DEVICE_NAME, CHANNEL}; | ||
} | ||
|
||
@Override | ||
String[] getHeaderComments() | ||
{ | ||
return new String[]{"CSV Version=0.1.0"}; | ||
} | ||
|
||
@Override | ||
public void onBluetoothSurveyRecord(BluetoothRecord bluetoothRecord) | ||
{ | ||
try | ||
{ | ||
writeCsvRecord(convertToObjectArray(bluetoothRecord), false); | ||
} catch (IOException e) | ||
{ | ||
Timber.e(e, "Could not log the Bluetooth record to the CSV file"); | ||
} | ||
} | ||
|
||
@Override | ||
public void onBluetoothSurveyRecords(List<BluetoothRecord> bluetoothRecords) | ||
{ | ||
bluetoothRecords.forEach(record -> { | ||
try | ||
{ | ||
writeCsvRecord(convertToObjectArray(record), false); | ||
} catch (IOException e) | ||
{ | ||
Timber.e(e, "Could not log the Bluetooth record to the CSV file"); | ||
} | ||
}); | ||
|
||
try | ||
{ | ||
printer.flush(); | ||
} catch (IOException e) | ||
{ | ||
Timber.e(e, "Could not flush the Bluetooth records to the CSV file"); | ||
} | ||
} | ||
|
||
/** | ||
* @return A String array that contains the LTE record values that can be written out as a CSV | ||
* row. | ||
*/ | ||
private String[] convertToObjectArray(BluetoothRecord record) | ||
{ | ||
BluetoothRecordData data = record.getData(); | ||
|
||
return new String[]{ | ||
data.getDeviceTime(), | ||
String.valueOf(data.getLatitude()), | ||
String.valueOf(data.getLongitude()), | ||
String.valueOf(data.getAltitude()), | ||
String.valueOf(data.getSpeed()), | ||
String.valueOf(data.getAccuracy()), | ||
data.getMissionId(), | ||
String.valueOf(data.getRecordNumber()), | ||
data.getSourceAddress(), | ||
data.getDestinationAddress(), | ||
data.hasSignalStrength() ? String.valueOf(data.getSignalStrength().getValue()) : "", | ||
data.hasTxPower() ? String.valueOf(data.getTxPower().getValue()) : "", | ||
data.getTechnology() == Technology.UNRECOGNIZED ? "" : data.getTechnology().name(), | ||
data.getSupportedTechnologies() == SupportedTechnologies.UNRECOGNIZED ? "" : data.getSupportedTechnologies().name(), | ||
data.getOtaDeviceName(), | ||
data.hasChannel() ? String.valueOf(data.getChannel().getValue()) : "" | ||
}; | ||
} | ||
} |
101 changes: 101 additions & 0 deletions
101
networksurvey/src/main/java/com/craxiom/networksurvey/logging/CdmaCsvLogger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package com.craxiom.networksurvey.logging; | ||
|
||
import static com.craxiom.networksurvey.constants.csv.CdmaCsvConstants.ACCURACY; | ||
import static com.craxiom.networksurvey.constants.csv.CdmaCsvConstants.ALTITUDE; | ||
import static com.craxiom.networksurvey.constants.csv.CdmaCsvConstants.BSID; | ||
import static com.craxiom.networksurvey.constants.csv.CdmaCsvConstants.CHANNEL; | ||
import static com.craxiom.networksurvey.constants.csv.CdmaCsvConstants.DEVICE_TIME; | ||
import static com.craxiom.networksurvey.constants.csv.CdmaCsvConstants.ECIO; | ||
import static com.craxiom.networksurvey.constants.csv.CdmaCsvConstants.GROUP_NUMBER; | ||
import static com.craxiom.networksurvey.constants.csv.CdmaCsvConstants.LATITUDE; | ||
import static com.craxiom.networksurvey.constants.csv.CdmaCsvConstants.LONGITUDE; | ||
import static com.craxiom.networksurvey.constants.csv.CdmaCsvConstants.MISSION_ID; | ||
import static com.craxiom.networksurvey.constants.csv.CdmaCsvConstants.NID; | ||
import static com.craxiom.networksurvey.constants.csv.CdmaCsvConstants.PN_OFFSET; | ||
import static com.craxiom.networksurvey.constants.csv.CdmaCsvConstants.PROVIDER; | ||
import static com.craxiom.networksurvey.constants.csv.CdmaCsvConstants.RECORD_NUMBER; | ||
import static com.craxiom.networksurvey.constants.csv.CdmaCsvConstants.SERVING_CELL; | ||
import static com.craxiom.networksurvey.constants.csv.CdmaCsvConstants.SID; | ||
import static com.craxiom.networksurvey.constants.csv.CdmaCsvConstants.SIGNAL_STRENGTH; | ||
import static com.craxiom.networksurvey.constants.csv.CdmaCsvConstants.SPEED; | ||
import static com.craxiom.networksurvey.constants.csv.CdmaCsvConstants.ZONE; | ||
|
||
import android.os.Looper; | ||
|
||
import com.craxiom.messaging.CdmaRecord; | ||
import com.craxiom.messaging.CdmaRecordData; | ||
import com.craxiom.networksurvey.constants.NetworkSurveyConstants; | ||
import com.craxiom.networksurvey.listeners.ICellularSurveyRecordListener; | ||
import com.craxiom.networksurvey.services.NetworkSurveyService; | ||
|
||
import java.io.IOException; | ||
|
||
import timber.log.Timber; | ||
|
||
/** | ||
* Responsible for taking in CDMA survey records and logging them to a CSV file. | ||
*/ | ||
public class CdmaCsvLogger extends CsvRecordLogger implements ICellularSurveyRecordListener | ||
{ | ||
public CdmaCsvLogger(NetworkSurveyService networkSurveyService, Looper serviceLooper) | ||
{ | ||
super(networkSurveyService, serviceLooper, NetworkSurveyConstants.CSV_LOG_DIRECTORY_NAME, | ||
NetworkSurveyConstants.CDMA_FILE_NAME_PREFIX, true); | ||
} | ||
|
||
@Override | ||
String[] getHeaders() | ||
{ | ||
return new String[]{DEVICE_TIME, LATITUDE, LONGITUDE, ALTITUDE, SPEED, ACCURACY, | ||
MISSION_ID, RECORD_NUMBER, GROUP_NUMBER, | ||
SID, NID, ZONE, BSID, CHANNEL, PN_OFFSET, SIGNAL_STRENGTH, ECIO, SERVING_CELL, PROVIDER}; | ||
} | ||
|
||
@Override | ||
String[] getHeaderComments() | ||
{ | ||
return new String[]{"CSV Version=0.1.0"}; | ||
} | ||
|
||
@Override | ||
public synchronized void onCdmaSurveyRecord(CdmaRecord record) | ||
{ | ||
try | ||
{ | ||
writeCsvRecord(convertToObjectArray(record), true); | ||
} catch (IOException e) | ||
{ | ||
Timber.e(e, "Could not log the CDMA record to the CSV file"); | ||
} | ||
} | ||
|
||
/** | ||
* @return A String array that contains the CDMA record values that can be written out as a CSV | ||
* row. | ||
*/ | ||
private String[] convertToObjectArray(CdmaRecord record) | ||
{ | ||
CdmaRecordData data = record.getData(); | ||
|
||
return new String[]{ | ||
data.getDeviceTime(), | ||
String.valueOf(data.getLatitude()), | ||
String.valueOf(data.getLongitude()), | ||
String.valueOf(data.getAltitude()), | ||
String.valueOf(data.getSpeed()), | ||
String.valueOf(data.getAccuracy()), | ||
data.getMissionId(), | ||
String.valueOf(data.getRecordNumber()), | ||
String.valueOf(data.getGroupNumber()), | ||
data.hasSid() ? String.valueOf(data.getSid().getValue()) : "", | ||
data.hasNid() ? String.valueOf(data.getNid().getValue()) : "", | ||
data.hasZone() ? String.valueOf(data.getZone().getValue()) : "", | ||
data.hasBsid() ? String.valueOf(data.getBsid().getValue()) : "", | ||
data.hasChannel() ? String.valueOf(data.getChannel().getValue()) : "", | ||
data.hasPnOffset() ? String.valueOf(data.getPnOffset().getValue()) : "", | ||
data.hasSignalStrength() ? String.valueOf(data.getSignalStrength().getValue()) : "", | ||
data.hasEcio() ? String.valueOf(data.getEcio().getValue()) : "", | ||
data.hasServingCell() ? String.valueOf(data.getServingCell().getValue()) : "", | ||
data.getProvider()}; | ||
} | ||
} |
Oops, something went wrong.