├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.md ├── app ├── .gitignore ├── .idea │ ├── .gitignore │ ├── .name │ ├── compiler.xml │ ├── gradle.xml │ ├── jarRepositories.xml │ ├── misc.xml │ └── vcs.xml ├── app │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── bluebridgeapp │ │ │ └── ExampleInstrumentedTest.java │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── cpp │ │ │ ├── CMakeLists.txt │ │ │ └── bluebridgeapp.cpp │ │ ├── ic_launcher-playstore.png │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── bluebridgeapp │ │ │ │ ├── AnchorView.java │ │ │ │ ├── MainActivity.java │ │ │ │ ├── MqttSettingsDialogFragment.java │ │ │ │ ├── Settings.java │ │ │ │ └── Utils.java │ │ └── res │ │ │ ├── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── drawable │ │ │ ├── bluetooth.png │ │ │ ├── settings.png │ │ │ ├── strength0.png │ │ │ ├── strength1.png │ │ │ ├── strength2.png │ │ │ ├── strength3.png │ │ │ ├── strength4.png │ │ │ └── strength5.png │ │ │ ├── layout │ │ │ ├── activity_main.xml │ │ │ └── mqtt_settings_dialog.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ ├── ic_launcher_foreground.png │ │ │ └── ic_launcher_round.png │ │ │ ├── raw │ │ │ ├── beeper.mp3 │ │ │ └── ping.mp3 │ │ │ ├── values-night │ │ │ └── themes.xml │ │ │ └── values │ │ │ ├── colors.xml │ │ │ ├── ic_launcher_background.xml │ │ │ ├── strings.xml │ │ │ └── themes.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── bluebridgeapp │ │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle ├── components └── n2klib │ ├── ActisenseReader.cpp │ ├── CMakeLists.txt │ ├── N2kDeviceList.cpp │ ├── N2kGroupFunction.cpp │ ├── N2kGroupFunctionDefaultHandlers.cpp │ ├── N2kMaretron.cpp │ ├── N2kMessages.cpp │ ├── N2kMsg.cpp │ ├── N2kStream.cpp │ ├── NMEA2000.cpp │ ├── NMEA2000_esp32.cpp │ ├── RingBuffer.tpp │ ├── Seasmart.cpp │ └── include │ ├── ActisenseReader.h │ ├── ESP32_CAN_def.h │ ├── N2kCANMsg.h │ ├── N2kDef.h │ ├── N2kDeviceList.h │ ├── N2kGroupFunction.h │ ├── N2kGroupFunctionDefaultHandlers.h │ ├── N2kMaretron.h │ ├── N2kMessages.h │ ├── N2kMessagesEnumToStr.h │ ├── N2kMsg.h │ ├── N2kStream.h │ ├── N2kTypes.h │ ├── NMEA2000.h │ ├── NMEA2000StdTypes.h │ ├── NMEA2000_CAN.h │ ├── NMEA2000_CompilerDefns.h │ ├── NMEA2000_esp32.h │ ├── RingBuffer.h │ ├── Seasmart.h │ └── n2klib.h ├── doc ├── .gitignore ├── Doxyfile ├── SMS commands.docx └── dataflow.svg ├── hw ├── .gitignore ├── BlueBridge - PCB.pdf ├── BlueBridge - Project.pdf ├── BlueBridge.pcb ├── BlueBridge.prj ├── BlueBridge.sch └── bom.xlsx ├── main ├── CMakeLists.txt ├── WMM_COF.c ├── flash.c ├── flash.h ├── led.c ├── led.h ├── main.cpp ├── main.h ├── modem.c ├── modem.h ├── modem_interface.c ├── modem_interface.h ├── mqtt.c ├── mqtt.h ├── nmea.c ├── nmea.h ├── pdu.c ├── pdu.h ├── pressure_sensor.c ├── pressure_sensor.h ├── property_parser.c ├── property_parser.h ├── publisher.c ├── publisher.h ├── serial.c ├── serial.h ├── settings.c ├── settings.h ├── sms.c ├── sms.h ├── spp_acceptor.c ├── spp_acceptor.h ├── temperature_sensor.c ├── temperature_sensor.h ├── timer.c ├── timer.h ├── util.c ├── util.h ├── wmm.c └── wmm.h ├── sdkconfig.defaults ├── todo.txt └── website ├── Mapiator.js ├── images ├── strength0.png ├── strength1.png ├── strength2.png ├── strength3.png ├── strength4.png ├── strength5.png ├── zoomIn_blur.png ├── zoomIn_focus.png ├── zoomOut_blur.png └── zoomOut_focus.png ├── index.html ├── reativeAngleBg.bmp └── segment-display.js /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | sdkconfig 3 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | add_compile_definitions(ESP32) 3 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 4 | project(BlueBridge) 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 John Blaiklock 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | The user of this code is not a citizen, business or resident of Russia or Belarus. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 |

