Skip to content

Commit

Permalink
Merge branch 'dev' into feature/set-msgRepeatOptions-based-on-context
Browse files Browse the repository at this point in the history
  • Loading branch information
dmccoystephenson committed May 21, 2024
2 parents 3c9eb8d + 833ffc4 commit b490753
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.annotation.JsonIgnore;

import us.dot.its.jpo.ode.model.OdeObject;

public class RoadSideUnit {
public static class RSU extends OdeObject {

@JsonIgnore
private final Logger logger = LoggerFactory.getLogger(this.getClass());

private static final long serialVersionUID = 3149576493038209597L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,15 @@ public void run() {
destIndex);
} else {
// Misc error
logger.error("Error on RSU SNMP deposit to {}: {}", curRsu.getRsuTarget(), "Error code "
+ rsuResponse.getResponse().getErrorStatus() + " " + rsuResponse.getResponse().getErrorStatusText());
logger.error("Error on RSU SNMP deposit to {}: {}", curRsu.getRsuTarget(), "Error code '"
+ rsuResponse.getResponse().getErrorStatus() + "' '" + rsuResponse.getResponse().getErrorStatusText() + "'");
// Log the PDUs involved in the failed deposit
logger.debug("PDUs involved in failed RSU SNMP deposit to " + curRsu.getRsuTarget()
+ " => Request PDU: " + rsuResponse.getRequest() + " Response PDU: " + rsuResponse.getResponse());
}

}
logger.info("TIM deposit response {}", responseList);
logger.info("TIM deposit response {}", responseList);
}
Thread.sleep(100);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,28 @@ public ResponseEvent set(PDU pdu, Snmp snmpob, UserTarget targetob, Boolean keep
// Try to send the SNMP request (synchronously)
ResponseEvent responseEvent = null;
try {
// attempt to discover & set authoritative engine ID
byte[] authEngineID = snmpob.discoverAuthoritativeEngineID(targetob.getAddress(), 1000);
if (authEngineID != null && authEngineID.length > 0) {
targetob.setAuthoritativeEngineID(authEngineID);
}
if (authEngineID != null) {
responseEvent = snmpob.set(pdu, targetob);
if (!keepOpen) {
snmpob.close();

// send request
responseEvent = snmpob.set(pdu, targetob);
if (!keepOpen) {
snmpob.close();
}

// if RSU responded and we didn't get an authEngineID, log a warning
if (responseEvent != null && responseEvent.getResponse() != null) {
if (authEngineID == null) {
logger.warn("Failed to discover authoritative engine ID for SNMP target: {}", targetob.getAddress());
}
} else {
logger.error("Unable to send TIM to RSU {}: authEngineID is null", targetob.getAddress());
}
} catch (IOException e) {
throw new IOException("Failed to send SNMP request: " + e);
}

return responseEvent;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,11 @@ public void testDepositingTimWithExtraProperties(@Capturing TimTransmogrifier ca
assertEquals("{\"success\":\"true\"}", actualResponse.getBody());
}

@Test
public void testSuccessfulRsuMessageReturnsSuccessMessagePost(@Capturing TimTransmogrifier capturingTimTransmogrifier, @Capturing XmlUtils capturingXmlUtils) {
String timToSubmit = "{\"request\": {\"rsus\": [{\"latitude\": 30.123456, \"longitude\": -100.12345, \"rsuId\": 123, \"route\": \"myroute\", \"milepost\": 10, \"rsuTarget\": \"172.0.0.1\", \"rsuRetries\": 3, \"rsuTimeout\": 5000, \"rsuIndex\": 7, \"rsuUsername\": \"myusername\", \"rsuPassword\": \"mypassword\"}], \"snmp\": {\"rsuid\": \"83\", \"msgid\": 31, \"mode\": 1, \"channel\": 183, \"interval\": 2000, \"deliverystart\": \"2024-05-13T14:30:00Z\", \"deliverystop\": \"2024-05-13T22:30:00Z\", \"enable\": 1, \"status\": 4}}, \"tim\": {\"msgCnt\": \"1\", \"timeStamp\": \"2024-05-10T19:01:22Z\", \"packetID\": \"123451234512345123\", \"urlB\": \"null\", \"dataframes\": [{\"startDateTime\": \"2024-05-13T20:30:05.014Z\", \"durationTime\": \"30\", \"sspTimRights\": \"1\", \"frameType\": \"advisory\", \"msgId\": {\"roadSignID\": {\"mutcdCode\": \"warning\", \"viewAngle\": \"1111111111111111\", \"position\": {\"latitude\": 30.123456, \"longitude\": -100.12345}}}, \"priority\": \"5\", \"sspLocationRights\": \"1\", \"regions\": [{\"name\": \"I_myroute_RSU_172.0.0.1\", \"anchorPosition\": {\"latitude\": 30.123456, \"longitude\": -100.12345}, \"laneWidth\": \"50\", \"directionality\": \"3\", \"closedPath\": \"false\", \"description\": \"path\", \"path\": {\"scale\": 0, \"nodes\": [{\"delta\": \"node-LL\", \"nodeLat\": 0.0, \"nodeLong\": 0.0}, {\"delta\": \"node-LL\", \"nodeLat\": 0.0, \"nodeLong\": 0.0}], \"type\": \"ll\"}, \"direction\": \"0000000000010000\"}], \"sspMsgTypes\": \"1\", \"sspMsgContent\": \"1\", \"content\": \"workZone\", \"items\": [\"771\"], \"url\": \"null\"}]}}";
ResponseEntity<String> actualResponse = testTimDepositController.postTim(timToSubmit);
assertEquals("{\"success\":\"true\"}", actualResponse.getBody());
}

}

0 comments on commit b490753

Please sign in to comment.