Skip to content

Commit

Permalink
added generic receiver classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael7371 committed Sep 25, 2023
1 parent 36de40d commit acf570b
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ public class PayloadParser extends LogFileParser {
// least 20 bytes long

public static final int PAYLOAD_LENGTH_LENGTH = 2;

protected short payloadLength;
protected byte[] payload;
protected String payloadType;

public PayloadParser() {
super();
Expand Down Expand Up @@ -103,16 +104,11 @@ public void writeTo(OutputStream os) throws IOException {
}


/**
* Attempts to strip WSMP header bytes. If message starts with "0014",
* message is raw BSM. Otherwise, headers are >= 20 bytes, so look past that
* for start of payload BSM.
*
* @param packet
*/

public byte[] removeHeader(byte[] packet) {
String hexPacket = HexUtils.toHexString(packet);

logger.debug("RemoveHeader recordType: " + recordType);
int startIndex = hexPacket.indexOf(BSM_START_FLAG);
if (startIndex == 0) {
logger.debug("Message is raw BSM with no headers.");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package us.dot.its.jpo.ode.udp.generic;

public enum MessageType {
UNKNOWN,
BSM,
MAP,
SPAT,
SRM,
SSM,
TIM
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package us.dot.its.jpo.ode.udp.generic;

public class TypePayload {

private MessageType type;
private byte[] payload;

public TypePayload(MessageType type, byte[] payload){
this.type = type;
this.payload = payload;
}

public MessageType getType() {
return type;
}

public void setType(MessageType type) {
this.type = type;
}

public byte[] getPayload() {
return payload;
}


public void setPayload(byte[] payload) {
this.payload = payload;
}


public String toString(){
return "{ \"type\":" + type + "\"payload\":" + payload + "}";
}

}

0 comments on commit acf570b

Please sign in to comment.