Skip to content

Commit

Permalink
update to latest AIS-catcher version, 2 additional UDP channels, shar…
Browse files Browse the repository at this point in the history
…ing option
  • Loading branch information
jvde-github committed May 20, 2024
1 parent 648ff9a commit 0e2cba3
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 36 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "com.jvdegithub.aiscatcher"
minSdk 23
targetSdk 33
versionCode 92
versionName '0.92'
versionCode 95
versionName '0.95'

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/assets/webassets
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public interface AisCallback {

static native int createUDP(String h, String p);

static native int createSharing(boolean b, String key);


static native int getSampleRate();

static native String getRateDescription();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public void requestLocationUpdates() {
PERMISSION_REQUEST_CODE);
} else {
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5 * 60 * 1000, 0, this);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30 * 1000, 0, this);
isUpdatingLocation = true;
} else if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 5 * 60 * 1000, 0, this);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 30 * 1000, 0, this);
isUpdatingLocation = true;

Toast.makeText(context, "GPS not available. Using network for location updates.", Toast.LENGTH_LONG).show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public void setDarkMode(boolean only_force) {

private void onWeb () {

Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://localhost:" + port));
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://aiscatcher.org"));
startActivity(browserIntent);
}

Expand Down
40 changes: 39 additions & 1 deletion app/src/main/java/com/jvdegithub/aiscatcher/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ protected void onCreate(Bundle savedInstanceState) {
static void setDefault(Context context) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);

preferences.edit().putString("sSHARINGKEY", "").commit();
preferences.edit().putBoolean("sSHARING", false).commit();

preferences.edit().putString("oCGF_WIDE", "Default").commit();
preferences.edit().putString("oMODEL_TYPE", "Default").commit();
preferences.edit().putBoolean("oFP_DS", false).commit();
Expand Down Expand Up @@ -87,6 +90,15 @@ static void setDefault(Context context) {
preferences.edit().putString("u2HOST", "127.0.0.1").commit();
preferences.edit().putString("u2PORT", "10111").commit();

preferences.edit().putBoolean("u3SWITCH", false).commit();
preferences.edit().putString("u3HOST", "127.0.0.1").commit();
preferences.edit().putString("u3PORT", "10111").commit();

preferences.edit().putBoolean("u4SWITCH", false).commit();
preferences.edit().putString("u4HOST", "127.0.0.1").commit();
preferences.edit().putString("u4PORT", "10111").commit();


preferences.edit().putInt("mLINEARITY", 17).commit();
preferences.edit().putString("mRATE", "2500K").commit();
preferences.edit().putBoolean("mBIASTEE", false).commit();
Expand Down Expand Up @@ -117,8 +129,12 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
((EditTextPreference) getPreferenceManager().findPreference("tHOST")).setOnBindEditTextListener(validateIP);
((EditTextPreference) getPreferenceManager().findPreference("u1HOST")).setOnBindEditTextListener(validateIP);
((EditTextPreference) getPreferenceManager().findPreference("u2HOST")).setOnBindEditTextListener(validateIP);
((EditTextPreference) getPreferenceManager().findPreference("u3HOST")).setOnBindEditTextListener(validateIP);
((EditTextPreference) getPreferenceManager().findPreference("u4HOST")).setOnBindEditTextListener(validateIP);
((EditTextPreference) getPreferenceManager().findPreference("u1PORT")).setOnBindEditTextListener(validatePort);
((EditTextPreference) getPreferenceManager().findPreference("u2PORT")).setOnBindEditTextListener(validatePort);
((EditTextPreference) getPreferenceManager().findPreference("u3PORT")).setOnBindEditTextListener(validatePort);
((EditTextPreference) getPreferenceManager().findPreference("u4PORT")).setOnBindEditTextListener(validatePort);
((SeekBarPreference) getPreferenceManager().findPreference("mLINEARITY")).setUpdatesContinuously(true);

setSummaries();
Expand All @@ -131,7 +147,7 @@ static public int getModelType(Context context)
}

private void setSummaries() {
setSummaryText(new String[]{"tPORT","tHOST","sPORT","sHOST","u1HOST","u1PORT","u2HOST","u2PORT", "rFREQOFFSET"});
setSummaryText(new String[]{"tPORT","tHOST","sPORT","sHOST","u1HOST","u1PORT","u2HOST","u2PORT", "u3HOST","u3PORT", "u4HOST","u4PORT", "rFREQOFFSET", "sSHARINGKEY"});
setSummaryList(new String[]{"rTUNER","rRATE","sRATE","tRATE","tPROTOCOL","tTUNER","mRATE","hRATE","oMODEL_TYPE","oCGF_WIDE"});
setSummarySeekbar(new String[]{"mLINEARITY", "sGAIN"});
}
Expand Down Expand Up @@ -250,6 +266,11 @@ static public boolean Apply(Context context) {

if (!SetUDPoutput("u1", context)) return false;
if (!SetUDPoutput("u2", context)) return false;
if (!SetUDPoutput("u3", context)) return false;
if (!SetUDPoutput("u4", context)) return false;

if(!SetSharing(context)) return false;

return true;
}

Expand Down Expand Up @@ -339,4 +360,21 @@ static private boolean SetUDPoutput(String s, Context context) {
}
return true;
}
static private boolean SetSharing(Context context) {
String defaultKey = "a6392e08-c57e-4e7a-a4fb-d73bfc7619ae";

SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);

