Packet dumper outputs data in TNC2 format now. Make raw packet serializable and used that to send it with broadcast reciever.
Packet dumper outputs data in TNC2 format now. Make raw packet serializable and used that to send it with broadcast reciever.

--- a/src/com/dryerzinia/aprs_x/data_model/packet/RawPacket.java
+++ b/src/com/dryerzinia/aprs_x/data_model/packet/RawPacket.java
@@ -1,8 +1,12 @@
 package com.dryerzinia.aprs_x.data_model.packet;
 
+import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.List;
 
-public class RawPacket {
+public class RawPacket implements Serializable {
+
+	private static final long serialVersionUID = 1167807283105252815L;
 
 	private long id;
 
@@ -15,7 +19,7 @@
 
 	private byte[] data;
 
-	private APRSExtendedData exData;
+	private transient APRSExtendedData exData;
 
 	public long getID(){
 		
@@ -32,6 +36,12 @@
 	public String getDestinationAddress() {
 
 		return destinationAddress;
+
+	}
+
+	public List<String> getRepeaterAddress() {
+
+		return repeaterAddresses;
 
 	}
 
@@ -102,7 +112,25 @@
 	@Override
 	public String toString() {
 
-		return "";
+		// TNC2 format
+
+		String s = sourceAddress + ">" + destinationAddress;
+
+		for(int i = 0; i < repeaterAddresses.size(); i++)
+			s += "," + repeaterAddresses.get(i);
+		s += ":";
+
+		for(int i = 16 + (7 * repeaterAddresses.size()); i < data.length - 2; i++){
+
+			char c = (char) data[i];
+			if(c >= 32 && c <= 126)
+				s += c;
+			else
+				s += '.';
+
+		}
+
+		return s;
 
 	}
 

--- a/src/com/dryerzinia/aprs_x/db/table/RawPacketTable.java
+++ b/src/com/dryerzinia/aprs_x/db/table/RawPacketTable.java
@@ -2,6 +2,7 @@
 

 import java.util.Arrays;

 import java.util.HashSet;

+import java.util.List;

 

 import com.dryerzinia.aprs_x.data_model.packet.RawPacket;

 

@@ -115,6 +116,25 @@
 		values.put(RawPacketTable.COLUMN_SOURCE_ADDRESS, pkt.getSourceAddress());

 		values.put(RawPacketTable.COLUMN_DESTINATION_ADDRESS, pkt.getDestinationAddress());

 

+		List<String> repeaterAddresses = pkt.getRepeaterAddress();

+

+		if(repeaterAddresses.size() >= 1)

+			values.put(RawPacketTable.COLUMN_REPEATER_1_ADDRESS, repeaterAddresses.get(0));

+		if(repeaterAddresses.size() >= 2)

+			values.put(RawPacketTable.COLUMN_REPEATER_2_ADDRESS, repeaterAddresses.get(1));

+		if(repeaterAddresses.size() >= 3)

+			values.put(RawPacketTable.COLUMN_REPEATER_3_ADDRESS, repeaterAddresses.get(2));

+		if(repeaterAddresses.size() >= 4)

+			values.put(RawPacketTable.COLUMN_REPEATER_4_ADDRESS, repeaterAddresses.get(3));

+		if(repeaterAddresses.size() >= 5)

+			values.put(RawPacketTable.COLUMN_REPEATER_5_ADDRESS, repeaterAddresses.get(4));

+		if(repeaterAddresses.size() >= 6)

+			values.put(RawPacketTable.COLUMN_REPEATER_6_ADDRESS, repeaterAddresses.get(5));

+		if(repeaterAddresses.size() >= 7)

+			values.put(RawPacketTable.COLUMN_REPEATER_7_ADDRESS, repeaterAddresses.get(6));

+		if(repeaterAddresses.size() >= 8)

+			values.put(RawPacketTable.COLUMN_REPEATER_8_ADDRESS, repeaterAddresses.get(7));

+

 		values.put(RawPacketTable.COLUMN_RAW_DATA, pkt.getRawData());

 

 		return values;


--- a/src/com/dryerzinia/aprs_x/services/BluetoothLeService.java
+++ b/src/com/dryerzinia/aprs_x/services/BluetoothLeService.java
@@ -214,8 +214,10 @@
 	        			RawPacketTable.getContentValues(pkt)
 	        		);
 	
+	        		Log.d(TAG, pkt.toString());
+
 	        		final Intent intent = new Intent(action);
-	        		intent.putExtra(BLE_TNC_PACKET_DATA, packetData);
+	        		intent.putExtra(BLE_TNC_PACKET_DATA, pkt);
 	                sendBroadcast(intent);
 	
 	        		packetCurrentLength = MAX_PACKET_LENGTH;

--- a/src/com/dryerzinia/aprs_x/test/DeviceControlActivity.java
+++ b/src/com/dryerzinia/aprs_x/test/DeviceControlActivity.java
@@ -48,6 +48,7 @@
 import java.util.UUID;
 
 import com.dryerzinia.aprs_x.R;
+import com.dryerzinia.aprs_x.data_model.packet.RawPacket;
 import com.dryerzinia.aprs_x.services.BluetoothLeService;
 
 /**
@@ -151,23 +152,17 @@
 
                     Log.d(TAG, "Displaying Packet");
 
-                	byte[] data = intent.getByteArrayExtra(BluetoothLeService.BLE_TNC_PACKET_DATA);
-	
-	                Log.d(TAG, "Len: " + data.length);
-	
+                	RawPacket pkt = (RawPacket) intent.getSerializableExtra(BluetoothLeService.BLE_TNC_PACKET_DATA);
+		
 	                try {
 	                	mLogOutputStream.write(0x00);
-	                	mLogOutputStream.write(data.length);
-						mLogOutputStream.write(data);
+	                	mLogOutputStream.write(pkt.getRawData().length);
+						mLogOutputStream.write(pkt.getRawData());
 						mLogOutputStream.flush();
 					} catch (IOException e1) {
 					}
 	
-	            	try {
-	                    Log.d(TAG, "Data: " + new String(data, "US-ASCII"));
-	            		displayData(new String(data, "US-ASCII"));
-					} catch (UnsupportedEncodingException e) {
-					}
+            		displayData(pkt.toString());
 
                 }