Skip to content

Commit

Permalink
Modified SNMP handling to fix NTICP1218 deposits
Browse files Browse the repository at this point in the history
  • Loading branch information
dmccoystephenson committed Mar 1, 2024
1 parent 87ca65d commit d6d2dff
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public void testGettersAndSetters() {
@Test
public void testSnmpTimestampFromIso() throws ParseException {
String snmpTS = SNMP.snmpTimestampFromIso("2017-05-04T21:55:00-05:00");
// String snmpTS = SNMP.snmpTimestampFromIso(" 2024-03-01T20:29:33.033Z");
assertEquals("07E1050415370000", snmpTS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public static class RSU extends OdeObject {
public RSU() {
super();

// default to 4.1 SNMP protocol
this.snmpProtocol = SnmpProtocol.FOURDOT1;
// default to NTCIP1218 SNMP protocol
this.snmpProtocol = SnmpProtocol.NTCIP1218;
}

public RSU(String rsuTarget, String rsuUsername, String rsuPassword, int rsuRetries, int rsuTimeout) {
Expand All @@ -45,8 +45,8 @@ public RSU(String rsuTarget, String rsuUsername, String rsuPassword, int rsuRetr
this.rsuRetries = rsuRetries;
this.rsuTimeout = rsuTimeout;

// default to 4.1 SNMP protocol
this.snmpProtocol = SnmpProtocol.FOURDOT1;
// default to NTCIP1218 SNMP protocol
this.snmpProtocol = SnmpProtocol.NTCIP1218;
}

public RSU(String rsuTarget, String rsuUsername, String rsuPassword, int rsuRetries, int rsuTimeout, SnmpProtocol snmpProtocol) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void setStatus(int status) {
this.status = status;
}

public static String snmpTimestampFromIso(String isoTimestamp) throws ParseException {
public static String snmpTimestampFromIso(String isoTimestamp) throws ParseException { // from wyocv apps: 2024-03-01T20:29:33.033Z
ZonedDateTime zdt = DateTimeUtils.isoDateTime(isoTimestamp);


Expand All @@ -136,7 +136,7 @@ public static String snmpTimestampFromIso(String isoTimestamp) throws ParseExcep
sb.append(String.format("%02X", zdt.getHour()));
sb.append(String.format("%02X", zdt.getMinute()));
sb.append(String.format("%02X", zdt.getSecond()));
sb.append(String.format("%02X", zdt.getNano()));
sb.append(String.format("%02X", zdt.getNano()).substring(0, 2));
return sb.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static VariableBinding getVbRsuMsgRepeatTxChannel(int index, int channel)
public static VariableBinding getVbRsuMsgRepeatTxInterval(int index, int interval) {
return new VariableBinding(
new OID(rsu_msg_repeat_tx_interval_oid().concat(".").concat(Integer.toString(index))),
new Integer32(interval)
new Integer32(interval * 1000) // NTCIP1218 requires this is milliseconds and the original value is provided in seconds so we need to multiply by 1000
);
}

Expand Down Expand Up @@ -86,7 +86,7 @@ public static VariableBinding getVbRsuMsgRepeatPriority(int index) {
}

public static VariableBinding getVbRsuMsgRepeatOptions(int index) {
byte[] val = {(byte) 0xc0};
byte[] val = {(byte) 0x00};
return new VariableBinding(
new OID(rsu_msg_repeat_options_oid().concat(".").concat(Integer.toString(index))),
new OctetString(val)
Expand Down

0 comments on commit d6d2dff

Please sign in to comment.