2
0

ANT_ReferenceLibrary.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  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. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. namespace ANT_Managed_Library
  13. {
  14. /// <summary>
  15. /// Contains all the ANT constants and enumerations for general use.
  16. /// Note: Where desired, in functions where enumerations are required, a byte type can be
  17. /// cast to the enumeration to feed the function raw byte values.
  18. /// IE: <c>ANTDeviceInstance.RequestMessage((RequestMessageID)0x4E));</c> would compile.
  19. /// </summary>
  20. public sealed class ANT_ReferenceLibrary
  21. {
  22. //removed class scope static modifier because it interferes with some serialization, so a private constructor is needed to enforce static use
  23. private ANT_ReferenceLibrary()
  24. {
  25. throw new Exception("This is a static class, do not create instances");
  26. }
  27. #pragma warning disable 1591
  28. /// <summary>
  29. /// Possible port connection types.
  30. /// </summary>
  31. public enum PortType : byte
  32. {
  33. USB = 0x00,
  34. COM = 0x01
  35. };
  36. /// <summary>
  37. /// Possible framing modes.
  38. /// Use FramerType.basicANT unless you know you need to use another.
  39. /// </summary>
  40. public enum FramerType : byte
  41. {
  42. basicANT = 0x00,
  43. };
  44. /// <summary>
  45. /// Channel Type flags. A valid channel type is one BASE parameter (Slave XOR Receive)
  46. /// combined by '|' (bitwise OR) with any desired ADV parameters
  47. /// </summary>
  48. [Flags]
  49. public enum ChannelType : byte
  50. {
  51. BASE_Slave_Receive_0x00 = 0x00,
  52. BASE_Master_Transmit_0x10 = 0x10,
  53. ADV_Shared_0x20 = 0x20,
  54. ADV_TxRx_Only_or_RxAlwaysWildCard_0x40 = 0x40,
  55. };
  56. [Flags]
  57. public enum ChannelTypeExtended : byte
  58. {
  59. ADV_AlwaysSearch_0x01 = 0x01,
  60. ADV_FrequencyAgility_0x04 = 0x04,
  61. ADV_FastStart_0x10 = 0x10,
  62. ADV_AsyncTx_0x20 = 0x20,
  63. }
  64. /// <summary>
  65. /// The int status codes returned by the acknowledged and broadcast messaging functions.
  66. /// </summary>
  67. public enum MessagingReturnCode : int
  68. {
  69. Fail = 0,
  70. Pass = 1,
  71. Timeout = 2,
  72. Cancelled = 3,
  73. InvalidParams = 4,
  74. }
  75. /// <summary>
  76. /// Basic Channel status message codes, the bottom two bits of the received status message
  77. /// </summary>
  78. public enum BasicChannelStatusCode : byte
  79. {
  80. UNASSIGNED_0x0 = 0x0,
  81. ASSIGNED_0x1 = 0x1,
  82. SEARCHING_0x2 = 0x2,
  83. TRACKING_0x3 = 0x3,
  84. }
  85. /// <summary>
  86. /// Transmit Power offsets
  87. /// </summary>
  88. public enum TransmitPower : byte
  89. {
  90. RADIO_TX_POWER_MINUS20DB_0x00 = 0x00,
  91. RADIO_TX_POWER_MINUS10DB_0x01 = 0x01,
  92. RADIO_TX_POWER_MINUS5DB_0x02 = 0x02,
  93. RADIO_TX_POWER_0DB_0x03 = 0x03
  94. };
  95. /// <summary>
  96. /// Startup message
  97. /// </summary>
  98. public enum StartupMessage : byte
  99. {
  100. RESET_POR_0x00 = 0x00,
  101. RESET_RST_0x01 = 0x01,
  102. RESET_WDT_0x02 = 0x02,
  103. RESET_CMD_0x20 = 0x20,
  104. RESET_SYNC_0x40 = 0x40,
  105. RESET_SUSPEND_0x80 = 0x80
  106. };
  107. /// <summary>
  108. /// Message ID to request message.
  109. /// Note: Where desired, raw byte values can be cast to the enum type. IE: <c>(RequestMessageID)0x4E</c> will compile.
  110. /// </summary>
  111. public enum RequestMessageID : byte
  112. {
  113. VERSION_0x3E = 0x3E,
  114. CHANNEL_ID_0x51 = 0x51,
  115. CHANNEL_STATUS_0x52 = 0x52,
  116. CAPABILITIES_0x54 = 0x54,
  117. SERIAL_NUMBER_0x61 = 0x61,
  118. USER_NVM_0x7C = 0x7C,
  119. };
  120. /// <summary>
  121. /// Command Codes for SensRcore operations
  122. /// </summary>
  123. public enum SensRcoreScriptCommandCodes : byte
  124. {
  125. SCRIPT_CMD_FORMAT_0x00 = 0x00,
  126. SCRIPT_CMD_DUMP_0x01 = 0x01,
  127. SCRIPT_CMD_SET_DEFAULT_SECTOR_0x02 = 0x02,
  128. SCRIPT_CMD_END_SECTOR_0x03 = 0x03,
  129. SCRIPT_CMD_END_DUMP_0x04 = 0x04,
  130. SCRIPT_CMD_LOCK_0x05 = 0x05,
  131. };
  132. /// <summary>
  133. /// Flags for configuring device ANT library
  134. /// </summary>
  135. [Flags]
  136. public enum LibConfigFlags
  137. {
  138. RADIO_CONFIG_ALWAYS_0x01 = 0x01,
  139. MESG_OUT_INC_TIME_STAMP_0x20 = 0x20,
  140. MESG_OUT_INC_RSSI_0x40 = 0x40,
  141. MESG_OUT_INC_DEVICE_ID_0x80 = 0x80,
  142. }
  143. /// <summary>
  144. /// Flags for configuring advanced bursting features.
  145. /// </summary>
  146. [Flags]
  147. public enum AdvancedBurstConfigFlags : uint
  148. {
  149. FREQUENCY_HOP_ENABLE = 0x00000001,
  150. };
  151. public enum EncryptedChannelMode : byte
  152. {
  153. DISABLE = 0x00,
  154. ENABLE = 0x01,
  155. ENABLE_USER_INFO = 0x02,
  156. };
  157. public enum EncryptionInfo : byte
  158. {
  159. ENCRYPTION_ID = 0x00,
  160. USER_INFO_STRING = 0x01,
  161. RANDOM_NUMBER_SEED = 0x02,
  162. };
  163. public enum EncryptionNVMOp : byte
  164. {
  165. LOAD_KEY_FROM_NVM = 0x00,
  166. STORE_KEY_TO_NVM = 0x01,
  167. }
  168. /// <summary>
  169. /// Event groups for configuring Event Buffering
  170. /// </summary>
  171. [Flags]
  172. public enum EventBufferConfig : byte
  173. {
  174. BUFFER_LOW_PRIORITY_EVENTS = 0x00,
  175. BUFFER_ALL_EVENTS = 0x01
  176. };
  177. /// <summary>
  178. /// MessageIDs for reference
  179. /// </summary>
  180. public enum ANTMessageID : byte
  181. {
  182. INVALID_0x00 = 0x00,
  183. EVENT_0x01 = 0x01,
  184. VERSION_0x3E = 0x3E,
  185. RESPONSE_EVENT_0x40 = 0x40,
  186. UNASSIGN_CHANNEL_0x41 = 0x41,
  187. ASSIGN_CHANNEL_0x42 = 0x42,
  188. CHANNEL_MESG_PERIOD_0x43 = 0x43,
  189. CHANNEL_SEARCH_TIMEOUT_0x44 = 0x44,
  190. CHANNEL_RADIO_FREQ_0x45 = 0x45,
  191. NETWORK_KEY_0x46 = 0x46,
  192. RADIO_TX_POWER_0x47 = 0x47,
  193. RADIO_CW_MODE_0x48 = 0x48,
  194. SYSTEM_RESET_0x4A = 0x4A,
  195. OPEN_CHANNEL_0x4B = 0x4B,
  196. CLOSE_CHANNEL_0x4C = 0x4C,
  197. REQUEST_0x4D = 0x4D,
  198. BROADCAST_DATA_0x4E = 0x4E,
  199. ACKNOWLEDGED_DATA_0x4F = 0x4F,
  200. BURST_DATA_0x50 = 0x50,
  201. CHANNEL_ID_0x51 = 0x51,
  202. CHANNEL_STATUS_0x52 = 0x52,
  203. RADIO_CW_INIT_0x53 = 0x53,
  204. CAPABILITIES_0x54 = 0x54,
  205. STACKLIMIT_0x55 = 0x55,
  206. SCRIPT_DATA_0x56 = 0x56,
  207. SCRIPT_CMD_0x57 = 0x57,
  208. ID_LIST_ADD_0x59 = 0x59,
  209. ID_LIST_CONFIG_0x5A = 0x5A,
  210. OPEN_RX_SCAN_0x5B = 0x5B,
  211. EXT_BROADCAST_DATA_0x5D = 0x5D,
  212. EXT_ACKNOWLEDGED_DATA_0x5E = 0x5E,
  213. EXT_BURST_DATA_0x5F = 0x5F,
  214. CHANNEL_RADIO_TX_POWER_0x60 = 0x60,
  215. GET_SERIAL_NUM_0x61 = 0x61,
  216. GET_TEMP_CAL_0x62 = 0x62,
  217. SET_LP_SEARCH_TIMEOUT_0x63 = 0x63,
  218. SERIAL_NUM_SET_CHANNEL_ID_0x65 = 0x65,
  219. RX_EXT_MESGS_ENABLE_0x66 = 0x66,
  220. ENABLE_LED_FLASH_0x68 = 0x68,
  221. XTAL_ENABLE_0x6D = 0x6D,
  222. STARTUP_MESG_0x6F = 0x6F,
  223. AUTO_FREQ_CONFIG_0x70 = 0x70,
  224. PROX_SEARCH_CONFIG_0x71 = 0x71,
  225. ADV_BURST_DATA_0x72 = 0x72,
  226. EVENT_BUFFER_CONFIG_0x74 = 0x74,
  227. HIGH_DUTY_SEARCH_CONFIG_0x77 = 0x77,
  228. ADV_BURST_CONFIG_0x78 = 0x78,
  229. EVENT_FILTER_CONFIG_0x79 = 0x79,
  230. FIT1_SET_AGC_0x8F = 0x8F,
  231. /// <summary>
  232. /// *** CONFLICT: w/ Sensrcore, Fit1 will never have sensrcore enabled
  233. /// </summary>
  234. FIT1_SET_EQUIP_STATE_0x91 = 0x91,
  235. // SensRcore Messages
  236. SET_CHANNEL_INPUT_MASK_0x90 = 0x90,
  237. SET_CHANNEL_DATA_TYPE_0x91 = 0x91,
  238. READ_PINS_FOR_SECT_0x92 = 0x92,
  239. TIMER_SELECT_0x93 = 0x93,
  240. ATOD_SETTINGS_0x94 = 0x94,
  241. SET_SHARED_ADDRESS_0x95 = 0x95,
  242. RSSI_POWER_0xC0 = 0xC0,
  243. RSSI_BROADCAST_DATA_0xC1 = 0xC1,
  244. RSSI_ACKNOWLEDGED_DATA_0xC2 = 0xC2,
  245. RSSI_BURST_DATA_0xC3 = 0xC3,
  246. RSSI_SEARCH_THRESHOLD_0xC4 = 0xC4,
  247. SLEEP_0xC5 = 0xC5,
  248. SET_USB_INFO_0xC7 = 0xC7,
  249. };
  250. /// <summary>
  251. /// EventIDs for reference
  252. /// </summary>
  253. public enum ANTEventID : byte
  254. {
  255. RESPONSE_NO_ERROR_0x00 = 0x00,
  256. NO_EVENT_0x00 = 0x00,
  257. EVENT_RX_SEARCH_TIMEOUT_0x01 = 0x01,
  258. EVENT_RX_FAIL_0x02 = 0x02,
  259. EVENT_TX_0x03 = 0x03,
  260. EVENT_TRANSFER_RX_FAILED_0x04 = 0x04,
  261. EVENT_TRANSFER_TX_COMPLETED_0x05 = 0x05,
  262. EVENT_TRANSFER_TX_FAILED_0x06 = 0x06,
  263. EVENT_CHANNEL_CLOSED_0x07 = 0x07,
  264. EVENT_RX_FAIL_GO_TO_SEARCH_0x08 = 0x08,
  265. EVENT_CHANNEL_COLLISION_0x09 = 0x09,
  266. /// <summary>
  267. /// a pending transmit transfer has begun
  268. /// </summary>
  269. EVENT_TRANSFER_TX_START_0x0A = 0x0A,
  270. EVENT_CHANNEL_ACTIVE_0x0F = 0x0F,
  271. EVENT_TRANSFER_TX_COMPLETED_RSSI_0x10 = 0x10,
  272. /// <summary>
  273. /// returned on attempt to perform an action from the wrong channel state
  274. /// </summary>
  275. CHANNEL_IN_WRONG_STATE_0x15 = 0x15,
  276. /// <summary>
  277. /// returned on attempt to communicate on a channel that is not open
  278. /// </summary>
  279. CHANNEL_NOT_OPENED_0x16 = 0x16,
  280. /// <summary>
  281. /// returned on attempt to open a channel without setting the channel ID
  282. /// </summary>
  283. CHANNEL_ID_NOT_SET_0x18 = 0x18,
  284. /// <summary>
  285. /// returned when attempting to start scanning mode
  286. /// </summary>
  287. CLOSE_ALL_CHANNELS_0x19 = 0x19,
  288. /// <summary>
  289. /// returned on attempt to communicate on a channel with a TX transfer in progress
  290. /// </summary>
  291. TRANSFER_IN_PROGRESS_0x1F = 0x1F,
  292. /// <summary>
  293. /// returned when sequence number is out of order on a Burst transfer
  294. /// </summary>
  295. TRANSFER_SEQUENCE_NUMBER_ERROR_0x20 = 0x20,
  296. TRANSFER_IN_ERROR_0x21 = 0x21,
  297. TRANSFER_BUSY_0x22 = 0x22,
  298. /// <summary>
  299. /// returned if a data message is provided that is too large
  300. /// </summary>
  301. MESSAGE_SIZE_EXCEEDS_LIMIT_0x27 = 0x27,
  302. /// <summary>
  303. /// returned when the message has an invalid parameter
  304. /// </summary>
  305. INVALID_MESSAGE_0x28 = 0x28,
  306. /// <summary>
  307. /// returned when an invalid network number is provided
  308. /// </summary>
  309. INVALID_NETWORK_NUMBER_0x29 = 0x29,
  310. /// <summary>
  311. /// returned when the provided list ID or size exceeds the limit
  312. /// </summary>
  313. INVALID_LIST_ID_0x30 = 0x30,
  314. /// <summary>
  315. /// returned when attempting to transmit on channel 0 when in scan mode
  316. /// </summary>
  317. INVALID_SCAN_TX_CHANNEL_0x31 = 0x31,
  318. /// <summary>
  319. /// returned when an invalid parameter is specified in a configuration message
  320. /// </summary>
  321. INVALID_PARAMETER_PROVIDED_0x33 = 0x33,
  322. /// <summary>
  323. /// ANT event que has overflowed and lost 1 or more events
  324. /// </summary>
  325. EVENT_QUE_OVERFLOW_0x35 = 0x35,
  326. /// <summary>
  327. /// error writing to script
  328. /// </summary>
  329. SCRIPT_FULL_ERROR_0x40 = 0x40,
  330. /// <summary>
  331. /// error writing to script
  332. /// </summary>
  333. SCRIPT_WRITE_ERROR_0x41 = 0x41,
  334. /// <summary>
  335. /// error accessing script page
  336. /// </summary>
  337. SCRIPT_INVALID_PAGE_ERROR_0x42 = 0x42,
  338. /// <summary>
  339. /// the scripts are locked and can't be dumped
  340. /// </summary>
  341. SCRIPT_LOCKED_ERROR_0x43 = 0x43,
  342. /// <summary>
  343. /// Fit1 only event added for timeout of the pairing state after the Fit module becomes active
  344. /// </summary>
  345. FIT_ACTIVE_SEARCH_TIMEOUT_0x60 = 0x60,
  346. /// <summary>
  347. /// Fit1 only
  348. /// </summary>
  349. FIT_WATCH_PAIR_0x61 = 0x61,
  350. /// <summary>
  351. /// Fit1 only
  352. /// </summary>
  353. FIT_WATCH_UNPAIR_0x62 = 0x62,
  354. };
  355. /// <summary>
  356. /// PIDs for reference
  357. /// </summary>
  358. public enum USB_PID : ushort
  359. {
  360. ANT_INTERFACE_BOARD = 0x4102,
  361. ANT_ARCT = 0x4103
  362. };
  363. public const byte MAX_MESG_SIZE = 41; // Must match MARSHALL_MESG_MAX_SIZE_VALUE in unmanagedWrapper dll_exports.cpp
  364. #pragma warning restore 1591
  365. }
  366. }