ANTFS_ClientParameters.cs 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Runtime.InteropServices;
  13. namespace ANT_Managed_Library.ANTFS
  14. {
  15. /// <summary>
  16. /// ANT-FS Client Parameters.
  17. /// The application should initialize ALL fields of the configuration struct,
  18. /// otherwise, they will all be zero
  19. /// </summary>
  20. [StructLayout(LayoutKind.Sequential)]
  21. public struct ANTFS_ClientParameters
  22. {
  23. /// <summary>
  24. /// Device serial number. Set to 0 to use the serial number of the USB device
  25. /// </summary>
  26. public uint SerialNumber;
  27. /// <summary>
  28. /// Client device type (transmitted in beacon)
  29. /// </summary>
  30. public ushort BeaconDeviceType;
  31. /// <summary>
  32. /// Client manufacturing ID (transmitted in beacon)
  33. /// </summary>
  34. public ushort BeaconManufacturerID;
  35. /// <summary>
  36. /// Radio frequency to use while in Link state.
  37. /// </summary>
  38. public byte BeaconRadioFrequency;
  39. /// <summary>
  40. /// Beacon Period, as described in the ANT-FS Technology specification
  41. /// </summary>
  42. [MarshalAs(UnmanagedType.U1)]
  43. public BeaconPeriod LinkPeriod;
  44. /// <summary>
  45. /// Indicates whether pairing authentication is enabled
  46. /// </summary>
  47. [MarshalAs(UnmanagedType.Bool)]
  48. public bool IsPairingEnabled;
  49. /// <summary>
  50. /// Indicates whether upload functionality is supported
  51. /// </summary>
  52. [MarshalAs(UnmanagedType.Bool)]
  53. public bool IsUploadEnabled;
  54. /// <summary>
  55. /// Indicates whether there is data available for download
  56. /// </summary>
  57. [MarshalAs(UnmanagedType.Bool)]
  58. public bool IsDataAvailable;
  59. /// <summary>
  60. /// Authentication type to include in beacon, as described in the ANT-FS Technology specification
  61. /// </summary>
  62. [MarshalAs(UnmanagedType.U1)]
  63. public AuthenticationType AuthenticationType;
  64. /// <summary>
  65. /// Time, in seconds, that the client will wait without receiving any commands from the host before dropping to Link state.
  66. /// Set to 255 to disable. Zero is NOT a valid value.
  67. /// </summary>
  68. public byte BeaconTimeout;
  69. /// <summary>
  70. /// Time, in seconds, that the client library will wait for a response from the application to a pairing request.
  71. /// </summary>
  72. public byte PairingTimeout;
  73. /// <summary>
  74. /// ANTFS_ClientParameters, with the default beacon parameters
  75. /// </summary>
  76. /// <param name="deviceType">Client device type</param>
  77. /// <param name="manufacturerID">Client manufacturing ID</param>
  78. public ANTFS_ClientParameters(ushort deviceType, ushort manufacturerID)
  79. {
  80. // Default beacon configuration: Match unmanaged ANTFSClient::SetDefaultBeacon
  81. BeaconDeviceType = deviceType;
  82. BeaconManufacturerID = manufacturerID;
  83. SerialNumber = 0; // Use the USB device serial number by default
  84. BeaconRadioFrequency = 50; // ANT-FS RF Frequency
  85. LinkPeriod = BeaconPeriod.EightHz;
  86. IsPairingEnabled = true;
  87. IsUploadEnabled = false;
  88. IsDataAvailable = false;
  89. AuthenticationType = AuthenticationType.Pairing;
  90. BeaconTimeout = 60; // In seconds
  91. PairingTimeout = 5; // In seconds
  92. }
  93. }
  94. }