Blue Bridge

5 |

6 | 7 |

8 | 9 | The Blue Bridge project is a hardware device, embedded software, an Android application and a webpage for sharing of boat data to allow remote monitoring and anchor watching. Boat data are received from the boat's instruments via NMEA2000 and NMEA0183 connections and are then distributed via Bluetooth to local recipients or via the internet for remote recipients with internet access. Also included in the hardware are: an atmospheric pressure sensor which is shared both with the data recipients via Bluetooth and the internet and also the boat's NMEA2000 data network, and connections for a pair of PT-1000 sensors which measure the temperature inside 2 exhaust gas pipes the values of which are distrubted via NMEA2000. 10 | 11 | For local recipients the boat data are converted to NMEA0183 format and sent via a Bluetooth link to a local device. This could be a laptop, tablet or phone running a navigation software package (the format of the data are tailored for OpenCPN but will work with other navigation packages). Another recipient of the boat data over Bluetooth can be the Android anchor watching app that is part of this project. 12 | 13 | For remote recipients the boat data are sent out using a GSM modem with a data connection to a server on the internet. This server is a MQTT broker from which other internet connected devices can receive the data. Remote recipients of the data can be a webpage included as part of this project or the same Android anchor watching app mentioned above using an internet connection rather than a Bluetooth one. This allows remote monitoring of the boat's instruments and position using the webpage or 14 | remote anchor watching using the Android application. 15 | 16 | The diagram above shows the various connections. The hardware device has no user interface so is configured via SMS messages from any mobile phone. Details of these messages are under the docs folder. 17 | 18 | This is the webpage that is found under the webpage folder above: 19 |
20 | http://miniwinwm.000webhostapp.com/ 21 |

22 | This is the Android anchor watching app found under the app folder above built with Android Studio: 23 |

24 | 25 |

26 |
27 | This project using custom hardware running an ESP32 based DevKitC board. In addition to this are the following daughter boards: a BMP280 pressure sensor board, a SIM800L GSM modem board and a modem power supply board. The schematic and PCB layout are created in DesignSpark from RS. All hardware design files are found under the hw folder above. This is the hardware as assembled: 28 |

29 | 30 |

31 | Software development for the ESP32 is done using the Espressif ESP-IDF development environment. Currently the following data items are received by the NMEA2000 connection: depth, log, trip, boatspeed, wind direction, wind speed, GPS position, SoG, CoG, water temperature. The following data items are recived by the NMEA0183 connection: GPS position, SoG, CoG, AIS data. Either interface could be extended to receive further data items. 32 |

33 | This project has now reached first release and has been tested on a boat with a Raymarine NMEA2000/STNG based system. Bug fixing and minor changes and feature additions may still occur. To see a list of outstanding work and changes to come see todo.txt. 34 |

