OTA.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. #ifndef __OTA_20190702__
  2. #define __OTA_20190702__
  3. #include "SynSerial.h"
  4. #include <list>
  5. #define BUFFER_LEN 10240
  6. #pragma once
  7. typedef struct __SIACP__
  8. {
  9. std::string name; // 命令描述;
  10. std::string head; // 命令头;
  11. std::string code; // 命令码;
  12. std::string mark; // 特殊标记;
  13. bool bMulticode ; // 命令码是否多参数;
  14. int cmd_wait_time ; // 两条串口指令间隔时间;
  15. int read_wait_time ; // 写完串口后,等待多久读;
  16. } _SIACP_, *_pSIACP_;
  17. // 包头码(包引导码)
  18. enum PHeader {
  19. TV_Debug = 0xAA,
  20. TV_Return = 0xAB,
  21. TV_Panel_Debug = 0xAC,
  22. TV_Panel_Return = 0xAD,
  23. TV_Debug_Other = 0xAE,
  24. TV_Other_Return = 0xAF,
  25. };
  26. // 命令结果码;
  27. enum RCode {
  28. RC_OK = 0x0A, // 命令执行通过;
  29. RC_ERR = 0x0E, // 命令错误或无法执行;
  30. RC_LOSE = 0x0F, // 命令丢失(链路层出错);
  31. };
  32. //////////////////////////////////////////////////////////////////////////
  33. enum LOG_ENUM
  34. {
  35. NORMAL_LOG = 0,
  36. ERROR_LOG,
  37. OK_LOG,
  38. INFO_LOG
  39. };
  40. extern std::string HexString2Bytes(std::string strHex, const int& len /* = 3 */);
  41. extern std::string Bytes2HexString(const unsigned char* pbuffer, int nLen);
  42. extern std::string Bytes2HexString(const unsigned char* pbuffer, int nLen, char chSpace);
  43. class CSIACP
  44. {
  45. public:
  46. CSIACP(void);
  47. ~CSIACP(void);
  48. void SetMainDlg(void* p);
  49. void ShowMessage(LPCTSTR lpMsg, LOG_ENUM logtype = NORMAL_LOG);
  50. protected:
  51. CSynSerial* m_pSerial;
  52. void* m_pMainDlg;
  53. typedef struct __RTN__
  54. {
  55. int len; // 返回的数据长度;
  56. std::string data; // 返回的数据内容;
  57. __RTN__()
  58. {
  59. len = 0;
  60. }
  61. }RTN, * pRTN;
  62. std::vector<RTN> m_vtdata;
  63. std::vector<_SIACP_> m_vtcommand;
  64. BOOL ExecSerialCommand(const _SIACP_& siacp, std::string command);
  65. BOOL ParserSerialData(std::vector<RTN>& vtdata, const _SIACP_& siacp, byte* pbuffer, DWORD dwlen);
  66. const _SIACP_* GetSiacp(std::string name);
  67. std::string GetSiacpCommand(const _SIACP_& siacp, std::string others, int othersLen);
  68. std::string GetSiacpCommand(std::string name, std::string others, int othersLen);
  69. public:
  70. void LoadCommand();
  71. void SaveCommand(std::vector<_SIACP_> &vtSiacp, std::string path);
  72. void SaveCommand(_SIACP_ (&Siacp)[42], std::string path);
  73. BOOL OpenComm(int nSerialPort, DWORD dwBaudrate);
  74. void CloseComm();
  75. BOOL IsOpen() {
  76. return m_pSerial && m_pSerial->IsOpen();
  77. }
  78. BOOL SendCommand(std::string cmd_name, const byte* pszOthers = NULL, DWORD dwOthersLen = 0);
  79. BOOL SendCommand2(std::string cmd_name, std::string data = "", size_t nlen = 0);
  80. public:
  81. // 等待tv启动成功;
  82. BOOL SCBC_WaitTVBoot();
  83. BOOL SCBC_MTKInit();
  84. // 进入工厂模式;
  85. BOOL SCBC_EnterFactory();
  86. // 离开工厂模式;
  87. BOOL SCBC_LeaveFactory();
  88. // 初始化Wb;
  89. BOOL SCBC_WBInit();
  90. // 获取pid;
  91. BOOL SCBC_GetProjectId(int& pid);
  92. // 软件版本号;
  93. BOOL SCBC_GetSoftVersion(std::string& strVer);
  94. // 设备ID
  95. BOOL SCBC_GetDeviceId(std::string& strDid);
  96. // ClientType;
  97. BOOL SCBC_GetClientType(std::string& strClt);
  98. // MAC地址;
  99. BOOL SCBC_GetMAC(std::string& strMac);
  100. // HDCP Key;
  101. BOOL SCBC_GetHDCPKey(std::string& strHDCP);
  102. // HDCP Key2.2;
  103. BOOL SCBC_GetHDCPKey22(std::string& strHDCP22);
  104. // Widi;
  105. BOOL SCBC_GetWidi(std::string& strWidi);
  106. // Netflix ESN;
  107. BOOL SCBC_GetNetflixESN(std::string& strESN);
  108. // Widevine;
  109. BOOL SCBC_GetWidevine(std::string& strWidevine);
  110. // ci plus key;
  111. BOOL SCBC_GetCiKey(std::string& strCikey);
  112. // OSD Language;
  113. BOOL SCBC_GetOSDLanguage(std::string& strOSDLan);
  114. // Shop Language;
  115. BOOL SCBC_GetShopLanguage(std::string& strShopLan);
  116. BOOL SCBC_GetChannel(std::string& channel);
  117. BOOL SCBC_SetProjectId(const int& pid);
  118. BOOL SCBC_SetProjectId(std::string pid);
  119. BOOL SCBC_SetProjectId(const byte* pBuffer, const int& nLen);
  120. BOOL SCBC_SetDeviceId(std::string strDeviceId);
  121. BOOL SCBC_SetDeviceId(const byte* pBuffer, const int &nLen);
  122. BOOL SCBC_SetMAC(std::string strMac);
  123. BOOL SCBC_SetMAC(const byte* pBuffer, const int& nLen);
  124. BOOL SCBC_SetHDCPKey(std::string strHDCP, BOOL bHasSpace = FALSE);
  125. BOOL SCBC_SetHDCPKey(const byte* pBuffer, const int& nLen);
  126. BOOL SCBC_SetHDCPKey22(std::string strHDCP22, BOOL bHasSpace = FALSE);
  127. BOOL SCBC_SetHDCPKey22(const byte* pBuffer, const int& nLen);
  128. BOOL SCBC_SetNetflixESN(std::string strESN, BOOL bHasSpace = FALSE);
  129. BOOL SCBC_SetNetflixESN(const byte* pBuffer, const int& nLen);
  130. BOOL SCBC_SetWidi(std::string strWidi, BOOL bHasSpace = FALSE);
  131. BOOL SCBC_SetWidi(const byte* pBuffer, const int& nLen);
  132. BOOL SCBC_SetWidevine(std::string strWidevine, BOOL bHasSpace = FALSE);
  133. BOOL SCBC_SetWidevine(const byte* pBuffer, const int& nLen);
  134. BOOL SCBC_SetCiKey(std::string strCiKey, BOOL bHasSpace = FALSE);
  135. BOOL SCBC_SetCiKey(const byte* pBuffer, const int& nLen);
  136. BOOL SCBC_SetOSDLanguage(std::string lan, BOOL bHasSpace = TRUE);
  137. BOOL SCBC_SetOSDLanguage(const byte* pBuffer, const int& nLen);
  138. BOOL SCBC_SetShopLanguage(std::string lan, BOOL bHasSpace = TRUE);
  139. BOOL SCBC_SetShopLanguage(const byte* pBuffer, const int& nLen);
  140. BOOL SCBC_SetChannel(std::string channel, BOOL bHasSpace = TRUE);
  141. BOOL SCBC_SetChannel(const byte* pBuffer, const int& nLen);
  142. BOOL SCBC_SetWBNormal(std::string data);
  143. BOOL SCBC_SetWBNormal(const byte* pBuffer, const int& nLen);
  144. BOOL SCBC_SetWBCool(std::string data);
  145. BOOL SCBC_SetWBCool(const byte* pBuffer, const int& nLen);
  146. BOOL SCBC_SetWBWarm(std::string data);
  147. BOOL SCBC_SetWBWarm(const byte* pBuffer, const int& nLen);
  148. BOOL SCBC_CheckDeviceId();
  149. BOOL SCBC_CheckMAC();
  150. BOOL SCBC_CheckHDCP();
  151. BOOL SCBC_CheckHDCP22();
  152. BOOL SCBC_CheckNetflixESN();
  153. BOOL SCBC_CheckWidi();
  154. BOOL SCBC_CheckWidevine();
  155. BOOL SCBC_CheckCikey();
  156. BOOL SCBC_StarWarmUpMode();
  157. BOOL SCBC_StopWarmUpMode();
  158. };
  159. extern std::string HexString2Bytes(std::string strHex, const int& len = 3);
  160. #endif