dsi_framer_ant.hpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. /*
  2. This software is subject to the license described in the License.txt file
  3. included with this software distribution. You may not use this file except
  4. in compliance with this license.
  5. Copyright (c) Dynastream Innovations Inc. 2016
  6. All rights reserved.
  7. */
  8. #if !defined(DSI_FRAMER_ANT_HPP)
  9. #define DSI_FRAMER_ANT_HPP
  10. #include "types.h"
  11. #include "antmessage.h"
  12. #include "antdefines.h"
  13. #include "dsi_framer.hpp"
  14. #include "dsi_thread.h"
  15. //////////////////////////////////////////////////////////////////////////////////
  16. // Public Definitions
  17. //////////////////////////////////////////////////////////////////////////////////
  18. #define DSI_FRAMER_ANT_ENONE ((UCHAR) 0x00)
  19. #define DSI_FRAMER_ANT_EQUEUE_OVERFLOW ((UCHAR) 0x01)
  20. #define DSI_FRAMER_ANT_ESERIAL ((UCHAR) 0x02)
  21. #define DSI_FRAMER_ANT_EINVALID_SIZE ((UCHAR) 0x03)
  22. #define DSI_FRAMER_ANT_CRC_ERROR ((UCHAR) 0x04)
  23. #define DSI_FRAMER_ANT_DEFAULT_RESPONSE_TIME ((ULONG) 1000)
  24. #define RX_FIFO_SIZE ((USHORT) 256)
  25. typedef struct ANT_MESSAGE
  26. {
  27. UCHAR ucMessageID;
  28. UCHAR aucData[MESG_MAX_SIZE_VALUE];
  29. } ANT_MESSAGE;
  30. typedef struct
  31. {
  32. UCHAR ucSize;
  33. ANT_MESSAGE stANTMessage;
  34. } ANT_MESSAGE_ITEM;
  35. typedef enum
  36. {
  37. ANTFRAMER_FAIL = 0,
  38. ANTFRAMER_PASS = 1,
  39. ANTFRAMER_TIMEOUT = 2,
  40. ANTFRAMER_CANCELLED = 3,
  41. ANTFRAMER_INVALIDPARAM = 4
  42. } ANTFRAMER_RETURN;
  43. typedef struct
  44. {
  45. ULONG ulSize;
  46. UCHAR* pucData;
  47. } ANTFS_DATA;
  48. typedef struct
  49. {
  50. UCHAR ucCommandID;
  51. UCHAR ucMessageID;
  52. UCHAR aucData[MESG_MAX_SIZE_VALUE];
  53. } FS_MESSAGE;
  54. class ANTMessageResponse;
  55. //////////////////////////////////////////////////////////////////////////////////
  56. // Public Class Prototypes
  57. //////////////////////////////////////////////////////////////////////////////////
  58. class DSIFramerANT : public DSIFramer
  59. {
  60. private:
  61. BOOL bSplitAdvancedBursts; //If this flag is set Advanced burst messages will be decomposed into simple burst messages.
  62. UCHAR ucPrevSequenceNum; //Previous Sequence number, used for splitting advanced bursts.
  63. protected:
  64. UCHAR ucRxIndex;
  65. UCHAR aucRxFifo[RX_FIFO_SIZE];
  66. UCHAR ucCheckSum;
  67. UCHAR ucRxSize;
  68. USHORT usMessageHead;
  69. USHORT usMessageTail;
  70. ANT_MESSAGE_ITEM astMessageBuffer[65536];
  71. UCHAR ucError;
  72. UCHAR ucSerialError;
  73. BOOL bInitOkay;
  74. BOOL bClosing;
  75. UCHAR ucFSResponse;
  76. volatile BOOL *pbCancel;
  77. DSI_MUTEX stMutexCriticalSection;
  78. DSI_MUTEX stMutexResponseRequest;
  79. DSI_CONDITION_VAR stCondMessageReady;
  80. DSI_CONDITION_VAR stCondResponseReady;
  81. ANTMessageResponse *pclResponseListStart;
  82. USHORT GetMessageSize(void);
  83. void ProcessMessage(void);
  84. void CheckResponseList(void);
  85. BOOL SendCommand(ANT_MESSAGE *pstANTMessage_, USHORT usMessageSize_, ULONG ulResponseTime_ = 0);
  86. BOOL SendFSCommand(FS_MESSAGE *pstFSMessage_, USHORT usMessageSize_, UCHAR* pucFSResponse, ULONG ulResponseTime_ = 0);
  87. ANTFRAMER_RETURN SetupAckDataTransfer(UCHAR ucMessageID_, UCHAR ucANTChannel_, UCHAR *pucData_, UCHAR ucMaxDataSize_, ULONG ulResponseTime_ = 0);
  88. ANTFRAMER_RETURN SetupBurstDataTransfer(UCHAR ucMessageID_, UCHAR ucANTChannel_, UCHAR * pucData_, ULONG ulSize_,UCHAR ucMaxDataSize_, ULONG ulResponseTime_ = 0);
  89. virtual BOOL CreateAntMsg_wOptExtBuf(ANT_MESSAGE **ppstExtBufAntMsg_, ULONG ulReqMinDataSize_); ///Default implementation allocates a new standard ANT_MESSAGE struct which must be free() after use. Subclassed framers use this to allocate additional (overflow) buffer space.
  90. public:
  91. // Constuctor and Destructor
  92. DSIFramerANT();
  93. DSIFramerANT(DSISerial *pclSerial_);
  94. ~DSIFramerANT();
  95. void SetCancelParameter(volatile BOOL *pbCancel_);
  96. volatile BOOL* GetCancelParameter();
  97. BOOL Init(DSISerial *pclSerial_ = (DSISerial*)NULL);
  98. /////////////////////////////////////////////////////////////////
  99. // Initializes the DSIFramer object. Must be called before using
  100. // other methods of this class or their behaviour will be
  101. // undefined.
  102. /////////////////////////////////////////////////////////////////
  103. // Inherited methods.
  104. void ProcessByte(UCHAR ucByte_);
  105. void Error(UCHAR ucError_);
  106. BOOL WriteMessage(void *pstANTMessage_, USHORT usMessageSize_);
  107. /////////////////////////////////////////////////////////////////
  108. // As per the notes in dsi_framer.h.
  109. // Parameters:
  110. // *pstANTMessage_: A pointer to an ANT_MESSAGE structure.
  111. // usMessageSize_: The size of the data in the aucData
  112. // element of the ANT_MESSAGE structure
  113. // pointed to by *pstANTMessage_ parameter.
  114. /////////////////////////////////////////////////////////////////
  115. USHORT WaitForMessage(ULONG ulMilliseconds_);
  116. /////////////////////////////////////////////////////////////////
  117. // As per the notes in dsi_framer.h.
  118. /////////////////////////////////////////////////////////////////
  119. USHORT GetMessage(void *pstANTMessage_, USHORT usMessageSize_ = 0);
  120. /////////////////////////////////////////////////////////////////
  121. // As per the notes in dsi_framer.h.
  122. // Parameters:
  123. // *pstANTMessage_: A pointer to an ANT_MESSAGE structure.
  124. // usMessageSize_: The size of the data in the aucData
  125. // element of the ANT_MESSAGE structure
  126. // pointed to by *pstANTMessage_ parameter.
  127. // Note that this will never exceed
  128. // sizeof(ANT_MESSAGE.aucData).
  129. // Return:
  130. // messageSize on success
  131. // DSI_FRAMER_TIMEDOUT if no message is available
  132. // DSI_FRAMER_ERROR if an error occured and a msg is returned with msgID=
  133. // msgID=DSI_FRAMER_ANT_EQUEUE_OVERFLOW - the received msg queue is full and one or more messages have been discarded
  134. // msgID=DSI_FRAMER_ANT_EINVALID_SIZE - min(usMessageSize, actualMsgSize) > MESG_MAX_SIZE_VALUE and message was discarded
  135. // msgID=DSI_FRAMER_ANT_ESERIAL then data[0]=
  136. // data[0] = DSI_FRAMER_ANT_CRC_ERROR - a message failed crc check and was discarded
  137. // data[0] = DSI_SERIAL_EWRITE - the serial class reported an error writing a message, could be from a parameter error or device connection lost (if device connection lost a read error or device lost error will occur as well)
  138. // data[0] = DSI_SERIAL_EREAD - the serial class reported a read failure (the read thread is aborted, device connection is lost)
  139. // data[0] = DSI_SERIAL_DEVICE_GONE - the serial library reported the device connection is lost
  140. /////////////////////////////////////////////////////////////////
  141. // DSIFramerANT-specific methods.
  142. UCHAR GetChannelNumber(ANT_MESSAGE* pstANTMessage_);
  143. /////////////////////////////////////////////////////////////////
  144. // Parameters:
  145. // *pstANTMessage_: A pointer to an ANT_MESSAGE structure.
  146. // Returns the channel number associated to the ANT_MESSAGE
  147. // received by ANT. Returns MAX_UCHAR if this is a general
  148. // protocol event, not related to a particular channel
  149. /////////////////////////////////////////////////////////////////
  150. /////////////////////////////////////////////////////////////////
  151. // Configuration Messages
  152. /////////////////////////////////////////////////////////////////
  153. void SetSplitAdvBursts(BOOL bSplitAdvBursts_);
  154. BOOL SetNetworkKey(UCHAR ucNetworkNumber_, UCHAR *pucKey_, ULONG ulResponseTime_ = 0);
  155. BOOL UnAssignChannel(UCHAR ucANTChannel_, ULONG ulResponseTime_ = 0);
  156. BOOL AssignChannel(UCHAR ucANTChannel_, UCHAR ucChannelType_, UCHAR ucNetworkNumber_, ULONG ulResponseTime_ = 0);
  157. BOOL AssignChannelExt(UCHAR ucANTChannel_, UCHAR* pucChannelType_, UCHAR ucSize_, UCHAR ucNetworkNumber_, ULONG ulResponseTime_ = 0);
  158. BOOL SetChannelID(UCHAR ucANTChannel_, USHORT usDeviceNumber_, UCHAR ucDeviceType_, UCHAR ucTransmitType_, ULONG ulResponseTime_ = 0);
  159. BOOL SetSerialNumChannelId(UCHAR ucANTChannel_, UCHAR ucDeviceType_, UCHAR ucTransmissionType_, ULONG ulResponseTime_= 0);
  160. BOOL SetChannelPeriod(UCHAR ucANTChannel_, USHORT usMessagePeriod_, ULONG ulResponseTime_ = 0);
  161. BOOL SetFastSearch(UCHAR ucANTChannel_, ULONG ulResponseTime_ = 0);
  162. BOOL SetChannelSearchTimeout(UCHAR ucANTChannel_, UCHAR ucSearchTimeout_, ULONG ulResponseTime_);
  163. BOOL SetLowPriorityChannelSearchTimeout(UCHAR ucANTChannel_, UCHAR ucSearchTimeout_, ULONG ulResponseTime_ = 0);
  164. BOOL SetChannelRFFrequency(UCHAR ucANTChannel_,UCHAR ucRFFrequency_, ULONG ulResponseTime_ = 0);
  165. BOOL SetAllChannelsTransmitPower(UCHAR ucTransmitPower_, ULONG ulResponseTime_ = 0);
  166. BOOL SetChannelTransmitPower(UCHAR ucANTChannel_,UCHAR ucTransmitPower_, ULONG ulResponseTime_ = 0);
  167. BOOL InitCWTestMode(ULONG ulResponseTime_ = 0);
  168. BOOL SetCWTestMode(UCHAR ucTransmitPower_, UCHAR ucRFFreq_, ULONG ulResponseTime_ = 0);
  169. BOOL AddChannelID(UCHAR ucANTChannel_, USHORT usDeviceNumber_, UCHAR ucDeviceType_, UCHAR ucTransmissionType_, UCHAR ucListIndex_, ULONG ulResponseTime_ = 0);
  170. BOOL AddCryptoID(UCHAR ucANTChannel_, UCHAR* pucData_, UCHAR ucListIndex_, ULONG ulResponseTime_ = 0);
  171. BOOL ConfigList(UCHAR ucANTChannel_, UCHAR ucListSize_, UCHAR ucExclude_, ULONG ulResponseTime_ = 0);
  172. BOOL ConfigCryptoList(UCHAR ucANTChannel_, UCHAR ucListSize_, UCHAR ucBlacklist_, ULONG ulResponseTime_ = 0);
  173. BOOL OpenRxScanMode(ULONG ulResponseTime_ = 0);
  174. BOOL SetProximitySearch(UCHAR ucANTChannel_, UCHAR ucSearchThreshold_, ULONG ulResponseTime_ = 0);
  175. BOOL ConfigEventBuffer(UCHAR ucConfig_, USHORT usSize_, USHORT usTime_, ULONG ulResponseTime_ = 0);
  176. BOOL ConfigEventFilter(USHORT usEventFilter_, ULONG ulResponseTime_ = 0);
  177. BOOL ConfigHighDutySearch(UCHAR ucEnable_, UCHAR ucSuppressionCycles_, ULONG ulResponseTime_ = 0);
  178. BOOL ConfigSelectiveDataUpdate(UCHAR ucANTChannel_, UCHAR ucSduConfig_, ULONG ulResponseTime_ = 0);
  179. BOOL SetSelectiveDataUpdateMask(UCHAR ucMaskNumber_, UCHAR* pucSduMask_, ULONG ulResponseTime_ = 0);
  180. BOOL ConfigUserNVM(USHORT usAddress_, UCHAR* pucData_, UCHAR ucSize_, ULONG ulResponseTime_ = 0);
  181. BOOL SetChannelSearchPriority(UCHAR ucANTChannel_, UCHAR ucPriorityLevel_, ULONG ulResponseTime_ = 0);
  182. BOOL SetSearchSharingCycles(UCHAR ucANTChannel_, UCHAR ucSearchSharingCycles_, ULONG ulResponseTime_ = 0);
  183. BOOL ConfigFrequencyAgility(UCHAR ucANTChannel_, UCHAR ucFreq1_, UCHAR ucFreq2_, UCHAR ucFreq3_, ULONG ulResponseTime_ = 0);
  184. BOOL SleepMessage(ULONG ulResponseTime_ = 0);
  185. BOOL CrystalEnable(ULONG ulResponseTime_ = 0);
  186. BOOL SetLibConfig(UCHAR ucLibConfigFlags_, ULONG ulResponseTime_ = 0);
  187. BOOL ConfigAdvancedBurst_ext(BOOL bEnable_, UCHAR ucMaxPacketLength_,
  188. ULONG ulRequiredFields_, ULONG ulOptionalFields_,
  189. USHORT usStallCount_, UCHAR ucRetryCount_, ULONG ulResponseTime_);
  190. BOOL ConfigAdvancedBurst(BOOL bEnable_, UCHAR ucMaxPacketLength_,
  191. ULONG ulRequiredFields_, ULONG ulOptionalFields_,
  192. ULONG ulResponseTime_);
  193. BOOL SetCryptoKey(UCHAR ucVolatileKeyIndex, UCHAR *pucKey_, ULONG ulResponseTime_ = 0);
  194. BOOL SetCryptoID(UCHAR *pucData_, ULONG ulResponseTime_ = 0);
  195. BOOL SetCryptoUserInfo(UCHAR *pucData_, ULONG ulResponseTime_ = 0);
  196. BOOL SetCryptoRNGSeed(UCHAR *pucData_, ULONG ulResponseTime_ = 0);
  197. BOOL SetCryptoInfo(UCHAR ucParameter_, UCHAR *pucData_, ULONG ulResponseTime_ = 0);
  198. BOOL LoadCryptoKeyNVMOp(UCHAR ucNVMKeyIndex_, UCHAR ucVolatileKeyIndex_, ULONG ulResponseTime_ = 0);
  199. BOOL StoreCryptoKeyNVMOp(UCHAR ucNVMKeyIndex_, UCHAR *pucKey_, ULONG ulResponseTime_ = 0);
  200. BOOL CryptoKeyNVMOp(UCHAR ucOperation_, UCHAR ucNVMKeyIndex_, UCHAR *pucData_, ULONG ulResponseTime_ = 0);
  201. /////////////////////////////////////////////////////////////////
  202. // Script Messages for SensRcore use
  203. /////////////////////////////////////////////////////////////////
  204. BOOL ScriptWrite( UCHAR ucSize_, UCHAR *pucCmdData_, ULONG ulResponseTime_ = 0);
  205. BOOL ScriptClear( ULONG ulResponseTime_ = 0);
  206. BOOL ScriptSetDefaultSector( UCHAR ucSectNumber_, ULONG ulResponseTime_ = 0);
  207. BOOL ScriptEndSector( ULONG ulResponseTime_ = 0);
  208. BOOL ScriptDump( ULONG ulResponseTime_ = 0);
  209. BOOL ScriptLock( ULONG ulResponseTime_ = 0);
  210. ////////////////////////////////////////////////////////////////
  211. // FIT1e Messages
  212. /////////////////////////////////////////////////////////////////
  213. BOOL FITSetFEState(UCHAR ucFEState_, ULONG ulResponseTime_ = 0);
  214. BOOL FITAdjustPairingSettings(UCHAR ucSearchLv_, UCHAR ucPairLv_, UCHAR ucTrackLv_, ULONG ulResponseTime_ = 0);
  215. /////////////////////////////////////////////////////////////////
  216. // Request messages
  217. /////////////////////////////////////////////////////////////////
  218. BOOL RequestMessage(UCHAR ucChannel_, UCHAR ucMessageID_);
  219. BOOL GetCapabilities(UCHAR *pucCapabilities_ = (UCHAR *)NULL, ULONG ulResponseTime_ = 0);
  220. /////////////////////////////////////////////////////////////////
  221. // Parameters:
  222. // *pucCapabilities_: The array to copy the capabilities
  223. // bytes into.
  224. // *pucMaxBytes_: A pointer to the number of bytes the
  225. // passed in buffer can hold. The function
  226. // will update the pointer to indicate how
  227. // many bytes were copied.
  228. // ulResponseTime_: The time to wait for a response (milliseconds)
  229. //
  230. // Return:
  231. // FALSE if the request for capabilities fails.
  232. // FALSE if ulResponseTime_ is 0,
  233. // or pucMaxBytes_ is null
  234. // or pucCapabilities_ is null.
  235. // TRUE if Capabilities successfully copied. If copied
  236. // successfully, pucMaxBytes_ will be updated to reflect
  237. // how many bytes were copied.
  238. /////////////////////////////////////////////////////////////////
  239. BOOL GetCapabilitiesExt(UCHAR *pucCapabilities_ = (UCHAR *)NULL, UCHAR *pucMaxBytes_ = (UCHAR *)NULL, ULONG ulResponseTime_ = 0);
  240. BOOL GetChannelID(UCHAR ucANTChannel_, USHORT *pusDeviceNumber_ = (USHORT *)NULL, UCHAR *pucDeviceType_ = (UCHAR *)NULL, UCHAR *pucTransmitType_ = (UCHAR *)NULL, ULONG ulResponseTime_ = 0);
  241. BOOL GetChannelStatus(UCHAR ucANTChannel_, UCHAR *pucStatus_ = (UCHAR *)NULL, ULONG ulResponseTime_ = 0);
  242. BOOL SendRequest(UCHAR ucRequestedMesgID_, UCHAR ucANTChannel_, ANT_MESSAGE_ITEM *pstANTResponse_ = (ANT_MESSAGE_ITEM *)NULL, ULONG ulResponseTime_ = 0);
  243. BOOL SendUserNvmRequest(UCHAR ucRequestedMesgID_, UCHAR ucANTChannel_, ANT_MESSAGE_ITEM *pstANTResponse_ = (ANT_MESSAGE_ITEM *)NULL, USHORT usAddress_ = 0, UCHAR ucSize_ = 0, ULONG ulResponseTime_ = 0);
  244. BOOL SendFSRequest(UCHAR MesgSize, ANT_MESSAGE_ITEM *pstANTResponse_, FS_MESSAGE stMessage, ULONG ulResponseTime_ = 0);
  245. /////////////////////////////////////////////////////////////////
  246. // Control messages
  247. /////////////////////////////////////////////////////////////////
  248. BOOL ResetSystem(ULONG ulResponseTime_ = 0);
  249. BOOL OpenChannel(UCHAR ucANTChannel_, ULONG ulResponseTime_ = 0);
  250. BOOL CloseChannel(UCHAR ucANTChannel_, ULONG ulResponseTime_ = 0);
  251. BOOL RxExtMesgsEnable(UCHAR ucEnable_, ULONG ulResponseTime_ = 0);
  252. BOOL EnableLED(UCHAR ucEnable_, ULONG ulResponseTime_ = 0);
  253. BOOL SetRSSISearchThreshold(UCHAR ucANTChannel_, UCHAR ucSearchThreshold_, ULONG ulResponseTime_ = 0);
  254. BOOL EncryptedChannelEnable(UCHAR ucANTChannel_, UCHAR ucMode_, UCHAR ucVolatileKeyIndex_, UCHAR ucDecimationRate_, ULONG ulResponseTime_ = 0);
  255. /////////////////////////////////////////////////////////////////
  256. // The following are the synchronous RF event functions used to
  257. // update the synchronous data sent over a channel
  258. /////////////////////////////////////////////////////////////////
  259. BOOL SendBroadcastData(UCHAR ucANTChannel_,UCHAR *pucData_);
  260. BOOL SendBurstDataPacket(UCHAR ucANTChannelSeq_, UCHAR *pucData_);
  261. BOOL SendAdvancedBurstDataPacket(UCHAR ucANTChannelSeq_, UCHAR *pucData_, UCHAR ucStdPcktsPerSerialMsg_);
  262. ANTFRAMER_RETURN SendAcknowledgedData(UCHAR ucANTChannel_, UCHAR *pucData_, ULONG ulResponseTime_ = 0);
  263. BOOL SendExtBroadcastData(UCHAR ucANTChannel_, UCHAR *pucData_);
  264. BOOL SendExtAcknowledgedData(UCHAR ucANTChannel, UCHAR *pucData, ULONG ulResponseTime_ = 0);
  265. BOOL SendExtBurstTransferPacket(UCHAR ucANTChannelSeq_, UCHAR *pucData_);
  266. ANTFRAMER_RETURN SendExtBurstTransfer(UCHAR ucANTChannel_, UCHAR *pucData_, ULONG ulSize_, ULONG ulResponseTime_ = 0);
  267. ANTFRAMER_RETURN SendTransfer(UCHAR ucANTChannel_, UCHAR * pucData_, ULONG ulSize_, ULONG ulResponseTime_ = 0);
  268. ANTFRAMER_RETURN SendAdvancedTransfer(UCHAR ucANTChannel_, UCHAR * pucData_, ULONG ulSize_, UCHAR ucStdPcktsPerSerialMsg_, ULONG ulResponseTime_ = 0);
  269. ANTFRAMER_RETURN SendANTFSTransfer(UCHAR ucANTChannel_, UCHAR* pucHeader_, UCHAR* pucFooter_, UCHAR * pucData_, ULONG ulSize_, ULONG ulResponseTime_, volatile ULONG *pulProgress_);
  270. ANTFRAMER_RETURN SendANTFSClientTransfer(UCHAR ucANTChannel_, ANTFS_DATA* pstHeader_, ANTFS_DATA* pstFooter_, ANTFS_DATA* pstData_, ULONG ulResponseTime_, volatile ULONG *pulProgress_);
  271. //////////////////////////////////////////////////////////////////
  272. // USB Functions (platform specific)
  273. //////////////////////////////////////////////////////////////////
  274. BOOL SetUSBDescriptorString(UCHAR ucStringNum_, UCHAR* pucDescString_, UCHAR ucStringSize_, ULONG ulResponseTime_ = 0);
  275. BOOL GetDeviceUSBInfo(UCHAR ucDeviceNum_, UCHAR* pucProductString_, UCHAR* pucSerialString_, USHORT usBufferSize_);
  276. BOOL GetDeviceUSBPID(USHORT& usPid_);
  277. BOOL GetDeviceUSBVID(USHORT& usVid_);
  278. /////////////////////////////////////////////////////////////////
  279. /////////////////////////////////////////////////////////////////
  280. /////////////////////////////////////////////////////////////////
  281. // ANT_IntegratedClient Implementation
  282. /////////////////////////////////////////////////////////////////
  283. /////////////////////////////////////////////////////////////////
  284. /////////////////////////////////////////////////////////////////
  285. //Memory Device Commands
  286. BOOL InitEEPROMDevice(USHORT usPageSize_, UCHAR ucAddressConfig_, ULONG ulResponseTime_);
  287. //File System Commands
  288. BOOL InitFSMemory(ULONG ulResponseTime_);
  289. BOOL FormatFSMemory(USHORT usNumberOfSectors_, USHORT usPagesPerSector_, ULONG ulResponseTime_);
  290. BOOL SaveDirectory(ULONG ulResponseTime_);
  291. BOOL DirectoryRebuild(ULONG ulResponseTime_);
  292. BOOL FileDelete(UCHAR ucFileHandle_, ULONG ulResponseTime_);
  293. BOOL FileClose(UCHAR ucFileHandle_,ULONG ulResponseTime_);
  294. BOOL SetFileSpecificFlags(UCHAR ucFileHandle_, UCHAR ucFlags_,ULONG ulResponseTime_);
  295. UCHAR DirectoryReadLock(BOOL bLock_, ULONG ulResponseTime_);
  296. BOOL SetSystemTime(ULONG ulTime_, ULONG ulResponseTime_);
  297. //File System Requests
  298. ULONG GetUsedSpace(ULONG ulResponseTime_);
  299. ULONG GetFreeFSSpace(ULONG ulResponseTime_);
  300. USHORT FindFileIndex(UCHAR ucFileDataType_, UCHAR ucFileSubType_, USHORT usFileNumber_, ULONG ulResponseTime_);
  301. UCHAR ReadDirectoryAbsolute(ULONG ulOffset_, UCHAR ucSize_, UCHAR* pucBuffer_, ULONG ulResponseTime_);
  302. UCHAR DirectoryReadEntry (USHORT usFileIndex_, UCHAR* ucFileDirectoryBuffer_, ULONG ulResponseTime_);
  303. ULONG DirectoryGetSize(ULONG ulResponseTime_);
  304. USHORT FileCreate(USHORT usFileIndex_, UCHAR ucFileDataType_, ULONG ulFileIdentifier_, UCHAR ucFileDataTypeSpecificFlags_, UCHAR ucGeneralFlags, ULONG ulResponseTime_);
  305. UCHAR FileOpen(USHORT usFileIndex_, UCHAR ucOpenFlags_, ULONG ulResponseTime_);
  306. UCHAR FileReadAbsolute(UCHAR ucFileHandle_, ULONG ulOffset_, UCHAR ucReadSize_, UCHAR* pucReadBuffer_, ULONG ulResponseTime_);
  307. UCHAR FileReadRelative(UCHAR ucFileHandle_, UCHAR ucReadSize_, UCHAR *pucReadBuffer_, ULONG ulResponseTime_);
  308. UCHAR FileWriteAbsolute(UCHAR ucFileHandle_, ULONG ulFileOffset_, UCHAR ucWriteSize_, const UCHAR* pucWriteBuffer_, UCHAR* ucBytesWritten_, ULONG ulResponseTime_);
  309. UCHAR FileWriteRelative(UCHAR ucFileHandle_, UCHAR ucWriteSize_, const UCHAR* pucWriteBuffer_, UCHAR* ucBytesWritten_, ULONG ulResponseTime_);
  310. ULONG FileGetSize(UCHAR ucFileHandle_, ULONG ulResponseTime_);
  311. ULONG FileGetSizeInMem(UCHAR ucFileHandle_, ULONG ulResponseTime_);
  312. UCHAR FileGetSpecificFlags(UCHAR ucFileHandle_, ULONG ulResponseTime_);
  313. ULONG FileGetSystemTime(ULONG ulResponseTime_);
  314. //FS-Crypto Commands
  315. UCHAR CryptoAddUserKeyIndex(UCHAR ucIndex_, UCHAR* pucKey_, ULONG ulResponseTime_);
  316. UCHAR CryptoSetUserKeyIndex(UCHAR ucIndex_, ULONG ulResponseTime_);
  317. UCHAR CryptoSetUserKeyVal(UCHAR* pucKey_, ULONG ulResponseTime_);
  318. //FIT Commands
  319. UCHAR FitFileIntegrityCheck(UCHAR ucFileHandle_, ULONG ulResponseTime_);
  320. //ANT-FS Commands
  321. UCHAR OpenBeacon(ULONG ulResponseTime_);
  322. UCHAR CloseBeacon(ULONG ulResponseTime_);
  323. UCHAR ConfigBeacon(USHORT usDeviceType_, USHORT usManufacturer_, UCHAR ucAuthType_, UCHAR ucBeaconStatus_, ULONG ulResponseTime_);
  324. UCHAR SetFriendlyName(UCHAR ucLength_, const UCHAR* pucString_, ULONG ulResponseTime_);
  325. UCHAR SetPasskey(UCHAR ucLength_, const UCHAR* pucString_, ULONG ulResponseTime_);
  326. UCHAR SetBeaconState(UCHAR ucBeaconStatus_, ULONG ulResponseTime_);
  327. UCHAR PairResponse(BOOL bAccept_, ULONG ulResponseTime_);
  328. UCHAR SetLinkFrequency(UCHAR ucChannelNumber_, UCHAR ucFrequency_, ULONG ulResponseTime_);
  329. UCHAR SetBeaconTimeout(UCHAR ucTimeout_, ULONG ulResponseTime_);
  330. UCHAR SetPairingTimeout(UCHAR ucTimeout_, ULONG ulResponseTime_);
  331. UCHAR EnableRemoteFileCreate(BOOL bEnable_, ULONG ulResponseTime_);
  332. //ANT-FS Responses
  333. UCHAR GetCmdPipe(UCHAR ucOffset_, UCHAR ucReadSize_, UCHAR* pucReadBuffer_, ULONG ulResponseTime_);
  334. UCHAR SetCmdPipe(UCHAR ucOffset_, UCHAR ucWriteSize_, const UCHAR* pucWriteBuffer_, ULONG ulResponseTime_);
  335. //GetFSResponse
  336. UCHAR GetLastError();
  337. /////////////////////////////////////////////////////////////////
  338. /////////////////////////////////////////////////////////////////
  339. /////////////////////////////////////////////////////////////////
  340. friend class ANTMessageResponse;
  341. };
  342. class ANTMessageResponse
  343. {
  344. public:
  345. // Constuctor and Destructor
  346. ANTMessageResponse();
  347. ~ANTMessageResponse();
  348. BOOL Attach(UCHAR ucMessageID_, UCHAR *pucData_, UCHAR ucBytesToMatch_, DSIFramerANT * pclFramer_, DSI_CONDITION_VAR *pstCondResponseReady_ = (DSI_CONDITION_VAR*)NULL);
  349. void Remove();
  350. BOOL WaitForResponse(ULONG ulMilliseconds_);
  351. ///////////////////////////////////////////////////////////////
  352. // Variables
  353. ///////////////////////////////////////////////////////////////
  354. DSIFramerANT * pclFramer;
  355. ANTMessageResponse * pclNext;
  356. UCHAR ucBytesToMatch;
  357. ANT_MESSAGE_ITEM stMessageItem;
  358. DSI_CONDITION_VAR stCondResponseReady;
  359. DSI_CONDITION_VAR *pstCondResponseReady;
  360. BOOL bResponseReady;
  361. };
  362. #endif // !defined(DSI_FRAMER_ANT_HPP)