35 | Future additions: The latest hardware design has the option of fitting a RF transceiver module. This could be used to implement communication with a wireless remote control for an autopilot. 36 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /app/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /app/.idea/.name: -------------------------------------------------------------------------------- 1 | BlueBridgeApp -------------------------------------------------------------------------------- /app/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 19 | 20 | -------------------------------------------------------------------------------- /app/.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | -------------------------------------------------------------------------------- /app/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 24 | -------------------------------------------------------------------------------- /app/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | } 4 | 5 | android { 6 | compileSdk 32 7 | 8 | defaultConfig { 9 | applicationId "com.example.bluebridgeapp" 10 | minSdk 21 11 | targetSdk 32 12 | versionCode 1 13 | versionName "1.0" 14 | 15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 16 | externalNativeBuild { 17 | cmake { 18 | cppFlags '' 19 | } 20 | } 21 | } 22 | 23 | buildTypes { 24 | release { 25 | minifyEnabled false 26 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 27 | } 28 | } 29 | compileOptions { 30 | sourceCompatibility JavaVersion.VERSION_1_8 31 | targetCompatibility JavaVersion.VERSION_1_8 32 | } 33 | externalNativeBuild { 34 | cmake { 35 | path file('src/main/cpp/CMakeLists.txt') 36 | version '3.18.1' 37 | } 38 | } 39 | packagingOptions { 40 | exclude 'META-INF/INDEX.LIST' 41 | exclude 'META-INF/io.netty.versions.properties' 42 | } 43 | } 44 | 45 | dependencies { 46 | implementation 'com.hivemq:hivemq-mqtt-client:1.3.0' 47 | implementation 'androidx.appcompat:appcompat:1.4.1' 48 | implementation 'com.google.android.material:material:1.5.0' 49 | implementation 'androidx.constraintlayout:constraintlayout:2.1.3' 50 | testImplementation 'junit:junit:4.13.2' 51 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 52 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 53 | } -------------------------------------------------------------------------------- /app/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/app/src/androidTest/java/com/example/bluebridgeapp/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.example.bluebridgeapp; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.platform.app.InstrumentationRegistry; 6 | import androidx.test.ext.junit.runners.AndroidJUnit4; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 24 | assertEquals("com.example.bluebridgeapp", appContext.getPackageName()); 25 | } 26 | } -------------------------------------------------------------------------------- /app/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 17 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/app/src/main/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # For more information about using CMake with Android Studio, read the 3 | # documentation: https://d.android.com/studio/projects/add-native-code.html 4 | 5 | # Sets the minimum version of CMake required to build the native library. 6 | 7 | cmake_minimum_required(VERSION 3.18.1) 8 | 9 | # Declares and names the project. 10 | 11 | project("bluebridgeapp") 12 | 13 | # Creates and names a library, sets it as either STATIC 14 | # or SHARED, and provides the relative paths to its source code. 15 | # You can define multiple libraries, and CMake builds them for you. 16 | # Gradle automatically packages shared libraries with your APK. 17 | 18 | add_library( # Sets the name of the library. 19 | bluebridgeapp 20 | 21 | # Sets the library as a shared library. 22 | SHARED 23 | 24 | # Provides a relative path to your source file(s). 25 | bluebridgeapp.cpp 26 | ) 27 | 28 | # Searches for a specified prebuilt library and stores the path as a 29 | # variable. Because CMake includes system libraries in the search path by 30 | # default, you only need to specify the name of the public NDK library 31 | # you want to add. CMake verifies that the library exists before 32 | # completing its build. 33 | 34 | find_library( # Sets the name of the path variable. 35 | log-lib 36 | 37 | # Specifies the name of the NDK library that 38 | # you want CMake to locate. 39 | log ) 40 | 41 | # Specifies libraries CMake should link to your target library. You 42 | # can link multiple libraries, such as libraries you define in this 43 | # build script, prebuilt third-party libraries, or system libraries. 44 | 45 | target_link_libraries( # Specifies the target library. 46 | bluebridgeapp 47 | 48 | # Links the target library to the log library 49 | # included in the NDK. 50 | ${log-lib} ) 51 | -------------------------------------------------------------------------------- /app/app/src/main/cpp/bluebridgeapp.cpp: -------------------------------------------------------------------------------- 1 | // Write C++ code here. 2 | // 3 | // Do not forget to dynamically load the C++ library into your application. 4 | // 5 | // For instance, 6 | // 7 | // In MainActivity.java: 8 | // static { 9 | // System.loadLibrary("bluebridgeapp"); 10 | // } 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/app/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /app/app/src/main/java/com/example/bluebridgeapp/AnchorView.java: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) John Blaiklock 2022 BlueBridge 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | */ 24 | 25 | package com.example.bluebridgeapp; 26 | 27 | import android.content.Context; 28 | import android.content.DialogInterface; 29 | import android.graphics.Canvas; 30 | import android.graphics.Color; 31 | import android.graphics.Paint; 32 | import android.util.AttributeSet; 33 | import android.view.View; 34 | 35 | import androidx.appcompat.app.AlertDialog; 36 | 37 | public class AnchorView extends View { 38 | private static final int maxPosDiffMetresCount = 250; 39 | float[] xPosDiffsMetres; 40 | float[] yPosDiffsMetres; 41 | float groundWindAngle; 42 | int posDiffsMetresCount; 43 | int nextPosDiffMetresPos; 44 | AlertDialog alert; 45 | boolean drawGroundWindAngleRequired; 46 | 47 | public AnchorView(Context context, AttributeSet attrs) { 48 | super(context, attrs); 49 | Reset(); 50 | 51 | AlertDialog.Builder builder = new AlertDialog.Builder(context); 52 | builder.setMessage("Delete all existing points?"); 53 | builder.setCancelable(true); 54 | 55 | builder.setPositiveButton( 56 | "Yes", 57 | new DialogInterface.OnClickListener() { 58 | public void onClick(DialogInterface dialog, int id) { 59 | dialog.cancel(); 60 | Reset(); 61 | drawAnchorView(); 62 | } 63 | }); 64 | 65 | builder.setNegativeButton( 66 | "No", 67 | new DialogInterface.OnClickListener() { 68 | public void onClick(DialogInterface dialog, int id) { 69 | dialog.cancel(); 70 | } 71 | }); 72 | 73 | alert = builder.create(); 74 | 75 | setOnClickListener(new View.OnClickListener() { 76 | public void onClick(View v) { 77 | alert.show(); 78 | } 79 | }); 80 | } 81 | 82 | public void Reset() { 83 | xPosDiffsMetres = new float[maxPosDiffMetresCount]; 84 | yPosDiffsMetres = new float[maxPosDiffMetresCount]; 85 | posDiffsMetresCount = 0; 86 | nextPosDiffMetresPos = 0; 87 | } 88 | 89 | public void AddGroundWindAngle(float trueWindAngle) { 90 | this.groundWindAngle = trueWindAngle; 91 | drawGroundWindAngleRequired = true; 92 | } 93 | 94 | public void AddPosDiffMetres(float xDiffMetres, float yDiffMetres) { 95 | xPosDiffsMetres[nextPosDiffMetresPos] = xDiffMetres; 96 | yPosDiffsMetres[nextPosDiffMetresPos] = -yDiffMetres; 97 | posDiffsMetresCount++; 98 | if (posDiffsMetresCount > maxPosDiffMetresCount) { 99 | posDiffsMetresCount = maxPosDiffMetresCount; 100 | } 101 | nextPosDiffMetresPos++; 102 | if (nextPosDiffMetresPos == maxPosDiffMetresCount) { 103 | nextPosDiffMetresPos = 0; 104 | } 105 | } 106 | 107 | protected void onDraw(Canvas canvas) { 108 | super.onDraw(canvas); 109 | Paint paint = new Paint(); 110 | canvas.drawRGB(3, 119, 252); 111 | int width = getWidth(); 112 | int height = getHeight(); 113 | int widthHeightMin = Math.min(width, height); 114 | float pixelsPerMetre = (float)widthHeightMin / 200.0f; 115 | 116 | paint.setColor(Color.YELLOW); 117 | paint.setTextSize(20); 118 | canvas.drawText("25m", 10, 20, paint); 119 | canvas.drawLine(10, 30, 10 + pixelsPerMetre * 25, 30, paint); 120 | canvas.drawLine(10, 25, 10, 30, paint); 121 | canvas.drawLine(10 + pixelsPerMetre * 25, 25, 10 + pixelsPerMetre * 25, 30, paint); 122 | canvas.drawLine(width / 2 - 10, height / 2 - 10, width / 2 + 10, height / 2 + 10, paint); 123 | canvas.drawLine(width / 2 + 10, height / 2 - 10, width / 2 - 10, height / 2 + 10, paint); 124 | 125 | int i; 126 | paint.setColor(Color.BLACK); 127 | for (i = 0; i < posDiffsMetresCount - 1; i++) { 128 | canvas.drawPoint(width / 2 + xPosDiffsMetres[i] * pixelsPerMetre, 129 | height / 2 + yPosDiffsMetres[i] * pixelsPerMetre, paint); 130 | canvas.drawPoint(width / 2 + xPosDiffsMetres[i] * pixelsPerMetre - 1, 131 | height / 2 + yPosDiffsMetres[i] * pixelsPerMetre -1, paint); 132 | canvas.drawPoint(width / 2 + xPosDiffsMetres[i] * pixelsPerMetre + 1, 133 | height / 2 + yPosDiffsMetres[i] * pixelsPerMetre + 1, paint); 134 | canvas.drawPoint(width / 2 + xPosDiffsMetres[i] * pixelsPerMetre - 1, 135 | height / 2 + yPosDiffsMetres[i] * pixelsPerMetre + 1, paint); 136 | canvas.drawPoint(width / 2 + xPosDiffsMetres[i] * pixelsPerMetre + 1, 137 | height / 2 + yPosDiffsMetres[i] * pixelsPerMetre - 1, paint); 138 | } 139 | 140 | paint.setColor(Color.YELLOW); 141 | canvas.drawPoint(width / 2 + xPosDiffsMetres[i] * pixelsPerMetre, 142 | height / 2 + yPosDiffsMetres[i] * pixelsPerMetre, paint); 143 | canvas.drawPoint(width / 2 + xPosDiffsMetres[i] * pixelsPerMetre - 1, 144 | height / 2 + yPosDiffsMetres[i] * pixelsPerMetre -1, paint); 145 | canvas.drawPoint(width / 2 + xPosDiffsMetres[i] * pixelsPerMetre + 1, 146 | height / 2 + yPosDiffsMetres[i] * pixelsPerMetre + 1, paint); 147 | canvas.drawPoint(width / 2 + xPosDiffsMetres[i] * pixelsPerMetre - 1, 148 | height / 2 + yPosDiffsMetres[i] * pixelsPerMetre + 1, paint); 149 | canvas.drawPoint(width / 2 + xPosDiffsMetres[i] * pixelsPerMetre + 1, 150 | height / 2 + yPosDiffsMetres[i] * pixelsPerMetre - 1, paint); 151 | 152 | if (drawGroundWindAngleRequired) { 153 | drawGroundWindAngleRequired = false; 154 | 155 | paint.setAntiAlias(true); 156 | paint.setStrokeWidth(4f); 157 | paint.setStyle(Paint.Style.STROKE); 158 | 159 | float startX = width - 60.0f; 160 | float startY = height - 60.0f; 161 | float endX = startX + (float) (40.0 * Math.sin(Math.toRadians(groundWindAngle))); 162 | float endY = startY - (float) (40.0 * Math.cos(Math.toRadians(groundWindAngle))); 163 | canvas.drawLine(startX, startY, endX, endY, paint); 164 | 165 | float endX2 = startX + (float) (25.0 * Math.sin(Math.toRadians(groundWindAngle - 10.0f))); 166 | float endY2 = startY - (float) (25.0 * Math.cos(Math.toRadians(groundWindAngle - 10.0f))); 167 | canvas.drawLine(endX2, endY2, endX, endY, paint); 168 | float endX3 = startX + (float) (25.0 * Math.sin(Math.toRadians(groundWindAngle + 10.0f))); 169 | float endY3 = startY - (float) (25.0 * Math.cos(Math.toRadians(groundWindAngle + 10.0f))); 170 | canvas.drawLine(endX3, endY3, endX, endY, paint); 171 | } 172 | } 173 | 174 | public void drawAnchorView() { 175 | invalidate(); 176 | } 177 | } 178 | -------------------------------------------------------------------------------- /app/app/src/main/java/com/example/bluebridgeapp/MqttSettingsDialogFragment.java: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) John Blaiklock 2022 BlueBridge 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | */ 24 | 25 | package com.example.bluebridgeapp; 26 | 27 | import android.app.Dialog; 28 | import android.content.Context; 29 | import android.content.DialogInterface; 30 | import android.content.SharedPreferences; 31 | import android.os.Bundle; 32 | import android.text.Editable; 33 | import android.view.LayoutInflater; 34 | import android.view.View; 35 | import android.view.ViewGroup; 36 | import android.widget.CheckBox; 37 | import android.widget.EditText; 38 | import android.widget.RadioButton; 39 | import android.widget.TextView; 40 | 41 | import androidx.appcompat.app.AlertDialog; 42 | import androidx.fragment.app.DialogFragment; 43 | 44 | public class MqttSettingsDialogFragment extends DialogFragment { 45 | EditText codeEditText; 46 | EditText brokerEditText; 47 | EditText portEditText; 48 | RadioButton bluetoothRadioButton; 49 | RadioButton internetRadioButton; 50 | TextView codeTextView; 51 | TextView brokerTextView; 52 | TextView portTextView; 53 | CheckBox watchingPingCheckBox; 54 | Settings settings; 55 | 56 | public interface MqttSettingsDialogListener 57 | { 58 | public void onDialogPositiveClick(DialogFragment dialog); 59 | public void onDialogNegativeClick(DialogFragment dialog); 60 | } 61 | 62 | MqttSettingsDialogListener listener; 63 | 64 | public MqttSettingsDialogFragment(Settings settings) 65 | { 66 | this.settings = settings; 67 | } 68 | 69 | public void onAttach(Context context) 70 | { 71 | super.onAttach(context); 72 | try 73 | { 74 | listener = (MqttSettingsDialogListener)context; 75 | } 76 | catch (ClassCastException e) 77 | { 78 | // The activity doesn't implement the interface 79 | } 80 | } 81 | 82 | public Dialog onCreateDialog(Bundle savedInstanceState) { 83 | AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 84 | LayoutInflater inflater = requireActivity().getLayoutInflater(); 85 | View view = inflater.inflate(R.layout.mqtt_settings_dialog, null); 86 | 87 | codeEditText = (EditText)view.findViewById(R.id.codeEditText); 88 | brokerEditText = (EditText)view.findViewById(R.id.brokerEditText); 89 | portEditText = (EditText)view.findViewById(R.id.portEditText); 90 | bluetoothRadioButton = (RadioButton)view.findViewById(R.id.bluetoothRadioButton); 91 | internetRadioButton = (RadioButton)view.findViewById(R.id.internetRadioButton); 92 | codeTextView = (TextView)view.findViewById(R.id.codeTextView); 93 | brokerTextView = (TextView)view.findViewById(R.id.brokerTextView); 94 | portTextView = (TextView)view.findViewById(R.id.portTextView); 95 | watchingPingCheckBox = (CheckBox)view.findViewById(R.id.watchingPingCheckBox); 96 | 97 | bluetoothRadioButton.setOnClickListener(new View.OnClickListener() 98 | { 99 | public void onClick(View v) 100 | { 101 | codeEditText.setEnabled(false); 102 | brokerEditText.setEnabled(false); 103 | portEditText.setEnabled(false); 104 | codeTextView.setEnabled(false); 105 | brokerTextView.setEnabled(false); 106 | portTextView.setEnabled(false); 107 | } 108 | }); 109 | 110 | internetRadioButton.setOnClickListener(new View.OnClickListener() 111 | { 112 | public void onClick(View v) 113 | { 114 | codeEditText.setEnabled(true); 115 | brokerEditText.setEnabled(true); 116 | portEditText.setEnabled(true); 117 | codeTextView.setEnabled(true); 118 | brokerTextView.setEnabled(true); 119 | portTextView.setEnabled(true); 120 | } 121 | }); 122 | 123 | codeEditText.setText(settings.getCodeHexString()); 124 | brokerEditText.setText(settings.getBroker()); 125 | portEditText.setText(String.format("%d", settings.getPort())); 126 | if (settings.getConnectionType() == ConnectionType.BLUETOOTH) { 127 | bluetoothRadioButton.setChecked(true); 128 | internetRadioButton.setChecked(false); 129 | codeEditText.setEnabled(false); 130 | brokerEditText.setEnabled(false); 131 | portEditText.setEnabled(false); 132 | codeTextView.setEnabled(false); 133 | brokerTextView.setEnabled(false); 134 | portTextView.setEnabled(false); 135 | } else { 136 | bluetoothRadioButton.setChecked(false); 137 | internetRadioButton.setChecked(true); 138 | codeEditText.setEnabled(true); 139 | brokerEditText.setEnabled(true); 140 | portEditText.setEnabled(true); 141 | codeTextView.setEnabled(true); 142 | brokerTextView.setEnabled(true); 143 | portTextView.setEnabled(true); 144 | } 145 | watchingPingCheckBox.setChecked(settings.getWatchingPing()); 146 | 147 | builder.setView(view) 148 | .setPositiveButton("OK", new DialogInterface.OnClickListener() { 149 | public void onClick(DialogInterface dialog, int id) { 150 | settings.setCodeHexString(codeEditText.getText().toString()); 151 | settings.setBroker(brokerEditText.getText().toString()); 152 | settings.setPort(portEditText.getText().toString()); 153 | settings.setConnectionType(bluetoothRadioButton.isChecked() ? ConnectionType.BLUETOOTH : ConnectionType.INTERNET); 154 | settings.setWatchingPing(watchingPingCheckBox.isChecked()); 155 | listener.onDialogPositiveClick(MqttSettingsDialogFragment.this); 156 | } 157 | }) 158 | .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { 159 | public void onClick(DialogInterface dialog, int id) { 160 | MqttSettingsDialogFragment.this.getDialog().cancel(); 161 | } 162 | }); 163 | 164 | return builder.create(); 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /app/app/src/main/java/com/example/bluebridgeapp/Utils.java: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) John Blaiklock 2022 BlueBridge 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | */ 24 | 25 | package com.example.bluebridgeapp; 26 | 27 | import android.app.Activity; 28 | import android.view.inputmethod.InputMethodManager; 29 | 30 | public class Utils { 31 | public final static float DEGREES_TO_RADS = 57.296f; 32 | 33 | /** 34 | * Calculate distance in metres between 2 points coordinates in degrees 35 | * 36 | * @param lat1 Latitude of first point in degrees 37 | * @param long1 longitude of first point in degrees 38 | * @param lat2 Latitude of second point in degrees 39 | * @param long2 longitude of second point in degrees 40 | * @return Distance between points in m 41 | * */ 42 | public static float DistanceBetweenPoints(float lat1, float long1, float lat2, float long2) 43 | { 44 | float half_dlat; 45 | float half_dlong; 46 | float a; 47 | float c; 48 | 49 | lat1 /= DEGREES_TO_RADS; 50 | long1 /= DEGREES_TO_RADS; 51 | lat2 /= DEGREES_TO_RADS; 52 | long2 /= DEGREES_TO_RADS; 53 | half_dlat = (lat2 - lat1) / 2.0f; 54 | half_dlong = (long2 - long1) / 2.0f; 55 | a = (float)(Math.sin(half_dlat) * Math.sin(half_dlat) + Math.sin(half_dlong) * Math.sin(half_dlong) * Math.cos(lat1) * Math.cos(lat2)); 56 | c = 2.0f * (float)(Math.atan2(Math.sqrt(a), Math.sqrt(1.0f - a))); 57 | 58 | return 6371000.0f * c; 59 | } 60 | 61 | /** 62 | * Hide the soft keyboard shown when text input is expected 63 | * 64 | * @param activity The activity owning the input control corresponding to the soft keyboard 65 | */ 66 | public static void hideSoftKeyboard(Activity activity) { 67 | InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE); 68 | if (activity.getCurrentFocus() != null) { 69 | if (inputMethodManager.isAcceptingText()) { 70 | inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(),0); 71 | } 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /app/app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 9 | 10 | 16 | 19 | 22 | 23 | 24 | 25 | 31 | -------------------------------------------------------------------------------- /app/app/src/main/res/drawable/bluetooth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/drawable/bluetooth.png -------------------------------------------------------------------------------- /app/app/src/main/res/drawable/settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/drawable/settings.png -------------------------------------------------------------------------------- /app/app/src/main/res/drawable/strength0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/drawable/strength0.png -------------------------------------------------------------------------------- /app/app/src/main/res/drawable/strength1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/drawable/strength1.png -------------------------------------------------------------------------------- /app/app/src/main/res/drawable/strength2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/drawable/strength2.png -------------------------------------------------------------------------------- /app/app/src/main/res/drawable/strength3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/drawable/strength3.png -------------------------------------------------------------------------------- /app/app/src/main/res/drawable/strength4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/drawable/strength4.png -------------------------------------------------------------------------------- /app/app/src/main/res/drawable/strength5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/drawable/strength5.png -------------------------------------------------------------------------------- /app/app/src/main/res/layout/mqtt_settings_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 26 | 27 | 31 | 32 | 38 | 39 | 49 | 50 | 56 | 57 | 68 | 69 | 75 | 76 | 87 | 88 | 94 | 95 | 99 | 100 | 106 | 107 | 113 | 114 | 115 | 121 | 122 | 127 | -------------------------------------------------------------------------------- /app/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/app/src/main/res/raw/beeper.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/raw/beeper.mp3 -------------------------------------------------------------------------------- /app/app/src/main/res/raw/ping.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/app/src/main/res/raw/ping.mp3 -------------------------------------------------------------------------------- /app/app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /app/app/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFFFFF 4 | -------------------------------------------------------------------------------- /app/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Blue Bridge 3 | -------------------------------------------------------------------------------- /app/app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/app/src/test/java/com/example/bluebridgeapp/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.example.bluebridgeapp; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | plugins { 3 | id 'com.android.application' version '7.1.2' apply false 4 | id 'com.android.library' version '7.1.2' apply false 5 | } 6 | 7 | task clean(type: Delete) { 8 | delete rootProject.buildDir 9 | } -------------------------------------------------------------------------------- /app/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Enables namespacing of each library's R class so that its R class includes only the 19 | # resources declared in the library itself and none from the library's dependencies, 20 | # thereby reducing the size of the R class for that library 21 | android.nonTransitiveRClass=true -------------------------------------------------------------------------------- /app/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miniwinwm/BlueBridge/8222e5194dd167519d65d60fea6bcfdc094eb5f6/app/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Mar 03 19:03:20 GMT 2022 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /app/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /app/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /app/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | google() 5 | mavenCentral() 6 | } 7 | } 8 | dependencyResolutionManagement { 9 | repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS) 10 | repositories { 11 | google() 12 | mavenCentral() 13 | } 14 | } 15 | rootProject.name = "BlueBridgeApp" 16 | include ':app' 17 | -------------------------------------------------------------------------------- /components/n2klib/ActisenseReader.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ActisenseReader.cpp 3 | 4 | Copyright (c) 2015-2021 Timo Lappalainen, Kave Oy, www.kave.fi 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | this software and associated documentation files (the "Software"), to deal in 8 | the Software without restriction, including without limitation the rights to use, 9 | copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the 10 | Software, and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 20 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 21 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | 24 | This is class for reading Actisense format messages from given stream. 25 | */ 26 | #include "ActisenseReader.h" 27 | #include 28 | 29 | //***************************************************************************** 30 | tActisenseReader::tActisenseReader() { 31 | DefaultSource=65; 32 | ReadStream=0; 33 | ClearBuffer(); 34 | } 35 | 36 | //***************************************************************************** 37 | void tActisenseReader::ClearBuffer() { 38 | MsgWritePos=0; 39 | byteSum=0; 40 | StartOfTextReceived=false; 41 | MsgIsComing=false; 42 | EscapeReceived=false; 43 | } 44 | 45 | //***************************************************************************** 46 | bool tActisenseReader::AddByteToBuffer(char NewByte) { 47 | if (MsgWritePos>=MAX_STREAM_MSG_BUF_LEN) return false; 48 | 49 | MsgBuf[MsgWritePos]=NewByte; 50 | MsgWritePos++; 51 | if ( MsgBuf[1]+3!=MsgWritePos ) byteSum+=NewByte; // !Do not add CRC to byteSum 52 | return true; 53 | } 54 | 55 | #define Escape 0x10 56 | #define StartOfText 0x02 57 | #define EndOfText 0x03 58 | #define MsgTypeN2kData 0x93 59 | #define MsgTypeN2kRequest 0x94 60 | 61 | //***************************************************************************** 62 | bool tActisenseReader::CheckMessage(tN2kMsg &N2kMsg) { 63 | 64 | N2kMsg.Clear(); 65 | 66 | if (MsgWritePos!=MsgBuf[1]+3) { 67 | return false; // Length does not match. Add type, length and crc 68 | } 69 | 70 | uint8_t CheckSum = (uint8_t)((byteSum == 0) ? 0 : (256 - byteSum)); 71 | if ( CheckSum!=MsgBuf[MsgWritePos-1] ) { 72 | return false; // Checksum does not match 73 | } 74 | 75 | int i=2; 76 | N2kMsg.Priority=MsgBuf[i++]; 77 | N2kMsg.PGN=GetBuf3ByteUInt(i,MsgBuf); 78 | N2kMsg.Destination=MsgBuf[i++]; 79 | if ( MsgBuf[0]==MsgTypeN2kData ) { 80 | N2kMsg.Source=MsgBuf[i++]; 81 | N2kMsg.MsgTime=GetBuf4ByteUInt(i,MsgBuf); 82 | } else { 83 | N2kMsg.Source=DefaultSource; 84 | N2kMsg.MsgTime=millis(); 85 | } 86 | N2kMsg.DataLen=MsgBuf[i++]; 87 | 88 | if ( N2kMsg.DataLen>tN2kMsg::MaxDataLen ) { 89 | N2kMsg.Clear(); 90 | return false; // Too long data 91 | } 92 | 93 | for (int j=0; i<02><93>