1
0

sdm.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. 2012
  6. All rights reserved.
  7. */
  8. #ifndef SDM_H
  9. #define SDM_H
  10. #define SDM_REV 1.3 // Device Profile Rev.
  11. #define SDM_DEVICE_TYPE ((UCHAR) 124)
  12. #define SDM_TX_TYPE ((UCHAR) 5)
  13. #define SDM_MSG_PERIOD ((USHORT) 8134) // ~4.03Hz
  14. #define SDM_HALF_PERIOD ((USHORT) 16268) // ~2.01Hz
  15. #define SDM_RESERVED ((UCHAR) 0xFF)
  16. #define SDM_UNUSED ((UCHAR) 0x00)
  17. #define SDM_PAGE1 ((UCHAR) 1)
  18. #define SDM_PAGE2 ((UCHAR) 2)
  19. #define SDM_PAGE3 ((UCHAR) 3)
  20. #define SDM_PAGE4 ((UCHAR) 4)
  21. #define SDM_PAGE5 ((UCHAR) 5)
  22. #define SDM_PAGE6 ((UCHAR) 6)
  23. #define SDM_PAGE7 ((UCHAR) 7)
  24. #define SDM_PAGE8 ((UCHAR) 8)
  25. #define SDM_PAGE9 ((UCHAR) 9)
  26. #define SDM_PAGE10 ((UCHAR) 10)
  27. #define SDM_PAGE11 ((UCHAR) 11)
  28. #define SDM_PAGE12 ((UCHAR) 12)
  29. #define SDM_PAGE13 ((UCHAR) 13)
  30. #define SDM_PAGE14 ((UCHAR) 14)
  31. #define SDM_PAGE15 ((UCHAR) 15)
  32. #define SDM_PAGE16 ((UCHAR) 0x10)
  33. #define SDM_PAGE22 ((UCHAR) 0x16)
  34. #define SDM_PAGE70 ((UCHAR) 70)
  35. #define SDM_DATA_REQUEST ((UCHAR) 0x01)
  36. #define SDM_MAX_SPEED256 ((USHORT) 0x0FFF)
  37. //#define SDM_MAX_CADENCE16 ((USHORT) 0x0FFF) // 4095 = 0xFFF = 255.9375 spm != 15 m/s (this was the original value that caused a bug in the code)
  38. #define SDM_MAX_CADENCE16 ((USHORT) 0x4FFB) // 20475 = 0x4FFB = 1279.6875 spm = 15 m/s
  39. //Status definitions
  40. #define SDM_STATE_SHIFT 0
  41. #define SDM_STATE_MASK ((UCHAR) (0x03 << SDM_STATE_SHIFT))
  42. #define SDM_STATE_INACTIVE ((UCHAR) 0x00)
  43. #define SDM_STATE_ACTIVE ((UCHAR) 0x01)
  44. #define SDM_HEALTH_SHIFT 2
  45. #define SDM_HEALTH_MASK ((UCHAR) (0x03 << SDM_HEALTH_SHIFT))
  46. #define SDM_HEALTH_OK ((UCHAR) 0x00)
  47. #define SDM_HEALTH_ERROR ((UCHAR) 0x01)
  48. #define SDM_HEALTH_WARNING ((UCHAR) 0x02)
  49. #define SDM_BAT_SHIFT 4
  50. #define SDM_BAT_MASK ((UCHAR) (0x03 << SDM_BAT_SHIFT))
  51. #define SDM_BAT_NEW ((UCHAR) 0x00)
  52. #define SDM_BAT_GOOD ((UCHAR) 0x01)
  53. #define SDM_BAT_OK ((UCHAR) 0x02)
  54. #define SDM_BAT_LOW ((UCHAR) 0x03)
  55. #define SDM_LOCATION_SHIFT 6
  56. #define SDM_LOCATION_MASK ((UCHAR) (0x03 << SDM_LOCATION_SHIFT))
  57. #define SDM_LOCATION_LACES ((UCHAR) 0x00)
  58. #define SDM_LOCATION_MIDSOLE ((UCHAR) 0x01)
  59. #define SDM_LOCATION_CHEST ((UCHAR) 0x02)
  60. #define SDM_LOCATION_OTHER ((UCHAR) 0x03)
  61. #define SDM_COMMON_INTERVAL 65
  62. #define SDM_TIME_MASK ((UCHAR) 0x01) // Bit masks for the capabilities byte
  63. #define SDM_DISTANCE_MASK ((UCHAR) 0x02)
  64. #define SDM_SPEED_MASK ((UCHAR) 0x04)
  65. #define SDM_LATENCY_MASK ((UCHAR) 0x08)
  66. #define SDM_CADENCE_MASK ((UCHAR) 0x10)
  67. #define SDM_CALORIES_MASK ((UCHAR) 0x20)
  68. #define SDM_CAPAB_ALL ((UCHAR) 0x3F) // value for having all capabilities on - CHANGE if you add new capabilities
  69. #define SDM_CAPAB_INITIAL ((UCHAR) 0x1F) // value to initialized the capabilities flag to - this is calories off
  70. public ref struct SDMStatus{
  71. UCHAR ucLocation;
  72. UCHAR ucBatteryStatus;
  73. UCHAR ucHealth;
  74. UCHAR ucUseState;
  75. };
  76. public ref struct SDMCapab{ // For tracking the capabilities (Request Page 22) bit fields
  77. UCHAR ucTime;
  78. UCHAR ucDistance;
  79. UCHAR ucSpeed;
  80. UCHAR ucLatency;
  81. UCHAR ucCadence;
  82. UCHAR ucCalories;
  83. };
  84. typedef enum{ // Units available for representing simulator data
  85. SDM_MS, // m/s (speed)
  86. SDM_KPH, // km/h (speed)
  87. SDM_MPH, // miles/h (speed)
  88. SDM_SPM, // strides/minute (cadence)
  89. } SDMUnit;
  90. #endif