antfs_host_channel.hpp 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022
  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(ANTFS_HOST_CHANNEL_HPP)
  9. #define ANTFS_HOST_CHANNEL_HPP
  10. #include "types.h"
  11. #include "dsi_thread.h"
  12. #include "dsi_timer.hpp"
  13. #include "dsi_framer_ant.hpp"
  14. #include "dsi_debug.hpp"
  15. #include "dsi_response_queue.hpp"
  16. #include "dsi_ant_message_processor.hpp"
  17. #include "antfsmessage.h"
  18. #include "antfs_host_interface.hpp"
  19. //////////////////////////////////////////////////////////////////////////////////
  20. // Public Definitions
  21. //////////////////////////////////////////////////////////////////////////////////
  22. #define DIRECT_TRANSFER_SIZE ((MAX_USHORT + 1) * 8)
  23. #define MAX_IGNORE_LIST_SIZE 2048
  24. UCHAR const aucTransportFrequencyList[16] = {3 ,7 ,15,20,25,29,34,40,45,49,54,60,65,70,75,80};
  25. #define TRANSPORT_FREQUENCY_LIST_SIZE ((UCHAR)sizeof(aucTransportFrequencyList))
  26. #define SEARCH_DEVICE_LIST_MAX_SIZE 512
  27. typedef struct
  28. {
  29. USHORT usHandle;
  30. ANTFS_DEVICE_PARAMETERS sDeviceParameters;
  31. ANTFS_DEVICE_PARAMETERS sDeviceSearchMask;
  32. } DEVICE_PARAMETERS_ITEM;
  33. typedef struct
  34. {
  35. USHORT usID;
  36. USHORT usManufacturerID;
  37. USHORT usDeviceType;
  38. USHORT usTimeout;
  39. } IGNORE_LIST_ITEM;
  40. typedef struct
  41. {
  42. ULONG ul_cfg_auth_timeout;
  43. ULONG ul_cfg_erase_timeout;
  44. ULONG ul_cfg_upload_request_timeout;
  45. ULONG ul_cfg_upload_response_timeout;
  46. ULONG ul_cfg_burst_check_timeout;
  47. } ANTFS_CONFIG_PARAMETERS;
  48. /////////////////////////////////////////////////////////////////
  49. // This class implements the ANT-FS Host specification.
  50. // It is intended to be used together with another class that manages
  51. // the connection to an ANT USB stick (e.g. DSIANTDevice or
  52. // .NET ANT_Device).
  53. /////////////////////////////////////////////////////////////////
  54. class ANTFSHostChannel : public ANTFSHostInterface, public DSIANTMessageProcessor
  55. {
  56. private:
  57. //////////////////////////////////////////////////////////////////////////////////
  58. // Private Definitions
  59. //////////////////////////////////////////////////////////////////////////////////
  60. enum ENUM_ANTFS_REQUEST
  61. {
  62. ANTFS_REQUEST_NONE = 0,
  63. ANTFS_REQUEST_INIT, // Init()
  64. ANTFS_REQUEST_SESSION_REQ, // RequestSession()
  65. ANTFS_REQUEST_SEARCH, // SearchForDevice()
  66. ANTFS_REQUEST_ID, // Request ID
  67. ANTFS_REQUEST_PING, // Ping
  68. ANTFS_REQUEST_PAIR, // Pair
  69. ANTFS_REQUEST_PROCEED, // ProceedToTransport
  70. ANTFS_REQUEST_AUTHENTICATE, // Authenticate()
  71. ANTFS_REQUEST_CONNECT, // Connect
  72. ANTFS_REQUEST_DISCONNECT, // Disconnect()
  73. ANTFS_REQUEST_CHANGE_LINK, // ChangeTransportChannelParameters()
  74. ANTFS_REQUEST_DOWNLOAD, // Download()
  75. ANTFS_REQUEST_UPLOAD, // Upload()
  76. ANTFS_REQUEST_MANUAL_TRANSFER, // ManualTransfer()
  77. ANTFS_REQUEST_ERASE, // EraseData()
  78. ANTFS_REQUEST_CONNECTION_LOST, // Internal, keep these at the end of the list order is important
  79. ANTFS_REQUEST_HANDLE_SERIAL_ERROR, // Internal
  80. ANTFS_REQUEST_SERIAL_ERROR_HANDLED // Internal
  81. };
  82. enum RETURN_STATUS
  83. {
  84. RETURN_FAIL = 0,
  85. RETURN_PASS,
  86. RETURN_STOP,
  87. RETURN_REJECT,
  88. RETURN_NA,
  89. RETURN_SERIAL_ERROR
  90. };
  91. //////////////////////////////////////////////////////////////////////////////////
  92. // Private Variables
  93. //////////////////////////////////////////////////////////////////////////////////
  94. DSIResponseQueue<ANTFS_HOST_RESPONSE> clResponseQueue;
  95. volatile BOOL bIgnoreListRunning;
  96. volatile BOOL bForceFullInit;
  97. BOOL bInitFailed;
  98. BOOL bPingEnabled;
  99. BOOL bForceUploadOffset;
  100. BOOL bRequestPageEnabled;
  101. UCHAR aucResponseBuf[MESG_MAX_SIZE_VALUE];
  102. UCHAR aucRxBuf[MESG_MAX_SIZE_VALUE];
  103. UCHAR aucTxBuf[MESG_MAX_SIZE_VALUE];
  104. UCHAR aucRemoteFriendlyName[FRIENDLY_NAME_MAX_LENGTH];
  105. UCHAR ucRemoteFriendlyNameLength;
  106. UCHAR ucAuthType;
  107. UCHAR aucTxPassword[TX_PASSWORD_MAX_LENGTH];
  108. volatile UCHAR ucTxPasswordLength;
  109. volatile UCHAR ucPasswordLength;
  110. UCHAR *pucUploadData;
  111. UCHAR *pucResponseBuffer;
  112. UCHAR *pucResponseBufferSize;
  113. ULONG ulAuthResponseTimeout;
  114. ULONG ulHostSerialNumber;
  115. ULONG ulFoundBeaconHostID;
  116. UCHAR ucChannelStatus;
  117. UCHAR ucRejectCode;
  118. UCHAR ucDisconnectType;
  119. UCHAR ucUndiscoverableTimeDuration;
  120. UCHAR ucUndiscoverableAppSpecificDuration;
  121. ANTFS_DEVICE_PARAMETERS stFoundDeviceParameters;
  122. volatile USHORT usFoundBeaconPeriod;
  123. volatile USHORT usFoundANTFSDeviceID;
  124. volatile USHORT usFoundANTFSManufacturerID;
  125. volatile USHORT usFoundANTFSDeviceType;
  126. volatile UCHAR ucFoundANTDeviceType;
  127. volatile UCHAR ucFoundANTTransmitType;
  128. volatile BOOL bFoundDeviceHasData;
  129. volatile BOOL bFoundDeviceUploadEnabled;
  130. volatile BOOL bFoundDeviceInPairingMode;
  131. volatile UCHAR ucFoundDeviceAuthenticationType;
  132. volatile UCHAR ucFoundDeviceState;
  133. volatile BOOL bFoundDevice;
  134. volatile BOOL bFoundDeviceIsValid;
  135. volatile BOOL bNewRxEvent;
  136. // Download Data
  137. UCHAR *pucTransferBuffer;
  138. UCHAR *pucTransferBufferDynamic;
  139. UCHAR aucTransferBufferFixed[MAX_USHORT + 16];
  140. UCHAR aucSendDirectBuffer[8 + DIRECT_TRANSFER_SIZE];
  141. volatile ULONG ulTransferArrayIndex;
  142. volatile ULONG ulPacketCount;
  143. volatile ULONG ulUploadIndexProgress;
  144. volatile BOOL bTxError;
  145. volatile BOOL bRxError;
  146. volatile BOOL bReceivedBurst;
  147. volatile BOOL bReceivedResponse;
  148. volatile ULONG ulTransferTotalBytesRemaining;
  149. volatile ULONG ulTransferBytesInBlock;
  150. volatile BOOL bTransfer;
  151. ULONG ulHostBlockSize;
  152. DSI_THREAD_ID hANTFSThread; // Handle for the ANTFS thread.
  153. DSI_MUTEX stMutexResponseQueue; // Mutex used with the response queue
  154. DSI_MUTEX stMutexCriticalSection; // Mutex used with the wait condition
  155. DSI_MUTEX stMutexIgnoreListAccess; // Mutex used with the ignore list
  156. DSI_CONDITION_VAR stCondANTFSThreadExit; // Event to signal the ANTFS thread has ended.
  157. DSI_CONDITION_VAR stCondRequest; // Event to signal there is a new request
  158. DSI_CONDITION_VAR stCondRxEvent; // Event to signal there is a new Rx message or failure
  159. DSI_CONDITION_VAR stCondWaitForResponse; // Event to signal there is a new response to the application
  160. volatile USHORT usSerialWatchdog;
  161. volatile BOOL bKillThread;
  162. volatile BOOL bANTFSThreadRunning;
  163. volatile BOOL bCancel; // Internal cancel parameter to use if not configured
  164. volatile BOOL *pbCancel;
  165. DSIFramerANT *pclANT;
  166. // ANT Channel parameters
  167. UCHAR ucNetworkNumber;
  168. //UCHAR ucChannelNumber;
  169. USHORT usRadioChannelID;
  170. UCHAR ucTheDeviceType;
  171. UCHAR ucTheTransmissionType;
  172. USHORT usTheMessagePeriod;
  173. UCHAR aucTheNetworkkey[8];
  174. UCHAR ucTheProxThreshold;
  175. volatile USHORT usSearchManufacturerID;
  176. volatile USHORT usSearchDeviceType;
  177. volatile USHORT usBlackoutTime;
  178. volatile UCHAR ucTransportLayerRadioFrequency;
  179. UCHAR ucSearchRadioFrequency;
  180. USHORT usTransferDataFileIndex;
  181. volatile ULONG ulTransferDataOffset;
  182. volatile ULONG ulTransferByteSize;
  183. volatile ULONG ulTransferBufferSize;
  184. volatile BOOL bLargeData;
  185. // Ignore List variables
  186. volatile USHORT usListIndex;
  187. IGNORE_LIST_ITEM astIgnoreList[MAX_IGNORE_LIST_SIZE];
  188. BOOL bTimerThreadInitDone;
  189. DSITimer *pclQueueTimer;
  190. volatile UCHAR ucLinkResponseRetries;
  191. UCHAR ucStrikes;
  192. volatile UCHAR ucTransportBeaconTicks;
  193. UCHAR ucTransportChannelPeriodSelection;
  194. UCHAR ucTransportFrequencySelection;
  195. UCHAR ucTransportFrequencyStaleCount;
  196. UCHAR ucCurrentTransportFreqElement;
  197. UCHAR aucFrequencyTable[TRANSPORT_FREQUENCY_LIST_SIZE];
  198. DEVICE_PARAMETERS_ITEM asDeviceParametersList[SEARCH_DEVICE_LIST_MAX_SIZE];
  199. USHORT usDeviceListSize;
  200. volatile ANTFS_HOST_STATE eANTFSState;
  201. volatile ENUM_ANTFS_REQUEST eANTFSRequest;
  202. ANTFS_CONFIG_PARAMETERS cfgParams;
  203. //////////////////////////////////////////////////////////////////////////////////
  204. // Private Function Prototypes
  205. //////////////////////////////////////////////////////////////////////////////////
  206. BOOL ReportDownloadProgress(void);
  207. BOOL ReInitDevice(void);
  208. void ResetHostState(void);
  209. RETURN_STATUS AttemptSearch(void);
  210. RETURN_STATUS AttemptConnect(void);
  211. RETURN_STATUS AttemptRequestSession(void);
  212. RETURN_STATUS AttemptSwitchFrequency(void);
  213. RETURN_STATUS AttemptDisconnect(void);
  214. void Ping(void);
  215. RETURN_STATUS AttemptDownload(void);
  216. RETURN_STATUS UploadLoop(void);
  217. RETURN_STATUS AttemptUpload(void);
  218. RETURN_STATUS AttemptManualTransfer(void);
  219. RETURN_STATUS Receive(void);
  220. RETURN_STATUS AttemptErase(void);
  221. RETURN_STATUS AttemptAuthenticate(void);
  222. // ANT Callback Functions
  223. BOOL FilterANTMessages(ANT_MESSAGE* pstMessage_, UCHAR ucANTChannel_);
  224. BOOL ANTProtocolEventProcess(UCHAR ucChannel_, UCHAR ucMessageCode_);
  225. BOOL ANTChannelEventProcess(UCHAR ucChannel_, UCHAR ucMessageCode_);
  226. void QueueTimerCallback(void);
  227. static DSI_THREAD_RETURN QueueTimerStart(void *pvParameter_);
  228. void HandleSerialError(void);
  229. void IncFreqStaleCount(UCHAR ucInc);
  230. void PopulateTransportFreqTable(void);
  231. UCHAR CheckForNewTransportFreq(void);
  232. void ANTFSThread(void);
  233. static DSI_THREAD_RETURN ANTFSThreadStart(void *pvParameter_);
  234. BOOL IsDeviceMatched(ANTFS_DEVICE_PARAMETERS *psDeviceParameters_, BOOL bPartialID_);
  235. void AddResponse(ANTFS_HOST_RESPONSE eResponse_);
  236. public:
  237. //////////////////////////////////////////////////////////////////////////////////
  238. // Public Function Prototypes
  239. //////////////////////////////////////////////////////////////////////////////////
  240. ANTFSHostChannel();
  241. ~ANTFSHostChannel();
  242. BOOL Init(DSIFramerANT* pclANT_, UCHAR ucChannel_);
  243. /////////////////////////////////////////////////////////////////
  244. // Begins to initialize the ANTFSHostChannel object.
  245. // Returns TRUE if successful. Otherwise, it returns FALSE.
  246. // Parameters:
  247. // *pclANT_: Pointer to a DSIFramerANT object.
  248. // ucChannel_: Channel number to use for the ANT-FS host
  249. // Operation:
  250. // This function is used from a class managing the connection
  251. // to ANT (e.g. DSIANTDevice or .NET ANT_Device), to
  252. // initialize the ANTFSHostChannel object. It is not possible
  253. // to change the channel number once ANT-FS is running.
  254. // The function returns immediately, and the ANTFSHostChannel object
  255. // will send a response of ANTFS_HOST_RESPONSE_INIT_PASS.
  256. // IT IS NOT NECESSARY TO CALL THIS FUNCTION DIRECTLY FROM USER APPLICATIONS.
  257. /////////////////////////////////////////////////////////////////
  258. void GetCurrentConfig( ANTFS_CONFIG_PARAMETERS* pCfg_ );
  259. /////////////////////////////////////////////////////////////////
  260. // Passes back the current value of configurable parameters.
  261. // If SetCurrentConfig has not been called, passes back the defaults.
  262. /////////////////////////////////////////////////////////////////
  263. BOOL SetCurrentConfig( const ANTFS_CONFIG_PARAMETERS* pCfg_ );
  264. /////////////////////////////////////////////////////////////////
  265. // Sets up the configurable parameters.
  266. // Returns TRUE if successful. Otherwise, it returns FALSE.
  267. // If FALSE is returned, all the parameters remain unchanged.
  268. // If this method has not been called, the default values are used.
  269. // It is possible to call this method multiple times in the program.
  270. /////////////////////////////////////////////////////////////////
  271. void Close(void);
  272. /////////////////////////////////////////////////////////////////
  273. // Stops any pending actions, closes all threads and cleans
  274. // up any dynamic memory being used by the library.
  275. // Operation:
  276. // This function is used from a class managing the connection
  277. // to ANT (e.g. DSIANTDevice or .NET ANT_Device), to
  278. // clean up any resources in use by the ANT-FS host.
  279. // IT IS NOT NECESSARY TO CALL THIS FUNCTION DIRECTLY FROM USER APPLICATIONS.
  280. /////////////////////////////////////////////////////////////////
  281. void ProcessMessage(ANT_MESSAGE* pstMessage_, USHORT usMesgSize_);
  282. /////////////////////////////////////////////////////////////////
  283. // Processes incoming ANT messages as per the ANT-FS Technology
  284. // Specification
  285. // Parameters:
  286. // pstMessage_: Pointer to an ANT message structure
  287. // usMesgSize_: ANT message size
  288. // Operation:
  289. // This function is used from a class managing the connection
  290. // to ANT (e.g. DSIANTDevice or .NET ANT_Device).
  291. // IT IS NOT NECESSARY TO CALL THIS FUNCTION DIRECTLY FROM USER APPLICATIONS.
  292. /////////////////////////////////////////////////////////////////
  293. void ProcessDeviceNotification(ANT_DEVICE_NOTIFICATION eCode_, void* pvParameter_);
  294. /////////////////////////////////////////////////////////////////
  295. // Processes device level notifications
  296. // Parameters:
  297. // eCode_: Device notification event code
  298. // pvParameter_: Pointer to struct defining specific parameters related
  299. // to the event code
  300. // Operation:
  301. // This function si used from a class managing the connection
  302. // to ANT (e.g. DSIANTDevice or .NET ANT_Device).
  303. // IT IS NOT NECESSARY TO CALL THIS FUNCTION DIRECTLY FROM USER APPLICATIONS.
  304. /////////////////////////////////////////////////////////////////
  305. void Cancel(void);
  306. /////////////////////////////////////////////////////////////////
  307. // Cancels any pending actions and returns the library to the
  308. // appropriate ANTFS layer if possible. ie if the library was
  309. // executing a download command in the transport layer, the
  310. // library would be returned to ANTFS_HOST_STATE_TRANSPORT after
  311. // execution of this function.
  312. /////////////////////////////////////////////////////////////////
  313. void SetChannelID(UCHAR ucDeviceType_, UCHAR ucTransmissionType_);
  314. /////////////////////////////////////////////////////////////////
  315. // Configures the ANT channel ID for the ANT-FS Host channel
  316. // Parameters:
  317. // ucDeviceType_: ANT Channel Device Type
  318. // ucTransmissionType_: ANT Channel Transmission Type
  319. // Operation:
  320. // Changes to the channel ID are only applied after calling
  321. // SearchForDevice.
  322. /////////////////////////////////////////////////////////////////
  323. void SetChannelPeriod(USHORT usChannelPeriod_);
  324. /////////////////////////////////////////////////////////////////
  325. // Configures the ANT channel period for the ANT-FS Host channel
  326. // Parameters:
  327. // usChannelPeriod_: Channel period to use while in link state
  328. // Operation:
  329. // Changes to the channel ID are only applied after calling
  330. // SearchForDevice. If using ANT-FS broadcast, this is the
  331. // channel period the host will return to when using the
  332. // Disconnect command with the Return To Broadcast option.
  333. // To change the channel period while an ANT-FS session is open,
  334. // use SwitchFrequency().
  335. /////////////////////////////////////////////////////////////////
  336. // TODO: Does this function make sense here, or should it just assign the network number?
  337. // The ANTFSHost wrapper class could continue to provide this one for backwards compatibility
  338. void SetNetworkKey(UCHAR ucNetwork_, UCHAR ucNetworkkey[]);
  339. /////////////////////////////////////////////////////////////////
  340. // Configures the ANT network key for the ANT-FS channel
  341. // Parameters:
  342. // ucNetwork_: Network number (0 - 2)
  343. // ucNetworkkey: Array containing the 8 byte network key
  344. // Operation:
  345. // Changes to the network key are only applied after calling
  346. // SearchForDevice.
  347. /////////////////////////////////////////////////////////////////
  348. void SetProximitySearch(UCHAR ucSearchThreshold_);
  349. /////////////////////////////////////////////////////////////////
  350. // Sets the value for the proximity bin setting for searching.
  351. // Note: If applying this value fails when attempting to start search,
  352. // it is ignored to maintain compatibility with devices that
  353. // do not support this feature. This means that a real failure can occur
  354. // on a device that actually does support it, and it will be missed. The
  355. // debug log will show if this command fails.
  356. // Parameters:
  357. // ucSearchThreshold_: Desired proximity bin from 0-10 (If value is
  358. // set higher then 10, it is automatically capped at 10)
  359. // Operation:
  360. // Changes to the proximity search bin are only applied after calling
  361. // SearchForDevice.
  362. /////////////////////////////////////////////////////////////////
  363. void SetSerialNumber(ULONG ulSerialNumber_);
  364. /////////////////////////////////////////////////////////////////
  365. // Configures the host serial number.
  366. // Parameters:
  367. // ulSerialNumber_: 4-byte host serial number
  368. /////////////////////////////////////////////////////////////////
  369. BOOL EnablePing(BOOL bEnable_);
  370. /////////////////////////////////////////////////////////////////
  371. // Enables ping message to be sent to the remote device periodically.
  372. // This can be used to keep the remote device from timing out during
  373. // operations that wait for user input (i.e. pairing)
  374. // Parameters:
  375. // bEnable_: Periodic ping enable.
  376. // Returns TRUE if successful. Otherwise, it returns FALSE.
  377. /////////////////////////////////////////////////////////////////
  378. BOOL GetEnabled(void);
  379. /////////////////////////////////////////////////////////////////
  380. // Returns the current status of ANT-FS message processing
  381. // Returns TRUE if ANT-FS is enabled. Otherwise, it returns FALSE.
  382. // Operation:
  383. // This function is used from a class managing the connection
  384. // to ANT (e.g. DSIANTDevice or .NET ANT_Device).
  385. // IT IS NOT NECESSARY TO CALL THIS FUNCTION DIRECTLY FROM USER APPLICATIONS.
  386. /////////////////////////////////////////////////////////////////
  387. ANTFS_HOST_STATE GetStatus(void);
  388. /////////////////////////////////////////////////////////////////
  389. // Returns the current library status.
  390. /////////////////////////////////////////////////////////////////
  391. /////////////////////////////////////////////////////////////////
  392. // Returns the current ANTFS state from the last seen ANTFS beacon of the
  393. // connected device.
  394. // Returns the beacon ANTFS state:
  395. // REMOTE_DEVICE_STATE_LINK
  396. // REMOTE_DEVICE_STATE_AUTH
  397. //...REMOTE_DEVICE_STATE_TRANS
  398. //...REMOTE_DEVICE_STATE_BUSY
  399. // or REMOTE_DEVICE_BEACON_NOT_FOUND if no device is connected
  400. /////////////////////////////////////////////////////////////////
  401. UCHAR GetConnectedDeviceBeaconAntfsState(void);
  402. BOOL GetFoundDeviceParameters(ANTFS_DEVICE_PARAMETERS *pstDeviceParameters_, UCHAR *aucFriendlyName_, UCHAR *pucBufferSize_);
  403. /////////////////////////////////////////////////////////////////
  404. // Copies the parameters of the most recently found device to the
  405. // supplied parameter.
  406. // Parameters:
  407. // *ptsDeviceParameters_: A pointer to a structure that will
  408. // receive a copy of the device parameters.
  409. // *aucFriendlyName_: A pointer to a buffer where the remote
  410. // device friendly name will be copied.
  411. // *pucBufferSize_: Pointer to a UCHAR variable that should contain the
  412. // maximum size of the buffer pointed to by aucFriendlyName_.
  413. // After the function returns, the UCHAR variable
  414. // will be set to reflect the size of friendly name string
  415. // that has been copied to aucFriendlyName_.
  416. // Returns TRUE if successful. Otherwise, it returns FALSE.
  417. /////////////////////////////////////////////////////////////////
  418. BOOL GetFoundDeviceChannelID(USHORT *pusDeviceNumber_ = (USHORT *)NULL, UCHAR *pucDeviceType_ = (UCHAR *)NULL, UCHAR *pucTransmitType_ = (UCHAR *)NULL);
  419. /////////////////////////////////////////////////////////////////
  420. // Copies the ANT channel ID of the most recently found device to
  421. // the supplied parameters.
  422. // Parameters:
  423. // *pusDeviceNumber_: A pointer to a USHORT variable that will
  424. // receive the ANT device number of the device.
  425. // *pucDeviceType_: A pointer to a UCHAR variable that will
  426. // hold the device type of the found device.
  427. // *pucTransmitType_: Pointer to a UCHAR variable that will
  428. // receive the transmission type of the found
  429. // device
  430. // Returns TRUE if successful. Otherwise, it returns FALSE.
  431. /////////////////////////////////////////////////////////////////
  432. BOOL GetUploadStatus(ULONG *pulByteProgress_, ULONG *pulTotalLength_);
  433. /////////////////////////////////////////////////////////////////
  434. // Gets the transfer progress of a pending or a complete
  435. // upload.
  436. // Parameters:
  437. // *pulByteProgress_: Pointer to a ULONG that will receive
  438. // the current byte progress of a pending or
  439. // complete upload.
  440. // *pulTotalLength_: Pointer to a ULONG that will receive the
  441. // total length of the file being uploaded.
  442. // Returns TRUE if successful. Otherwise, it returns FALSE.
  443. // Operation:
  444. // A data upload occurs when information is requested to be sent to
  445. // a remote device. This function may be called at any point
  446. // during an upload as a progress indicator. After the upload
  447. // is complete, this information is valid until another request
  448. // for a data transfer is made.
  449. /////////////////////////////////////////////////////////////////
  450. BOOL GetDownloadStatus(ULONG *pulByteProgress_, ULONG *pulTotalLength_);
  451. /////////////////////////////////////////////////////////////////
  452. // Gets the transfer progress of a pending or a complete
  453. // download.
  454. // Parameters:
  455. // *pulByteProgress_: Pointer to a ULONG that will receive
  456. // the current byte progress of a pending or
  457. // complete download.
  458. // *pulTotalLength_: Pointer to a ULONG that will receive the
  459. // total expected length of the download.
  460. // Returns TRUE if successful. Otherwise, it returns FALSE.
  461. // Operation:
  462. // A data download occurs when information is requested from a
  463. // remote device. This function may be called at any point
  464. // during a download as a progress indicator. After the transfer
  465. // is complete, this information is valid until another request
  466. // for a data transfer is made.
  467. /////////////////////////////////////////////////////////////////
  468. BOOL GetTransferData(ULONG *pulDataSize_ , void *pvData_ = NULL);
  469. /////////////////////////////////////////////////////////////////
  470. // Gets the received data from a transfer (download/manual transfer).
  471. //
  472. // Parameters:
  473. // *ulDataSize_ : Pointer to a ULONG that will receive
  474. // the size of the data available in bytes.
  475. // *pvData_ : Pointer to a buffer where the received data
  476. // will be copied. NULL can be passed to this
  477. // parameter so that the size can be retried
  478. // without copying any data. The application
  479. // can then call this function again to after it
  480. // has allocated a buffer of sufficient size to
  481. // handle the data.
  482. // Returns TRUE if successful. Otherwise, it returns FALSE.
  483. /////////////////////////////////////////////////////////////////
  484. BOOL RecoverTransferData(ULONG *pulDataSize_ , void *pvData_ = NULL);
  485. /////////////////////////////////////////////////////////////////
  486. // Gets the partially received data from a failed transfer (download/manual transfer).
  487. //
  488. // Parameters:
  489. // *ulDataSize_ : Pointer to a ULONG that will receive
  490. // the size of the data available in bytes.
  491. // *pvData_ : Pointer to a buffer where the received data
  492. // will be copied. NULL can be passed to this
  493. // parameter so that the size can be retried
  494. // without copying any data. The application
  495. // can then call this function again to after it
  496. // has allocated a buffer of sufficient size to
  497. // handle the data.
  498. // Returns TRUE if successful. Otherwise, it returns FALSE.
  499. /////////////////////////////////////////////////////////////////
  500. UCHAR GetVersion(UCHAR *pucVersionString_, UCHAR ucBufferSize_);
  501. /////////////////////////////////////////////////////////////////
  502. // Copies at most ucBufferSize_ characters from the version
  503. // string into the supplied pucVersionString_ buffer.
  504. // Parameters:
  505. // *pucVersionString_ Pointer to a buffer of characters into
  506. // which to receive the version string.
  507. // ucBufferSize_ The maximum number of characters to
  508. // copy into *pucVersionString_.
  509. // Returns the number of characters copied to *pucVersionString_.
  510. // Operation:
  511. // If the version string has fewer than ucBufferSize_
  512. // characters, the *pucVersionString_ will be padded with a
  513. // '\n'.
  514. /////////////////////////////////////////////////////////////////
  515. ANTFS_RETURN RequestSession(UCHAR ucBroadcastRadioFrequency_ = ANTFS_RF_FREQ, UCHAR ucConnectRadioFrequency_ = ANTFS_DEFAULT_TRANSPORT_FREQ);
  516. /////////////////////////////////////////////////////////////////
  517. // Requests an ANT-FS session from currently connected broadcast
  518. // device
  519. // Parameters:
  520. // ucBroadcastRadioFrequency_: This specifies the frequency on
  521. // which the broadcast device is transmitting.
  522. // This frequency is calculated as
  523. // (ucBroadcastRadioFrequency_ * 1 MHz +
  524. // 2400 MHz). MAX_UCHAR (0xFF) is reserved.
  525. // ucConnectRadioFrequency_: This specifies the frequency
  526. // on which the connection communication
  527. // will occur. This frequency is calculated
  528. // as (ucConnectRadioFrequency_ * 1 MHz +
  529. // 2400 MHz). If ucConnectRadioFrequency_
  530. // is set to ANTFS_AUTO_FREQUENCY_SELECTION
  531. // (0xFF), then the library will use an
  532. // adaptive frequency-hopping scheme.
  533. // Returns ANTFS_RETURN_PASS if successful. Otherwise, it returns
  534. // ANTFS_RETURN_FAIL if the library is in the wrong state, or
  535. // ANTFS_RETURN_BUSY if the library is busy with another request.
  536. // Operation:
  537. // Once this function is called successfully, the application
  538. // must wait for the response from the ANTFSHost object.
  539. // Possible responses are:
  540. // ANTFS_HOST_RESPONSE_CONNECT_PASS
  541. // ANTFS_HOST_RESPONSE_REQUEST_SESSION_FAIL,
  542. // ANTFS_HOST_RESPONSE_SERIAL_FAIL
  543. // To return to broadcast state, use the Disconnect() function.
  544. /////////////////////////////////////////////////////////////////
  545. ANTFS_RETURN SearchForDevice(UCHAR ucSearchRadioFrequency_ = ANTFS_RF_FREQ, UCHAR ucConnectRadioFrequency_ = ANTFS_DEFAULT_TRANSPORT_FREQ, USHORT usRadioChannelID_ = 0, BOOL bUseRequestPage_ = FALSE);
  546. /////////////////////////////////////////////////////////////////
  547. // Begins a search for ANTFS remote devices.
  548. // Parameters:
  549. // ucSearchRadioFrequency_: This specifies the frequency on
  550. // which to search for devices. This
  551. // frequency is calculated as
  552. // (ucSearchRadioFrequency_ * 1 MHz +
  553. // 2400 MHz). MAX_UCHAR (0xFF) is reserved.
  554. // ucConnectRadioFrequency_: This specifies the frequency
  555. // on which the connection communication
  556. // will occur. This frequency is calculated
  557. // as (ucConnectRadioFrequency_ * 1 MHz +
  558. // 2400 MHz). If ucConnectRadioFrequency_
  559. // is set to ANTFS_AUTO_FREQUENCY_SELECTION
  560. // (0xFF), then the library will use an
  561. // adaptive frequency-hopping scheme.
  562. // usRadioChannelID_: This specifies the channel ID for the
  563. // the ANT channel search. Set to zero to
  564. // wildcard.
  565. // bUseRequestPage_: Specifies whether the search will include
  566. // ANT-FS broadcast devices, using a request
  567. // page to begin an ANT-FS session
  568. // Returns ANTFS_RETURN_PASS if successful. Otherwise, it returns
  569. // ANTFS_RETURN_FAIL if the library is in the wrong state, or
  570. // ANTFS_RETURN_BUSY if the library is busy with another request.
  571. // Operation:
  572. // Once this function is called successfully, the application
  573. // must wait for the response from the ANTFSHost object.
  574. // Possible responses are:
  575. // ANTFS_HOST_RESPONSE_CONNECT_PASS
  576. // ANTFS_HOST_RESPONSE_SERIAL_FAIL
  577. // The library will continue to search for devices until a device
  578. // is found, the Cancel() function is called, an error occurs, or
  579. // the library is closed.
  580. /////////////////////////////////////////////////////////////////
  581. ANTFS_RETURN Authenticate(UCHAR ucAuthenticationType_, UCHAR *pucAuthenticationString_, UCHAR ucLength_, UCHAR *aucResponseBuffer_, UCHAR *pucResponseBufferSize_, ULONG ulResponseTimeout_);
  582. /////////////////////////////////////////////////////////////////
  583. // Request to establish an authenticated session with the connected
  584. // remote device.
  585. // Parameters:
  586. // ucAuthenticationType_: The type of authentication to
  587. // execute on the remote device.
  588. // *pucAuthenticationString_: A string that may be used in
  589. // conjunction with the particular
  590. // authentication type in use (e.g. a
  591. // password or a friendly name.
  592. // ucLength_: The length of the authentication string,
  593. // including any '\n' terminator. This
  594. // parameter may be set to zero if an
  595. // authentication string is not required.
  596. // *pucResponseBuffer_: Pointer to the buffer where additional
  597. // data from the response will be saved. This will
  598. // include data such as passwords and friendly names.
  599. // This memory must be allocated by the application.
  600. // *pucResponseBufferSize_: Pointer to UCHAR varible that contains the
  601. // size of the buffer pointed to by pucResponseBuffer_.
  602. // After the response has be recived, the UCHAR variable
  603. // will be set to reflect the size of the new data received
  604. // in pucResponseBuffer_.
  605. // ulResponseTimeout_: Number of miliseconds to wait for a response after
  606. // the authenticate command is sent.
  607. // Returns ANTFS_RETURN_PASS if successful. Otherwise, it returns
  608. // ANTFS_RETURN_FAIL if the library is in the wrong state, or
  609. // ANTFS_RETURN_BUSY if the library is busy with another request.
  610. // Operation:
  611. // Once the request is posted, the application must wait for the
  612. // response from the ANTFSHost object. Possible responses are:
  613. // ANTFS_HOST_RESPONSE_AUTHENTICATE_NA
  614. // ANTFS_HOST_RESPONSE_AUTHENTICATE_PASS
  615. // ANTFS_HOST_RESPONSE_AUTHENTICATE_REJECT
  616. // ANTFS_HOST_RESPONSE_AUTHENTICATE_FAIL
  617. // ANTFS_HOST_RESPONSE_CONNECTION_LOST
  618. // ANTFS_HOST_RESPONSE_SERIAL_FAIL
  619. // Upon receiving the ANTFS_HOST_RESPONSE_AUTHENTICATE_PASS, an
  620. // authentication string provided by the remoted device may be
  621. // available in the response buffer. This depends on the
  622. // authentication type used. The transport
  623. // layer connection is also only established after receiving
  624. // ANTFS_HOST_RESPONSE_AUTHENTICATE_PASS .
  625. /////////////////////////////////////////////////////////////////
  626. ANTFS_RETURN Download(USHORT usFileIndex_, ULONG ulDataOffset_, ULONG ulMaxDataLength_, ULONG ulMaxBlockSize_ = 0);
  627. /////////////////////////////////////////////////////////////////
  628. // Request a download of a file from the authenticated device.
  629. // Parameters:
  630. // usFileIndex_: The file number to be downloaded. Some
  631. // file numbers are reserved for special
  632. // purposes, such as the device directory
  633. // (0). Consult the ANT_FS specification
  634. // and any docs for specific device types.
  635. // ulDataOffset_: The byte offset from where to begin
  636. // transferring the data.
  637. // ulMaxDataLength_: ULONG varible that contains the maximum
  638. // number of bytes to download. Set to 0 if
  639. // if the host does not wish to limit the
  640. // size of the download.
  641. // ulMaxBlockSize_: Maximum number of bytes that the host
  642. // wishes to download in a single block.
  643. // Set to zero to disable.
  644. // Returns ANTFS_RETURN_PASS if successful. Otherwise, it returns
  645. // ANTFS_RETURN_FAIL if the library is in the wrong state, or
  646. // ANTFS_RETURN_BUSY if the library is busy with another request.
  647. // Operation:
  648. // Once the request is posted, the application must wait for the
  649. // response from the ANTFSHost object. Possible responses are:
  650. // ANTFS_HOST_RESPONSE_DOWNLOAD_PASS
  651. // ANTFS_HOST_RESPONSE_DOWNLOAD_REJECT
  652. // ANTFS_HOST_RESPONSE_DOWNLOAD_FAIL
  653. // ANTFS_HOST_RESPONSE_CONNECTION_LOST
  654. // ANTFS_HOST_RESPONSE_SERIAL_FAIL
  655. // Upon receiving ANTFS_HOST_RESPONSE_DOWNLOAD_PASS the downloaed data
  656. // will be available in the transfer buffer. See GetTransferData().
  657. /////////////////////////////////////////////////////////////////
  658. ANTFS_RETURN Upload(USHORT usFileIndex_, ULONG ulDataOffset_, ULONG ulDataLength_, void *pvData_, BOOL bForceOffset_ = TRUE, ULONG ulMaxBlockSize_ = 0);
  659. /////////////////////////////////////////////////////////////////
  660. // Request an upload of a file to the authenticated device.
  661. // Parameters:
  662. // usFileIndex_: The file number to be uploaded. Some
  663. // file numbers are reserved for special
  664. // purposes, such as the device directory
  665. // (0). Consult the ANT_FS specification
  666. // and any docs for specific device types.
  667. // ulDataOffset_: The byte offset from where to begin
  668. // transferring the data.
  669. // ulDataLength_: The byte length of data to be uploaded
  670. // to the remote device.
  671. // Return value:
  672. // *pvData_: Pointer to the location where the data
  673. // to be uploaded is stored.
  674. // bForceOffset_: Set to TRUE (default) to enforce the
  675. // provided byte data offset. Set to FALSE
  676. // to continue a transfer, indicating that
  677. // the host will continue the upload at the
  678. // last data offset specified by the client
  679. // in the Upload Response.
  680. // ulMaxBlockSize_: Maximum block size that the host can send
  681. // in a single block of data. Set to zero
  682. // to disable
  683. // Returns ANTFS_RETURN_PASS if successful. Otherwise, it returns
  684. // ANTFS_RETURN_FAIL if the library is in the wrong state, or
  685. // ANTFS_RETURN_BUSY if the library is busy with another request.
  686. // Operation:
  687. // Once the request is posted, the application must wait for the
  688. // response from the ANTFSHost object. Possible responses are:
  689. // ANTFS_HOST_RESPONSE_UPLOAD_PASS
  690. // ANTFS_HOST_RESPONSE_UPLOAD_REJECT
  691. // ANTFS_HOST_RESPONSE_UPLOAD_FAIL
  692. // ANTFS_HOST_RESPONSE_CONNECTION_LOST
  693. // ANTFS_HOST_RESPONSE_SERIAL_FAIL
  694. /////////////////////////////////////////////////////////////////
  695. ANTFS_RETURN ManualTransfer(USHORT usFileIndex_, ULONG ulDataOffset_, ULONG ulDataLength_, void *pvData_);
  696. /////////////////////////////////////////////////////////////////
  697. // Send data directly to the device without requesting first.
  698. // This is especially useful for communicating small pieces of
  699. // data to the device. Another use is the implementation of a
  700. // higher-level communication protocol. Care must be taken to
  701. // ensure the device can handle the amount of data being sent
  702. // using this method.
  703. // usFileIndex_: The file number to be uploaded. Some
  704. // file numbers are reserved for special
  705. // purposes, such as the device directory
  706. // (0). Consult the ANT_FS specification
  707. // and any docs for specific device types.
  708. // ulDataOffset_: The byte offset from where to begin
  709. // transferring the data. Note that this
  710. // value will always get rounded up to the
  711. // next higher multiple of 8. Under normal
  712. // use, this parameter should always be set
  713. // to zero, and the only time it would be
  714. // non-zero is for retrying ManualTransfer()
  715. // from a known offset.
  716. // ulDataLength_: The byte length of data to be sent to
  717. // the remote device.
  718. // *pvData_: The Pointer to a buffer where the
  719. // data to be sent is stored.
  720. // Returns ANTFS_RETURN_PASS if successful. Otherwise, it returns
  721. // ANTFS_RETURN_FAIL if the library is in the wrong state, or
  722. // ANTFS_RETURN_BUSY if the library is busy with another request.
  723. // Operation:
  724. // Once the request is posted, the application must wait for the
  725. // response from the ANTFSHost object. Possible responses are:
  726. // ANTFS_HOST_RESPONSE_MANUAL_TRANSFER_PASS
  727. // ANTFS_HOST_RESPONSE_MANUAL_TRANSFER_TRANSMIT_FAIL
  728. // ANTFS_HOST_RESPONSE_MANUAL_TRANSFER_RESPONSE_FAIL
  729. // ANTFS_HOST_RESPONSE_CONNECTION_LOST
  730. // ANTFS_HOST_RESPONSE_SERIAL_FAIL
  731. // Upon receiving ANTFS_HOST_RESPONSE_MANUAL_TRANSFER_PASS the downloaed data
  732. // will be available in the transfer buffer. See GetTransferData().
  733. /////////////////////////////////////////////////////////////////
  734. ANTFS_RETURN EraseData(USHORT usFileIndex_);
  735. /////////////////////////////////////////////////////////////////
  736. // Request the erasure of a file on the authenticated remote
  737. // device.
  738. // Parameters:
  739. // usFileIndex_: The file number of the file to be erased.
  740. // Returns ANTFS_RETURN_PASS if successful. Otherwise, it returns
  741. // ANTFS_RETURN_FAIL if the library is in the wrong state, or
  742. // ANTFS_RETURN_BUSY if the library is busy with another request.
  743. // Operation:
  744. // Once the request is posted, the application must wait for the
  745. // response from the ANTFSHost object. Possible responses are:
  746. // ANTFS_HOST_RESPONSE_ERASE_PASS
  747. // ANTFS_HOST_RESPONSE_ERASE_FAIL
  748. // ANTFS_HOST_RESPONSE_CONNECTION_LOST
  749. // ANTFS_HOST_RESPONSE_SERIAL_FAIL
  750. /////////////////////////////////////////////////////////////////
  751. ANTFS_RETURN Disconnect(USHORT usBlackoutTime_, UCHAR ucDisconnectType_ = 0, UCHAR ucTimeDuration_ = 0, UCHAR ucAppSpecificDuration_ = 0);
  752. /////////////////////////////////////////////////////////////////
  753. // Disconnect from a remote device. Optionally put that device
  754. // on a blackout list for a period of time. The application can
  755. // also request the remote device to become undiscoverable for a
  756. // specified time/application specific duration.
  757. // Parameters:
  758. // usBlackoutTime_: The number of seconds the device ID
  759. // should remain on the blackout list. If
  760. // set to zero (0), then the device will
  761. // not be put on the blackout list. If set
  762. // to MAX_USHORT (0xFFFF), the device will
  763. // remain on the blackout list until
  764. // explicitly removed, or until the blackout
  765. // list is reset.
  766. // ucDisconnectType_: Specifies whether the client should
  767. // return to LINK state (default) or broadcast mode.
  768. // Values from 128 - 255 can be used to specify
  769. // application specific disconnect behavior.
  770. // ucTimeDuration_: Time, in 30 seconds increments, the client
  771. // device will remain undiscoverable after
  772. // disconnect has been requested. Set to 0 to
  773. // disable.
  774. // ucAppSpecificDuration_: Application specific duration the client
  775. // shall remain undiscoverable after disconnection.
  776. // This field is left to the developer, or defined
  777. // in an ANT+ Device Profile. Set to 0 to disable.
  778. // Returns ANTFS_RETURN_PASS if successful. Otherwise, it returns
  779. // ANTFS_RETURN_FAIL if the library is in the wrong state, or
  780. // ANTFS_RETURN_BUSY if the library is busy with another request.
  781. // Operation:
  782. // Once the request is posted, the application must wait for the
  783. // response from the ANTFSHost object. Possible responses are:
  784. // ANTFS_HOST_RESPONSE_DISCONNECT_PASS
  785. // ANTFS_HOST_RESPONSE_CONNECTION_LOST
  786. // ANTFS_HOST_RESPONSE_SERIAL_FAIL
  787. // The remote device will not show up in any search results for
  788. // the duration specified in usBlackoutTime_. This allows the
  789. // host to more easily find other devices in crowded
  790. // environments. The host can also request the remote device to
  791. // become undiscoverable, to more easily find other devices, however
  792. // not all client devices might implement this feature. Not all
  793. // client devices support a broadcast mode.
  794. // If no disconnect type is specified, the default behavior will be to
  795. // return to the LINK state, and the host will close the
  796. // channel after disconnecting. If the disconnect type is set to 1,
  797. // the host will return to broadcast mode, and will keep its channel
  798. // open.
  799. /////////////////////////////////////////////////////////////////
  800. // TODO: Need to define a response for this?
  801. ANTFS_RETURN SwitchFrequency(UCHAR ucRadioFrequency_, UCHAR ucChannelPeriod_ = BEACON_PERIOD_KEEP);
  802. /////////////////////////////////////////////////////////////////
  803. // Request the connected remote device to switch to the specified
  804. // radio frequency and channel period
  805. // Parameters:
  806. // ucRadioFrequency_: This specifies the frequency
  807. // on which the connection communication
  808. // will occur. This frequency is calculated
  809. // as (ucRadioFrequency_ * 1 MHz + 2400 MHz).
  810. // ucBeaconPeriod_: This specifies the beacon period on which
  811. // the communication will continue. Use
  812. // BEACON_PERIOD_KEEP to only change the radio
  813. // frequency.
  814. // Returns ANTFS_RETURN_PASS if successful. Otherwise, it returns
  815. // ANTFS_RETURN_FAIL if the library is in the wrong state, or
  816. // ANTFS_RETURN_BUSY if the library is busy with another request.
  817. // Operation:
  818. // This function can only be used in transport state, to change
  819. // the channel parameters.
  820. // Once this function is called successfully, the application
  821. // must wait for the response from the ANTFSHost object.
  822. // Possible responses are:
  823. // ANTFS_HOST_RESPONSE_CONNECTION_LOST
  824. // ANTFS_HOST_RESPONSE_SERIAL_FAIL
  825. /////////////////////////////////////////////////////////////////
  826. USHORT AddSearchDevice(ANTFS_DEVICE_PARAMETERS *pstDeviceSearchMask_, ANTFS_DEVICE_PARAMETERS *pstDeviceParameters_);
  827. /////////////////////////////////////////////////////////////////
  828. // Adds a set of parameters for which to search to the internal
  829. // search device list.
  830. // Parameters:
  831. // *pstDeviceSearchMask_: A pointer to an
  832. // ANTFS_DEVICE_PARAMETERS structure. Set a
  833. // member to zero (0) to wildcard search for
  834. // it. Otherwise, set the bits that you want
  835. // to be matched to 1 in each member. Members
  836. // that are integer values will be treated the
  837. // same as bit fields for the purposes for the mask.
  838. // *pstDeviceParameters_: A pointer to an
  839. // ANTFS_DEVICE_PARAMETERS structure. Set
  840. // the member to the desired search value.
  841. // A member in this structure is ignored if
  842. // the associated member in the
  843. // *pstDeviceSearchMask_ parameter is set
  844. // to zero (0) for wildcard.
  845. // Returns a handle the the search device entry. If the return
  846. // value is NULL, the function failed adding the device entry.
  847. // This means that the device list is already full.
  848. // Operation:
  849. // Note that the default search masks should normally be applied
  850. // to the ucStatusByte1 and ucStatusByte2 members of the
  851. // *pstDeviceSearchMask_ parameter. Eg;
  852. // pstMyDeviceSearchMask->ucStatusByte1 =
  853. // ANTFS_STATUS1_DEFAULT_SEARCH_MASK & ucMyStatus1Criteria;
  854. // Setting bits outside the masks, especially reserved bits, may
  855. // lead to undesired behaviour.
  856. /////////////////////////////////////////////////////////////////
  857. void RemoveSearchDevice(USHORT usHandle_);
  858. /////////////////////////////////////////////////////////////////
  859. // Removes a device entry from the internal search list.
  860. // Parameters:
  861. // usHandle_: Handle to the device entry to be removed
  862. // from the list.
  863. /////////////////////////////////////////////////////////////////
  864. void ClearSearchDeviceList(void);
  865. /////////////////////////////////////////////////////////////////
  866. // Clears the internal search device list.
  867. /////////////////////////////////////////////////////////////////
  868. BOOL Blackout(ULONG ulDeviceID_, USHORT usManufacturerID_, USHORT usDeviceType_, USHORT usBlackoutTime_);
  869. /////////////////////////////////////////////////////////////////
  870. // Put the device on a blackout list for a period of time.
  871. // Parameters:
  872. // ulDeviceID_: The device ID of a specific device.
  873. // usManufacturerID_: The specific manufacturer ID.
  874. // usDeviceType_: The specific device type.
  875. // usBlackoutTime_: The number of seconds the device ID
  876. // should remain on the blackout list. If
  877. // set to zero (0), then the device will
  878. // not be put on the blackout list. If set
  879. // to MAX_USHORT (0xFFFF), the device will
  880. // remain on the blackout list until
  881. // explicitly removed, or until the blackout
  882. // list is reset.
  883. // Returns TRUE if successful. Otherwise, it returns FALSE.
  884. // A wildcard parameter (0) is not allowed in any of the device
  885. // ID parameters and will result in returning FALSE.
  886. // Operation:
  887. // The remote device will not show up in any search results for
  888. // the duration specified in usBlackoutTime_. This allows the
  889. // host to more easily find other devices in crowded
  890. // environments.
  891. /////////////////////////////////////////////////////////////////
  892. BOOL RemoveBlackout(ULONG ulDeviceID_, USHORT usManufacturerID_, USHORT usDeviceType_);
  893. /////////////////////////////////////////////////////////////////
  894. // Remove the device from the blackout list.
  895. // Parameters:
  896. // ulDeviceID_: The device ID of a specific device.
  897. // usManufacturerID_: The specific manufacturer ID.
  898. // usDeviceType_: The specific device type.
  899. // Returns TRUE if successful. Returns FALSE if the device is
  900. // not found in the blackout list. A wildcard parameter (0) is
  901. // not allowed in any of the device ID parameters and will result
  902. // in returning FALSE.
  903. /////////////////////////////////////////////////////////////////
  904. void ClearBlackoutList(void);
  905. /////////////////////////////////////////////////////////////////
  906. // Clears the blackout list.
  907. /////////////////////////////////////////////////////////////////
  908. ANTFS_HOST_RESPONSE WaitForResponse(ULONG ulMilliseconds_);
  909. /////////////////////////////////////////////////////////////////
  910. // Wait for a response from the ANTFS host library
  911. // Parameters:
  912. // ulMilliseconds_: Set this value to the minimum time to
  913. // wait before returning. If the value is
  914. // 0, the function will return immediately.
  915. // If the value is DSI_THREAD_INFINITE, the
  916. // function will not time out.
  917. // If one or more responses are pending before the timeout
  918. // expires the function will return the first response that
  919. // occured. If no response is pending at the time the timeout
  920. // expires, ANTFS_HOST_RESPONSE_NONE is returned.
  921. /////////////////////////////////////////////////////////////////
  922. };
  923. #endif // ANTFS_HOST_CHANNEL