parameters.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #pragma once
  2. #include <stdint.h>
  3. #define MAX_PUBLIC_KEYS 5
  4. #define PUBLIC_KEY_LEN 32
  5. #define PARAM_NAME_MAX_LEN 16
  6. #define PARAM_FLAG_HIDDEN (1U<<0)
  7. class Parameters {
  8. public:
  9. uint8_t lock_level;
  10. uint8_t can_node;
  11. uint8_t bcast_powerup;
  12. uint32_t baudrate = 57600;
  13. uint8_t ua_type;
  14. uint8_t id_type;
  15. char uas_id[21] = "ABCD123456789";
  16. float wifi_nan_rate;
  17. float bt4_rate;
  18. float bt5_rate;
  19. uint8_t webserver_enable;
  20. char wifi_ssid[21] = "RID_123456";
  21. char wifi_password[21] = "penguin1234";
  22. struct {
  23. char b64_key[64];
  24. } public_keys[MAX_PUBLIC_KEYS];
  25. enum class ParamType {
  26. NONE=0,
  27. UINT8=1,
  28. UINT32=2,
  29. FLOAT=3,
  30. CHAR20=4,
  31. CHAR64=5,
  32. };
  33. struct Param {
  34. char name[PARAM_NAME_MAX_LEN+1];
  35. ParamType ptype;
  36. const void *ptr;
  37. float default_value;
  38. float min_value;
  39. float max_value;
  40. uint16_t flags;
  41. void set_float(float v) const;
  42. void set_uint8(uint8_t v) const;
  43. void set_uint32(uint32_t v) const;
  44. void set_char20(const char *v) const;
  45. void set_char64(const char *v) const;
  46. uint8_t get_uint8() const;
  47. uint32_t get_uint32() const;
  48. float get_float() const;
  49. const char *get_char20() const;
  50. const char *get_char64() const;
  51. };
  52. static const struct Param params[];
  53. static const Param *find(const char *name);
  54. static const Param *find_by_index(uint16_t idx);
  55. void init(void);
  56. bool have_basic_id_info(void) const;
  57. private:
  58. void load_defaults(void);
  59. };
  60. extern Parameters g;