Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-du-car committed Nov 29, 2023
1 parent d5998cf commit 040a99b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace TelematicBridge
{
TelematicBridgePlugin::TelematicBridgePlugin(const string &name) : PluginClient(name)
{
_telematicUnitPtr = make_shared<TelematicUnit>();
_telematicUnitPtr = make_unique<TelematicUnit>();
UpdateConfigSettings();
AddMessageFilter("*", "*", IvpMsgFlags_None);
AddMessageFilter("J2735", "*", IvpMsgFlags_RouteDSRC);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace TelematicBridge
private:
static CONSTEXPR const char *Telematic_MSGTYPE_J2735_STRING = "J2735";
static CONSTEXPR const char *UNIT_TYPE_INFRASTRUCTURE = "Infrastructure";
std::shared_ptr<TelematicUnit> _telematicUnitPtr;
std::unique_ptr<TelematicUnit> _telematicUnitPtr;
std::string _unitId;
std::string _unitName;
std::string _natsURL;
Expand Down
4 changes: 3 additions & 1 deletion src/v2i-hub/TelematicBridgePlugin/src/TelematicUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ namespace TelematicBridge
{
// Reset registration status
bool isRegistered = false;
int attempts_count = 0;

while (!isRegistered)
while (!isRegistered && attempts_count < REGISTRATION_MAX_ATTEMPTS)
{
attempts_count++;
PLOG(logDEBUG2) << "Inside register unit requestor";
natsMsg *reply = nullptr;
string payload = "{\"unit_id\":\"" + _unit.unitId + "\"}";
Expand Down
1 change: 1 addition & 0 deletions src/v2i-hub/TelematicBridgePlugin/src/TelematicUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ namespace TelematicBridge
static CONSTEXPR const char *TOPICS_KEY = "topics"; // topics key used to find topics value from JSON
static CONSTEXPR const char *NAME_KEY = "name"; // topics key used to find topics value from JSON
static const int MILLI_TO_MICRO = 1000;
static const int REGISTRATION_MAX_ATTEMPTS = 30; //The maximum numbers of attempts allowed to register this unit with server

public:
/**
Expand Down

0 comments on commit 040a99b

Please sign in to comment.