parameters.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #pragma once
  2. #include <stdint.h>
  3. #define MAX_PUBLIC_KEYS 10
  4. #define PUBLIC_KEY_LEN 32
  5. #define PARAM_NAME_MAX_LEN 16
  6. class Parameters {
  7. public:
  8. uint8_t lock_level;
  9. uint8_t can_node;
  10. uint8_t bcast_powerup;
  11. char uas_id[21] = "ABCD123456789";
  12. float wifi_nan_rate;
  13. float bt4_rate;
  14. float bt5_rate;
  15. uint8_t webserver_enable;
  16. char wifi_ssid[21] = "RemoteID_XXXXXXXX";
  17. char wifi_password[21] = "SecretPassword";
  18. /*
  19. header at the front of storage
  20. */
  21. struct header {
  22. struct public_key {
  23. uint8_t key[PUBLIC_KEY_LEN];
  24. } public_keys[MAX_PUBLIC_KEYS];
  25. uint32_t reserved[30];
  26. };
  27. enum class ParamType {
  28. NONE=0,
  29. UINT8=1,
  30. FLOAT=2,
  31. CHAR20=3,
  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. void set(float v) const;
  41. void set(uint8_t v) const;
  42. void set(const char *v) const;
  43. uint8_t get_uint8() const;
  44. float get_float() const;
  45. const char *get_char20() const;
  46. };
  47. static const struct Param params[];
  48. static const Param *find(const char *name);
  49. static const Param *find_by_index(uint16_t idx);
  50. void init(void);
  51. private:
  52. void load_defaults(void);
  53. };
  54. extern Parameters g;