antfs_host.hpp 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  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 in compliance
  4. with this license.
  5. Copyright (c) Dynastream Innovations Inc. 2013
  6. All rights reserved.
  7. */
  8. #if !defined(ANTFS_HOST_H)
  9. #define ANTFS_HOST_H
  10. #include "types.h"
  11. #include "dsi_debug.hpp"
  12. #include "antfs_host_channel.hpp"
  13. #include "dsi_ant_device.hpp"
  14. //////////////////////////////////////////////////////////////////////////////////
  15. // This class is a wrapper for ANTFSHostChannel.
  16. // It manages the connection to the ANT USB device (via DSIANTDevice)
  17. // and handles the ANT-FS host state machine (via ANTFSHostChannel).
  18. // Events and states from those two classes are mapped into the ANTFS_RESPONSE
  19. // and ANTFS_STATE enums, which are maintained for backwards compatibility.
  20. //////////////////////////////////////////////////////////////////////////////////
  21. //////////////////////////////////////////////////////////////////////////////////
  22. // Public Definitions
  23. //////////////////////////////////////////////////////////////////////////////////
  24. typedef enum
  25. {
  26. ANTFS_RESPONSE_NONE = 0,
  27. ANTFS_RESPONSE_OPEN_PASS,
  28. ANTFS_RESPONSE_SERIAL_FAIL,
  29. ANTFS_RESPONSE_REQUEST_SESSION_FAIL,
  30. ANTFS_RESPONSE_CONNECT_PASS,
  31. ANTFS_RESPONSE_DISCONNECT_PASS,
  32. ANTFS_RESPONSE_CONNECTION_LOST,
  33. ANTFS_RESPONSE_AUTHENTICATE_NA,
  34. ANTFS_RESPONSE_AUTHENTICATE_PASS,
  35. ANTFS_RESPONSE_AUTHENTICATE_REJECT,
  36. ANTFS_RESPONSE_AUTHENTICATE_FAIL,
  37. ANTFS_RESPONSE_DOWNLOAD_PASS,
  38. ANTFS_RESPONSE_DOWNLOAD_REJECT,
  39. ANTFS_RESPONSE_DOWNLOAD_INVALID_INDEX,
  40. ANTFS_RESPONSE_DOWNLOAD_FILE_NOT_READABLE,
  41. ANTFS_RESPONSE_DOWNLOAD_NOT_READY,
  42. ANTFS_RESPONSE_DOWNLOAD_FAIL,
  43. ANTFS_RESPONSE_UPLOAD_PASS,
  44. ANTFS_RESPONSE_UPLOAD_REJECT,
  45. ANTFS_RESPONSE_UPLOAD_INVALID_INDEX,
  46. ANTFS_RESPONSE_UPLOAD_FILE_NOT_WRITEABLE,
  47. ANTFS_RESPONSE_UPLOAD_INSUFFICIENT_SPACE,
  48. ANTFS_RESPONSE_UPLOAD_FAIL,
  49. ANTFS_RESPONSE_ERASE_PASS,
  50. ANTFS_RESPONSE_ERASE_FAIL,
  51. ANTFS_RESPONSE_MANUAL_TRANSFER_PASS,
  52. ANTFS_RESPONSE_MANUAL_TRANSFER_TRANSMIT_FAIL,
  53. ANTFS_RESPONSE_MANUAL_TRANSFER_RESPONSE_FAIL,
  54. ANTFS_RESPONSE_CANCEL_DONE
  55. } ANTFS_RESPONSE;
  56. typedef enum
  57. {
  58. ANTFS_STATE_IDLE = 0,
  59. ANTFS_STATE_IDLE_POLLING_USB,
  60. ANTFS_STATE_OPEN,
  61. ANTFS_STATE_DISCONNECTING,
  62. ANTFS_STATE_SEARCHING, // LINK
  63. ANTFS_STATE_CONNECTED, // AUTH
  64. ANTFS_STATE_AUTHENTICATING,
  65. ANTFS_STATE_TRANSPORT,
  66. ANTFS_STATE_DOWNLOADING,
  67. ANTFS_STATE_UPLOADING,
  68. ANTFS_STATE_ERASING,
  69. ANTFS_STATE_SENDING,
  70. ANTFS_STATE_RECEIVING
  71. } ANTFS_STATE;
  72. //////////////////////////////////////////////////////////////////////////////////
  73. // Public Function Prototypes
  74. //////////////////////////////////////////////////////////////////////////////////
  75. class ANTFSHost
  76. {
  77. private:
  78. //////////////////////////////////////////////////////////////////////////////////
  79. // Private Definitions
  80. //////////////////////////////////////////////////////////////////////////////////
  81. //////////////////////////////////////////////////////////////////////////////////
  82. // Private Variables
  83. //////////////////////////////////////////////////////////////////////////////////
  84. DSIANTDevice* pclMsgHandler;
  85. ANTFSHostChannel* pclHost;
  86. DSIResponseQueue<ANTFS_RESPONSE> clResponseQueue;
  87. volatile BOOL bOpen;
  88. BOOL bInitFailed;
  89. ANTFS_STATE eWrappedState;
  90. ULONG ulHostSerialNumber;
  91. DSI_THREAD_ID hANTFSThread; // Handle for the ANTFS thread.
  92. DSI_MUTEX stMutexResponseQueue; // Mutex used with the response queue
  93. DSI_MUTEX stMutexCriticalSection; // Mutex used with the wait condition
  94. DSI_CONDITION_VAR stCondANTFSThreadExit; // Event to signal the ANTFS thread has ended.
  95. DSI_CONDITION_VAR stCondWaitForResponse; // Event to signal there is a new response to the application
  96. volatile BOOL bKillThread;
  97. volatile BOOL bANTFSThreadRunning;
  98. //////////////////////////////////////////////////////////////////////////////////
  99. // Private Function Prototypes
  100. //////////////////////////////////////////////////////////////////////////////////
  101. BOOL InitHost(UCHAR ucUSBDeviceNum_, USHORT usBaudRate_, BOOL bAutoInit_);
  102. void ANTFSThread(void);
  103. static DSI_THREAD_RETURN ANTFSThreadStart(void *pvParameter_);
  104. void AddResponse(ANTFS_RESPONSE eResponse_);
  105. public:
  106. ANTFSHost();
  107. ~ANTFSHost();
  108. UCHAR GetVersion(UCHAR *pucVersionString_, UCHAR ucBufferSize_);
  109. /////////////////////////////////////////////////////////////////
  110. // Copies at most ucBufferSize_ characters from the version
  111. // string into the supplied pucVersionString_ buffer.
  112. // Parameters:
  113. // *pucVersionString_ Pointer to a buffer of characters into
  114. // which to receive the version string.
  115. // ucBufferSize_ The maximum number of characters to
  116. // copy into *pucVersionString_.
  117. // Returns the number of characters copied to *pucVersionString_.
  118. // Operation:
  119. // If the version string has fewer than ucBufferSize_
  120. // characters, the *pucVersionString_ will be padded with a
  121. // '\n'.
  122. /////////////////////////////////////////////////////////////////
  123. BOOL Init(void);
  124. /////////////////////////////////////////////////////////////////
  125. // Begins to initialize the ANTFSHost object.
  126. // Returns TRUE if successful. Otherwise, it returns FALSE.
  127. // Operation:
  128. // If ANTFSHost fails to initialize the USBstick, It will
  129. // continue to retry the intitialization once a second until
  130. // it is sucessful. Once everything has be sucessfully initialized
  131. // a response of ANTFS_RESPONSE_CONNECT_PASS will be sent.
  132. //
  133. // This version of Init will only work for the ANT USB stick with
  134. // USB device descriptor "ANT USB Stick"
  135. /////////////////////////////////////////////////////////////////
  136. BOOL Init(UCHAR ucUSBDeviceNum_, USHORT usBaudRate_);
  137. /////////////////////////////////////////////////////////////////
  138. // Begins to initialize the ANTFSHost object.
  139. // Returns TRUE if successful. Otherwise, it returns FALSE.
  140. // Parameters:
  141. // ucUSBDeviceNum_: USB port number
  142. // usBaudRate_: Serial baud rate
  143. // Operation:
  144. // If ANTFSHost fails to initialize the USBstick, It will
  145. // continue to retry the intitialization once a second until
  146. // it is sucessful. Once everything has be sucessfully initialized
  147. // a response of ANTFS_RESPONSE_CONNECT_PASS will be sent.
  148. /////////////////////////////////////////////////////////////////
  149. void SetChannelID(UCHAR ucDeviceType_, UCHAR ucTransmissionType_);
  150. void SetMessagePeriod(USHORT usMessagePeriod_);
  151. void SetNetworkkey(UCHAR ucNetworkkey[]);
  152. void SetProximitySearch(UCHAR ucSearchThreshold_);
  153. /////////////////////////////////////////////////////////////////
  154. // Sets the value for the proximity bin setting for searching.
  155. // Note: If applying this value fails when attempting to start search,
  156. // it is ignored to maintain compatibility with devices that
  157. // do not support this feature. This means that a real failure can occur
  158. // on a device that actually does support it, and it will be missed. The
  159. // debug log will show if this command fails.
  160. // Parameters:
  161. // ucSearchThreshold_ Desired proximity bin from 0-10 (If value is
  162. // set higher then 10, it is automatically capped at 10)
  163. /////////////////////////////////////////////////////////////////
  164. void Close(void);
  165. /////////////////////////////////////////////////////////////////
  166. // Stops any pending actions, closes all devices down and cleans
  167. // up any dynamic memory being used by the library.
  168. /////////////////////////////////////////////////////////////////
  169. ANTFS_STATE GetStatus(void);
  170. /////////////////////////////////////////////////////////////////
  171. // Returns the current library status.
  172. /////////////////////////////////////////////////////////////////
  173. ANTFS_RESPONSE WaitForResponse(ULONG ulMilliseconds_);
  174. /////////////////////////////////////////////////////////////////
  175. // Wait for a response from the ANTFSHost object.
  176. // Parameters:
  177. // ulMilliseconds_: Set this value to the minimum time to
  178. // wait before returning. If the value is
  179. // 0, the function will return immediately.
  180. // If the value is DSI_THREAD_INFINITE, the
  181. // function will not time out.
  182. // If one or more responses are pending before the timeout
  183. // expires the function will return the first response that
  184. // occured. If no response is pending at the time the timeout
  185. // expires, ANTFS_RESPONSE_NONE is returned.
  186. /////////////////////////////////////////////////////////////////
  187. void Cancel(void);
  188. /////////////////////////////////////////////////////////////////
  189. // Cancels any pending actions and returns the library to the
  190. // appropriate ANTFS layer if possible. ie if the library was
  191. // executing a download command in the transport layer, the
  192. // library would be returned to ANTFS_STATE_TRANSPORT after
  193. // execution of this function.
  194. /////////////////////////////////////////////////////////////////
  195. USHORT AddSearchDevice(ANTFS_DEVICE_PARAMETERS *pstDeviceSearchMask_, ANTFS_DEVICE_PARAMETERS *pstDeviceParameters_);
  196. /////////////////////////////////////////////////////////////////
  197. // Adds a set of parameters for which to search to the internal
  198. // search device list.
  199. // Parameters:
  200. // *pstDeviceSearchMask_: A pointer to an
  201. // ANTFS_DEVICE_PARAMETERS structure. Set a
  202. // member to zero (0) to wildcard search for
  203. // it. Otherwise, set the bits that you want
  204. // to be matched to 1 in each member. Members
  205. // that are integer values will be treated the
  206. // same as bit fields for the purposes for the mask.
  207. // *pstDeviceParameters_: A pointer to an
  208. // ANTFS_DEVICE_PARAMETERS structure. Set
  209. // the member to the desired search value.
  210. // A member in this structure is ignored if
  211. // the associated member in the
  212. // *pstDeviceSearchMask_ parameter is set
  213. // to zero (0) for wildcard.
  214. // Returns a handle the the search device entry. If the return
  215. // value is 0, the function failed adding the device entry.
  216. // This means that the device list is already full.
  217. // Operation:
  218. // Note that the default search masks should normally be applied
  219. // to the ucStatusByte1 and ucStatusByte2 members of the
  220. // *pstDeviceSearchMask_ parameter. Eg;
  221. // pstMyDeviceSearchMask->ucStatusByte1 =
  222. // ANTFS_STATUS1_DEFAULT_SEARCH_MASK & ucMyStatus1Criteria;
  223. // Setting bits outside the masks, especially reserved bits, may
  224. // lead to undesired behaviour.
  225. /////////////////////////////////////////////////////////////////
  226. void RemoveSearchDevice(USHORT usHandle_);
  227. /////////////////////////////////////////////////////////////////
  228. // Removes a device entry from the internal search list.
  229. // Parameters:
  230. // usHandle_: Handle to the device entry to be removed
  231. // from the list.
  232. /////////////////////////////////////////////////////////////////
  233. void ClearSearchDeviceList(void);
  234. /////////////////////////////////////////////////////////////////
  235. // Clears the internal search device list.
  236. /////////////////////////////////////////////////////////////////
  237. ANTFS_RETURN SearchForDevice(UCHAR ucSearchRadioFrequency_ = ANTFS_RF_FREQ, UCHAR ucConnectRadioFrequency_ = ANTFS_DEFAULT_TRANSPORT_FREQ, USHORT usRadioChannelID_ = 0, BOOL bUseRequestPage_ = FALSE);
  238. /////////////////////////////////////////////////////////////////
  239. // Begins a search for ANTFS remote devices.
  240. // Parameters:
  241. // ucSearchRadioFrequency_: This specifies the frequency on
  242. // which to search for devices. This
  243. // frequency is calculated as
  244. // (ucSearchRadioFrequency_ * 1 MHz +
  245. // 2400 MHz). MAX_UCHAR (0xFF) is reserved.
  246. // ucConnectRadioFrequency_: This specifies the frequency
  247. // on which the connection communication
  248. // will occur. This frequency is calculated
  249. // as (ucConnectRadioFrequency_ * 1 MHz +
  250. // 2400 MHz). If ucConnectRadioFrequency_
  251. // is set to ANTFS_AUTO_FREQUENCY_SELECTION
  252. // (0xFF), then the library will use an
  253. // adaptive frequency-hopping scheme.
  254. // usRadioChannelID_: This specifies the channel ID for the
  255. // the ANT channel search. Set to zero to
  256. // wildcard.
  257. // bUseRequestPage_: Specifies whether the search will include
  258. // ANT-FS broadcast devices, using a request
  259. // page to begin an ANT-FS session
  260. // Returns ANTFS_RETURN_PASS if successful. Otherwise, it returns
  261. // ANTFS_RETURN_FAIL if the library is in the wrong state, or
  262. // ANTFS_RETURN_BUSY if the library is busy with another request.
  263. // Operation:
  264. // Once this function is called successfully, the application
  265. // must wait for the response from the ANTFSHost object.
  266. // Possible responses are:
  267. // ANTFS_RESPONSE_CONNECT_PASS
  268. // ANTFS_RESPONSE_SERIAL_FAIL
  269. // The library will continue to search for devices until a device
  270. // is found, the Cancel() function is called, an error occurs, or
  271. // the library is closed.
  272. /////////////////////////////////////////////////////////////////
  273. BOOL GetFoundDeviceParameters(ANTFS_DEVICE_PARAMETERS *pstDeviceParameters_, UCHAR *aucFriendlyName_, UCHAR *pucBufferSize_);
  274. /////////////////////////////////////////////////////////////////
  275. // Copies the parameters of the most recently found device to the
  276. // supplied parameter.
  277. // Parameters:
  278. // *ptsDeviceParameters_: A pointer to a structure that will
  279. // receive a copy of the device parameters.
  280. // *aucFriendlyName_: A pointer to a buffer where the remote
  281. // device friendly name will be copied.
  282. // *pucBufferSize_: Pointer to a UCHAR variable that should contain the
  283. // maximum size of the buffer pointed to by aucFriendlyName_.
  284. // aucFriendlyName will receive a copy of min(pucBufferSize, actualSize) length.
  285. // After the function returns, this variable
  286. // will be set to reflect the actual size of friendly name string.
  287. // Returns TRUE if successful. Otherwise, it returns FALSE.
  288. /////////////////////////////////////////////////////////////////
  289. BOOL GetFoundDeviceChannelID(USHORT *pusDeviceNumber_ = (USHORT *)NULL, UCHAR *pucDeviceType_ = (UCHAR *)NULL, UCHAR *pucTransmitType_ = (UCHAR *)NULL);
  290. /////////////////////////////////////////////////////////////////
  291. // Copies the ANT channel ID of the most recently found device to
  292. // the supplied parameters.
  293. // Parameters:
  294. // *pusDeviceNumber_: A pointer to a USHORT variable that will
  295. // receive the ANT device number of the device.
  296. // *pucDeviceType_: A pointer to a UCHAR variable that will
  297. // hold the =device type of the found device.
  298. // *pucTransmitType_: Pointer to a UCHAR variable that will
  299. // receive the transmission type of the found
  300. // device
  301. // Returns TRUE if successful. Otherwise, it returns FALSE.
  302. /////////////////////////////////////////////////////////////////
  303. BOOL GetUploadStatus(ULONG *pulByteProgress_, ULONG *pulTotalLength_);
  304. /////////////////////////////////////////////////////////////////
  305. // Gets the transfer progress of a pending or a complete
  306. // upload.
  307. // Parameters:
  308. // *pulByteProgress_: Pointer to a ULONG that will receive
  309. // the current byte progress of a pending or
  310. // complete upload.
  311. // *pulTotalLength_: Pointer to a ULONG that will receive the
  312. // total length of the file being uploaded.
  313. // Returns TRUE if successful. Otherwise, it returns FALSE.
  314. // Operation:
  315. // A data upload occurs when information is requested to be sent to
  316. // a remote device. This function may be called at any point
  317. // during an upload as a progress indicator. After the upload
  318. // is complete, this information is valid until another request
  319. // for a data transfer is made.
  320. /////////////////////////////////////////////////////////////////
  321. BOOL GetDownloadStatus(ULONG *pulByteProgress_, ULONG *pulTotalLength_);
  322. /////////////////////////////////////////////////////////////////
  323. // Gets the transfer progress of a pending or a complete
  324. // download.
  325. // Parameters:
  326. // *pulByteProgress_: Pointer to a ULONG that will receive
  327. // the current byte progress of a pending or
  328. // complete download.
  329. // *pulTotalLength_: Pointer to a ULONG that will receive the
  330. // total expected length of the download.
  331. // Returns TRUE if successful. Otherwise, it returns FALSE.
  332. // Operation:
  333. // A data download occurs when information is requested from a
  334. // remote device. This function may be called at any point
  335. // during a download as a progress indicator. After the transfer
  336. // is complete, this information is valid until another request
  337. // for a data transfer is made.
  338. /////////////////////////////////////////////////////////////////
  339. BOOL GetTransferData(ULONG *pulDataSize_ , void *pvData_ = NULL);
  340. /////////////////////////////////////////////////////////////////
  341. // Gets the received data from a transfer (download/manual transfer).
  342. //
  343. // Parameters:
  344. // *ulDataSize_ : Pointer to a ULONG that will receive
  345. // the size of the data available in bytes.
  346. // *pvData_ : Pointer to a buffer where the received data
  347. // will be copied. NULL can be passed to this
  348. // parameter so that the size can be retried
  349. // without copying any data. The application
  350. // can then call this function again to after it
  351. // has allocated a buffer of sufficient size to
  352. // handle the data.
  353. // Returns TRUE if successful. Otherwise, it returns FALSE.
  354. /////////////////////////////////////////////////////////////////
  355. ANTFS_RETURN Authenticate(UCHAR ucAuthenticationType_, UCHAR *pucAuthenticationString_, UCHAR ucLength_, UCHAR *aucResponseBuffer_, UCHAR *pucResponseBufferSize_, ULONG ulResponseTimeout_);
  356. /////////////////////////////////////////////////////////////////
  357. // Request to pair with the connected remote device.
  358. // Parameters:
  359. // ucAuthenticationType_: The type of authentication to
  360. // execute on the remote device.
  361. // *pucAuthenticationString_: A string that may be used in
  362. // conjunction with the particular
  363. // authentication type in use (e.g. a
  364. // password or a friendly name.
  365. // ucLength_: The length of the authentication string,
  366. // including any '\n' terminator. This
  367. // parameter may be set to zero if an
  368. // authentication string is not required.
  369. // *pucResponseBuffer_: Pointer to the buffer where additional
  370. // data from the response will be saved. This will
  371. // include data such as passwords and friendly names.
  372. // This memory must be allocated by the application.
  373. // *pucResponseBufferSize_: Pointer to UCHAR varible that contains the
  374. // size of the buffer pointed to by pucResponseBuffer_.
  375. // After the response has be recived, the UCHAR variable
  376. // will be set to reflect the size of the new data received
  377. // in pucResponseBuffer_.
  378. // ulResponseTimeout_: Number of miliseconds to wait for a response after
  379. // the authenticate command is sent.
  380. // Returns ANTFS_RETURN_PASS if successful. Otherwise, it returns
  381. // ANTFS_RETURN_FAIL if the library is in the wrong state, or
  382. // ANTFS_RETURN_BUSY if the library is busy with another request.
  383. // Operation:
  384. // Once the request is posted, the application must wait for the
  385. // response from the ANTFSHost object. Possible responses are:
  386. // ANTFS_RESPONSE_AUTHENTICATE_NA
  387. // ANTFS_RESPONSE_AUTHENTICATE_PASS
  388. // ANTFS_RESPONSE_AUTHENTICATE_REJECT
  389. // ANTFS_RESPONSE_AUTHENTICATE_FAIL
  390. // ANTFS_RESPONSE_CONNECTION_LOST
  391. // ANTFS_RESPONSE_SERIAL_FAIL
  392. // Upon receiving the ANTFS_RESPONSE_AUTHENTICATE_PASS, an
  393. // authentication string provided by the remoted device may be
  394. // available in the response buffer. This depends on the
  395. // authentication type used. The transport
  396. // layer connection is also only established after receiving
  397. // ANTFS_RESPONSE_AUTHENTICATE_PASS .
  398. /////////////////////////////////////////////////////////////////
  399. ANTFS_RETURN Disconnect(USHORT usBlackoutTime_, UCHAR ucDisconnectType_ = 0, UCHAR ucTimeDuration_ = 0, UCHAR ucAppSpecificDuration_ = 0);
  400. /////////////////////////////////////////////////////////////////
  401. // Disconnect from a remote device. Optionally put that device
  402. // on a blackout list for a period of time. The application can
  403. // also request the remote device to become undiscoverable for a
  404. // specified time/application specific duration.
  405. // Parameters:
  406. // usBlackoutTime_: The number of seconds the device ID
  407. // should remain on the blackout list. If
  408. // set to zero (0), then the device will
  409. // not be put on the blackout list. If set
  410. // to MAX_USHORT (0xFFFF), the device will
  411. // remain on the blackout list until
  412. // explicitly removed, or until the blackout
  413. // list is reset.
  414. // ucDisconnectType_: Specifies whether the client should
  415. // return to LINK state or broadcast mode
  416. // (ANT-FS broadcast)
  417. // ucTimeDuration_: Time, in 30 seconds increments, the client
  418. // device will remain undiscoverable after
  419. // disconnect has been requested. Set to 0 to
  420. // disable.
  421. // ucAppSpecificDuration_: Application specific duration the client
  422. // shall remain undiscoverable after disconnection.
  423. // This field is left to the developer, or defined
  424. // in an ANT+ Device Profile. Set to 0 to disable.
  425. // Returns ANTFS_RETURN_PASS if successful. Otherwise, it returns
  426. // ANTFS_RETURN_FAIL if the library is in the wrong state, or
  427. // ANTFS_RETURN_BUSY if the library is busy with another request.
  428. // Operation:
  429. // Once the request is posted, the application must wait for the
  430. // response from the ANTFSHost object. Possible responses are:
  431. // ANTFS_RESPONSE_DISCONNECT_PASS
  432. // ANTFS_RESPONSE_CONNECTION_LOST
  433. // ANTFS_RESPONSE_SERIAL_FAIL
  434. // The remote device will not show up in any search results for
  435. // the duration specified in usBlackoutTime_. This allows the
  436. // host to more easily find other devices in crowded
  437. // environments. The host can also request the remote device to
  438. // become undiscoverable, to more easily find other devices, however
  439. // not all client devices might implement this feature. Not all
  440. // client devices support a broadcast mode.
  441. /////////////////////////////////////////////////////////////////
  442. BOOL Blackout(ULONG ulDeviceID_, USHORT usManufacturerID_, USHORT usDeviceType_, USHORT usBlackoutTime_);
  443. /////////////////////////////////////////////////////////////////
  444. // Put the device on a blackout list for a period of time.
  445. // Parameters:
  446. // ulDeviceID_: The device ID of a specific device.
  447. // usManufacturerID_: The specific manufacturer ID.
  448. // usDeviceType_: The specific device type.
  449. // usBlackoutTime_: The number of seconds the device ID
  450. // should remain on the blackout list. If
  451. // set to zero (0), then the device will
  452. // not be put on the blackout list. If set
  453. // to MAX_USHORT (0xFFFF), the device will
  454. // remain on the blackout list until
  455. // explicitly removed, or until the blackout
  456. // list is reset.
  457. // Returns TRUE if successful. Otherwise, it returns FALSE.
  458. // A wildcard parameter (0) is not allowed in any of the device
  459. // ID parameters and will result in returning FALSE.
  460. // Operation:
  461. // The remote device will not show up in any search results for
  462. // the duration specified in usBlackoutTime_. This allows the
  463. // host to more easily find other devices in crowded
  464. // environments.
  465. /////////////////////////////////////////////////////////////////
  466. BOOL RemoveBlackout(ULONG ulDeviceID_, USHORT usManufacturerID_, USHORT usDeviceType_);
  467. /////////////////////////////////////////////////////////////////
  468. // Remove the device from the blackout list.
  469. // Parameters:
  470. // ulDeviceID_: The device ID of a specific device.
  471. // usManufacturerID_: The specific manufacturer ID.
  472. // usDeviceType_: The specific device type.
  473. // Returns TRUE if successful. Returns FALSE if the device is
  474. // not found in the blackout list. A wildcard parameter (0) is
  475. // not allowed in any of the device ID parameters and will result
  476. // in returning FALSE.
  477. /////////////////////////////////////////////////////////////////
  478. void ClearBlackoutList(void);
  479. /////////////////////////////////////////////////////////////////
  480. // Clears the blackout list.
  481. /////////////////////////////////////////////////////////////////
  482. ANTFS_RETURN Download(USHORT usFileIndex_, ULONG ulDataOffset_, ULONG ulMaxDataLength_, ULONG ulMaxBlockSize_ = 0);
  483. /////////////////////////////////////////////////////////////////
  484. // Request a download of a file from the authenticated device.
  485. // Parameters:
  486. // usFileIndex_: The file number to be downloaded. Some
  487. // file numbers are reserved for special
  488. // purposes, such as the device directory
  489. // (0). Consult the ANT_FS specification
  490. // and any docs for specific device types.
  491. // ulDataOffset_: The byte offset from where to begin
  492. // transferring the data.
  493. // ulMaxDataLength_: ULONG varible that contains the maximum
  494. // number of bytes to download.
  495. // ulMaxBlockSize_: Maximum number of bytes that the host
  496. // wishes to download in a single block.
  497. // Set to zero to disable.
  498. // Returns ANTFS_RETURN_PASS if successful. Otherwise, it returns
  499. // ANTFS_RETURN_FAIL if the library is in the wrong state, or
  500. // ANTFS_RETURN_BUSY if the library is busy with another request.
  501. // Operation:
  502. // Once the request is posted, the application must wait for the
  503. // response from the ANTFSHost object. Possible responses are:
  504. // ANTFS_RESPONSE_DOWNLOAD_PASS
  505. // ANTFS_RESPONSE_DOWNLOAD_REJECT
  506. // ANTFS_RESPONSE_DOWNLOAD_FAIL
  507. // ANTFS_RESPONSE_CONNECTION_LOST
  508. // ANTFS_RESPONSE_SERIAL_FAIL
  509. // Upon receiving ANTFS_RESPONSE_DOWNLOAD_PASS the downloaed data
  510. // will be available in the transfer buffer. See GetTransferData().
  511. /////////////////////////////////////////////////////////////////
  512. ANTFS_RETURN Upload(USHORT usFileIndex_, ULONG ulDataOffset_, ULONG ulDataLength_, void *pvData_, BOOL bForceOffset_ = TRUE, ULONG ulMaxBlockSize_ = 0);
  513. /////////////////////////////////////////////////////////////////
  514. // Request an upload of a file to the authenticated device.
  515. // Parameters:
  516. // usFileIndex_: The file number to be uploaded. Some
  517. // file numbers are reserved for special
  518. // purposes, such as the device directory
  519. // (0). Consult the ANT_FS specification
  520. // and any docs for specific device types.
  521. // ulDataOffset_: The byte offset from where to begin
  522. // transferring the data.
  523. // ulDataLength_: The byte length of data to be uploaded
  524. // to the remote device.
  525. // Return value:
  526. // *pvData_: Pointer to the location where the data
  527. // to be uploaded is stored. This pointer must be valid
  528. // throughout the entire transfer.
  529. // bForceOffset_: Set to TRUE (default) to enforce the
  530. // provided byte data offset. Set to FALSE
  531. // to continue a transfer, indicating that
  532. // the host will continue the upload at the
  533. // last data offset specified by the client
  534. // in the Upload Response.
  535. // ulMaxBlockSize_: Maximum block size that the host can send
  536. // in a single block of data. Set to zero
  537. // to disable
  538. // Returns ANTFS_RETURN_PASS if successful. Otherwise, it returns
  539. // ANTFS_RETURN_FAIL if the library is in the wrong state, or
  540. // ANTFS_RETURN_BUSY if the library is busy with another request.
  541. // Operation:
  542. // Once the request is posted, the application must wait for the
  543. // response from the ANTFSHost object. Possible responses are:
  544. // ANTFS_RESPONSE_UPLOAD_PASS
  545. // ANTFS_RESPONSE_UPLOAD_REJECT
  546. // ANTFS_RESPONSE_UPLOAD_FAIL
  547. // ANTFS_RESPONSE_CONNECTION_LOST
  548. // ANTFS_RESPONSE_SERIAL_FAIL
  549. /////////////////////////////////////////////////////////////////
  550. ANTFS_RETURN ManualTransfer(USHORT usFileIndex_, ULONG ulDataOffset_, ULONG ulDataLength_, void *pvData_);
  551. /////////////////////////////////////////////////////////////////
  552. // Send data directly to the device without requesting first.
  553. // This is especially useful for communicating small pieces of
  554. // data to the device. Another use is the implementation of a
  555. // higher-level communication protocol. Care must be taken to
  556. // ensure the device can handle the amount of data being sent
  557. // using this method.
  558. // usFileIndex_: The file number to be uploaded. Some
  559. // file numbers are reserved for special
  560. // purposes, such as the device directory
  561. // (0). Consult the ANT_FS specification
  562. // and any docs for specific device types.
  563. // ulDataOffset_: The byte offset from where to begin
  564. // transferring the data. Note that this
  565. // value will always get rounded up to the
  566. // next higher multiple of 8. Under normal
  567. // use, this parameter should always be set
  568. // to zero, and the only time it would be
  569. // non-zero is for retrying ManualTransfer()
  570. // from a known offset.
  571. // ulDataLength_: The byte length of data to be sent to
  572. // the remote device.
  573. // *pvData_: The Pointer to a buffer where the
  574. // data to be sent is stored.
  575. // Returns ANTFS_RETURN_PASS if successful. Otherwise, it returns
  576. // ANTFS_RETURN_FAIL if the library is in the wrong state, or
  577. // ANTFS_RETURN_BUSY if the library is busy with another request.
  578. // Operation:
  579. // Once the request is posted, the application must wait for the
  580. // response from the ANTFSHost object. Possible responses are:
  581. // ANTFS_RESPONSE_MANUAL_TRANSFER_PASS
  582. // ANTFS_RESPONSE_MANUAL_TRANSFER_TRANSMIT_FAIL
  583. // ANTFS_RESPONSE_MANUAL_TRANSFER_RESPONSE_FAIL
  584. // ANTFS_RESPONSE_CONNECTION_LOST
  585. // ANTFS_RESPONSE_SERIAL_FAIL
  586. // Upon receiving ANTFS_RESPONSE_MANUAL_TRANSFER_PASS the downloaed data
  587. // will be available in the transfer buffer. See GetTransferData().
  588. /////////////////////////////////////////////////////////////////
  589. ANTFS_RETURN EraseData(USHORT usFileIndex_);
  590. /////////////////////////////////////////////////////////////////
  591. // Request the erasure of a file on the authenticated remote
  592. // device.
  593. // Parameters:
  594. // usFileIndex_: The file number of the file to be erased.
  595. // Returns ANTFS_RETURN_PASS if successful. Otherwise, it returns
  596. // ANTFS_RETURN_FAIL if the library is in the wrong state, or
  597. // ANTFS_RETURN_BUSY if the library is busy with another request.
  598. // Operation:
  599. // Once the request is posted, the application must wait for the
  600. // response from the ANTFSHost object. Possible responses are:
  601. // ANTFS_RESPONSE_ERASE_PASS
  602. // ANTFS_RESPONSE_ERASE_FAIL
  603. // ANTFS_RESPONSE_CONNECTION_LOST
  604. // ANTFS_RESPONSE_SERIAL_FAIL
  605. /////////////////////////////////////////////////////////////////
  606. BOOL EnablePing(BOOL bEnable_);
  607. /////////////////////////////////////////////////////////////////
  608. // Enables ping message to be sent to the remote device periodically.
  609. // This can be used to keep the remote device from timing out during
  610. // operations that wait for user input (i.e. pairing).
  611. // Parameters:
  612. // bEnable_: Periodic ping enable.
  613. // Returns TRUE if successful. Otherwise, it returns FALSE.
  614. /////////////////////////////////////////////////////////////////
  615. #if defined(DEBUG_FILE)
  616. void SetDebug(BOOL bDebugOn_, const char *pcDirectory_ = (const char*) NULL);
  617. /////////////////////////////////////////////////////////////////
  618. // Enables debug files
  619. // Parameters:
  620. // bDebugOn_: Enable/disable debug logs.
  621. // *pcDirectory_: A string to use as the path for storing
  622. // debug logs. Set to NULL to use the working
  623. // directory as the default path.
  624. /////////////////////////////////////////////////////////////////
  625. #endif
  626. };
  627. #endif // !defined(ANTFS_HOST_H)