Skip to content

Commit

Permalink
CXC-28: Update CARMA Cloud Plugin to have configurable IP/Port
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbourelly999 committed Apr 3, 2024
1 parent 24d6989 commit 4010b7d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
20 changes: 15 additions & 5 deletions src/v2i-hub/CARMACloudPlugin/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@
"default":"127.0.0.1",
"description":"Server IP address for V2X hub"
},
{
"key":"WebServicePort",
"default":"22222",
"description":"Server Port for V2X hub to receive TCM messages"
},
{
"key":"CARMACloudIP",
"default":"http://127.0.0.1",
"description":"Server IP address for V2X hub"
},
{
"key":"CARMACloudPort",
"default":"33333",
"description":"Server Port for V2X hub to receive TCM messages"
},
{
"key":"fetchTime",
"default":"15",
Expand Down Expand Up @@ -63,11 +78,6 @@
"default": "No response received from CMV after repeatedly broadcast TCMs.",
"description": "If the plugin does not receives any aknowledgement from CMV within the configured seconds that match the original TCM, the plugin will create an NO ACK message and display it on UI."
},
{
"key":"WebServicePort",
"default":"22222",
"description":"Server Port for V2X hub to receive TCM messages"
},
{
"key":"listTCM",
"default":"true",
Expand Down
14 changes: 9 additions & 5 deletions src/v2i-hub/CARMACloudPlugin/src/CARMACloudPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ CARMACloudPlugin::CARMACloudPlugin(string name) :PluginClient(name) {
SubscribeToMessages();
std::thread webthread(&CARMACloudPlugin::StartWebService,this);
webthread.detach(); // wait for the thread to finish
url ="http://127.0.0.1:33333"; // 33333 is the port that will send from v2xhub to carma cloud ## initally was 23665
base_hb = "/carmacloud/v2xhub";
base_req = "/carmacloud/tcmreq";
base_ack = "/carmacloud/tcmack";
Expand Down Expand Up @@ -95,7 +94,7 @@ void CARMACloudPlugin::HandleCARMARequest(tsm4Message &msg, routeable_message &r
sprintf(xml_str,"<?xml version=\"1.0\" encoding=\"UTF-8\"?><TrafficControlRequest port=\"%s\" list=\"%s\"><reqid>%s</reqid><reqseq>%ld</reqseq><scale>%ld</scale>%s</TrafficControlRequest>",std::to_string(webport).c_str(),list_tcm.c_str(),reqid, reqseq,scale,bounds_str);

PLOG(logINFO) << "Sent TCR to cloud: "<< xml_str<<endl;
CloudSend(xml_str,url, base_req, method);
CloudSend(xml_str,carma_cloud_url, base_req, method);
}

void CARMACloudPlugin::HandleMobilityOperationMessage(tsm3Message &msg, routeable_message &routeableMsg){
Expand Down Expand Up @@ -179,7 +178,7 @@ void CARMACloudPlugin::HandleMobilityOperationMessage(tsm3Message &msg, routeabl
<< "</acknowledgement><description>" << even_log_description
<< "</description></TrafficControlAcknowledgement>";
PLOG(logINFO) << "Sent Negative ACK: "<< sss.str() <<endl;
CloudSendAsync(sss.str(),url, base_ack, method);
CloudSendAsync(sss.str(),carma_cloud_url, base_ack, method);
}
}
}
Expand Down Expand Up @@ -366,7 +365,7 @@ void CARMACloudPlugin::TCMAckCheckAndRebroadcastTCM()
<< "</acknowledgement><description>" << _TCMNOAcknowledgementDescription
<< "</description></TrafficControlAcknowledgement>";
PLOG(logINFO) << "Sent No ACK as Time Out: "<< sss.str() <<endl;
CloudSendAsync(sss.str(),url, base_ack, method);
CloudSendAsync(sss.str(),carma_cloud_url, base_ack, method);

_not_ACK_TCMs->erase(tcmv01_req_id_hex);
//If time out, stop tracking the starting time of the TCMs being broadcast so far
Expand Down Expand Up @@ -496,7 +495,12 @@ void CARMACloudPlugin::UpdateConfigSettings() {
GetConfigValue<int>("TCMRepeatedlyBroadCastTotalTimes", _TCMRepeatedlyBroadCastTotalTimes);
GetConfigValue<int>("TCMRepeatedlyBroadcastSleep", _TCMRepeatedlyBroadcastSleep);
GetConfigValue<string>("listTCM",list_tcm);

std::string carma_cloud_ip;
uint carma_cloud_port;
GetConfigValue<string>("CARMACloudIP",carma_cloud_ip);
GetConfigValue<uint>("CARMACloudPort",carma_cloud_port);
carma_cloud_url = carma_cloud_ip + ":" + std::to_string(carma_cloud_port);
PLOG(logDEBUG) << "Setting CARMA Cloud URL to " << carma_cloud_url << std::endl;

}

Expand Down
2 changes: 1 addition & 1 deletion src/v2i-hub/CARMACloudPlugin/src/CARMACloudPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class CARMACloudPlugin: public PluginClient {
pthread_mutex_t _timMutex = PTHREAD_MUTEX_INITIALIZER;
J2735MessageFactory factory;
uint64_t _frequency = 0;
string url;
string carma_cloud_url;
string base_hb;
string base_req;
string method;
Expand Down

0 comments on commit 4010b7d

Please sign in to comment.