diff --git a/src/rsu-connector/AzureSDKWrapper/CustomHSM.h b/src/rsu-connector/AzureSDKWrapper/CustomHSM.h index 83f584d..698f6cf 100644 --- a/src/rsu-connector/AzureSDKWrapper/CustomHSM.h +++ b/src/rsu-connector/AzureSDKWrapper/CustomHSM.h @@ -48,4 +48,4 @@ class CustomHsm /// @param dpsKey x509 Device Certificate in PEM format. bool setKey( const std::vector& dpsKey ); }; -#endif // DEVICECONNECTOR_AZURESDKWRAPPER_CUSTOMHSM_H_ \ No newline at end of file +#endif // DEVICECONNECTOR_AZURESDKWRAPPER_CUSTOMHSM_H_ diff --git a/src/rsu-connector/AzureSDKWrapper/IMessageLifeTimeTracker.h b/src/rsu-connector/AzureSDKWrapper/IMessageLifeTimeTracker.h index 5fc950c..36a9060 100644 --- a/src/rsu-connector/AzureSDKWrapper/IMessageLifeTimeTracker.h +++ b/src/rsu-connector/AzureSDKWrapper/IMessageLifeTimeTracker.h @@ -36,4 +36,4 @@ struct IMessageLifeTimeTracker : private NonCopyable virtual DeliveryState State() = 0; }; -#endif // DEVICECONNECTOR_AZURESDKWRAPPER_IMESSAGELIFETIMETRACKER_H_ \ No newline at end of file +#endif // DEVICECONNECTOR_AZURESDKWRAPPER_IMESSAGELIFETIMETRACKER_H_ diff --git a/src/rsu-connector/AzureSDKWrapper/IProvisioningClient.h b/src/rsu-connector/AzureSDKWrapper/IProvisioningClient.h index cbeaa2c..3fc2729 100644 --- a/src/rsu-connector/AzureSDKWrapper/IProvisioningClient.h +++ b/src/rsu-connector/AzureSDKWrapper/IProvisioningClient.h @@ -30,4 +30,4 @@ struct IProvisioningClient : private NonCopyable virtual const std::string& IotHubUri() const = 0; }; -#endif // CONNECTOR_AZURESDKWRAPPER_IPROVISIONINGCLIENT_H_ \ No newline at end of file +#endif // CONNECTOR_AZURESDKWRAPPER_IPROVISIONINGCLIENT_H_ diff --git a/src/rsu-connector/AzureSDKWrapper/IotHubClientWrapper.cpp b/src/rsu-connector/AzureSDKWrapper/IotHubClientWrapper.cpp index fcc1c88..4e21a70 100644 --- a/src/rsu-connector/AzureSDKWrapper/IotHubClientWrapper.cpp +++ b/src/rsu-connector/AzureSDKWrapper/IotHubClientWrapper.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -58,8 +59,8 @@ static IOTHUBMESSAGE_DISPOSITION_RESULT_TAG ReactionToDisposition( MessageReacti struct IotHubClientWrapper::IotHubClientWrapperImpl { - IotHubClientWrapperImpl( const std::string& iotHubUri, const std::string& deviceId ); - IotHubClientWrapperImpl( const std::string& connectionString ); + IotHubClientWrapperImpl( const std::string& iotHubUri, const std::string& deviceId, const std::string& statusFile); + IotHubClientWrapperImpl( const std::string& connectionString, const std::string& statusFile); ~IotHubClientWrapperImpl(); void SetLogTraceOption( bool value ); @@ -83,6 +84,7 @@ struct IotHubClientWrapper::IotHubClientWrapperImpl return MessageReaction::Abandoned; } }; + std::string statusFileName; static void sStatusCallback( IOTHUB_CLIENT_CONNECTION_STATUS result, IOTHUB_CLIENT_CONNECTION_STATUS_REASON reason, void* userContextCallback ) @@ -92,6 +94,50 @@ struct IotHubClientWrapper::IotHubClientWrapperImpl spdlog::error( "Status callback with NULL user context." ); return; } + + IotHubClientWrapperImpl* ctx = static_cast( userContextCallback ); + + fstream status; + status.open( ctx->statusFileName, ios::out ); + if ( !status ) + { + spdlog::warn( "Status file cannot be created" ); + } + else + { + switch ( reason ) + { + case IOTHUB_CLIENT_CONNECTION_EXPIRED_SAS_TOKEN: + status << "{ \"status\": \"EXPIRED_SAS_TOKEN\" }\n"; + break; + case IOTHUB_CLIENT_CONNECTION_DEVICE_DISABLED: + status << "{ \"status\": \"DEVICE_DISABLED\" }\n"; + break; + case IOTHUB_CLIENT_CONNECTION_BAD_CREDENTIAL: + status << "{ \"status\": \"BAD_CREDENTIAL\" }\n"; + break; + case IOTHUB_CLIENT_CONNECTION_RETRY_EXPIRED: + status << "{ \"status\": \"RETRY_EXPIRED\" }\n"; + break; + case IOTHUB_CLIENT_CONNECTION_NO_NETWORK: + status << "{ \"status\": \"NO_NETWORK\" }\n"; + break; + case IOTHUB_CLIENT_CONNECTION_COMMUNICATION_ERROR: + status << "{ \"status\": \"COMMUNICATION_ERROR\" }\n"; + break; + case IOTHUB_CLIENT_CONNECTION_OK: + status << "{ \"status\": \"OK\" }\n"; + break; + case IOTHUB_CLIENT_CONNECTION_NO_PING_RESPONSE: + status << "{ \"status\": \"NO_PING_RESPONSE\" }\n"; + break; + default: + status << "{ \"status\": \"UNKNOWN\" }\n"; + break; + } + status.close(); + } + spdlog::info( "Received status {} reason {}", result, reason ); } @@ -139,13 +185,16 @@ std::mutex IotHubClientWrapper::IotHubClientWrapperImpl::SendMessageLock; std::vector> IotHubClientWrapper::IotHubClientWrapperImpl::SendMessageTrackers; IotHubClientWrapper::IotHubClientWrapperImpl::IotHubClientWrapperImpl( const std::string& iotHubUri, - const std::string& deviceId ) + const std::string& deviceId, + const std::string& statusFile ) { if ( iotHubUri.empty() || deviceId.empty() ) { throw std::invalid_argument( "Connection String" ); } + statusFileName = statusFile; + IotHubClientHandle = IoTHubDeviceClient_CreateFromDeviceAuth( iotHubUri.c_str(), deviceId.c_str(), MQTT_Protocol ); if ( !IotHubClientHandle ) { @@ -156,13 +205,15 @@ IotHubClientWrapper::IotHubClientWrapperImpl::IotHubClientWrapperImpl( const std spdlog::debug( "IotHubClientWrapper" ); } -IotHubClientWrapper::IotHubClientWrapperImpl::IotHubClientWrapperImpl( const std::string& connectionString ) +IotHubClientWrapper::IotHubClientWrapperImpl::IotHubClientWrapperImpl( const std::string& connectionString, const std::string& statusFile) { if ( connectionString.empty() ) { throw std::invalid_argument( "Connection String" ); } + statusFileName = statusFile; + IotHubClientHandle = IoTHubDeviceClient_CreateFromConnectionString( connectionString.c_str(), MQTT_Protocol ); if ( !IotHubClientHandle ) { @@ -528,14 +579,14 @@ void IotHubClientWrapper::IotHubClientWrapperImpl::sReportedStateCallback( int s spdlog::info( "Send reported state response {}", statusCode ); } -IotHubClientWrapper::IotHubClientWrapper( const std::string& iotHubUri, const std::string& deviceId ) - : _impl( std::make_shared( iotHubUri, deviceId ) ) +IotHubClientWrapper::IotHubClientWrapper( const std::string& iotHubUri, const std::string& deviceId, const std::string& statusFile ) + : _impl( std::make_shared( iotHubUri, deviceId, statusFile) ) { spdlog::debug( "Created IotHub client." ); } -IotHubClientWrapper::IotHubClientWrapper( const std::string& connectionString ) - : _impl( std::make_shared( connectionString ) ) +IotHubClientWrapper::IotHubClientWrapper( const std::string& connectionString, const std::string& statusFile ) + : _impl( std::make_shared( connectionString, statusFile ) ) { spdlog::debug( "Created IotHub client." ); } diff --git a/src/rsu-connector/AzureSDKWrapper/IotHubClientWrapper.h b/src/rsu-connector/AzureSDKWrapper/IotHubClientWrapper.h index eb59587..21c4fd2 100644 --- a/src/rsu-connector/AzureSDKWrapper/IotHubClientWrapper.h +++ b/src/rsu-connector/AzureSDKWrapper/IotHubClientWrapper.h @@ -30,11 +30,13 @@ class IotHubClientWrapper : public IIotHubClient, private NonCopyable IotHubFactory::ProvisioningClient( const st } std::shared_ptr IotHubFactory::IotHubClient( const std::string& iotHubUri, - const std::string& deviceId ) const + const std::string& deviceId, + const std::string& statusFile ) const { - return std::make_shared( iotHubUri, deviceId ); + return std::make_shared( iotHubUri, deviceId, statusFile ); } -std::shared_ptr IotHubFactory::IotHubClient( const std::string& connectionString ) const +std::shared_ptr IotHubFactory::IotHubClient( const std::string& connectionString, const std::string& statusFile ) const { - return std::make_shared( connectionString ); + return std::make_shared( connectionString, statusFile ); } diff --git a/src/rsu-connector/AzureSDKWrapper/IotHubFactory.h b/src/rsu-connector/AzureSDKWrapper/IotHubFactory.h index 893df05..dc57504 100644 --- a/src/rsu-connector/AzureSDKWrapper/IotHubFactory.h +++ b/src/rsu-connector/AzureSDKWrapper/IotHubFactory.h @@ -34,14 +34,14 @@ class IotHubFactory /// @brief Construct a IotHub Client from IotHub URI and DeviceId as returned from the ProvisioningClient. /// @param iotHubUri The URI of the IotHub instance. /// @param deviceId The device id to be used on this IotHub.. - std::shared_ptr IotHubClient( const std::string& iotHubUri, const std::string& deviceId ) const; + std::shared_ptr IotHubClient( const std::string& iotHubUri, const std::string& deviceId, const std::string& statusFile ) const; /// @brief Construct a IotHub Client from connection string as given by the Azure portal. This is only provided for testing purposes. /// @param connectionString The IotHub connection string. - std::shared_ptr IotHubClient( const std::string& connectionString ) const; + std::shared_ptr IotHubClient( const std::string& connectionString, const std::string& statusFile ) const; private: struct IotHubFactoryImpl; std::shared_ptr _impl; }; -#endif // DEVICECONNECTOR_AZURESDKWRAPPER_IOTHUBFACTORY_H_ \ No newline at end of file +#endif // DEVICECONNECTOR_AZURESDKWRAPPER_IOTHUBFACTORY_H_ diff --git a/src/rsu-connector/AzureSDKWrapper/MethodRouter.h b/src/rsu-connector/AzureSDKWrapper/MethodRouter.h index e138e74..1391440 100644 --- a/src/rsu-connector/AzureSDKWrapper/MethodRouter.h +++ b/src/rsu-connector/AzureSDKWrapper/MethodRouter.h @@ -44,4 +44,4 @@ class MethodRouter : private NonCopyable std::shared_ptr _impl; }; -#endif /* CONNECTOR_METHODROUTER_H_ */ \ No newline at end of file +#endif /* CONNECTOR_METHODROUTER_H_ */ diff --git a/src/rsu-connector/Commands/AddPortForwarding.cpp b/src/rsu-connector/Commands/AddPortForwarding.cpp index bfc7322..4830b01 100644 --- a/src/rsu-connector/Commands/AddPortForwarding.cpp +++ b/src/rsu-connector/Commands/AddPortForwarding.cpp @@ -90,4 +90,4 @@ int AddPortForwarding::Run( const std::string& argument, std::string& response ) return 0; } -} // namespace Command \ No newline at end of file +} // namespace Command diff --git a/src/rsu-connector/Commands/AddPortForwarding.h b/src/rsu-connector/Commands/AddPortForwarding.h index fde12ad..6e3ab6a 100644 --- a/src/rsu-connector/Commands/AddPortForwarding.h +++ b/src/rsu-connector/Commands/AddPortForwarding.h @@ -49,4 +49,4 @@ class AddPortForwarding : public ICommand } // namespace Command -#endif // COMMAND_ADDPORTFORWARDING_H_ \ No newline at end of file +#endif // COMMAND_ADDPORTFORWARDING_H_ diff --git a/src/rsu-connector/Commands/ClearPortForwardings.cpp b/src/rsu-connector/Commands/ClearPortForwardings.cpp index 79d1dd5..61cfe04 100644 --- a/src/rsu-connector/Commands/ClearPortForwardings.cpp +++ b/src/rsu-connector/Commands/ClearPortForwardings.cpp @@ -48,4 +48,4 @@ int ClearPortForwardings::Run( const std::string& argument, std::string& respons return 0; } -} // namespace Command \ No newline at end of file +} // namespace Command diff --git a/src/rsu-connector/Commands/ClearPortForwardings.h b/src/rsu-connector/Commands/ClearPortForwardings.h index 9e83c98..02cce04 100644 --- a/src/rsu-connector/Commands/ClearPortForwardings.h +++ b/src/rsu-connector/Commands/ClearPortForwardings.h @@ -41,4 +41,4 @@ class ClearPortForwardings : public ICommand } // namespace Command -#endif // COMMAND_CLEARPORTFORWARDINGS_H_ \ No newline at end of file +#endif // COMMAND_CLEARPORTFORWARDINGS_H_ diff --git a/src/rsu-connector/Commands/ConfigureVPNConnection.cpp b/src/rsu-connector/Commands/ConfigureVPNConnection.cpp index 99877c8..863e9e6 100644 --- a/src/rsu-connector/Commands/ConfigureVPNConnection.cpp +++ b/src/rsu-connector/Commands/ConfigureVPNConnection.cpp @@ -86,4 +86,4 @@ int ConfigureVPNConnection::Run( const std::string& argument, std::string& respo return 0; } -} // namespace Command \ No newline at end of file +} // namespace Command diff --git a/src/rsu-connector/Commands/ConfigureVPNConnection.h b/src/rsu-connector/Commands/ConfigureVPNConnection.h index db55b07..47a9d9c 100644 --- a/src/rsu-connector/Commands/ConfigureVPNConnection.h +++ b/src/rsu-connector/Commands/ConfigureVPNConnection.h @@ -46,4 +46,4 @@ class ConfigureVPNConnection : public ICommand } // namespace Command -#endif // COMMAND_CONFIGUREVPNCONNECTION_H \ No newline at end of file +#endif // COMMAND_CONFIGUREVPNCONNECTION_H diff --git a/src/rsu-connector/Commands/GetNetworkDetails.h b/src/rsu-connector/Commands/GetNetworkDetails.h index 4ae1798..9a5e174 100644 --- a/src/rsu-connector/Commands/GetNetworkDetails.h +++ b/src/rsu-connector/Commands/GetNetworkDetails.h @@ -62,4 +62,4 @@ class GetNetworkDetails : public ICommand } // namespace Command -#endif // COMMAND_GETNETWORKDETAILS_H_ \ No newline at end of file +#endif // COMMAND_GETNETWORKDETAILS_H_ diff --git a/src/rsu-connector/Commands/GetPortForwardings.h b/src/rsu-connector/Commands/GetPortForwardings.h index 711f7da..baff311 100644 --- a/src/rsu-connector/Commands/GetPortForwardings.h +++ b/src/rsu-connector/Commands/GetPortForwardings.h @@ -44,4 +44,4 @@ class GetPortForwardings : public ICommand } // namespace Command -#endif // COMMAND_GETPORTTFORWARDINGS_H_ \ No newline at end of file +#endif // COMMAND_GETPORTTFORWARDINGS_H_ diff --git a/src/rsu-connector/Commands/GetVPNConfigurations.h b/src/rsu-connector/Commands/GetVPNConfigurations.h index 5d52404..f89601c 100644 --- a/src/rsu-connector/Commands/GetVPNConfigurations.h +++ b/src/rsu-connector/Commands/GetVPNConfigurations.h @@ -41,4 +41,4 @@ class GetVPNConfigurations : public ICommand } // namespace Command -#endif // COMMAND_GETVPNCONFIGURATIONS_H_ \ No newline at end of file +#endif // COMMAND_GETVPNCONFIGURATIONS_H_ diff --git a/src/rsu-connector/Commands/ICommand.h b/src/rsu-connector/Commands/ICommand.h index f6dcd7b..1d71ce9 100644 --- a/src/rsu-connector/Commands/ICommand.h +++ b/src/rsu-connector/Commands/ICommand.h @@ -25,4 +25,4 @@ struct ICommand } // namespace Command -#endif // COMMAND_ICOMMAND_H_ \ No newline at end of file +#endif // COMMAND_ICOMMAND_H_ diff --git a/src/rsu-connector/Commands/IPortForwardingActor.h b/src/rsu-connector/Commands/IPortForwardingActor.h index 3bd399a..c796c0e 100644 --- a/src/rsu-connector/Commands/IPortForwardingActor.h +++ b/src/rsu-connector/Commands/IPortForwardingActor.h @@ -54,4 +54,4 @@ struct IPortForwardingActor } // namespace Command -#endif // COMMAND_IPORTFORWARDINGACTOR_H_ \ No newline at end of file +#endif // COMMAND_IPORTFORWARDINGACTOR_H_ diff --git a/src/rsu-connector/Commands/IVPNActor.h b/src/rsu-connector/Commands/IVPNActor.h index bdc92d6..82bf026 100644 --- a/src/rsu-connector/Commands/IVPNActor.h +++ b/src/rsu-connector/Commands/IVPNActor.h @@ -67,4 +67,4 @@ struct IVPNActor } // namespace Command -#endif // COMMAND_IVPNACTOR_H_ \ No newline at end of file +#endif // COMMAND_IVPNACTOR_H_ diff --git a/src/rsu-connector/Commands/RemovePortForwarding.cpp b/src/rsu-connector/Commands/RemovePortForwarding.cpp index 07ed59c..2e09112 100644 --- a/src/rsu-connector/Commands/RemovePortForwarding.cpp +++ b/src/rsu-connector/Commands/RemovePortForwarding.cpp @@ -76,4 +76,4 @@ int RemovePortForwarding::Run( const std::string& argument, std::string& respons return 0; } -} // namespace Command \ No newline at end of file +} // namespace Command diff --git a/src/rsu-connector/Commands/RemovePortForwarding.h b/src/rsu-connector/Commands/RemovePortForwarding.h index db44a5f..6c6d250 100644 --- a/src/rsu-connector/Commands/RemovePortForwarding.h +++ b/src/rsu-connector/Commands/RemovePortForwarding.h @@ -41,4 +41,4 @@ class RemovePortForwarding : public ICommand } // namespace Command -#endif // COMMAND_REMOVEPORTFORWARDING_H_ \ No newline at end of file +#endif // COMMAND_REMOVEPORTFORWARDING_H_ diff --git a/src/rsu-connector/Commands/RestartConnector.h b/src/rsu-connector/Commands/RestartConnector.h index 3b94f2c..bdb41f5 100644 --- a/src/rsu-connector/Commands/RestartConnector.h +++ b/src/rsu-connector/Commands/RestartConnector.h @@ -41,4 +41,4 @@ class RestartConnector : public ICommand } // namespace Command -#endif // COMMAND_RESTARTCONNECTOR_H_ \ No newline at end of file +#endif // COMMAND_RESTARTCONNECTOR_H_ diff --git a/src/rsu-connector/Commands/StartVPNConnection.cpp b/src/rsu-connector/Commands/StartVPNConnection.cpp index 89fb3e9..a8830b3 100644 --- a/src/rsu-connector/Commands/StartVPNConnection.cpp +++ b/src/rsu-connector/Commands/StartVPNConnection.cpp @@ -87,4 +87,4 @@ int StartVPNConnection::Run( const std::string& argument, std::string& response return 0; } -} // namespace Command \ No newline at end of file +} // namespace Command diff --git a/src/rsu-connector/Commands/StartVPNConnection.h b/src/rsu-connector/Commands/StartVPNConnection.h index e3e56c8..b8889bf 100644 --- a/src/rsu-connector/Commands/StartVPNConnection.h +++ b/src/rsu-connector/Commands/StartVPNConnection.h @@ -42,4 +42,4 @@ class StartVPNConnection : public ICommand } // namespace Command -#endif // COMMAND_STARTVPNCONNECTION_H \ No newline at end of file +#endif // COMMAND_STARTVPNCONNECTION_H diff --git a/src/rsu-connector/Commands/StopVPNConnection.cpp b/src/rsu-connector/Commands/StopVPNConnection.cpp index d9c5cd1..0bda4c7 100644 --- a/src/rsu-connector/Commands/StopVPNConnection.cpp +++ b/src/rsu-connector/Commands/StopVPNConnection.cpp @@ -77,4 +77,4 @@ int StopVPNConnection::Run( const std::string& argument, std::string& response ) return 0; } -} // namespace Command \ No newline at end of file +} // namespace Command diff --git a/src/rsu-connector/Commands/StopVPNConnection.h b/src/rsu-connector/Commands/StopVPNConnection.h index d42be5a..7262927 100644 --- a/src/rsu-connector/Commands/StopVPNConnection.h +++ b/src/rsu-connector/Commands/StopVPNConnection.h @@ -41,4 +41,4 @@ class StopVPNConnection : public ICommand } // namespace Command -#endif // COMMAND_STOPVPNCONNECTION_H \ No newline at end of file +#endif // COMMAND_STOPVPNCONNECTION_H diff --git a/src/rsu-connector/DeviceTwin/IDeviceInformation.h b/src/rsu-connector/DeviceTwin/IDeviceInformation.h index 8c0993d..2029268 100644 --- a/src/rsu-connector/DeviceTwin/IDeviceInformation.h +++ b/src/rsu-connector/DeviceTwin/IDeviceInformation.h @@ -46,4 +46,4 @@ struct IDeviceInformation virtual bool VPNConnectionActive() = 0; }; -#endif // CONNECTOR_IDEVICEINFORMATION_H_ \ No newline at end of file +#endif // CONNECTOR_IDEVICEINFORMATION_H_ diff --git a/src/rsu-connector/HttpHandler/HttpHandlerFactory.cpp b/src/rsu-connector/HttpHandler/HttpHandlerFactory.cpp index 6bade24..85826a4 100644 --- a/src/rsu-connector/HttpHandler/HttpHandlerFactory.cpp +++ b/src/rsu-connector/HttpHandler/HttpHandlerFactory.cpp @@ -30,4 +30,4 @@ std::shared_ptr HttpHandlerFactory::Server( const std::string& ipAd std::shared_ptr HttpHandlerFactory::Client( const std::string& ipAddress, uint16_t port ) const { return std::make_shared( ipAddress, port ); -} \ No newline at end of file +} diff --git a/src/rsu-connector/HttpHandler/HttpHandlerFactory.h b/src/rsu-connector/HttpHandler/HttpHandlerFactory.h index bdf11b4..93c09c9 100644 --- a/src/rsu-connector/HttpHandler/HttpHandlerFactory.h +++ b/src/rsu-connector/HttpHandler/HttpHandlerFactory.h @@ -31,4 +31,4 @@ class HttpHandlerFactory /// @param port Port the client connects to. std::shared_ptr Client( const std::string& ipAddress, uint16_t port ) const; }; -#endif // CONNECTOR_HTTPHANDLER_HTTPHANDLERFACTORY_H_ \ No newline at end of file +#endif // CONNECTOR_HTTPHANDLER_HTTPHANDLERFACTORY_H_ diff --git a/src/rsu-connector/HttpHandler/HttpServer.h b/src/rsu-connector/HttpHandler/HttpServer.h index b95b0c6..57bf51e 100644 --- a/src/rsu-connector/HttpHandler/HttpServer.h +++ b/src/rsu-connector/HttpHandler/HttpServer.h @@ -49,4 +49,4 @@ class HttpServer : public IHttpServer std::shared_ptr _impl; }; -#endif // CONNECTOR_HTTPHANDLER_IHTTPSERVER_H_ \ No newline at end of file +#endif // CONNECTOR_HTTPHANDLER_IHTTPSERVER_H_ diff --git a/src/rsu-connector/HttpHandler/IHttpServer.h b/src/rsu-connector/HttpHandler/IHttpServer.h index e60d117..dd80230 100644 --- a/src/rsu-connector/HttpHandler/IHttpServer.h +++ b/src/rsu-connector/HttpHandler/IHttpServer.h @@ -50,4 +50,4 @@ struct IHttpServer : private NonCopyable virtual void AddHandler( const std::string& method, const std::string& path, HttpServerHandlerType handler ) = 0; }; -#endif // CONNECTOR_HTTPHANDLER_IHTTPSERVER_H_ \ No newline at end of file +#endif // CONNECTOR_HTTPHANDLER_IHTTPSERVER_H_ diff --git a/src/rsu-connector/JobScheduler/JobScheduler.h b/src/rsu-connector/JobScheduler/JobScheduler.h index 7389ad9..c3584fc 100644 --- a/src/rsu-connector/JobScheduler/JobScheduler.h +++ b/src/rsu-connector/JobScheduler/JobScheduler.h @@ -64,4 +64,4 @@ class JobScheduler : public IJobScheduler std::shared_ptr _impl; }; -#endif // DEVICECONNECTOR_JOBSCHEDULER_JOBSCHEDULER_H_ \ No newline at end of file +#endif // DEVICECONNECTOR_JOBSCHEDULER_JOBSCHEDULER_H_ diff --git a/src/rsu-connector/common/DestroyNotification.h b/src/rsu-connector/common/DestroyNotification.h index e21a7ff..8a35765 100644 --- a/src/rsu-connector/common/DestroyNotification.h +++ b/src/rsu-connector/common/DestroyNotification.h @@ -27,4 +27,4 @@ class DestroyNotification std::function destroyNotification{ []() {} }; }; -#endif /* CONNECTOR_COMMON_DESTROYNOTIFICATIONE_H_ */ \ No newline at end of file +#endif /* CONNECTOR_COMMON_DESTROYNOTIFICATIONE_H_ */ diff --git a/src/rsu-connector/main/IotHubOrNull.cpp b/src/rsu-connector/main/IotHubOrNull.cpp index bb57b8c..42b4a09 100644 --- a/src/rsu-connector/main/IotHubOrNull.cpp +++ b/src/rsu-connector/main/IotHubOrNull.cpp @@ -17,7 +17,8 @@ struct IotHubOrNull::IotHubOrNullImpl std::string SharedAccessSignature; std::string CertificateFileName; std::string DeviceKeyFileName; - ; + std::string StatusFileName; + std::shared_ptr Factory{ nullptr }; std::shared_ptr Hub{ nullptr }; bool MethodHandlerSet{ false }; @@ -116,6 +117,15 @@ IotHubOrNull::IotHubOrNull( std::shared_ptr config ) : _impl( std throw std::runtime_error( "No authentification method specified." ); } + try + { + _impl->StatusFileName = config->GetStringValue( "HUB_StatusFile" ); + } + catch ( const std::exception& e ) + { + spdlog::warn( "Exception while reading HubStatusFile: {}", e.what() ); + } + _impl->Factory = std::make_shared( _impl->RegistrationId, _impl->SharedAccessSignature, _impl->CertificateFileName, @@ -154,7 +164,7 @@ bool IotHubOrNull::Connect() } spdlog::info( "Connecting to Iot hub." ); - _impl->Hub = _impl->Factory->IotHubClient( iotHubUri, deviceId ); + _impl->Hub = _impl->Factory->IotHubClient( iotHubUri, deviceId, _impl->StatusFileName ); if ( !_impl->Hub.get() ) { spdlog::error( "IotHub client is null" ); @@ -258,4 +268,4 @@ void IotHubOrNull::SetDeviceTwinHandler( std::functionHub->SetDeviceTwinHandler( handler ); } -} \ No newline at end of file +} diff --git a/src/rsu-connector/unittest/CustomHSMTest.cpp b/src/rsu-connector/unittest/CustomHSMTest.cpp index 312de14..bf2aa7c 100644 --- a/src/rsu-connector/unittest/CustomHSMTest.cpp +++ b/src/rsu-connector/unittest/CustomHSMTest.cpp @@ -249,4 +249,4 @@ ih2t7Bs4FNzuO/r7BxrjPJmFzD+cDvUDBNF+ )"; CHECK( !hsm->setCertificate( std::vector( expectedCert.begin(), expectedCert.end() ) ) ); -} \ No newline at end of file +} diff --git a/src/rsu-connector/unittest/MockPortForwardingActor.h b/src/rsu-connector/unittest/MockPortForwardingActor.h index 862cd1e..cad0766 100644 --- a/src/rsu-connector/unittest/MockPortForwardingActor.h +++ b/src/rsu-connector/unittest/MockPortForwardingActor.h @@ -54,4 +54,4 @@ struct MockPortForwardingActor : public Command::IPortForwardingActor ReloadFirewallCalled = true; return ReloadFirewallReturn; } -}; \ No newline at end of file +}; diff --git a/src/rsu-connector/unittest/MockVPNActor.h b/src/rsu-connector/unittest/MockVPNActor.h index 72f68f5..47b4944 100644 --- a/src/rsu-connector/unittest/MockVPNActor.h +++ b/src/rsu-connector/unittest/MockVPNActor.h @@ -54,4 +54,4 @@ struct MockVPNActor : public Command::IVPNActor config = GetVPNResponse; return GetVPNConfigurationsReturn; } -}; \ No newline at end of file +};