boolean b = preferences.getBoolean("sSHARING", false);
if (b) {
String key = preferences.getString("sSHARINGKEY", defaultKey);
if (key.equals("")) key = defaultKey;
return AisCatcherJava.createSharing(b, key) == 0;

}
else
AisCatcherJava.createSharing(b, defaultKey);
return true;
}

}
2 changes: 1 addition & 1 deletion app/src/main/jni/AIS-catcher
Submodule AIS-catcher updated 95 files
+22 −30 .github/workflows/build.yml
+4 −3 Application/AIS-catcher.h
+28 −1 Application/Config.cpp
+3 −2 Application/Config.h
+105 −18 Application/Main.cpp
+129 −0 Application/Prometheus.cpp
+57 −0 Application/Prometheus.h
+41 −8 Application/Receiver.cpp
+18 −13 Application/Receiver.h
+349 −138 Application/WebViewer.cpp
+11 −37 Application/WebViewer.h
+42 −14 CMakeLists.txt
+2 −2 DBMS/PostgreSQL.cpp
+2 −2 DBMS/PostgreSQL.h
+2 −2 DSP/DSP.cpp
+28 −7 DSP/DSP.h
+1 −1 DSP/Demod.h
+21 −3 DSP/Model.cpp
+16 −2 DSP/Model.h
+0 −2 Device/AIRSPY.cpp
+1 −1 Device/AIRSPY.h
+2 −1 Device/Device.h
+1 −1 Device/FileRAW.cpp
+1 −1 Device/FileWAV.cpp
+1 −1 Device/HACKRF.cpp
+1 −1 Device/HACKRF.h
+63 −0 Device/N2KsktCAN.cpp
+71 −0 Device/N2KsktCAN.h
+4 −4 Device/RTLSDR.cpp
+4 −4 Device/RTLSDR.h
+29 −11 Device/RTLTCP.cpp
+6 −2 Device/RTLTCP.h
+39 −4 Device/Serial.cpp
+3 −5 Device/SpyServer.cpp
+3 −3 Device/UDP.cpp
+1 −1 Device/UDP.h
+2 −2 Device/ZMQ.h
+20 −3 Dockerfile
+0 −3,923 HTML/HTML.cpp
+0 −3,919 HTML/HTML_local.cpp
+620 −2 HTML/favicon.cpp
+1,113 −6,740 HTML/index.html
+741 −0 HTML/index_html.cpp
+1,113 −6,740 HTML/index_local.html
+739 −0 HTML/index_local_html.cpp
+4,732 −0 HTML/script.js
+2,837 −0 HTML/script_js.cpp
+2,233 −0 HTML/style.css
+2,385 −0 HTML/style_css.cpp
+5 −4 IO/HTTPClient.cpp
+7 −1 IO/HTTPClient.h
+60 −19 IO/HTTPServer.cpp
+49 −35 IO/HTTPServer.h
+55 −12 IO/IO.h
+218 −0 IO/N2KInterface.cpp
+136 −0 IO/N2KInterface.h
+774 −0 IO/N2KStream.cpp
+74 −0 IO/N2KStream.h
+27 −3 IO/Network.cpp
+1 −0 IO/Network.h
+17 −1 JSON/Parser.cpp
+69 −8 Library/Common.h
+83 −44 Library/JSONAIS.cpp
+2 −2 Library/JSONAIS.h
+6 −0 Library/Keys.cpp
+6 −0 Library/Keys.h
+79 −2 Library/Message.cpp
+7 −1 Library/Message.h
+432 −0 Library/N2K.cpp
+47 −0 Library/N2K.h
+221 −118 Library/NMEA.cpp
+6 −4 Library/NMEA.h
+2 −1 Library/Signals.h
+6 −1 Library/Stream.h
+34 −15 Library/TCP.cpp
+4 −0 Library/TCP.h
+70 −4 Library/Utilities.cpp
+34 −1 Library/Utilities.h
+30 −0 Library/ZIP.h
+2 −2 Makefile
+238 −137 README.md
+95 −14 Ships/DB.cpp
+14 −61 Ships/DB.h
+6 −4 Ships/History.h
+387 −0 Ships/Ships.cpp
+57 −0 Ships/Ships.h
+10 −36 Ships/Statistics.h
+19 −0 build.NMEA2000
+53 −0 build.html
+17 −0 build.me
+6 −0 msvc/AIS-catcher RTLSDR.vcxproj
+1 −1 plugins/google_option.pjs
+1 −1 plugins/marinetraffic_option.pjs
+1 −1 plugins/shipxplorer_option.pjs
+1 −1 plugins/vesselfinder_option.pjs
4 changes: 2 additions & 2 deletions app/src/main/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ add_library( # Sets the name of the library.
./airspyhf/libairspyhf/src/airspyhf.c
./airspyhf/libairspyhf/src/iqbalancer.c

./AIS-catcher/Application/Receiver.cpp ./AIS-catcher/Application/Config.cpp ./AIS-catcher/Ships/DB.cpp ./AIS-catcher/DBMS/PostgreSQL.cpp
./AIS-catcher/Application/Receiver.cpp ./AIS-catcher/Application/Config.cpp ./AIS-catcher/Ships/DB.cpp ./AIS-catcher/Ships/Ships.cpp ./AIS-catcher/DBMS/PostgreSQL.cpp
./AIS-catcher/Device/AIRSPYHF.cpp ./AIS-catcher/Device/FileWAV.cpp ./AIS-catcher/Device/RTLSDR.cpp ./AIS-catcher/Device/SDRPLAY.cpp ./AIS-catcher/DSP/Demod.cpp ./AIS-catcher/DSP/Model.cpp
./AIS-catcher/Library/AIS.cpp ./AIS-catcher/Library/JSONAIS.cpp ./AIS-catcher/Library/Keys.cpp ./AIS-catcher/IO/HTTPClient.cpp
./AIS-catcher/Device/FileRAW.cpp ./AIS-catcher/Device/HACKRF.cpp ./AIS-catcher/Device/UDP.cpp ./AIS-catcher/Device/RTLTCP.cpp
./AIS-catcher/Device/ZMQ.cpp ./AIS-catcher/Device/SoapySDR.cpp ./AIS-catcher/Device/SpyServer.cpp ./AIS-catcher/Library/Message.cpp ./AIS-catcher/Library/NMEA.cpp
./AIS-catcher/Library/Utilities.cpp ./AIS-catcher/Library/TCP.cpp ./AIS-catcher/JSON/JSON.cpp ./AIS-catcher/IO/Network.cpp ./AIS-catcher/IO/HTTPServer.cpp
./AIS-catcher/JSON/StringBuilder.cpp ./AIS-catcher/JSON/Parser.cpp ./AIS-catcher/Device/AIRSPY.cpp ./AIS-catcher/Device/Serial.cpp
./AIS-catcher/DSP/DSP.cpp ./AIS-catcher/IO/IO.cpp ./AIS-catcher/Application/WebViewer.cpp
./AIS-catcher/DSP/DSP.cpp ./AIS-catcher/IO/IO.cpp ./AIS-catcher/Application/WebViewer.cpp ./AIS-catcher/Application/Prometheus.cpp

JNI/AIScatcherNDK.cpp)

