configuration.h
Go to the documentation of this file.
1 /**************************************************************************/ /**
2  * @brief Device configuration settings control messages.
3  * @file
4  ******************************************************************************/
5 
6 #pragma once
7 
11 
12 namespace point_one {
13 namespace fusion_engine {
14 namespace messages {
15 
16 // Enforce 4-byte alignment and packing of all data structures and values.
17 // Floating point values are aligned on platforms that require it. This is done
18 // with a combination of setting struct attributes, and manual alignment
19 // within the definitions. See the "Message Packing" section of the README.
20 #pragma pack(push, 1)
21 
22 /**
23  * @brief An identifier for the contents of a parameter configuration message.
24  * @ingroup config_and_ctrl_messages
25  *
26  * See also @ref SetConfigMessage.
27  */
28 enum class ConfigType : uint16_t {
29  INVALID = 0,
30 
31  /**
32  * The location of the device IMU with respect to the vehicle body frame (in
33  * meters).
34  *
35  * Payload format: @ref Point3f
36  */
37  DEVICE_LEVER_ARM = 16,
38 
39  /**
40  * The orientation of the device IMU with respect to the vehicle body axes.
41  *
42  * Payload format: @ref CoarseOrientation
43  */
45 
46  /**
47  * The location of the GNSS antenna with respect to the vehicle body frame (in
48  * meters).
49  *
50  * Payload format: @ref Point3f
51  */
52  GNSS_LEVER_ARM = 18,
53 
54  /**
55  * The offset of the desired output location with respect to the vehicle
56  * body frame (in meters).
57  *
58  * Payload format: @ref Point3f
59  */
60  OUTPUT_LEVER_ARM = 19,
61 
62  /**
63  * Information about the vehicle including model and dimensions.
64  *
65  * Payload format: @ref VehicleDetails
66  */
67  VEHICLE_DETAILS = 20,
68 
69  /**
70  * Information pertaining to wheel speed/rotation measurements when wheel data
71  * is transmitted via software.
72  *
73  * @note
74  * For hardware wheel tick voltage capture, use @ref
75  * ConfigType::HARDWARE_TICK_CONFIG instead.
76  *
77  * Payload format: @ref WheelConfig
78  */
79  WHEEL_CONFIG = 21,
80 
81  /**
82  * Indicates the mode and direction used when capturing vehicle wheel tick
83  * data from a voltage pulse on an I/O pin.
84  *
85  * @note
86  * For software wheel tick capture (wheel ticks sent as FusionEngine messages
87  * or on a CAN bus), use @ref ConfigType::WHEEL_CONFIG instead.
88  *
89  * Payload format: @ref HardwareTickConfig
90  */
92 
93  /**
94  * Used to set horizontal (yaw) & vertical (pitch) biases (in degrees) on
95  * a dual-antenna heading platform configuration.
96  *
97  * Payload format: @ref HeadingBias
98  */
99  HEADING_BIAS = 23,
100 
101  /**
102  * A bitmask indicating which GNSS constellations are enabled.
103  *
104  * Payload format: `uint32_t` (see @ref sat_type_masks)
105  */
107 
108  /**
109  * A bitmask indicating which GNSS frequency bands are enabled.
110  *
111  * Payload format: `uint32_t` (see @ref freq_band_masks)
112  */
114 
115  /**
116  * Specify a UTC leap second count override value to use for all UTC time
117  * conversions. Setting this value will disable all internal leap second
118  * sources, including data received from the GNSS almanac decoded from
119  * available signals.
120  *
121  * Set to -1 to disable leap second override and re-enable internal leap
122  * second handling.
123  *
124  * Payload format: `int32_t`
125  */
126  LEAP_SECOND = 52,
127 
128  /**
129  * Specify a GPS legacy week rollover count override to use when converting
130  * all legacy 10-bit GPS week numbers. Setting this value will disable all
131  * internal week rollover sources, including data received from modern GPS
132  * navigation messages (CNAV, CNAV2) or non-GPS constellations.
133  *
134  * Set to -1 to disable week rollover override and re-enable internal
135  * handling.
136  *
137  * Payload format: `int32_t`
138  */
139  GPS_WEEK_ROLLOVER = 53,
140 
141  /**
142  * Ionospheric delay model configuration.
143  *
144  * Payload format: @ref IonosphereConfig
145  */
146  IONOSPHERE_CONFIG = 54,
147 
148  /**
149  * Tropospheric delay model configuration.
150  *
151  * Payload format: @ref TroposphereConfig
152  */
153  TROPOSPHERE_CONFIG = 55,
154 
155  /**
156  * Change a configuration setting for a specified output interface.
157  *
158  * Payload format: `InterfaceConfigSubmessage`
159  */
160  INTERFACE_CONFIG = 200,
161 
162  /**
163  * Configure the UART1 serial baud rate (in bits/second).
164  *
165  * @deprecated
166  * The @ref ConfigType::INTERFACE_CONFIG type combined with @ref
167  * InterfaceConfigType::BAUD_RATE in the @ref InterfaceConfigSubmessage should
168  * be used to configure this value going forward.
169  *
170  * Payload format: `uint32_t`
171  */
172  UART1_BAUD = 256,
173 
174  /**
175  * Configure the UART2 serial baud rate (in bits/second).
176  *
177  * @deprecated
178  * The @ref ConfigType::INTERFACE_CONFIG type combined with @ref
179  * InterfaceConfigType::BAUD_RATE in the @ref InterfaceConfigSubmessage should
180  * be used to configure this value going forward.
181  *
182  * Payload format: `uint32_t`
183  */
184  UART2_BAUD = 257,
185 
186  /**
187  * Enable/disable output of diagnostic data on UART1.
188  *
189  * @deprecated
190  * The @ref ConfigType::INTERFACE_CONFIG type combined with @ref
191  * InterfaceConfigType::OUTPUT_DIAGNOSTICS_MESSAGES in the @ref
192  * InterfaceConfigSubmessage should be used to configure this value going
193  * forward.
194  *
195  * @note
196  * Enabling this setting will override the message rate/off settings for some
197  * FusionEngine messages.
198  *
199  * Payload format: `bool`
200  */
202 
203  /**
204  * Enable/disable output of diagnostic data on UART2.
205  *
206  * @deprecated
207  * The @ref ConfigType::INTERFACE_CONFIG type combined with @ref
208  * InterfaceConfigType::OUTPUT_DIAGNOSTICS_MESSAGES in the @ref
209  * InterfaceConfigSubmessage should be used to configure this value going
210  * forward.
211  *
212  * @note
213  * Enabling this setting will override the message rate/off settings for some
214  * FusionEngine messages.
215  *
216  * Payload format: `bool`
217  */
219 
220  /**
221  * Enable watchdog timer to restart device after fatal errors.
222  *
223  * Payload format: `bool`
224  */
225  ENABLE_WATCHDOG_TIMER = 300,
226 
227  /**
228  * A string for identifying a device.
229  *
230  * This is a string of ASCII characters padded to 32 bytes with `NULL`.
231  *
232  * Payload format: `char[32]`
233  */
234  USER_DEVICE_ID = 301,
235 
236  /**
237  * Configuration of L-band Demodulator Parameters.
238  *
239  * @note
240  * This setting is only available on devices with an L-band receiver.
241  *
242  * Payload format: @ref LBandConfig
243  */
244  LBAND_PARAMETERS = 1024,
245 };
246 
247 /**
248  * @brief Get a human-friendly string name for the specified @ref ConfigType.
249  * @ingroup config_and_ctrl_messages
250  *
251  * @param type The desired configuration parameter type.
252  *
253  * @return The corresponding string name.
254  */
256  switch (type) {
257  case ConfigType::INVALID:
258  return "Invalid";
259 
261  return "Device Lever Arm";
262 
264  return "Device Coarse Orientation";
265 
267  return "GNSS Lever Arm";
268 
270  return "Output Lever Arm";
271 
273  return "Vehicle Details";
274 
276  return "Wheel Config";
277 
279  return "Hardware Tick Config";
280 
282  return "Heading Bias";
283 
285  return "Enabled GNSS Systems";
286 
288  return "Enabled GNSS Frequency Bands";
289 
291  return "Leap Second";
292 
294  return "GPS Week Rollover";
295 
297  return "Ionosphere Config";
298 
300  return "Troposphere Config";
301 
303  return "UART1 Baud Rate";
304 
306  return "UART2 Baud Rate";
307 
309  return "UART1 Diagnostic Messages Enabled";
310 
312  return "UART2 Diagnostic Messages Enabled";
313 
315  return "Watchdog Timer Enabled";
316 
318  return "User Device ID";
319 
321  return "Interface Submessage";
322 
324  return "LBand Parameters";
325  }
326 
327  return "Unrecognized Configuration";
328 }
329 
330 /**
331  * @brief @ref ConfigType stream operator.
332  * @ingroup config_and_ctrl_messages
333  */
334 inline p1_ostream& operator<<(p1_ostream& stream, ConfigType type) {
335  stream << to_string(type) << " (" << (int)type << ")";
336  return stream;
337 }
338 
339 /**
340  * @brief An identifier for the contents of a output interface configuration
341  * submessage.
342  * @ingroup config_and_ctrl_messages
343  *
344  * See also @ref InterfaceConfigSubmessage.
345  */
346 enum class InterfaceConfigType : uint8_t {
347  INVALID = 0,
348 
349  /**
350  * Enable/disable output of diagnostic data on this interface.
351  *
352  * Valid for:
353  * - All @ref TransportType
354  *
355  * @note
356  * Enabling this setting will override the message rate/off settings for some
357  * FusionEngine messages.
358  *
359  * Payload format: `bool`
360  */
362 
363  /**
364  * Configure the serial baud rate (in bits/second).
365  *
366  * Valid for:
367  * - @ref TransportType::SERIAL
368  *
369  * Payload format: `uint32_t`
370  */
371  BAUD_RATE = 2,
372 
373  /**
374  * Configure the network address for a client to connect to.
375  *
376  * For UNIX domain sockets, this string represents the path to the local
377  * socket file.
378  *
379  * Valid for:
380  * - @ref TransportType::TCP
381  * - @ref TransportType::UDP
382  * - @ref TransportType::UNIX
383  *
384  * Payload format: `char[64]` containing a NULL terminated string.
385  */
386  REMOTE_ADDRESS = 3,
387 
388  /**
389  * Configure the network port.
390  *
391  * Valid for:
392  * - @ref TransportType::TCP
393  * - @ref TransportType::UDP
394  * - @ref TransportType::WEBSOCKET
395  *
396  * Payload format: `uint16_t`
397  */
398  PORT = 4,
399 
400  /**
401  * Enable/disable the interface.
402  *
403  * Valid for all @ref TransportType values.
404  *
405  * Payload format: `bool`
406  */
407  ENABLED = 5,
408 
409  /**
410  * Set the interface direction (client/server).
411  *
412  * Valid for:
413  * - @ref TransportType::TCP
414  * - @ref TransportType::WEBSOCKET
415  * - @ref TransportType::UNIX
416  *
417  * Payload format: @ref TransportDirection
418  */
419  DIRECTION = 6,
420 
421  /**
422  * Set the UNIX domain socket type (streaming/datagram/sequenced).
423  *
424  * Valid for:
425  * - @ref TransportType::UNIX
426  *
427  * Payload format: @ref SocketType
428  */
429  SOCKET_TYPE = 7,
430 };
431 
432 /**
433  * @brief Get a human-friendly string name for the specified @ref ConfigType.
434  * @ingroup config_and_ctrl_messages
435  *
436  * @param type The desired configuration parameter type.
437  *
438  * @return The corresponding string name.
439  */
441  switch (type) {
443  return "Invalid";
444 
446  return "Diagnostic Messages Enabled";
447 
449  return "Serial Baud Rate";
450 
452  return "Remote Network Address";
453 
455  return "Network Port";
456 
458  return "Interface Enabled";
459 
461  return "Transport Direction";
462 
464  return "Socket Type";
465 
466  default:
467  return "Unrecognized Configuration";
468  }
469 }
470 
471 /**
472  * @brief @ref InterfaceConfigType stream operator.
473  * @ingroup config_and_ctrl_messages
474  */
476  stream << to_string(type) << " (" << (int)type << ")";
477  return stream;
478 }
479 
480 /**
481  * @brief The type of a device's configuration settings.
482  * @ingroup config_and_ctrl_messages
483  */
484 enum class ConfigurationSource : uint8_t {
485  ACTIVE = 0, ///< Active configuration currently in use by the device.
486  SAVED = 1, ///< Settings currently saved to persistent storage.
487  /**
488  * Read only device defaults. Attempting to write to this source will fail
489  * with a @ref Response::VALUE_ERROR.
490  */
491  DEFAULT = 2,
492 };
493 
494 /**
495  * @brief Get a human-friendly string name for the specified @ref
496  * ConfigurationSource.
497  * @ingroup config_and_ctrl_messages
498  *
499  * @param source The desired configuration source.
500  *
501  * @return The corresponding string name.
502  */
504  switch (source) {
506  return "Active";
507 
509  return "Saved";
510 
512  return "Default";
513 
514  default:
515  return "Unrecognized Source";
516  }
517 }
518 
519 /**
520  * @brief @ref ConfigurationSource stream operator.
521  * @ingroup config_and_ctrl_messages
522  */
524  stream << to_string(source) << " (" << (int)source << ")";
525  return stream;
526 }
527 
528 /**
529  * @brief The type configuration save operation to be performed.
530  * @ingroup config_and_ctrl_messages
531  */
532 enum class SaveAction : uint8_t {
533  /** Save all active parameters to persistent storage. */
534  SAVE = 0,
535  /** Revert the active configuration to previously saved values. */
536  REVERT_TO_SAVED = 1,
537  /** Reset the active _and_ saved configuration to default values. */
538  REVERT_TO_DEFAULT = 2,
539 };
540 
541 /**
542  * @brief Get a human-friendly string name for the specified @ref SaveAction.
543  * @ingroup config_and_ctrl_messages
544  *
545  * @param action The desired save operation.
546  *
547  * @return The corresponding string name.
548  */
550  switch (action) {
551  case SaveAction::SAVE:
552  return "Save";
553 
555  return "Revert To Saved";
556 
558  return "Revert To Default";
559 
560  default:
561  return "Unknown";
562  }
563 }
564 
565 /**
566  * @brief @ref SaveAction stream operator.
567  * @ingroup config_and_ctrl_messages
568  */
569 inline p1_ostream& operator<<(p1_ostream& stream, SaveAction action) {
570  stream << to_string(action) << " (" << (int)action << ")";
571  return stream;
572 }
573 
574 /**
575  * @brief Set a user configuration parameter (@ref MessageType::SET_CONFIG,
576  * version 1.0).
577  * @ingroup config_and_ctrl_messages
578  *
579  * The format of the parameter value is defined by the the specified @ref
580  * config_type (@ref ConfigType). For example, an antenna lever arm definition
581  * may require three 32-bit `float` values, one for each axis, while a serial
582  * port baud rate may be specified as single 32-bit unsigned integer
583  * (`uint32_t`).
584  *
585  * Not all parameters defined in @ref ConfigType are supported on all devices.
586  *
587  * Parameter changes are applied to the device's active configuration
588  * immediately, but are not saved to persistent storage and will be restored to
589  * their previous values on reset. To save configuration settings to persistent
590  * storage, see @ref SaveConfigMessage.
591  *
592  * # Expected Response
593  * The device will respond with a @ref CommandResponseMessage indicating whether
594  * or not the request succeeded.
595  */
597  static constexpr MessageType MESSAGE_TYPE = MessageType::SET_CONFIG;
598  static constexpr uint8_t MESSAGE_VERSION = 0;
599 
600  /** Flag to immediately save the config after applying this setting. */
601  static constexpr uint8_t FLAG_APPLY_AND_SAVE = 0x01;
602  /**
603  * Flag to restore the config_type back to its default value.
604  *
605  * When set, the @ref config_length_bytes should be 0 and no data should be
606  * included unless the config_type is @ref ConfigType::INTERFACE_CONFIG. In
607  * that case the @ref config_length_bytes should be
608  * `sizeof(InterfaceConfigSubmessage)` with a an @ref
609  * InterfaceConfigSubmessage as the parameter value without any further
610  * payload.
611  */
612  static constexpr uint8_t FLAG_REVERT_TO_DEFAULT = 0x02;
613 
614  /** The type of parameter to be configured. */
616 
617  /** Bitmask of additional flags to modify the command. */
618  uint8_t flags = 0;
619 
620  uint8_t reserved[1] = {0};
621 
622  /** The size of the parameter value (in bytes). */
623  uint32_t config_length_bytes = 0;
624 
625  /**
626  * A pointer to the beginning of the configuration parameter value.
627  *
628  * The size and format of the contents is specified by the @ref config_type.
629  * See @ref ConfigType.
630  */
631  // uint8_t config_change_data[0];
632 };
633 
634 /**
635  * @brief Query the value of a user configuration parameter (@ref
636  * MessageType::GET_CONFIG, version 1.1).
637  * @ingroup config_and_ctrl_messages
638  *
639  * # Expected Response
640  * The device will respond with a @ref ConfigResponseMessage containing the
641  * requested parameter value or an error @ref Response value if the request did
642  * not succeed.
643  */
645  static constexpr MessageType MESSAGE_TYPE = MessageType::GET_CONFIG;
646  static constexpr uint8_t MESSAGE_VERSION = 1;
647 
648  /** The desired parameter. */
650 
651  /** The config source to request data from (active, saved, etc.). */
653 
654  uint8_t reserved[1] = {0};
655 
656  /**
657  * When @ref config_type is @ref ConfigType::INTERFACE_CONFIG, a @ref
658  * InterfaceConfigSubmessage must be added to the end of this message with
659  * empty @ref InterfaceConfigSubmessage::config_data.
660  */
661  //uint8_t optional_submessage_header[0];
662 };
663 
664 /**
665  * @brief Save or reload configuration settings (@ref MessageType::SAVE_CONFIG,
666  * version 1.0).
667  * @ingroup config_and_ctrl_messages
668  *
669  * # Expected Response
670  * The device will respond with a @ref CommandResponseMessage indicating whether
671  * or not the request succeeded.
672  */
674  static constexpr MessageType MESSAGE_TYPE = MessageType::SAVE_CONFIG;
675  static constexpr uint8_t MESSAGE_VERSION = 0;
676 
677  /** The action to performed. */
679 
680  uint8_t reserved[3] = {0};
681 };
682 
683 /**
684  * @brief Response to a @ref GetConfigMessage request (@ref
685  * MessageType::CONFIG_RESPONSE, version 1.0).
686  * @ingroup config_and_ctrl_messages
687  *
688  * This message is followed by `N` bytes, where `N` is equal to @ref
689  * config_length_bytes that make up the data associated with @ref config_type.
690  * For example if the @ref config_type is @ref ConfigType::UART1_BAUD, the
691  * payload will include a single 32-bit unsigned integer:
692  *
693  * ```
694  * {MessageHeader, ConfigResponseMessage, uint32_t}
695  * ```
696  *
697  * In response to a @ref GetConfigMessage with an invalid or unsupported @ref
698  * ConfigType, @ref config_type in the resulting @ref ConfigResponseMessage will
699  * be set to @ref ConfigType::INVALID, and @ref response will indicate the
700  * reason. Note that all @ref GetConfigMessage requests, including invalid and
701  * rejected requests, will receive a @ref ConfigResponseMessage, not a
702  * @ref CommandResponseMessage.
703  */
705  static constexpr MessageType MESSAGE_TYPE = MessageType::CONFIG_RESPONSE;
706  static constexpr uint8_t MESSAGE_VERSION = 0;
707 
708  /**
709  * Flag to indicate the active value for this configuration differs from the
710  * value saved to persistent memory.
711  */
712  static constexpr uint8_t FLAG_ACTIVE_DIFFERS_FROM_SAVED = 0x1;
713 
714  /** The source of the parameter value (active, saved, etc.). */
716 
717  /** Flags that describe the configuration parameter. */
718  uint8_t flags = 0;
719 
720  /** The type of configuration parameter contained in this message. */
722 
723  /** The response status (success, error, etc.). */
724  Response response = Response::OK;
725 
726  uint8_t reserved[3] = {0};
727 
728  /** The size of the parameter value (in bytes). */
729  uint32_t config_length_bytes = 0;
730 
731  /**
732  * A pointer to the beginning of the configuration parameter value.
733  *
734  * The size and format of the contents is specified by the @ref config_type.
735  * See @ref ConfigType.
736  */
737  //uint8_t config_change_data[0];
738 };
739 
740 /**************************************************************************/ /**
741  * @defgroup config_types Configuration Settings Type Definitions
742  * @{
743  ******************************************************************************/
744 
745 /**
746  * @brief A 3-dimensional vector (used for lever arms, etc.).
747  */
748 struct P1_ALIGNAS(4) Point3f {
749  float x = NAN;
750  float y = NAN;
751  float z = NAN;
752 };
753 
754 /**
755  * @brief The orientation of a device with respect to the vehicle body axes.
756  *
757  * A device's orientation is defined by specifying how the +x and +z axes of its
758  * IMU are aligned with the vehicle body axes. For example, in a car:
759  * - `forward,up`: device +x = vehicle +x, device +z = vehicle +z (i.e.,
760  * IMU pointed towards the front of the vehicle).
761  * - `left,up`: device +x = vehicle +y, device +z = vehicle +z (i.e., IMU
762  * pointed towards the left side of the vehicle)
763  * - `up,backward`: device +x = vehicle +z, device +z = vehicle -x (i.e.,
764  * IMU pointed vertically upward, with the top of the IMU pointed towards the
765  * trunk)
766  */
768  enum class Direction : uint8_t {
769  FORWARD = 0, ///< Aligned with vehicle +x axis.
770  BACKWARD = 1, ///< Aligned with vehicle -x axis.
771  LEFT = 2, ///< Aligned with vehicle +y axis.
772  RIGHT = 3, ///< Aligned with vehicle -y axis.
773  UP = 4, ///< Aligned with vehicle +z axis.
774  DOWN = 5, ///< Aligned with vehicle -z axis.
775  INVALID = 255
776  };
777 
778  /** The direction of the device +x axis relative to the vehicle body axes. */
779  Direction x_direction = Direction::FORWARD;
780 
781  /** The direction of the device +z axis relative to the vehicle body axes. */
782  Direction z_direction = Direction::UP;
783 
784  uint8_t reserved[2] = {0};
785 };
786 
787 /**
788  * @brief The make and model of the vehicle.
789  * @ingroup config_and_ctrl_messages
790  */
791 enum class VehicleModel : uint16_t {
792  UNKNOWN_VEHICLE = 0,
793  DATASPEED_CD4 = 1,
794  // In general, all J1939 vehicles support a subset of the J1939 standard and
795  // may be set to vehicle model `J1939`. Their 29-bit CAN IDs may differ
796  // based on how the platform assigns message priorities and source
797  // addresses, but the underlying program group number (PGN) and message
798  // contents will be consistent.
799  //
800  // For most vehicles, it is not necessary to specify and particular make and
801  // model.
802  J1939 = 2,
803 
804  LEXUS_CT200H = 20,
805 
806  KIA_SORENTO = 40,
807  KIA_SPORTAGE = 41,
808 
809  AUDI_Q7 = 60,
810  AUDI_A8L = 61,
811 
812  TESLA_MODEL_X = 80,
813  TESLA_MODEL_3 = 81,
814 
815  HYUNDAI_ELANTRA = 100,
816 
817  PEUGEOT_206 = 120,
818 
819  MAN_TGX = 140,
820 
821  FACTION = 160,
822 
823  LINCOLN_MKZ = 180,
824 
825  BMW_7 = 200,
826  BMW_MOTORRAD = 201,
827 
828  VW_4 = 220,
829 
830  RIVIAN = 240,
831 };
832 
833 /**
834  * @brief Get a human-friendly string name for the specified @ref VehicleModel.
835  * @ingroup config_and_ctrl_messages
836  *
837  * @param vehicle_model The desired vehicle model.
838  *
839  * @return The corresponding string name.
840  */
841 P1_CONSTEXPR_FUNC const char* to_string(VehicleModel vehicle_model) {
842  switch (vehicle_model) {
844  return "UNKNOWN";
846  return "DATASPEED_CD4";
847  case VehicleModel::J1939:
848  return "J1939";
850  return "LEXUS_CT200H";
852  return "KIA_SORENTO";
854  return "KIA_SPORTAGE";
856  return "AUDI_Q7";
858  return "AUDI_A8L";
860  return "TESLA_MODEL_X";
862  return "TESLA_MODEL_3";
864  return "HYUNDAI_ELANTRA";
866  return "PEUGEOT_206";
868  return "MAN_TGX";
870  return "FACTION";
872  return "LINCOLN_MKZ";
873  case VehicleModel::BMW_7:
874  return "BMW_7";
876  return "BMW_MOTORRAD";
877  case VehicleModel::VW_4:
878  return "VW_4";
880  return "RIVIAN";
881  default:
882  return "UNRECOGNIZED";
883  }
884 }
885 
886 /**
887  * @brief @ref VehicleModel stream operator.
888  * @ingroup config_and_ctrl_messages
889  */
890 inline p1_ostream& operator<<(p1_ostream& stream, VehicleModel vehicle_model) {
891  stream << to_string(vehicle_model) << " (" << (int)vehicle_model << ")";
892  return stream;
893 }
894 
895 /**
896  * @brief Information about the vehicle including model and dimensions.
897  * @ingroup config_and_ctrl_messages
898  */
901  uint8_t reserved[10] = {0};
902 
903  /** The distance between the front axle and rear axle (in meters). */
904  float wheelbase_m = NAN;
905 
906  /** The distance between the two front wheels (in meters). */
907  float front_track_width_m = NAN;
908 
909  /** The distance between the two rear wheels (in meters). */
910  float rear_track_width_m = NAN;
911 };
912 
913 /**
914  * @brief The type of vehicle/wheel speed measurements produced by the vehicle.
915  * @ingroup config_and_ctrl_messages
916  */
917 enum class WheelSensorType : uint8_t {
918  /** Wheel/vehicle speed data not available. */
919  NONE = 0,
920  // RESERVED = 1,
921  /**
922  * Individual rotational angle measurements for multiple wheels, reported as
923  * accumulated encoder ticks. See @ref WheelTickInput.
924  * */
925  TICKS = 2,
926  /**
927  * Individual speed measurements for multiple wheels, reported in
928  * meters/second. See @ref WheelSpeedInput.
929  */
930  WHEEL_SPEED = 3,
931  /**
932  * A single value indicating the vehicle speed (in meters/second). See @ref
933  * VehicleSpeedInput.
934  */
935  VEHICLE_SPEED = 4,
936  /**
937  * A single wheel rotational angle, reported as accumulated encoder ticks. See
938  * @ref VehicleSpeedInput.
939  */
940  VEHICLE_TICKS = 5,
941 };
942 
943 /**
944  * @brief Get a human-friendly string name for the specified @ref
945  * WheelSensorType.
946  * @ingroup config_and_ctrl_messages
947  *
948  * @param wheel_sensor_type The desired wheel sensor type.
949  *
950  * @return The corresponding string name.
951  */
952 P1_CONSTEXPR_FUNC const char* to_string(WheelSensorType wheel_sensor_type) {
953  switch (wheel_sensor_type) {
954  case WheelSensorType::NONE: {
955  return "None";
956  }
957  case WheelSensorType::TICKS: {
958  return "Ticks";
959  }
961  return "Wheel Speed";
962  }
964  return "Vehicle Speed";
965  }
967  return "Vehicle Ticks";
968  }
969  default: {
970  return "None";
971  }
972  }
973 }
974 
975 /**
976  * @brief @ref WheelSensorType stream operator.
977  * @ingroup config_and_ctrl_messages
978  */
980  WheelSensorType wheel_sensor_type) {
981  stream << to_string(wheel_sensor_type) << " (" << (int)wheel_sensor_type
982  << ")";
983  return stream;
984 }
985 
986 /**
987  * @brief The type of vehicle/wheel speed measurements to be applied.
988  * @ingroup config_and_ctrl_messages
989  */
990 enum class AppliedSpeedType : uint8_t {
991  /** Speed data not applied to the system. */
992  NONE = 0,
993  /** Rear wheel speed data to be applied to the system (recommended). */
994  REAR_WHEELS = 1,
995  /** Front wheel speed data to be applied to the system. */
996  FRONT_WHEELS = 2,
997  /** Front and rear wheel speed data to be applied to the system. */
999  /** Individual vehicle speed to be applied to the system. */
1000  VEHICLE_BODY = 4,
1001 };
1002 
1003 /**
1004  * @brief Get a human-friendly string name for the specified @ref
1005  * AppliedSpeedType.
1006  * @ingroup config_and_ctrl_messages
1007  *
1008  * @param applied_speed_type The desired applied speed type.
1009  *
1010  * @return The corresponding string name.
1011  */
1012 P1_CONSTEXPR_FUNC const char* to_string(AppliedSpeedType applied_speed_type) {
1013  switch (applied_speed_type) {
1014  case AppliedSpeedType::NONE: {
1015  return "None";
1016  }
1018  return "Rear Wheels";
1019  }
1021  return "Front Wheels";
1022  }
1024  return "Front and Rear Wheels";
1025  }
1027  return "Vehicle Body";
1028  }
1029  default: {
1030  return "Unrecognized";
1031  }
1032  }
1033 }
1034 
1035 /**
1036  * @brief @ref AppliedSpeedType stream operator.
1037  * @ingroup config_and_ctrl_messages
1038  */
1040  AppliedSpeedType applied_speed_type) {
1041  stream << to_string(applied_speed_type) << " (" << (int)applied_speed_type
1042  << ")";
1043  return stream;
1044 }
1045 
1046 /**
1047  * @brief Indication of which of the vehicle's wheels are steered.
1048  * @ingroup config_and_ctrl_messages
1049  */
1050 enum class SteeringType : uint8_t {
1051  /** Steered wheels unknown. */
1052  UNKNOWN = 0,
1053  /** Front wheels are steered. */
1054  FRONT = 1,
1055  /** Front and rear wheels are steered. */
1056  FRONT_AND_REAR = 2,
1057 };
1058 
1059 /**
1060  * @brief Get a human-friendly string name for the specified @ref SteeringType.
1061  * @ingroup config_and_ctrl_messages
1062  *
1063  * @param steering_type The desired steering type.
1064  *
1065  * @return The corresponding string name.
1066  */
1067 P1_CONSTEXPR_FUNC const char* to_string(SteeringType steering_type) {
1068  switch (steering_type) {
1069  case SteeringType::UNKNOWN: {
1070  return "Unknown Steering";
1071  }
1072  case SteeringType::FRONT: {
1073  return "Front Steering";
1074  }
1076  return "Front and Rear Steering";
1077  }
1078  default: {
1079  return "Unrecognized";
1080  }
1081  }
1082 }
1083 
1084 /**
1085  * @brief @ref SteeringType stream operator.
1086  * @ingroup config_and_ctrl_messages
1087  */
1088 inline p1_ostream& operator<<(p1_ostream& stream, SteeringType steering_type) {
1089  stream << to_string(steering_type) << " (" << (int)steering_type << ")";
1090  return stream;
1091 }
1092 
1093 /**
1094  * @brief Software vehicle/wheel speed measurement configuration settings.
1095  * @ingroup config_and_ctrl_messages
1096  *
1097  * @warning
1098  * The @ref WheelConfig payload is intended for use on vehicles where wheel
1099  * speed or angle (tick) data is received via software, either using
1100  * FusionEngine measurement messages, or from another software data source such
1101  * as a vehicle CAN bus. For vehicles using a hardware wheel tick voltage
1102  * signal, use @ref HardwareTickConfig instead.
1103  *
1104  * Wheel data may be differential (measurements from each individual wheel), or
1105  * scalar (a single speed measurement for the vehicle body).
1106  *
1107  * When using software wheel data, you must also specify @ref VehicleDetails,
1108  * which is used to describe the vehicle dimensions and make/model.
1109  *
1110  * See also:
1111  * - @ref WheelSpeedInput
1112  * - @ref VehicleSpeedInput
1113  * - @ref WheelTickInput
1114  * - @ref VehicleTickInput
1115  */
1117  /**
1118  * The type of vehicle/wheel speed measurements produced by the vehicle.
1119  */
1121 
1122  /**
1123  * The type of vehicle/wheel speed measurements to be applied to the
1124  * navigation solution.
1125  */
1127 
1128  /** Indication of which of the vehicle's wheels are steered. */
1130 
1131  uint8_t reserved1[1] = {0};
1132 
1133  /**
1134  * The rate at which wheel speed/tick measurements will be sent to the device
1135  * (in seconds).
1136  *
1137  * @note
1138  * This parameter is required when using software wheel measurements. It
1139  * may not be `NAN` if wheel measurements are enabled, and cannot be
1140  * determined automatically by the device.
1141  */
1142  float wheel_update_interval_sec = NAN;
1143 
1144  /**
1145  * Override the rate at which wheel tick measurements will be used by the
1146  * navigation engine (in seconds).
1147  *
1148  * If this parameter is `NAN` (default), the best rate will be selected
1149  * automatically by the device based on the input rate (@ref
1150  * wheel_update_interval_sec) and the wheel tick quantization (@ref
1151  * wheel_ticks_to_m).
1152  *
1153  * @warning
1154  * For most system configurations, we recommend setting this value to `NAN` to
1155  * let the device choose the appropriate setting. Use this setting with
1156  * caution.
1157  */
1158  float wheel_tick_output_interval_sec = NAN;
1159 
1160  /**
1161  * Ratio between angle of the steering wheel and the angle of the wheels on
1162  * the ground.
1163  *
1164  * Used when applying measurements from steered wheels only, ignored
1165  * otherwise.
1166  */
1167  float steering_ratio = NAN;
1168 
1169  /**
1170  * The scale factor to convert from wheel encoder ticks to distance (in
1171  * meters/tick).
1172  *
1173  * Used for @ref WheelSensorType::TICKS and @ref
1174  * WheelSensorType::VEHICLE_TICKS, ignored for wheel speed input.
1175  */
1176  float wheel_ticks_to_m = NAN;
1177 
1178  /**
1179  * The maximum value (inclusive) before the wheel tick measurement will roll
1180  * over.
1181  *
1182  * The rollover behavior depends on the value of @ref wheel_ticks_signed. For
1183  * example, a maximum value of 10 will work as follows:
1184  * - `wheel_ticks_signed == true`: [-11, 10]
1185  * - `wheel_ticks_signed == false`: [0, 10]
1186  *
1187  * Signed values are assumed to be asymmetric, consistent with a typical 2's
1188  * complement rollover.
1189  *
1190  * Used for @ref WheelSensorType::TICKS and @ref
1191  * WheelSensorType::VEHICLE_TICKS, ignored for wheel speed input.
1192  */
1193  uint32_t wheel_tick_max_value = 0;
1194 
1195  /**
1196  * `true` if the reported wheel tick measurements should be interpreted as
1197  * signed integers, or `false` if they should be interpreted as unsigned
1198  * integers.
1199  *
1200  * Used for @ref WheelSensorType::TICKS and @ref
1201  * WheelSensorType::VEHICLE_TICKS, ignored for wheel speed input. See
1202  * @ref wheel_tick_max_value for details.
1203  */
1204  bool wheel_ticks_signed = false;
1205 
1206  /**
1207  * `true` if the wheel tick measurements increase by a positive amount when
1208  * driving forward or backward. `false` if wheel tick measurements decrease
1209  * when driving backward.
1210  *
1211  * Used for @ref WheelSensorType::TICKS and @ref
1212  * WheelSensorType::VEHICLE_TICKS, ignored for wheel speed input.
1213  */
1214  bool wheel_ticks_always_increase = true;
1215 
1216  uint8_t reserved2[2] = {0};
1217 };
1218 
1219 /**
1220  * @brief The signal edge to use when capturing a wheel tick voltage signal.
1221  * @ingroup config_and_ctrl_messages
1222  */
1223 enum class TickMode : uint8_t {
1224  /** Wheel tick capture disabled. */
1225  OFF = 0,
1226  /** Capture a wheel tick on the rising edge of the incoming pulse. */
1227  RISING_EDGE = 1,
1228  /** Capture a wheel tick on the falling edge of the incoming pulse. */
1229  FALLING_EDGE = 2,
1230 };
1231 
1232 P1_CONSTEXPR_FUNC const char* to_string(TickMode tick_mode) {
1233  switch (tick_mode) {
1234  case TickMode::OFF:
1235  return "OFF";
1236  case TickMode::RISING_EDGE:
1237  return "RISING_EDGE";
1239  return "FALLING_EDGE";
1240  default:
1241  return "UNRECOGNIZED";
1242  }
1243 }
1244 
1245 /**
1246  * @brief @ref TickMode stream operator.
1247  * @ingroup config_and_ctrl_messages
1248  */
1249 inline p1_ostream& operator<<(p1_ostream& stream, TickMode tick_mode) {
1250  stream << to_string(tick_mode) << " (" << (int)tick_mode << ")";
1251  return stream;
1252 }
1253 
1254 /**
1255  * @brief The way to interpret an incoming voltage signal, used to indicate
1256  * direction of a hardware wheel tick pulse, if available.
1257  * @ingroup config_and_ctrl_messages
1258  */
1259 enum class TickDirection : uint8_t {
1260  /** Wheel tick direction not provided. */
1261  OFF = 0,
1262  /**
1263  * Assume vehicle is moving forward when direction signal voltage is high, and
1264  * backward when direction signal is low.
1265  */
1266  FORWARD_ACTIVE_HIGH = 1,
1267  /**
1268  * Assume vehicle is moving forward when direction signal voltage is low, and
1269  * backward when direction signal is high.
1270  */
1271  FORWARD_ACTIVE_LOW = 2,
1272 };
1273 
1274 P1_CONSTEXPR_FUNC const char* to_string(TickDirection tick_direction) {
1275  switch (tick_direction) {
1276  case TickDirection::OFF:
1277  return "OFF";
1279  return "FORWARD_ACTIVE_HIGH";
1281  return "FORWARD_ACTIVE_LOW";
1282  default:
1283  return "UNRECOGNIZED";
1284  }
1285 }
1286 
1287 /**
1288  * @brief @ref TickDirection stream operator.
1289  * @ingroup config_and_ctrl_messages
1290  */
1292  TickDirection tick_direction) {
1293  stream << to_string(tick_direction) << " (" << (int)tick_direction << ")";
1294  return stream;
1295 }
1296 
1297 /**
1298  * @brief Hardware wheel tick encoder configuration settings.
1299  * @ingroup config_and_ctrl_messages
1300  *
1301  * @warning
1302  * The @ref HardwareTickConfig payload is intended for use on vehicles with a
1303  * physical voltage signal, generated by a wheel encoder, that produces a series
1304  * of voltage pulses (encoder ticks) as the vehicle’s wheel rotates. These ticks
1305  * will be captured by the device on an input pin and used to indicate vehicle
1306  * speed. For vehicles using software wheel speed/tick information, including
1307  * data send using FusionEngine messages or a vehicle CAN bus, use @ref
1308  * WheelConfig instead.
1309  *
1310  * @note
1311  * In addition to the wheel tick signal, an optional voltage signal may be
1312  * provided to indicate vehicle direction. If this signal is not connected, the
1313  * @ref tick_direction setting MUST be set to `OFF` otherwise there will be
1314  * substantial errors in dead reckoning.
1315  *
1316  * See also @ref VehicleTickInput.
1317  */
1319  /**
1320  * If enabled -- tick mode is not @ref TickMode::OFF -- the device will
1321  * accumulate ticks received on the I/O pin, and use them as an indication of
1322  * vehicle speed. If enabled, you must also specify @ref wheel_ticks_to_m to
1323  * indicate the mapping of wheel tick encoder angle to tire circumference. All
1324  * other wheel tick-related parameters such as tick capture rate, rollover
1325  * value, etc. will be set internally.
1326  *
1327  * @warning
1328  * Do not enable this feature if a wheel tick voltage signal is not present.
1329  */
1331 
1332  /**
1333  * When direction is @ref TickDirection::OFF, the incoming ticks will be
1334  * treated as unsigned, meaning the tick count will continue to increase in
1335  * either direction of travel. If direction is not @ref TickDirection::OFF,
1336  * a second direction I/O pin will be used to indicate the direction of
1337  * travel and the accumulated tick count will increase/decrease accordingly.
1338  */
1340 
1341  uint8_t reserved1[2] = {0};
1342 
1343  /**
1344  * The scale factor to convert from wheel encoder ticks to distance (in
1345  * meters/tick). Used for @ref WheelSensorType::TICKS.
1346  */
1347  float wheel_ticks_to_m = NAN;
1348 };
1349 
1350 /**
1351  * @brief Heading bias horizontal/vertical configuration settings.
1352  * @ingroup config_and_ctrl_messages
1353  *
1354  * @note
1355  * Both HeadingBias values must be set for the system to use them.
1356  * If one value is NOT set, the system will not output the corrected
1357  * heading message.
1358  *
1359  * @ref HeadingOutput
1360  */
1362  /**
1363  * The offset between the heading measured by a secondary GNSS device and the
1364  * vehicle's direction of motion in the horizontal plane (defined by the
1365  * vehicle's forward and left axes).
1366  *
1367  * Bias is defined as the angle between the vector pointing from the primary
1368  * GNSS antenna to the secondary heading antenna, and the vector pointing from
1369  * the primary antenna pointing in the forward direction of the vehicle. A
1370  * positive angle means the secondary antenna is offset in a counter-clockwise
1371  * direction from the forward vector (positive yaw rotation).
1372  *
1373  * For example, if the primary antenna is in the back of the vehicle and the
1374  * secondary antenna is in the front, a positive angle would indicate that the
1375  * secondary antenna is offset to the left side of the vehicle.
1376  */
1377  float horizontal_bias_deg = NAN;
1378 
1379  /**
1380  * The offset between the heading measured by a secondary GNSS device and the
1381  * vehicle's direction of motion in the vertical plane (defined by the
1382  * vehicle's forward and up axes).
1383  *
1384  * A positive angle means the secondary antenna is offset in the downward
1385  * direction. For example, if the primary antenna is in the back of the
1386  * vehicle and the secondary antenna is in the front, a positive angle would
1387  * indicate that the secondary antenna is mounted below the primary antenna.
1388  */
1389  float vertical_bias_deg = NAN;
1390 };
1391 
1392 /**
1393  * @brief The ionospheric delay model to use.
1394  * @ingroup config_and_ctrl_messages
1395  */
1396 enum class IonoDelayModel : uint8_t {
1397  /** Select the best available ionospheric delay model. */
1398  AUTO = 0,
1399  /** Ionospheric delay model disabled. */
1400  OFF = 1,
1401  /** Use the Klobuchar ionospheric model. */
1402  KLOBUCHAR = 2,
1403  /** Use the SBAS ionospheric model. */
1404  SBAS = 3,
1405 };
1406 
1407 P1_CONSTEXPR_FUNC const char* to_string(IonoDelayModel iono_delay_model) {
1408  switch (iono_delay_model) {
1409  case IonoDelayModel::AUTO:
1410  return "AUTO";
1411  case IonoDelayModel::OFF:
1412  return "OFF";
1414  return "KLOBUCHAR";
1415  case IonoDelayModel::SBAS:
1416  return "SBAS";
1417  default:
1418  return "UNRECOGNIZED";
1419  }
1420 }
1421 
1422 /**
1423  * @brief @ref IonoDelayModel stream operator.
1424  * @ingroup config_and_ctrl_messages
1425  */
1427  IonoDelayModel iono_delay_model) {
1428  stream << to_string(iono_delay_model) << " (" << (int)iono_delay_model << ")";
1429  return stream;
1430 }
1431 
1432 /**
1433  * @brief Ionospheric delay model configuration.
1434  * @ingroup config_and_ctrl_messages
1435  */
1437  /** The ionospheric delay model to use. */
1439 
1440  uint8_t reserved[3] = {0};
1441 };
1442 
1443 /**
1444  * @brief The tropospheric delay model to use.
1445  * @ingroup config_and_ctrl_messages
1446  */
1447 enum class TropoDelayModel : uint8_t {
1448  /** Select the best available tropospheric delay model. */
1449  AUTO = 0,
1450  /** Tropospheric delay model disabled. */
1451  OFF = 1,
1452  /** Use the Saastamoinen tropospheric model. */
1453  SAASTAMOINEN = 2,
1454 };
1455 
1456 P1_CONSTEXPR_FUNC const char* to_string(TropoDelayModel tropo_delay_model) {
1457  switch (tropo_delay_model) {
1458  case TropoDelayModel::AUTO:
1459  return "AUTO";
1460  case TropoDelayModel::OFF:
1461  return "OFF";
1463  return "SAASTAMOINEN";
1464  default:
1465  return "UNRECOGNIZED";
1466  }
1467 }
1468 
1469 /**
1470  * @brief @ref TropoDelayModel stream operator.
1471  * @ingroup config_and_ctrl_messages
1472  */
1474  TropoDelayModel tropo_delay_model) {
1475  stream << to_string(tropo_delay_model) << " (" << (int)tropo_delay_model
1476  << ")";
1477  return stream;
1478 }
1479 
1480 /**
1481  * @brief Tropospheric delay model configuration.
1482  * @ingroup config_and_ctrl_messages
1483  */
1485  /** The tropospheric delay model to use. */
1487 
1488  uint8_t reserved[3] = {0};
1489 };
1490 
1491 /**
1492  * @brief Configuration of the L-band demodulator parameters.
1493  * @ingroup config_and_ctrl_messages
1494  */
1496  /**
1497  * The center frequency of the L-band beam (Hz).
1498  */
1499  double center_frequency_hz = 1555492500.0;
1500 
1501  /**
1502  * The size of the signal acquisition search space (in Hz) around the center
1503  * frequency.
1504  *
1505  * For example, a value of 6000 will search +/- 3 kHz around the center
1506  * frequency.
1507  */
1508  float search_window_hz = 2000.0;
1509 
1510  /**
1511  * If `true`, only output data frames with the configured service ID.
1512  * Otherwise, output all decoded frames.
1513  */
1514  bool filter_data_by_service_id = true;
1515 
1516  /** Enable/disable the descrambler. */
1517  bool use_descrambler = true;
1518 
1519  /** Service ID of the provider. */
1520  uint16_t pmp_service_id = 0x5555;
1521 
1522  /** Unique word of the provider. */
1523  uint64_t pmp_unique_word = 0xE15AE893E15AE893ull;
1524 
1525  /** Data rate of the provider (bps). */
1526  uint16_t pmp_data_rate_bps = 4800;
1527 
1528  /** The initialization value for the descrambling vector. */
1529  uint16_t descrambler_init = 0x6969;
1530 };
1531 
1532 /** @} */
1533 
1534 /**************************************************************************/ /**
1535  * @name Input/Output Stream Control
1536  * @{
1537  ******************************************************************************/
1538 
1539 /**
1540  * @brief The framing protocol of a message.
1541  */
1542 enum class ProtocolType : uint8_t {
1543  INVALID = 0,
1544  FUSION_ENGINE = 1,
1545  NMEA = 2,
1546  RTCM = 3,
1547  /** This is used for requesting the configuration for all protocols. */
1548  ALL = 0xFF,
1549 };
1550 
1551 /** Setting message_id to this value acts as a wild card. */
1552 constexpr uint16_t ALL_MESSAGES_ID = 0xFFFF;
1553 
1554 /**
1555  * @brief Get a human-friendly string name for the specified @ref
1556  * ProtocolType.
1557  * @ingroup config_and_ctrl_messages
1558  *
1559  * @param val The enum to get the string name for.
1560  *
1561  * @return The corresponding string name.
1562  */
1564  switch (val) {
1565  case ProtocolType::INVALID:
1566  return "Invalid";
1568  return "FusionEngine";
1569  case ProtocolType::NMEA:
1570  return "NMEA";
1571  case ProtocolType::RTCM:
1572  return "RTCM";
1573  case ProtocolType::ALL:
1574  return "ALL";
1575  default:
1576  return "Unrecognized";
1577  }
1578 }
1579 
1580 /**
1581  * @brief @ref ProtocolType stream operator.
1582  * @ingroup config_and_ctrl_messages
1583  */
1585  stream << to_string(val) << " (" << (int)val << ")";
1586  return stream;
1587 }
1588 
1589 /**
1590  * @brief Type of I/O interface transport.
1591  */
1592 enum class TransportType : uint8_t {
1593  INVALID = 0,
1594  /** A serial data interface (e.g. an RS232 connection). */
1595  SERIAL = 1,
1596  /** A interface that writes to a file. */
1597  FILE = 2,
1598  // RESERVED = 3,
1599  /**
1600  * A TCP client or server.
1601  *
1602  * A TCP client will connect to a specified TCP server address and port. A TCP
1603  * server will listen for incoming client connections, and may communicate
1604  * with multiple clients at a time. Responses to commands will be sent only to
1605  * the the issuing client. All other configured output messages will be sent
1606  * to all clients.
1607  *
1608  * See also @ref TransportDirection.
1609  */
1610  TCP = 4,
1611  /**
1612  * A UDP client or server.
1613  *
1614  * UDP connections are stateless, unlike TCP. A UDP interface will listen for
1615  * incoming messages on a specified port. It may optionally be configured to
1616  * sent output to a specific hostname or IP address, including broadcast or
1617  * multicast addresses. If an address is not specified, the interface will not
1618  * send any output automatically, but it will respond to incoming commands,
1619  * sending responses back to the remote client's address and port.
1620  */
1621  UDP = 5,
1622  // RESERVED = 6,
1623  /**
1624  * A WebSocket client or server.
1625  *
1626  * WebSocket connections are similar to TCP connections, and use TCP as their
1627  * underlying transport, but use the WebSocket protocol to send and receive
1628  * data.
1629  *
1630  * See also @ref TransportDirection.
1631  */
1632  WEBSOCKET = 7,
1633  /**
1634  * A UNIX domain socket client or server.
1635  *
1636  * UNIX domain socket connections may be configured as either client that
1637  * connects to an existing server, or a server that listens for one or more
1638  * incoming client connections. UNIX domain sockets may operate in one of
1639  * three possible modes:
1640  * - A connection-oriented streaming mode where packet boundaries are not
1641  * preserved (similar to TCP)
1642  * - Datagram mode where packet boundaries are preserved but connections
1643  * between the client and server are not maintained, and the interface sends
1644  * output to an optional configured file (similar to UDP)
1645  * - Sequenced packet mode, which is connection-oriented (like TCP) but also
1646  * preserves message boundaries (like UDP) and guarantees in-order delivery
1647  *
1648  * For a UNIX domain socket, you must specify:
1649  * - The @ref TransportDirection (client or server)
1650  * - The @ref SocketType (streaming, datagram, or sequenced)
1651  * - The path to a socket file to connect to (client) or create (server)
1652  */
1653  UNIX = 8,
1654  /**
1655  * Set/get the configuration for the interface on which the command was
1656  * received.
1657  */
1658  CURRENT = 254,
1659  /** Set/get the configuration for the all I/O interfaces. */
1660  ALL = 255,
1661 };
1662 
1663 /**
1664  * @brief Get a human-friendly string name for the specified @ref
1665  * TransportType.
1666  * @ingroup config_and_ctrl_messages
1667  *
1668  * @param val The enum to get the string name for.
1669  *
1670  * @return The corresponding string name.
1671  */
1673  switch (val) {
1675  return "Invalid";
1676  case TransportType::SERIAL:
1677  return "Serial";
1678  case TransportType::FILE:
1679  return "File";
1680  case TransportType::TCP:
1681  return "TCP";
1682  case TransportType::UDP:
1683  return "UDP";
1685  return "WebSocket";
1686  case TransportType::UNIX:
1687  return "UNIX";
1689  return "Current";
1690  case TransportType::ALL:
1691  return "All";
1692  }
1693  return "Unrecognized";
1694 }
1695 
1696 /**
1697  * @brief @ref TransportType stream operator.
1698  * @ingroup config_and_ctrl_messages
1699  */
1701  stream << to_string(val) << " (" << (int)val << ")";
1702  return stream;
1703 }
1704 
1705 /**
1706  * @brief The direction (client/server) for an individual interface.
1707  */
1708 enum class TransportDirection : uint8_t {
1709  INVALID = 0,
1710  /** A server listening for one or more incoming remote connections. */
1711  SERVER = 1,
1712  /** A client connecting to a specified remote server. */
1713  CLIENT = 2,
1714 };
1715 
1716 /**
1717  * @brief Get a human-friendly string name for the specified @ref
1718  * TransportDirection.
1719  * @ingroup config_and_ctrl_messages
1720  *
1721  * @param val The enum to get the string name for.
1722  *
1723  * @return The corresponding string name.
1724  */
1726  switch (val) {
1728  return "INVALID";
1730  return "SERVER";
1732  return "CLIENT";
1733  }
1734  return "Unrecognized";
1735 }
1736 
1737 /**
1738  * @brief @ref TransportDirection stream operator.
1739  * @ingroup config_and_ctrl_messages
1740  */
1742  stream << to_string(val) << " (" << (int)val << ")";
1743  return stream;
1744 }
1745 
1746 /**
1747  * @brief The socket type specifying how data is transmitted for UNIX domain
1748  * sockets.
1749  */
1750 enum class SocketType : uint8_t {
1751  INVALID = 0,
1752  /**
1753  * Operate in connection-oriented streaming mode and do not preserve message
1754  * boundaries (similar to TCP).
1755  */
1756  STREAM = 1,
1757  /**
1758  * Operate in datagram mode, preserving message boundaries but not maintaining
1759  * client connections (similar to UDP).
1760  */
1761  DATAGRAM = 2,
1762  /**
1763  * Operate in sequenced packet mode, which is both connection-oriented and
1764  * preserves message boundaries.
1765  */
1766  SEQPACKET = 3,
1767 };
1768 
1769 /**
1770  * @brief Get a human-friendly string name for the specified @ref SocketType.
1771  * @ingroup config_and_ctrl_messages
1772  *
1773  * @param val The enum to get the string name for.
1774  *
1775  * @return The corresponding string name.
1776  */
1778  switch (val) {
1779  case SocketType::INVALID:
1780  return "INVALID";
1781  case SocketType::STREAM:
1782  return "STREAM";
1783  case SocketType::DATAGRAM:
1784  return "DATAGRAM";
1785  case SocketType::SEQPACKET:
1786  return "SEQPACKET";
1787  }
1788  return "Unrecognized";
1789 }
1790 
1791 /**
1792  * @brief @ref SocketType stream operator.
1793  * @ingroup config_and_ctrl_messages
1794  */
1796  stream << to_string(val) << " (" << (int)val << ")";
1797  return stream;
1798 }
1799 
1800 /**
1801  * @brief Identifies an I/O interface.
1802  *
1803  * For example, serial port 1 or TCP server 2.
1804  *
1805  * @note
1806  * On most devices, serial ports (UARTs) use 1-based numbering: the first serial
1807  * port is typically index 1 (UART1).
1808  */
1810  /** The interface's transport type. **/
1812  /** An identifier for the instance of this transport. */
1813  uint8_t index = 0;
1814  uint8_t reserved[2] = {0};
1815 
1817 
1818  P1_CONSTEXPR_FUNC explicit InterfaceID(TransportType type, uint8_t index = 0)
1819  : type(type), index(index) {}
1820 
1821  P1_CONSTEXPR_FUNC bool operator==(const InterfaceID& other) const {
1822  return type == other.type && index == other.index;
1823  }
1824 
1825  P1_CONSTEXPR_FUNC bool operator!=(const InterfaceID& other) const {
1826  return !(*this == other);
1827  }
1828 
1829  P1_CONSTEXPR_FUNC bool operator<(const InterfaceID& other) const {
1830  if (type == other.type) {
1831  return index < other.index;
1832  } else {
1833  return type < other.type;
1834  }
1835  }
1836 
1837  P1_CONSTEXPR_FUNC bool operator>(const InterfaceID& other) const {
1838  return other < *this;
1839  }
1840 
1841  P1_CONSTEXPR_FUNC bool operator>=(const InterfaceID& other) const {
1842  return !(*this < other);
1843  }
1844 
1845  P1_CONSTEXPR_FUNC bool operator<=(const InterfaceID& other) const {
1846  return !(*this > other);
1847  }
1848 };
1849 
1850 /**
1851  * @brief @ref InterfaceID stream operator.
1852  * @ingroup config_and_ctrl_messages
1853  */
1855  stream << "[type=" << val.type << ", index=" << (int)val.index << "]";
1856  return stream;
1857 }
1858 
1859 /**
1860  * @brief Integer ID for NMEA messages.
1861  */
1862 enum class NmeaMessageType : uint16_t {
1863  INVALID = 0,
1864 
1865  /**
1866  * @name Standard NMEA Messages
1867  * @{
1868  */
1869  GGA = 1,
1870  GLL = 2,
1871  GSA = 3,
1872  GSV = 4,
1873  RMC = 5,
1874  VTG = 6,
1875  /** @} */
1876 
1877  /**
1878  * @name Point One Proprietary Messages
1879  * @{
1880  */
1881  P1CALSTATUS = 1000,
1882  P1MSG = 1001,
1883  /** @} */
1884 
1885  /**
1886  * @name Quectel Proprietary Messages
1887  * @{
1888  */
1889  PQTMVERNO = 1200,
1890  PQTMVER = 1201,
1891  PQTMGNSS = 1202,
1892  PQTMVERNO_SUB = 1203,
1893  PQTMVER_SUB = 1204,
1894  PQTMTXT = 1205,
1895  /** @} */
1896 };
1897 
1898 /**
1899  * @brief Get a human-friendly string name for the specified @ref
1900  * NmeaMessageType.
1901  * @ingroup config_and_ctrl_messages
1902  *
1903  * @param value The enum to get the string name for.
1904  *
1905  * @return The corresponding string name.
1906  */
1908  switch (value) {
1910  return "INVALID";
1911  case NmeaMessageType::GGA:
1912  return "GGA";
1913  case NmeaMessageType::GLL:
1914  return "GLL";
1915  case NmeaMessageType::GSA:
1916  return "GSA";
1917  case NmeaMessageType::GSV:
1918  return "GSV";
1919  case NmeaMessageType::RMC:
1920  return "RMC";
1921  case NmeaMessageType::VTG:
1922  return "VTG";
1924  return "P1CALSTATUS";
1926  return "P1MSG";
1928  return "PQTMVERNO";
1930  return "PQTMVER";
1932  return "PQTMGNSS";
1934  return "PQTMVERNO_SUB";
1936  return "PQTMVER_SUB";
1938  return "PQTMTXT";
1939  default:
1940  return "Unrecognized";
1941  }
1942 }
1943 
1944 /**
1945  * @brief @ref NmeaMessageType stream operator.
1946  * @ingroup config_and_ctrl_messages
1947  */
1949  stream << to_string(val) << " (" << (int)val << ")";
1950  return stream;
1951 }
1952 
1953 /**
1954  * @brief The output rate for a message type on an interface.
1955  */
1956 enum class MessageRate : uint8_t {
1957  /**
1958  * Disable output of this message.
1959  */
1960  OFF = 0,
1961  /**
1962  * Output this message each time a new value is available.
1963  */
1964  ON_CHANGE = 1,
1965  /** Alias for @ref MessageRate::ON_CHANGE. */
1966  MAX_RATE = 1,
1967  /**
1968  * Output this message every 10 milliseconds. Not supported for all messages
1969  * or platforms.
1970  */
1971  INTERVAL_10_MS = 2,
1972  /**
1973  * Output this message every 20 milliseconds. Not supported for all messages
1974  * or platforms.
1975  */
1976  INTERVAL_20_MS = 3,
1977  /**
1978  * Output this message every 40 milliseconds. Not supported for all messages
1979  * or platforms.
1980  */
1981  INTERVAL_40_MS = 4,
1982  /**
1983  * Output this message every 50 milliseconds. Not supported for all messages
1984  * or platforms.
1985  */
1986  INTERVAL_50_MS = 5,
1987  /**
1988  * Output this message every 100 milliseconds. Not supported for all messages
1989  * or platforms.
1990  */
1991  INTERVAL_100_MS = 6,
1992  /**
1993  * Output this message every 200 milliseconds. Not supported for all messages
1994  * or platforms.
1995  */
1996  INTERVAL_200_MS = 7,
1997  /**
1998  * Output this message every 500 milliseconds. Not supported for all messages
1999  * or platforms.
2000  */
2001  INTERVAL_500_MS = 8,
2002  /**
2003  * Output this message every second. Not supported for all messages or
2004  * platforms.
2005  */
2006  INTERVAL_1_S = 9,
2007  /**
2008  * Output this message every 2 seconds. Not supported for all messages or
2009  * platforms.
2010  */
2011  INTERVAL_2_S = 10,
2012  /**
2013  * Output this message every 5 seconds. Not supported for all messages or
2014  * platforms.
2015  */
2016  INTERVAL_5_S = 11,
2017  /**
2018  * Output this message every 10 seconds. Not supported for all messages or
2019  * platforms.
2020  */
2021  INTERVAL_10_S = 12,
2022  /**
2023  * Output this message every 30 seconds. Not supported for all messages or
2024  * platforms.
2025  */
2026  INTERVAL_30_S = 13,
2027  /**
2028  * Output this message every 60 seconds. Not supported for all messages or
2029  * platforms.
2030  */
2031  INTERVAL_60_S = 14,
2032  /**
2033  * Restore this message's rate back to its default value.
2034  */
2035  DEFAULT = 255
2036 };
2037 
2038 /**
2039  * @brief Get a human-friendly string name for the specified @ref
2040  * MessageRate.
2041  * @ingroup config_and_ctrl_messages
2042  *
2043  * @param value The enum to get the string name for.
2044  *
2045  * @return The corresponding string name.
2046  */
2048  switch (value) {
2049  case MessageRate::OFF:
2050  return "OFF";
2052  return "ON_CHANGE";
2054  return "INTERVAL_10_MS";
2056  return "INTERVAL_20_MS";
2058  return "INTERVAL_40_MS";
2060  return "INTERVAL_50_MS";
2062  return "INTERVAL_100_MS";
2064  return "INTERVAL_200_MS";
2066  return "INTERVAL_500_MS";
2068  return "INTERVAL_1_S";
2070  return "INTERVAL_2_S";
2072  return "INTERVAL_5_S";
2074  return "INTERVAL_10_S";
2076  return "INTERVAL_30_S";
2078  return "INTERVAL_60_S";
2079  case MessageRate::DEFAULT:
2080  return "DEFAULT";
2081  default:
2082  return "Unrecognized";
2083  }
2084 }
2085 
2086 /**
2087  * @brief @ref MessageRate stream operator.
2088  * @ingroup config_and_ctrl_messages
2089  */
2091  stream << to_string(val) << " (" << (int)val << ")";
2092  return stream;
2093 }
2094 
2095 /**
2096  * @brief Set the output rate for the requested message types (@ref
2097  * MessageType::SET_MESSAGE_RATE, version 1.0).
2098  *
2099  * Multiple message rates can be configured with a single command if wild cards
2100  * are used for the interface, protocol, or message ID. When multiple messages
2101  * are specified, the following behaviors apply:
2102  * - Messages that are currently @ref MessageRate::OFF will not be changed
2103  * unless the @ref FLAG_INCLUDE_DISABLED_MESSAGES bit is set in the @ref flags
2104  * or the new rate is @ref MessageRate::DEFAULT.
2105  * - If the rate is an interval, it will only affect the messages that support
2106  * being rate controlled.
2107  *
2108  * Setting all the messages on an interface to @ref MessageRate::DEFAULT will
2109  * also restore the default `*_OUTPUT_DIAGNOSTICS_MESSAGES` configuration option
2110  * value for that interface. See @ref ConfigType.
2111  *
2112  * @note
2113  * When specifying @ref ProtocolType::ALL, message ID @ref ALL_MESSAGES_ID must
2114  * also be specified. Further, the rate must be set to either
2115  * @ref MessageRate::OFF or @ref MessageRate::DEFAULT.
2116  *
2117  * @section set_rate_examples Typical Use Cases
2118  *
2119  * @subsection set_rate_restore Restore Default Settings For All Messages
2120  *
2121  * To restore the default configuration on UART1 for all message types across all
2122  * supported protocols, specify the following:
2123  * - Interface transport type: @ref TransportType::SERIAL
2124  * - Interface index: 1
2125  * - Protocol: @ref ProtocolType::ALL
2126  * - Message ID: @ref ALL_MESSAGES_ID
2127  * - Rate: @ref MessageRate::DEFAULT
2128  *
2129  * @subsection set_rate_restore_nmea Restore Default Settings For All NMEA
2130  *
2131  * To restore the default configuration on UART1 for all NMEA message types,
2132  * specify the following:
2133  * - Interface transport type: @ref TransportType::SERIAL
2134  * - Interface index: 1
2135  * - Protocol: @ref ProtocolType::NMEA
2136  * - Message ID: @ref ALL_MESSAGES_ID
2137  * - Rate: @ref MessageRate::DEFAULT
2138  *
2139  * @subsection set_rate_change_nmea Change UART1 Output Rate To 1 Hz:
2140  *
2141  * To change the rate of all NMEA message types to 1 Hz on UART1, specify the
2142  * following:
2143  * - Interface transport type: @ref TransportType::SERIAL
2144  * - Interface index: 1
2145  * - Protocol: @ref ProtocolType::NMEA
2146  * - Message ID: @ref ALL_MESSAGES_ID
2147  * - Rate: @ref MessageRate::INTERVAL_1_S
2148  *
2149  * @note
2150  * Note that this will not affect any message types that are not rate controlled
2151  * (e.g., @ref MessageType::EVENT_NOTIFICATION).
2152  *
2153  * @subsection set_rate_off_all Change The Uart1 Output Rates For All Messages To Be Off:
2154  *
2155  * To change the rate of all messages to their max rate on UART1, specify the
2156  * following:
2157  * - Interface transport type: @ref TransportType::SERIAL
2158  * - Interface index: 1
2159  * - Protocol: @ref ProtocolType::ALL
2160  * - flags: @ref FLAG_INCLUDE_DISABLED_MESSAGES
2161  * - Message ID: @ref ALL_MESSAGES_ID
2162  * - Rate: @ref MessageRate::OFF
2163  *
2164  * @note
2165  * This will disable every message.
2166  *
2167  * @subsection set_and_save_rate_off_all Change And Save The UART1 Output Rates For All Messages To Be Off:
2168  *
2169  * To change the rate of all messages to their max rate on UART1, specify the
2170  * following:
2171  * - Interface transport type: @ref TransportType::SERIAL
2172  * - Interface index: 1
2173  * - Protocol: @ref ProtocolType::ALL
2174  * - flags: 0x03 (@ref FLAG_INCLUDE_DISABLED_MESSAGES | @ref FLAG_APPLY_AND_SAVE)
2175  * - Message ID: @ref ALL_MESSAGES_ID
2176  * - Rate: @ref MessageRate::OFF
2177  *
2178  * @note
2179  * Both of the bit flags are set for this message. This will cause the
2180  * configuration to be saved to non-volatile memory.
2181  *
2182  * @ingroup config_and_ctrl_messages
2183  *
2184  * # Expected Response
2185  * The device will respond with a @ref CommandResponseMessage indicating whether
2186  * or not the request succeeded.
2187  */
2189  static constexpr MessageType MESSAGE_TYPE = MessageType::SET_MESSAGE_RATE;
2190  static constexpr uint8_t MESSAGE_VERSION = 0;
2191 
2192  /** Flag to immediately save the config after applying this setting. */
2193  static constexpr uint8_t FLAG_APPLY_AND_SAVE = 0x01;
2194 
2195  /**
2196  * Flag to apply bulk interval changes to all messages instead of just
2197  * enabled messages.
2198  */
2199  static constexpr uint8_t FLAG_INCLUDE_DISABLED_MESSAGES = 0x02;
2200 
2201  /**
2202  * The output interface to configure. If @ref TransportType::ALL, set rates on
2203  * all supported interfaces.
2204  */
2206 
2207  /**
2208  * The message protocol being configured. If @ref ProtocolType::ALL, set rates
2209  * on all supported protocols.
2210  */
2212 
2213  /** Bitmask of additional flags to modify the command. */
2214  uint8_t flags = 0;
2215 
2216  /**
2217  * The ID of the desired message type (e.g., 10000 for FusionEngine
2218  * @ref MessageType::POSE messages). See @ref NmeaMessageType for NMEA-0183
2219  * messages. If @ref ALL_MESSAGES_ID, set the rate for all messages on the
2220  * selected interface and protocol.
2221  */
2222  uint16_t message_id = ALL_MESSAGES_ID;
2223 
2224  /** The desired message rate. */
2226 
2227  uint8_t reserved2[3] = {0};
2228 };
2229 
2230 /**
2231  * @brief Get the configured output rate for the he requested message type on
2232  * the specified interface (@ref MessageType::GET_MESSAGE_RATE,
2233  * version 1.0).
2234  * @ingroup config_and_ctrl_messages
2235  *
2236  * Multiple message rates can be requested with a single command if wild cards
2237  * are used for the protocol, or message ID.
2238  *
2239  * # Expected Response
2240  * The device will respond with a @ref MessageRateResponse containing the
2241  * requested values or an error @ref Response value if the request did not
2242  * succeed.
2243  */
2245  static constexpr MessageType MESSAGE_TYPE = MessageType::GET_MESSAGE_RATE;
2246  static constexpr uint8_t MESSAGE_VERSION = 0;
2247 
2248  /**
2249  * The output interface to be queried.
2250  *
2251  * @ref TransportType::ALL is not supported. To query for multiple transports,
2252  * send separate requests.
2253  */
2255 
2256  /**
2257  * The desired message protocol. If @ref ProtocolType::ALL, return the current
2258  * settings for all supported protocols.
2259  */
2261 
2262  /** The source of the parameter value (active, saved, etc.). */
2264 
2265  /**
2266  * The ID of the desired message type (e.g., 10000 for FusionEngine
2267  * @ref MessageType::POSE messages). See @ref NmeaMessageType for NMEA-0183
2268  * messages. If @ref ALL_MESSAGES_ID, return the current settings for all
2269  * supported messages on the selected interface and protocol.
2270  */
2271  uint16_t message_id = ALL_MESSAGES_ID;
2272 };
2273 
2274 /**
2275  * @brief A list of transport interfaces supported by the device (@ref
2276  * MessageType::SUPPORTED_IO_INTERFACES, version 1.0).
2277  * @ingroup config_and_ctrl_messages
2278  */
2280  static constexpr MessageType MESSAGE_TYPE =
2282  static constexpr uint8_t MESSAGE_VERSION = 0;
2283 
2284  /** The number of interfaces reported by this message. */
2285  uint8_t num_interfaces = 0;
2286 
2287  uint8_t reserved1[7] = {0};
2288 
2289  /** This in then followed by an array of `num_interfaces` @ref InterfaceID. */
2290  // InterfaceID interfaces[num_interfaces]
2291 };
2292 
2293 /**
2294  * @brief An element of a @ref MessageRateResponse message.
2295  * @ingroup config_and_ctrl_messages
2296  */
2298  /**
2299  * Flag to indicate the active value for this configuration differs from the
2300  * value saved to persistent memory.
2301  */
2302  static constexpr uint8_t FLAG_ACTIVE_DIFFERS_FROM_SAVED = 0x1;
2303 
2304  /** The protocol of the message being returned. */
2306 
2307  /** Flags that describe the entry. */
2308  uint8_t flags = 0;
2309 
2310  /**
2311  * The ID of the returned message type (e.g., 10000 for FusionEngine
2312  * @ref MessageType::POSE messages). See @ref NmeaMessageType for NMEA-0183
2313  * messages.
2314  */
2315  uint16_t message_id = 0;
2316 
2317  /** The current configuration for this message. */
2318  MessageRate configured_rate = MessageRate::OFF;
2319 
2320  /**
2321  * The currently active output rate for this message, factoring in effects of
2322  * additional configuration settings that may override the configured rate
2323  * such as enabling diagnostic output.
2324  */
2325  MessageRate effective_rate = MessageRate::OFF;
2326 
2327  uint8_t reserved1[2] = {0};
2328 };
2329 
2330 /**
2331  * @brief Response to a @ref GetMessageRate request (@ref
2332  * MessageType::MESSAGE_RATE_RESPONSE, version 1.1).
2333  * @ingroup config_and_ctrl_messages
2334  */
2336  static constexpr MessageType MESSAGE_TYPE =
2338  static constexpr uint8_t MESSAGE_VERSION = 1;
2339 
2340  /** The source of the parameter value (active, saved, etc.). */
2342 
2343  /** The response status (success, error, etc.). */
2345 
2346  /** The number of rates reported by this message. */
2347  uint16_t num_rates = 0;
2348 
2349  /** The output interface corresponding with this response. */
2350  InterfaceID output_interface = {};
2351 
2352  /**
2353  * This in then followed by an array of num_rates MessageRateResponseEntry.
2354  */
2355  // MessageRateResponseEntry rates[num_rates]
2356 };
2357 
2358 /** Type of data stored on device. */
2359 enum class DataType : uint8_t {
2360  CALIBRATION_STATE = 0,
2361  CRASH_LOG = 1,
2362  FILTER_STATE = 2,
2363  USER_CONFIG = 3,
2364  INVALID = 255
2365 };
2366 
2367 /**
2368  * @brief Get a string representation of a @ref DataType.
2369  *
2370  * @param type The requested type.
2371  *
2372  * @return The corresponding string name.
2373  */
2375  switch (type) {
2377  return "CalibrationState";
2378  case DataType::CRASH_LOG:
2379  return "CrashLog";
2381  return "FilterState";
2382  case DataType::USER_CONFIG:
2383  return "UserConfig";
2384  default:
2385  return "Invalid";
2386  }
2387 }
2388 
2389 /**
2390  * @brief @ref DataType stream operator.
2391  * @ingroup config_and_ctrl_messages
2392  */
2393 inline p1_ostream& operator<<(p1_ostream& stream, DataType val) {
2394  stream << to_string(val) << " (" << (int)val << ")";
2395  return stream;
2396 }
2397 
2398 /**
2399  * @brief Import data from the host to the device (@ref
2400  * MessageType::IMPORT_DATA, version 1.0).
2401  * @ingroup config_and_ctrl_messages
2402  *
2403  * # Expected Response
2404  * The device will respond with a @ref CommandResponseMessage indicating whether
2405  * or not the request succeeded.
2406  */
2408  static constexpr MessageType MESSAGE_TYPE = MessageType::IMPORT_DATA;
2409  static constexpr uint8_t MESSAGE_VERSION = 0;
2410  /**
2411  * The type of data being imported.
2412  */
2414  /**
2415  * The location of the data to update (active, saved, etc.). For data that
2416  * doesn't have separate active and saved copies, this parameter is ignored.
2417  */
2419  uint8_t reserved1[2] = {0};
2420  /** @brief Version of data contents. */
2422  uint8_t reserved2[4] = {0};
2423  /** @brief Number of bytes to update. */
2424  uint32_t data_length_bytes = 0;
2425 
2426  /**
2427  * This in then followed by an array of data_length_bytes bytes for the data
2428  * contents.
2429  */
2430  // uint8_t data[data_length_bytes]
2431 };
2432 
2433 /**
2434  * @brief Export data from the device (@ref
2435  * MessageType::EXPORT_DATA, version 1.0).
2436  * @ingroup config_and_ctrl_messages
2437  *
2438  * # Expected Response
2439  * The device will respond with a @ref PlatformStorageDataMessage.
2440  */
2442  static constexpr MessageType MESSAGE_TYPE = MessageType::EXPORT_DATA;
2443  static constexpr uint8_t MESSAGE_VERSION = 0;
2444  /**
2445  * The type of data to be exported.
2446  */
2448  /**
2449  * The source to copy this data from. If the data_type doesn't separate active
2450  * and saved data, this will be ignored.
2451  */
2453  uint8_t reserved[2] = {0};
2454 };
2455 
2456 /**
2457  * @brief Message for reporting platform storage data (@ref
2458  * MessageType::PLATFORM_STORAGE_DATA, version 1.0).
2459  * @ingroup config_and_ctrl_messages
2460  *
2461  * See also @ref ExportDataMessage.
2462  *
2463  * Changes:
2464  * - Version 1: Added data_validity field.
2465  * - Version 2: Changed data_validity to a @ref Response enum and added
2466  * @ref source field.
2467  */
2469  static constexpr MessageType MESSAGE_TYPE =
2471  static constexpr uint8_t MESSAGE_VERSION = 2;
2472 
2473  /**
2474  * The type of data contained in this message.
2475  */
2477  /**
2478  * The status of the specified data type on the device.
2479  */
2481  /**
2482  * The source this data was copied from. If the @ref data_type doesn't separate
2483  * active and saved data, this will be set to @ref
2484  * ConfigurationSource::ACTIVE.
2485  */
2487  uint8_t reserved[1] = {0};
2488  /** Version of data contents. */
2490  /** Number of bytes in data contents. */
2491  uint32_t data_length_bytes = 0;
2492  /**
2493 
2494  * This in then followed by an array of data_length_bytes bytes for the data
2495  * contents.
2496  */
2497  // uint8_t data[data_length_bytes]
2498 };
2499 
2500 /**
2501  * @brief A submessage header for configuration data associated with the
2502  * @ref ConfigType::INTERFACE_CONFIG.
2503  * @ingroup config_and_ctrl_messages
2504  *
2505  * In @ref SetConfigMessage, @ref GetConfigMessage, and @ref
2506  * ConfigResponseMessage this struct can be used to access settings
2507  * associated with a a particular interface. For example, to set the baudrate
2508  * for serial port 1:
2509  *
2510  * ```
2511  * {
2512  * SetConfigMessage(
2513  * config_type=INTERFACE_CONFIG),
2514  * InterfaceConfigSubmessage(
2515  * interface=InterfaceID(TransportType::SERIAL, 1),
2516  * subtype=BAUD_RATE),
2517  * uint32_t 115200
2518  * }
2519  * ```
2520  */
2522  /**
2523  * The interface ID to target.
2524  *
2525  * @note
2526  * TransportType::ALL is not supported.
2527  */
2529 
2530  /**
2531  * The interface setting to get/set/describe.
2532  */
2534 
2535  uint8_t reserved[3] = {0};
2536 
2537  /**
2538  * A pointer to the beginning of the configuration parameter value if
2539  * setting/describing.
2540  *
2541  * The size and format of the contents is specified by the @ref subtype.
2542  * See @ref InterfaceConfigType.
2543  */
2544  //uint8_t config_data[0];
2545 };
2546 
2547 /** @} */
2548 
2549 #pragma pack(pop)
2550 
2551 } // namespace messages
2552 } // namespace fusion_engine
2553 } // namespace point_one
@ INTERVAL_10_S
Output this message every 10 seconds.
P1_CONSTEXPR_FUNC InterfaceID()=default
@ IMPORT_DATA
ImportDataMessage
@ DIRECTION
Set the interface direction (client/server).
@ INTERVAL_10_MS
Output this message every 10 milliseconds.
ConfigType
An identifier for the contents of a parameter configuration message.
Definition: configuration.h:28
@ VEHICLE_TICKS
A single wheel rotational angle, reported as accumulated encoder ticks.
@ ALL
Set/get the configuration for the all I/O interfaces.
A 3-dimensional vector (used for lever arms, etc.).
@ INTERVAL_5_S
Output this message every 5 seconds.
P1_CONSTEXPR_FUNC InterfaceID(TransportType type, uint8_t index=0)
@ RTCM
Identifies an I/O interface.
@ PQTMGNSS
TransportType type
The interface's transport type.
@ RMC
MessageType
Identifiers for the defined output message types.
Definition: defs.h:34
@ GPS_WEEK_ROLLOVER
Specify a GPS legacy week rollover count override to use when converting all legacy 10-bit GPS week n...
Library portability helper definitions.
@ VW_4
Response to a GetConfigMessage request (MessageType::CONFIG_RESPONSE, version 1.0).
@ SAVE
Save all active parameters to persistent storage.
@ OK
@ RIVIAN
@ MAX_RATE
Alias for MessageRate::ON_CHANGE.
The orientation of a device with respect to the vehicle body axes.
@ LEXUS_CT200H
@ DEFAULT
Restore this message's rate back to its default value.
@ ENABLED_GNSS_FREQUENCY_BANDS
A bitmask indicating which GNSS frequency bands are enabled.
@ IONOSPHERE_CONFIG
Ionospheric delay model configuration.
@ INVALID
Hardware wheel tick encoder configuration settings.
@ NONE
Wheel/vehicle speed data not available.
@ TESLA_MODEL_X
@ DEVICE_LEVER_ARM
The location of the device IMU with respect to the vehicle body frame (in meters).
TickMode
The signal edge to use when capturing a wheel tick voltage signal.
@ TROPOSPHERE_CONFIG
Tropospheric delay model configuration.
@ DATASPEED_CD4
@ UNIX
A UNIX domain socket client or server.
Tropospheric delay model configuration.
@ AUTO
Select the best available ionospheric delay model.
@ FORWARD_ACTIVE_LOW
Assume vehicle is moving forward when direction signal voltage is low, and backward when direction si...
@ REVERT_TO_SAVED
Revert the active configuration to previously saved values.
@ BMW_7
#define P1_ALIGNAS(N)
Definition: portability.h:57
@ AUTO
Select the best available tropospheric delay model.
@ FILE
A interface that writes to a file.
@ UART1_BAUD
Configure the UART1 serial baud rate (in bits/second).
@ INVALID
@ VEHICLE_BODY
Individual vehicle speed to be applied to the system.
@ PQTMVERNO
@ UART1_OUTPUT_DIAGNOSTICS_MESSAGES
Enable/disable output of diagnostic data on UART1.
@ SUPPORTED_IO_INTERFACES
SupportedIOInterfacesMessage
@ PQTMVER_SUB
Response to a GetMessageRate request (MessageType::MESSAGE_RATE_RESPONSE, version 1....
@ TESLA_MODEL_3
@ KIA_SPORTAGE
SteeringType
Indication of which of the vehicle's wheels are steered.
@ PQTMVERNO_SUB
@ HARDWARE_TICK_CONFIG
Indicates the mode and direction used when capturing vehicle wheel tick data from a voltage pulse on ...
@ UNKNOWN_VEHICLE
@ STREAM
Operate in connection-oriented streaming mode and do not preserve message boundaries (similar to TCP)...
@ INTERVAL_500_MS
Output this message every 500 milliseconds.
@ GLL
InterfaceConfigType
An identifier for the contents of a output interface configuration submessage.
@ AUDI_Q7
@ USER_DEVICE_ID
A string for identifying a device.
SaveAction
The type configuration save operation to be performed.
Information about the vehicle including model and dimensions.
IonoDelayModel
The ionospheric delay model to use.
@ INTERVAL_60_S
Output this message every 60 seconds.
Set the output rate for the requested message types (MessageType::SET_MESSAGE_RATE,...
@ REVERT_TO_DEFAULT
Reset the active and saved configuration to default values.
@ WEBSOCKET
A WebSocket client or server.
@ HEADING_BIAS
Used to set horizontal (yaw) & vertical (pitch) biases (in degrees) on a dual-antenna heading platfor...
A submessage header for configuration data associated with the ConfigType::INTERFACE_CONFIG.
Import data from the host to the device (MessageType::IMPORT_DATA, version 1.0).
@ MESSAGE_RATE_RESPONSE
MessageRateResponse
@ SAVE_CONFIG
SaveConfigMessage
MessageRate
The output rate for a message type on an interface.
@ REMOTE_ADDRESS
Configure the network address for a client to connect to.
DataType
Type of data stored on device.
@ INTERFACE_CONFIG
Change a configuration setting for a specified output interface.
P1_CONSTEXPR_FUNC bool operator<(const InterfaceID &other) const
@ ACTIVE
Active configuration currently in use by the device.
@ FRONT
Front wheels are steered.
P1_CONSTEXPR_FUNC bool operator!=(const InterfaceID &other) const
@ PEUGEOT_206
TransportType
Type of I/O interface transport.
@ INVALID
The base class for all message payloads.
Definition: defs.h:648
@ FILTER_STATE
@ INTERVAL_1_S
Output this message every second.
Query the value of a user configuration parameter (MessageType::GET_CONFIG, version 1....
@ ON_CHANGE
Output this message each time a new value is available.
@ INTERVAL_50_MS
Output this message every 50 milliseconds.
@ PQTMVER
@ INTERVAL_2_S
Output this message every 2 seconds.
@ OFF
Tropospheric delay model disabled.
@ INTERVAL_100_MS
Output this message every 100 milliseconds.
@ PQTMTXT
@ SERIAL
A serial data interface (e.g.
@ INVALID
@ INTERVAL_30_S
Output this message every 30 seconds.
@ OFF
Wheel tick capture disabled.
SocketType
The socket type specifying how data is transmitted for UNIX domain sockets.
GNSS signal and frequency type definitions.
Definition: logging.h:38
Get the configured output rate for the he requested message type on the specified interface (MessageT...
Export data from the device (MessageType::EXPORT_DATA, version 1.0).
@ CALIBRATION_STATE
@ FRONT_WHEELS
Front wheel speed data to be applied to the system.
DataVersion data_version
Version of data contents.
@ DEFAULT
Read only device defaults.
@ INVALID
uint8_t index
An identifier for the instance of this transport.
P1_CONSTEXPR_FUNC bool operator>(const InterfaceID &other) const
@ FRONT_AND_REAR_WHEELS
Front and rear wheel speed data to be applied to the system.
@ TCP
A TCP client or server.
@ P1MSG
@ INVALID
@ CURRENT
Set/get the configuration for the interface on which the command was received.
P1_CONSTEXPR_FUNC bool operator<=(const InterfaceID &other) const
@ UART2_BAUD
Configure the UART2 serial baud rate (in bits/second).
P1_CONSTEXPR_FUNC const char * to_string(ConfigType type)
Get a human-friendly string name for the specified ConfigType.
@ GSV
@ SERVER
A server listening for one or more incoming remote connections.
@ TICKS
Individual rotational angle measurements for multiple wheels, reported as accumulated encoder ticks.
@ AUDI_A8L
Direction
@ INTERVAL_200_MS
Output this message every 200 milliseconds.
VehicleModel
The make and model of the vehicle.
@ GET_MESSAGE_RATE
GetMessageRate
@ DEVICE_COARSE_ORIENTATION
The orientation of the device IMU with respect to the vehicle body axes.
@ NMEA
@ INTERVAL_40_MS
Output this message every 40 milliseconds.
std::ostream p1_ostream
Definition: portability.h:75
ConfigType config_type
The type of parameter to be configured.
Response
Command response status indicators.
Definition: defs.h:373
A list of transport interfaces supported by the device (MessageType::SUPPORTED_IO_INTERFACES,...
@ LINCOLN_MKZ
TickDirection
The way to interpret an incoming voltage signal, used to indicate direction of a hardware wheel tick ...
@ OFF
Disable output of this message.
p1_ostream & operator<<(p1_ostream &stream, ConfigType type)
ConfigType stream operator.
@ EXPORT_DATA
ExportDataMessage
@ VEHICLE_SPEED
A single value indicating the vehicle speed (in meters/second).
@ GSA
@ LBAND_PARAMETERS
Configuration of L-band Demodulator Parameters.
@ P1CALSTATUS
@ KLOBUCHAR
Use the Klobuchar ionospheric model.
@ MAN_TGX
Heading bias horizontal/vertical configuration settings.
An element of a MessageRateResponse message.
@ SBAS
Use the SBAS ionospheric model.
NmeaMessageType
Integer ID for NMEA messages.
@ SET_MESSAGE_RATE
SetMessageRate
Save or reload configuration settings (MessageType::SAVE_CONFIG, version 1.0).
@ HYUNDAI_ELANTRA
ProtocolType
The framing protocol of a message.
@ CRASH_LOG
#define P1_CONSTEXPR_FUNC
Definition: portability.h:105
Configuration of the L-band demodulator parameters.
Set a user configuration parameter (MessageType::SET_CONFIG, version 1.0).
@ CLIENT
A client connecting to a specified remote server.
@ ENABLE_WATCHDOG_TIMER
Enable watchdog timer to restart device after fatal errors.
Message for reporting platform storage data (MessageType::PLATFORM_STORAGE_DATA, version 1....
@ VTG
WheelSensorType
The type of vehicle/wheel speed measurements produced by the vehicle.
TropoDelayModel
The tropospheric delay model to use.
@ SEQPACKET
Operate in sequenced packet mode, which is both connection-oriented and preserves message boundaries.
@ GET_CONFIG
GetConfigMessage
@ FRONT_AND_REAR
Front and rear wheels are steered.
@ OUTPUT_LEVER_ARM
The offset of the desired output location with respect to the vehicle body frame (in meters).
@ OUTPUT_DIAGNOSTICS_MESSAGES
Enable/disable output of diagnostic data on this interface.
@ SAVED
Settings currently saved to persistent storage.
@ DATAGRAM
Operate in datagram mode, preserving message boundaries but not maintaining client connections (simil...
@ SET_CONFIG
SetConfigMessage
@ ENABLED
Enable/disable the interface.
@ VEHICLE_DETAILS
Information about the vehicle including model and dimensions.
@ NONE
Speed data not applied to the system.
@ OFF
Ionospheric delay model disabled.
P1_CONSTEXPR_FUNC bool operator==(const InterfaceID &other) const
@ INVALID
@ FORWARD
The vehicle is in a forward gear.
@ WHEEL_CONFIG
Information pertaining to wheel speed/rotation measurements when wheel data is transmitted via softwa...
Point One FusionEngine output message common definitions.
Software vehicle/wheel speed measurement configuration settings.
@ SAASTAMOINEN
Use the Saastamoinen tropospheric model.
@ USER_CONFIG
TransportDirection
The direction (client/server) for an individual interface.
Ionospheric delay model configuration.
@ PLATFORM_STORAGE_DATA
PlatformStorageDataMessage
@ WHEEL_SPEED
Individual speed measurements for multiple wheels, reported in meters/second.
@ FALLING_EDGE
Capture a wheel tick on the falling edge of the incoming pulse.
@ FORWARD_ACTIVE_HIGH
Assume vehicle is moving forward when direction signal voltage is high, and backward when direction s...
@ GGA
DataVersion data_version
Version of data contents.
@ FACTION
ConfigurationSource
The type of a device's configuration settings.
@ INTERVAL_20_MS
Output this message every 20 milliseconds.
@ REAR_WHEELS
Rear wheel speed data to be applied to the system (recommended).
@ UDP
A UDP client or server.
@ GNSS_LEVER_ARM
The location of the GNSS antenna with respect to the vehicle body frame (in meters).
@ BAUD_RATE
Configure the serial baud rate (in bits/second).
@ BMW_MOTORRAD
@ KIA_SORENTO
@ FUSION_ENGINE
@ ENABLED_GNSS_SYSTEMS
A bitmask indicating which GNSS constellations are enabled.
@ SOCKET_TYPE
Set the UNIX domain socket type (streaming/datagram/sequenced).
A struct representing the version of a data object.
Definition: data_version.h:24
@ OFF
Wheel tick direction not provided.
P1_CONSTEXPR_FUNC bool operator>=(const InterfaceID &other) const
@ LEAP_SECOND
Specify a UTC leap second count override value to use for all UTC time conversions.
@ RISING_EDGE
Capture a wheel tick on the rising edge of the incoming pulse.
@ PORT
Configure the network port.
@ UART2_OUTPUT_DIAGNOSTICS_MESSAGES
Enable/disable output of diagnostic data on UART2.
@ ALL
This is used for requesting the configuration for all protocols.
constexpr uint16_t ALL_MESSAGES_ID
Setting message_id to this value acts as a wild card.
AppliedSpeedType
The type of vehicle/wheel speed measurements to be applied.
@ J1939
@ UNKNOWN
Steered wheels unknown.
@ INVALID
@ CONFIG_RESPONSE
ConfigResponseMessage