Diag-Client-Lib
dm_conversation.h
Go to the documentation of this file.
1 /* Diagnostic Client library
2  * Copyright (C) 2024 Avijit Dey
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
8 #ifndef DIAGNOSTIC_CLIENT_LIB_APPL_SRC_DCM_CONVERSATION_DM_CONVERSATION_H
9 #define DIAGNOSTIC_CLIENT_LIB_APPL_SRC_DCM_CONVERSATION_DM_CONVERSATION_H
10 /* includes */
11 #include <string_view>
12 
19 #include "utility/sync_timer.h"
20 
21 namespace diag {
22 namespace client {
23 namespace conversation {
24 
28 class DmConversation final : public Conversation {
29  public:
38 
46  DmConversation(std::string_view conversion_name, DMConversationType &conversion_identifier);
47 
51  DmConversation(const DmConversation &other) noexcept = delete;
52  DmConversation &operator=(const DmConversation &other) noexcept = delete;
53 
57  DmConversation(DmConversation &&other) noexcept = delete;
58  DmConversation &operator=(DmConversation &&other) noexcept = delete;
59 
63  ~DmConversation() override;
64 
68  void Startup() noexcept override;
69 
73  void Shutdown() noexcept override;
74 
80  void RegisterConnection(std::unique_ptr<::uds_transport::Connection> connection) noexcept override;
81 
87  ::uds_transport::ConversionHandler &GetConversationHandler() noexcept override;
88 
98  ConnectResult ConnectToDiagServer(std::uint16_t target_address, IpAddress host_ip_addr) noexcept override;
99 
105  DisconnectResult DisconnectFromDiagServer() noexcept override;
106 
132  std::pair<::uds_transport::UdsTransportProtocolMgr::IndicationResult, ::uds_transport::UdsMessagePtr> IndicateMessage(
133  ::uds_transport::UdsMessage::Address source_addr, ::uds_transport::UdsMessage::Address target_addr,
134  ::uds_transport::UdsMessage::TargetAddressType type, ::uds_transport::ChannelID channel_id, std::size_t size,
135  ::uds_transport::Priority priority, ::uds_transport::ProtocolKind protocol_kind,
136  core_type::Span<std::uint8_t> payload_info) noexcept override;
137 
144  void HandleMessage(::uds_transport::UdsMessagePtr message) noexcept override;
145 
156  uds_message::UdsRequestMessageConstPtr message) noexcept override;
157 
158  private:
162  enum class SessionControlType : std::uint8_t {
163  kDefaultSession = 0x01,
164  kProgrammingSession = 0x02,
165  kExtendedSession = 0x03,
166  kSystemSafetySession = 0x04
167  };
168 
172  enum class SecurityLevelType : std::uint8_t {
173  kLocked = 0x00,
174  kUnLocked = 0x01,
175  };
176 
180  enum class ActivityStatusType : uint8_t { kActive = 0x00, kInactive = 0x01 };
181 
182  private:
192 
197 
202 
207 
211  std::uint32_t rx_buffer_size_;
212 
216  std::uint16_t p2_client_max_;
217 
221  std::uint16_t p2_star_client_max_;
222 
226  std::uint16_t source_address_;
227 
231  std::uint16_t target_address_;
232 
236  std::string remote_address_;
237 
241  std::string conversation_name_;
242 
246  std::unique_ptr<::uds_transport::ConversionHandler> dm_conversion_handler_;
247 
251  std::unique_ptr<::uds_transport::Connection> connection_ptr_;
252 
257 
262 
267 };
268 
269 } // namespace conversation
270 } // namespace client
271 } // namespace diag
272 
273 #endif // DIAGNOSTIC_CLIENT_LIB_APPL_SRC_DCM_CONVERSATION_DM_CONVERSATION_H
Class type to contains a value (of type ValueType), or an error (of type ErrorType)
Definition: result.h:29
Interface for diag client conversation.
Definition: conversation.h:24
DiagClientConversation::IpAddress IpAddress
Type alias for Ip address.
Definition: conversation.h:29
DiagError
Definitions of Diagnostics Request Response results.
Class to establish connection with Diagnostic Server.
std::pair<::uds_transport::UdsTransportProtocolMgr::IndicationResult, ::uds_transport::UdsMessagePtr > IndicateMessage(::uds_transport::UdsMessage::Address source_addr, ::uds_transport::UdsMessage::Address target_addr, ::uds_transport::UdsMessage::TargetAddressType type, ::uds_transport::ChannelID channel_id, std::size_t size, ::uds_transport::Priority priority, ::uds_transport::ProtocolKind protocol_kind, core_type::Span< std::uint8_t > payload_info) noexcept override
Function to indicate a start of reception of message.
void Startup() noexcept override
Function to start the DmConversation.
std::uint16_t p2_client_max_
Store the maximum p2 client time.
~DmConversation() override
Destructs an instance of DmConversation.
DmConversation & operator=(DmConversation &&other) noexcept=delete
DisconnectResult DisconnectFromDiagServer() noexcept override
Function to disconnect from Diagnostic Server.
DmConversation(const DmConversation &other) noexcept=delete
Deleted copy assignment and copy constructor.
std::unique_ptr<::uds_transport::ConversionHandler > dm_conversion_handler_
Store the dm conversation handler.
DmConversation(std::string_view conversion_name, DMConversationType &conversion_identifier)
Constructs an instance of DmConversation.
std::uint32_t rx_buffer_size_
Store the size of reception buffer size setting.
void HandleMessage(::uds_transport::UdsMessagePtr message) noexcept override
Function to Hands over a valid received Uds message.
void RegisterConnection(std::unique_ptr<::uds_transport::Connection > connection) noexcept override
Function to register the conversation to underlying transport protocol handler.
ConnectResult ConnectToDiagServer(std::uint16_t target_address, IpAddress host_ip_addr) noexcept override
Function to connect to Diagnostic Server.
std::uint16_t p2_star_client_max_
Store the maximum p2 star client time.
SecurityLevelType
Definitions of active security level.
DmConversation(DmConversation &&other) noexcept=delete
Deleted move assignment and move constructor.
::uds_transport::ConversionHandler & GetConversationHandler() noexcept override
Function to get the conversation handler from conversation object.
Result< uds_message::UdsResponseMessagePtr, DiagError > SendDiagnosticRequest(uds_message::UdsRequestMessageConstPtr message) noexcept override
Function to send Diagnostic Request and get Diagnostic Response.
ActivityStatusType activity_status_
Store the conversation activity status.
SessionControlType active_session_
Store the active diagnostic session.
std::uint16_t target_address_
Store the logical target address of remote server.
::uds_transport::ByteVector payload_rx_buffer_
Store the received uds response.
ActivityStatusType
Definitions of current activity status.
std::string remote_address_
Store the remote IP address of remote server.
SyncTimer sync_timer_
Store the synchronous timer.
SecurityLevelType active_security_level_
Store the active diagnostic security level.
void Shutdown() noexcept override
Function to shutdown the DmConversation.
std::uint16_t source_address_
Store the logical source address of conversation.
conversation_state_impl::ConversationStateImpl conversation_state_
Store the conversation state.
std::unique_ptr<::uds_transport::Connection > connection_ptr_
Store the underlying transport protocol connection object.
std::string conversation_name_
Store the conversation name.
DmConversation & operator=(const DmConversation &other) noexcept=delete
SessionControlType
Definitions of active diagnostic session.
static DiagClientConversation::DiagError ConvertResponseType(::uds_transport::UdsTransportProtocolMgr::TransmissionResult result_type)
Helper function to convert response type.
Span(T(&)[N]) -> Span< T, N >
std::unique_ptr< UdsMessage > UdsResponseMessagePtr
Type alias of unique_ptr for Response Message.
std::unique_ptr< const UdsMessage > UdsRequestMessageConstPtr
Type alias of unique_ptr for constant UdsRequestMessage.
std::string_view ProtocolKind
std::unique_ptr< UdsMessage > UdsMessagePtr
Definition: uds_message.h:71
uint32_t ChannelID
std::uint8_t Priority
std::vector< std::uint8_t > ByteVector
Structure containing DM conversation type.