Expand Down
75 changes: 52 additions & 23 deletions app/src/main/jni/JNI/AIScatcherNDK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,11 @@ struct Drivers {

//Device::Type type = Device::Type::NONE;
std::vector<IO::UDPStreamer > UDP_connections;
std::vector<IO::TCPClientStreamer > TCP_connections;
std::vector<std::string> UDPhost;
std::vector<std::string> UDPport;
bool sharing = false;
std::string sharingKey = "";

NMEAcounter NMEAcounter;
RAWcounter rawcounter;
Expand Down Expand Up @@ -309,8 +312,8 @@ Java_com_jvdegithub_aiscatcher_AisCatcherJava_applySetting(JNIEnv *env, jclass,

}

} catch (const char *msg) {
callbackError(env, msg);
} catch (std::exception& e) {
callbackError(env, e.what());
device = nullptr;
return -1;
}
Expand All @@ -328,13 +331,23 @@ Java_com_jvdegithub_aiscatcher_AisCatcherJava_Run(JNIEnv *env, jclass) {
tag.mode = 7;

try {
callbackConsole(env, "Creating output channels\n");
callbackConsole(env, "Creating UDP output channels\n");
UDP_connections.resize(UDPhost.size());
for (int i = 0; i < UDPhost.size(); i++) {
UDP_connections[i].Set("host",UDPhost[i]).Set("port",UDPport[i]);
UDP_connections[i].Start();
model->Output() >> UDP_connections[i];
}

if(sharing) {
callbackConsole(env, "Creating TCP output channels\n");
TCP_connections.resize(1);

TCP_connections[0].Set("HOST", "aiscatcher.org").Set("PORT", "4242").Set("JSON", "on").Set("FILTER", "on").Set("GPS", "off");
TCP_connections[0].Set("UUID", sharingKey);
TCP_connections[0].Start();
model->Output() >> TCP_connections[0];
}
callbackConsole(env, "Starting device\n");

device->setTag(tag);
Expand All @@ -357,8 +370,8 @@ Java_com_jvdegithub_aiscatcher_AisCatcherJava_Run(JNIEnv *env, jclass) {
}

}
catch (const char *msg) {
callbackError(env, msg);
catch (std::exception& e) {
callbackError(env, e.what());
}
catch (const std::exception &e) {
callbackError(env, e.what());
Expand All @@ -370,13 +383,14 @@ Java_com_jvdegithub_aiscatcher_AisCatcherJava_Run(JNIEnv *env, jclass) {
model->Output().out.clear();

for (auto &u: UDP_connections) u.Stop();
for (auto &t: TCP_connections) t.Stop();
UDP_connections.clear();
TCP_connections.clear();

UDPport.clear();
UDPhost.clear();


} catch (const char *msg) {
callbackError(env, msg);
} catch (std::exception& e) {
callbackError(env, e.what());
}

if (!stop) {
Expand All @@ -400,8 +414,8 @@ Java_com_jvdegithub_aiscatcher_AisCatcherJava_Close(JNIEnv *env, jclass) {
model = nullptr;
}
}
catch (const char *msg) {
callbackError(env, msg);
catch (std::exception& e) {
callbackError(env, e.what());
return -1;
}
return 0;
Expand Down Expand Up @@ -454,14 +468,9 @@ Java_com_jvdegithub_aiscatcher_AisCatcherJava_createReceiver(JNIEnv *env, jclass
device->OpenWithFileDescriptor(fd);
device->setFrequency(162000000);
}
catch (const char *msg) {
callbackError(env, msg);
device = nullptr;
return -1;
}
catch (const std::exception& e)
{
catch (std::exception& e) {
callbackError(env, e.what());
device = nullptr;
return -1;
}

Expand Down Expand Up @@ -504,8 +513,8 @@ Java_com_jvdegithub_aiscatcher_AisCatcherJava_createReceiver(JNIEnv *env, jclass
model->buildModel('A','B',device->getSampleRate(), false, device);
}

} catch (const char *msg) {
callbackError(env, msg);
} catch (std::exception& e) {
callbackError(env, e.what());
device = nullptr;
return -1;
}
Expand Down Expand Up @@ -536,13 +545,33 @@ Java_com_jvdegithub_aiscatcher_AisCatcherJava_createUDP(JNIEnv *env, jclass claz

callbackConsoleFormat(env, "UDP: %s %s\n", host.c_str(), port.c_str());

} catch (const char *msg) {
callbackError(env, msg);
} catch (std::exception& e) {
callbackError(env, e.what());
device = nullptr;
return -1;
}
return 0;
}

extern "C"
JNIEXPORT jint JNICALL
Java_com_jvdegithub_aiscatcher_AisCatcherJava_createSharing(JNIEnv *env, jclass clazz, jboolean b,
jstring k) {
if(b) {
jboolean isCopy;
std::string key = (env)->GetStringUTFChars(k, &isCopy);

sharing = communityFeed = true;
sharingKey = key;
callbackConsoleFormat(env, "Community Sharing: %s\n", key.c_str());
}
else {
sharing = communityFeed = false;
sharingKey = "";
}
return 0;
}

extern "C"
JNIEXPORT jint JNICALL
Java_com_jvdegithub_aiscatcher_AisCatcherJava_getSampleRate(JNIEnv *env, jclass clazz) {
Expand Down Expand Up @@ -620,4 +649,4 @@ extern "C"
JNIEXPORT jstring JNICALL
Java_com_jvdegithub_aiscatcher_AisCatcherJava_getRateDescription(JNIEnv *env, jclass clazz) {
return env->NewStringUTF(device->getRateDescription().c_str());
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/menu/bottom_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
android:id="@+id/action_web"
android:icon="@drawable/ic_baseline_web_asset_24"
android:orderInCategory="4"
android:title="Web Client" />
android:title="Community" />
</menu>
53 changes: 51 additions & 2 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@
android:key="system_category"
android:title="System">

<SwitchPreferenceCompat
android:key="sSHARING"
android:summary="Share AIS with aiscatcher.org"
android:defaultValue="False"
android:title="Community Share"/>

<EditTextPreference
android:key="sSHARINGKEY"
android:defaultValue=""
android:summary="Unique sharing key"
android:singleLine="true"
android:title="Sharing Key"/>

<SwitchPreferenceCompat
android:key="sFORCEDARK"
android:summary="Force app theme to Dark Mode"
Expand Down Expand Up @@ -211,8 +224,7 @@
<EditTextPreference
android:key="u2HOST"
android:dependency="u2SWITCH"
android:defaultValue="localhost"

android:defaultValue="127.0.0.1"
android:title="IP"/>

<EditTextPreference
Expand All @@ -221,6 +233,43 @@
android:defaultValue="4002"
android:title="Port"/>

<SwitchPreferenceCompat
android:key="u3SWITCH"
android:dependency="sSHARING"
android:defaultValue="False"
android:title="UDP Server 3"/>

<EditTextPreference
android:key="u3HOST"
android:dependency="u3SWITCH"
android:defaultValue="127.0.0.1"
android:title="IP"/>

<EditTextPreference
android:key="u3PORT"
android:dependency="u3SWITCH"
android:defaultValue="4002"
android:title="Port"/>

<SwitchPreferenceCompat
android:key="u4SWITCH"
android:dependency="sSHARING"
android:defaultValue="False"
android:title="UDP Server 4"/>

<EditTextPreference
android:key="u4HOST"
android:dependency="u4SWITCH"
android:defaultValue="127.0.0.1"
android:title="IP"/>

<EditTextPreference
android:key="u4PORT"
android:dependency="u4SWITCH"
android:defaultValue="4002"
android:title="Port"/>


</PreferenceCategory>

<PreferenceCategory
Expand Down

0 comments on commit 0e2cba3

Please sign in to comment.