Skip to content

Commit

Permalink
1.0.13
Browse files Browse the repository at this point in the history
Added "Team Color" by leveraging the NodeInfo long name.

Append " -[0-9]" to your node's long name and the plugin will map these values to the team colors as defined in the atak.proto
  • Loading branch information
niccellular committed Apr 30, 2024
1 parent d77f5b2 commit bf665ed
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
buildscript {


ext.PLUGIN_VERSION = "1.0.12"
ext.PLUGIN_VERSION = "1.0.13"
ext.ATAK_VERSION = "4.10.0"

def takdevVersion = '2.+'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import android.preference.PreferenceManager;

import com.atakmap.android.cot.CotMapComponent;
import com.atakmap.android.editableShapes.EditablePolyline;
import com.atakmap.android.maps.MapView;
import com.atakmap.coremap.cot.event.CotDetail;
import com.atakmap.coremap.cot.event.CotEvent;
Expand Down Expand Up @@ -98,24 +99,87 @@ public void onReceive(Context context, Intent intent) {
NodeInfo ni = intent.getParcelableExtra("com.geeksville.mesh.NodeInfo");
if (ni == null) return;
Log.d(TAG, ni.toString());
if (ni.getUser() == null) return;
if (ni.getPosition() == null) return;
if (ni.getPosition().getLatitude() == 0 && ni.getPosition().getLongitude() == 0) return;

String longName = ni.getUser().getLongName();
CotDetail groupDetail = new CotDetail("__group");

try {
String teamColor = longName.split("((?= -[0-9]?$))")[1];
Log.d(TAG, "Team Color: " + teamColor);
groupDetail.setAttribute("role", "Team Member");
switch (teamColor) {
case " -0":
case " -1":
groupDetail.setAttribute("name", "White");
break;
case " -2":
groupDetail.setAttribute("name", "Yellow");
break;
case " -3":
groupDetail.setAttribute("name", "Orange");
break;
case " -4":
groupDetail.setAttribute("name", "Magenta");
break;
case " -5":
groupDetail.setAttribute("name", "Red");
break;
case " -6":
groupDetail.setAttribute("name", "Maroon");
break;
case " -7":
groupDetail.setAttribute("name", "Purple");
break;
case " -8":
groupDetail.setAttribute("name", "Dark Blue");
break;
case " -9":
groupDetail.setAttribute("name", "Blue");
break;
case " -10":
groupDetail.setAttribute("name", "Cyan");
break;
case " -11":
groupDetail.setAttribute("name", "Teal");
break;
case " -12":
groupDetail.setAttribute("name", "Green");
break;
case " -13":
groupDetail.setAttribute("name", "Dark Green");
break;
case " -14":
groupDetail.setAttribute("name", "Brown");
break;
default:
groupDetail.setAttribute("name", "Black");
break;
}
} catch (Exception e) {
e.printStackTrace();
return;
}

if (prefs.getBoolean("plugin_meshtastic_tracker", false)) {
Log.d(TAG, "Sending CoT for NodeInfo");
CotEvent cotEvent = new CotEvent();
CoordinatedTime time = new CoordinatedTime();
cotEvent.setTime(time);
cotEvent.setStart(time);
cotEvent.setStale(time.addMinutes(10));
if (ni.getUser() == null) return;
cotEvent.setUID(ni.getUser().getLongName());
if (ni.getPosition() == null) return;
if (ni.getPosition().getLatitude() == 0 || ni.getPosition().getLongitude() == 0) return;

cotEvent.setUID(longName.replaceAll(" -[0-9]*$",""));
CotPoint gp = new CotPoint(ni.getPosition().getLatitude(), ni.getPosition().getLongitude(), ni.getPosition().getAltitude(), CotPoint.UNKNOWN, CotPoint.UNKNOWN);
cotEvent.setPoint(gp);
cotEvent.setHow("m-g");
cotEvent.setType("a-f-G-E-S");

CotDetail cotDetail = new CotDetail("detail");
cotEvent.setDetail(cotDetail);
cotDetail.addChild(groupDetail);
CotDetail remarksDetail = new CotDetail("remarks");
remarksDetail.setInnerText(ni.toString());
cotDetail.addChild(remarksDetail);
Expand Down

0 comments on commit bf665ed

Please sign in to comment.