1
0

ECSDKFramework.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. /*! \file ECSDKFramework.h */
  2. #pragma once
  3. #include "ECSDKTypes.h"
  4. #define EC_VERSION_STRING "1.1.17.2"
  5. namespace ECSDKFrameWork {
  6. /**
  7. * @brief The IECSDKListener class
  8. *
  9. * @note This interface provides information about the connection process,
  10. * the connection type, and so on
  11. */
  12. class EC_DLL_EXPORT IECSDKListener
  13. {
  14. public:
  15. /*!
  16. * \brief Virtual destructor.
  17. */
  18. virtual ~IECSDKListener();
  19. /**
  20. * @brief onSdkConnectStatus
  21. * @param status
  22. */
  23. virtual void onSdkConnectStatus(ECSDKConnectedStatus status, ECSDKConnectedType type) = 0;
  24. /**
  25. * @brief onLicenseAuthFail
  26. * @param errCode
  27. * @param errMsg
  28. */
  29. virtual void onLicenseAuthFail(int32_t errCode, const string& errMsg) = 0;
  30. /**
  31. * @brief onLicenseAuthSuccess
  32. * @param code
  33. * @param msg
  34. */
  35. virtual void onLicenseAuthSuccess(int32_t code, const string& msg) = 0;
  36. };
  37. /**
  38. * @class IECAccessDevice
  39. *
  40. * @brief An interface class to implement special usb device access.
  41. */
  42. class EC_DLL_EXPORT IECAccessDevice
  43. {
  44. public:
  45. virtual ~IECAccessDevice();
  46. /**
  47. * @brief Open usb device.
  48. *
  49. * @return Zero on success, others on fail.
  50. */
  51. virtual int32_t open() = 0;
  52. /**
  53. * @brief Read data from usb devices.
  54. *
  55. * @param data Read buffer.
  56. *
  57. * @param length Read size.
  58. *
  59. * @return The size of data read in bytes, zero if currently no read data available, or negative number on fail.
  60. */
  61. virtual int32_t read(void *data, uint32_t length) = 0;
  62. /**
  63. * @brief Write data into usb devices.
  64. *
  65. * @param data Write buffer.
  66. *
  67. * @param length Write size.
  68. *
  69. * @return The size of data written in bytes, negative number on fail.
  70. */
  71. virtual int32_t write(void *data, uint32_t length) = 0;
  72. /**
  73. * @brief Close usb device. Opposite to open.
  74. *
  75. * @see open
  76. */
  77. virtual void close() = 0;
  78. };
  79. /**
  80. * @class ECSDKConfig
  81. *
  82. * @brief Configure the functional interfaces of the ECSDKFramework.
  83. */
  84. class ECSDKConfigPrivate;
  85. class EC_DLL_EXPORT ECSDKConfig
  86. {
  87. public:
  88. explicit ECSDKConfig(const string& uuid, const string& version, const string& writableDir);
  89. explicit ECSDKConfig();
  90. ~ECSDKConfig();
  91. void setUUID(const string& uuid);
  92. void setVersion(const string& version);
  93. void setWorkSpace(const string& writableDir);
  94. void setCommonConfig(const string& cfgName, const string& cfgValue);
  95. void setCommonConfig(const string& cfgName, uint32_t cfgValue);
  96. void setCommonConfig(const string& cfgName, bool cfgValue);
  97. bool getCommonConfig(const string& cfgName, string& cfgValue);
  98. bool getCommonConfig(const string& cfgName, uint32_t& cfgValue);
  99. bool getCommonConfig(const string& cfgName, bool& cfgValue);
  100. inline ECSDKConfigPrivate* d_func() {
  101. return reinterpret_cast<ECSDKConfigPrivate*>(d_ptr);
  102. }
  103. private:
  104. ECSDKConfig(const ECSDKConfig &) = delete;
  105. ECSDKConfig &operator=(const ECSDKConfig &) = delete;
  106. ECSDKConfigPrivate* d_ptr;
  107. };
  108. /*!
  109. * \brief A macro used to reference ECSDKFramework instance.
  110. *
  111. * User can use this to simplify function call.
  112. */
  113. #define ecSdk (ECSDKFrameWork::ECSDKFramework::getInstance())
  114. /*!
  115. * \brief The ECSDKFramework class
  116. */
  117. class EC_DLL_EXPORT ECSDKFramework
  118. {
  119. public:
  120. /*!
  121. * \brief Singleton function.
  122. *
  123. * \return The instance of derived class.
  124. */
  125. static ECSDKFramework* getInstance();
  126. /*!
  127. * @brief Initialize ECSDKFramework environment.
  128. * After ECSDKFramework was initialized, user can call ECSDKFramework::start to communicate with the
  129. * connected phone. ECSDKFramework supports finding an connected phone(Android or iOS)
  130. * via USB cable and WiFi.
  131. *
  132. * \param cfg
  133. *
  134. * \param pListener
  135. *
  136. * \param dev This parameter usually does not require an assignment, and when the user needs to
  137. * use the eap connection mode, a read-write interface needs to be provided
  138. * \return
  139. */
  140. virtual bool initialize(ECSDKConfig* cfg, IECSDKListener* pListener) = 0;
  141. /*!
  142. * \brief release
  143. * \return
  144. */
  145. virtual void release() = 0;
  146. /*!
  147. * \brief setECSDKLogConfig
  148. * \param cfg
  149. */
  150. virtual void setECSDKLogConfig(const ECLogConfig& cfg) = 0;
  151. /*!
  152. * \brief Start this module.
  153. *
  154. * @return ECSDK_OK on success, others on fail.
  155. *
  156. * \note After calling this interface, the ECSDKFramework establishes a connection to the phone
  157. */
  158. virtual int32_t start() = 0;
  159. /*!
  160. * \brief Stop this module.
  161. *
  162. * \note Call this interface when you don't need to connect to your phone
  163. */
  164. virtual void stop() = 0;
  165. /*!
  166. * \brief Used to get version
  167. *
  168. * @return The ECSDKFramework version in string format, etc. "0.1.0.9.7.3".
  169. */
  170. virtual const string& getECVersion() = 0;
  171. /*!
  172. * \brief Used to get version code
  173. *
  174. * @return The ECSDKFramework version code.
  175. */
  176. virtual uint32_t getECVersionCode() = 0;
  177. /**
  178. * @brief This method will enable ota network update use sandbox environment.
  179. *
  180. * @note The default environment of ota network update is production.
  181. */
  182. virtual int32_t enableSandbox() = 0;
  183. /**
  184. * @brief User need to call this interface when the network state of the vehicle changes.
  185. *
  186. * \param action
  187. *
  188. * \param netInfo
  189. *
  190. * @return ECSDK_OK on success, others on fail.
  191. */
  192. virtual int32_t notifyWifiStateChanged(ECWifiStateAction action, const ECNetWorkInfo& netInfo) = 0;
  193. /**
  194. * @brief User need to call this interface when usb device state has changed.
  195. *
  196. * \param state usb device current status.
  197. *
  198. * @return ECSDK_OK on success, others on fail.
  199. */
  200. virtual int32_t notifyDeviceStateChanged(ECDeviceState state) = 0;
  201. /**
  202. * @brief This method will configure some information to tranpsport with a phone.
  203. *
  204. * @param key referred to ECTransportInfo
  205. *
  206. * @param value the value to corresponding key.
  207. *
  208. * @note Next connection takes effect.
  209. * User just need to call this method once. The config will be always valid until next ECSDKFramework::initialize.
  210. */
  211. virtual int32_t configTransportInfo(int32_t key, int32_t value) = 0;
  212. /**
  213. * @brief Bind the transport with a special device.
  214. * After binding, ECSDKFramework can access the device via the provided IECAccessDevice.
  215. *
  216. * @param type The transport to be bound.
  217. *
  218. * @param dev The device access methods, see IECAccessDevice.
  219. *
  220. * @return EC_OK on success, others on fail.
  221. *
  222. * @note Only platform-dependent transport(i.e EAP) needs to bind a USB device.
  223. */
  224. virtual int32_t bindTransportDevice(ECTransportType type, IECAccessDevice *dev) = 0;
  225. /**
  226. * @brief Unbind device for the given transport. Opposite to bindTransportDevice.
  227. *
  228. * @param type The transport to be unbound.
  229. *
  230. * @see ECSDKFramework::bindTransportDevice
  231. */
  232. virtual void unbindTransportDevice(ECTransportType type) = 0;
  233. protected:
  234. /*!
  235. * \brief Default constructor.
  236. */
  237. ECSDKFramework();
  238. /*!
  239. * \brief Destructor.
  240. */
  241. virtual ~ECSDKFramework();
  242. };
  243. }