parameters.h 1.7 KB

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