| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- #ifndef ECSDKTOOLKIT_H
- #define ECSDKTOOLKIT_H
- #include "ECSDKTypes.h"
- namespace ECSDKFrameWork {
- /**
- * @brief The ExtrasManageListener class
- */
- class EC_DLL_EXPORT IECToolKitListener
- {
- public:
- /**
- * @brief ~ExtrasManageListener
- */
- virtual ~IECToolKitListener();
- /**
- * @brief onQueryTime
- *
- * @param gmtTime GMT(UTC) time in milliseconds.
- *
- * @param localTime Local time in milliseconds.
- *
- * @param timeZone Time zone, etc. "Asia/Shanghai".
- */
- virtual void onQueryTime(uint64_t gmtTime, uint64_t localTime, const string& timeZone) {};
- /**
- * @brief onQueryGPS
- *
- * @param status Whether GPS information is valid, true means valid.
- *
- * @param longitude GPS longitude.
- *
- * @param latitude GPS latitude.
- */
- virtual void onQueryGPS(bool status, const ECGPSInfo& info) {};
-
- /**
- * @brief Called when bulk data is received(RESERVED).
- *
- * @param data Buffer of bulk data.
- *
- * @param length Buffer length.
- *
- * @note THIS IS A RESERVED METHOD. PLEASE IGNORE IT NOW.
- */
- virtual void onBulkDataReceived(const void *data, uint32_t length) {};
- /**
- * @brief Called when forwardToPhone result.
- *
- * @param forwardInfo the forward result.
- *
- */
- virtual void onForwardToPhone(const ECForwardInfo& forwardInfo) {};
- /**
- * @brief Called when GenerateQRCodeUrl result.
- *
- * @param url The url string.
- *
- */
- virtual void onGenerateQRCodeUrl(const string& url) {};
- };
- /**
- * @class ECCustomProtocol
- *
- * @brief An abstract class to send and receive custom data between HU and phone.
- *
- * @note An instantiated object of this abstract class can be gained by ECSDKToolKit::getInstance()->getCustomProtocol().
- */
- class EC_DLL_EXPORT ECCustomProtocol
- {
- public:
- struct ECCustomData
- {
- uint32_t cmdType; ///< the cmd type of custom data
- uint32_t reqSeq; ///< the request sequence of current send or reply.
- uint32_t rspSeq; ///< the response sequence of current send or reply.
- void* data; ///< the data buffer.
- uint32_t length; ///< the length of data buffer.
- ECCustomData()
- {
- cmdType = 0;
- reqSeq = 0;
- rspSeq = 0;
- data = nullptr;
- length = 0;
- }
- };
- /**
- * @class ICustomDataResponse
- *
- * @brief An interface class to implement response for a send with reply.
- */
- class ICustomDataResponse
- {
- public:
- /**
- * @brief Called when a reply from phone was received.
- *
- * @param data The custom data of reply from phone.
- *
- * @note the rspSeq of data will be non-zero, which was equal to the reqSeq of one send.
- */
- virtual void onReceive(const ECCustomData& data) {};
- /**
- * @brief Called When an error occurs for current send.
- *
- * @param reqSeq The real reqSeq of current send.
- *
- * @param errNo The error num.
- * -1 failed to allocate memory.
- * -2 failed to send to phone.
- * -3 the version of phone app does not support the function of custom protocol.
- * @param error The error description.
- */
- virtual void onError(uint32_t reqSeq, int32_t errorNo, const string& error) {};
- /**
- * @brief Called When the specified timeout time is reached.
- *
- * @param reqSeq The real reqSeq of current send.
- */
- virtual void onTimeout(uint32_t reqSeq) {};
- };
- /**
- * @class ICustomDataReceiver
- *
- * @brief An interface class to implement receive of custom data from phone.
- */
- class ICustomDataReceiver
- {
- public:
- /**
- * @brief Called When custom data from phone was received.
- *
- * @param data The custom data of phone.
- *
- * @note the rspSeq of data will be zero.
- */
- virtual void onReceive(const ECCustomData& data) {};
- };
- /**
- * @brief set a receiver to handle receive of custom data from phone.
- *
- * @param receiver The ICustomDataReceiver object.
- */
- virtual int32_t registerCustomDataReceiver(ICustomDataReceiver* receiver) = 0;
- /**
- * @brief send custom data to phone.
- *
- * @param data The custom data.
- *
- * @param timeout Timeout for corresponding reply to current send in seconds. An value of -1 indicates no timeout.
- *
- * @param responseCallback The ICustomDataResponse object.
- *
- * @note If the send has reply, then responseCallback cann't be null.
- *
- * If the send has no reply, then responseCallback should be null. ECCustomProtocol::sendCustomData(data) can be used.
- *
- * User has no need to set reqSeq and rspSeq of data. After the method is invoked, the reqSeq and rspSeq of data is set to the actual value used.
- */
- virtual int32_t sendCustomData(ECCustomData& data, int32_t timeout = -1, ICustomDataResponse* responseCallback = nullptr) = 0;
- /**
- * @brief reply custom data to phone.
- *
- * @param data The custom data.
- *
- * @param reqSeq The reqSeq of the custom data received. It will be as rspSeq of current send to phone.
- *
- * @note User has no need to set reqSeq and rspSeq of data. After the method is invoked, the reqSeq and rspSeq of data is set to the actual value used.
- */
- virtual int32_t replyCustomData(ECCustomData& data, uint32_t reqSeq) = 0;
- };
- /*
- * @brief The ECSDKExtrasManage class
- */
- class EC_DLL_EXPORT ECSDKToolKit
- {
- public:
- /**
- * @brief getInstance
- * @return
- */
- static ECSDKToolKit *getInstance();
- /**
- * @brief initialize
- * @param pListener
- * @return
- */
- virtual bool initialize(IECToolKitListener* listener = nullptr) = 0;
- /**
- * @brief release
- * @return
- */
- virtual void release() = 0;
- /**
- * @brief Open ftp server which forwards the local ports on HUD to the ports on the connected phone.
- *
- * @param userName Specifying the username of ftp.
- *
- * @param pwd Specifying the password of ftp.
- *
- * @return ECSDK_OK on success, others on fail.
- *
- * @note This interface shall be called only after
- * IECSDKListener::onSdkConnectStatus::EC_CONNECT_PHONE_SUCCEED
- *
- */
- virtual int32_t openFtpServer(const string& userName, const string& pwd) = 0;
- /**
- * @brief Send an request to phone for time information.
- *
- * @return ECSDK_OK on success, others on fail.
- */
- virtual int32_t queryTime() = 0;
- /**
- * @brief Send an request to phone for GPS information.
- *
- * @return ECSDK_OK on success, others on fail.
- *
- * @note The query result to see ExtrasManageListener::onQueryGPS.
- */
- virtual int32_t queryGPS() = 0;
- /**
- * @brief Send bulk data to phone(RESERVED).
- *
- * @param data Buffer of bulk data.
- *
- * @param length Buffer length.
- *
- * @return ECSDK_OK on success, others on fail.
- *
- * @note THIS IS A RESERVED METHOD. PLEASE IGNORE IT NOW.
- */
- virtual int32_t sendBulkDataToPhone(const void *data, uint32_t length) = 0;
- /**
- * @brief This method can set up forwarding of HU's port to connected phone's port when connection is via usb.
- *
- * @param in Which tell the local port and remote port which will be mapped.
- *
- * @return ECSDK_OK on success, others on fail.
- *
- * @note If the connection is via wifi, ip in forwardInfo is the connected phone's ip,
- * the localPort in forwardInfo is equal to the phonePort.
- *
- * If the connection is via usb, ip in forwardInfo will be 127.0.0.1,
- * the localPort is the real port of HU forwarded to connected phone.
- *
- * IECToolKitListener::onForwardToPhone will tell the result of forwardTophone.
- */
- virtual int32_t forwardToPhone(const ECForwardInfo& in) = 0;
-
- virtual ECCustomProtocol* getCustomProtocol() = 0;
- /**
- * @brief This method will get a url string for qr code.
- *
- * @param info The ssid and pwd of info will be encoded to url.
- *
- * @return ECSDK_OK on success, others on fail.
- */
- virtual int32_t generateQRCodeUrl(const ECQRInfo& info) = 0;
- protected:
- ECSDKToolKit();
- virtual ~ECSDKToolKit();
- };
- }
- #endif // ECSDKTOOLKIT_H
|