-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathparameters.h
More file actions
138 lines (119 loc) · 3.57 KB
/
parameters.h
File metadata and controls
138 lines (119 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#pragma once
#include <stdint.h>
#define MAX_PUBLIC_KEYS 5
#define PUBLIC_KEY_LEN 32
#define PARAM_NAME_MAX_LEN 16
#define PARAM_FLAG_NONE 0
#define PARAM_FLAG_PASSWORD (1U<<0)
#define PARAM_FLAG_HIDDEN (1U<<1)
enum class Region : uint8_t {
WORLD=0,
USA=1,
JAPAN=2,
EU=3,
};
/*
bits for which fields are required. Based on the region
*/
#define REG_REQUIRE_LOC (1U<<0)
#define REG_REQUIRE_BASIC_ID (1U<<1)
#define REG_REQUIRE_SELF_ID (1U<<2)
#define REG_REQUIRE_OPERATOR_ID (1U<<3)
#define REG_REQUIRE_SYSTEM (1U<<4)
#define REG_REQUIRE_OPERATOR_LOC (1U<<5)
#define REG_REQUIRE_SERIAL_NUM (1U<<6)
#define REG_REQUIRE_SERIAL_OR_SESSION (1U<<7)
#define REG_REQUIRE_REG_ID (1U<<8)
class Parameters {
public:
int8_t lock_level;
uint8_t can_node;
uint8_t bcast_powerup;
uint32_t baudrate = 57600;
uint8_t ua_type;
uint8_t id_type;
char uas_id[21] = "ABCD123456789";
uint8_t ua_type_2;
uint8_t id_type_2;
char uas_id_2[21] = "ABCD123456789";
float wifi_nan_rate;
float wifi_beacon_rate;
float wifi_power;
float bt4_rate;
float bt4_power;
float bt5_rate;
float bt5_power;
uint8_t done_init;
uint8_t webserver_enable;
uint8_t mavlink_sysid;
char wifi_ssid[21] = "";
char wifi_password[21] = "ArduRemoteID";
uint8_t wifi_channel = 6;
uint8_t to_factory_defaults = 0;
uint8_t options;
Region region;
struct {
char b64_key[64];
} public_keys[MAX_PUBLIC_KEYS];
enum class ParamType {
NONE=0,
UINT8=1,
UINT32=2,
FLOAT=3,
CHAR20=4,
CHAR64=5,
INT8=6,
};
struct Param {
char name[PARAM_NAME_MAX_LEN+1];
ParamType ptype;
const void *ptr;
float default_value;
float min_value;
float max_value;
uint16_t flags;
uint8_t min_len;
void set_float(float v) const;
void set_uint8(uint8_t v) const;
void set_int8(int8_t v) const;
void set_uint32(uint32_t v) const;
void set_char20(const char *v) const;
void set_char64(const char *v) const;
uint8_t get_uint8() const;
int8_t get_int8() const;
uint32_t get_uint32() const;
float get_float() const;
const char *get_char20() const;
const char *get_char64() const;
bool get_as_float(float &v) const;
void set_as_float(float v) const;
};
static const struct Param params[];
static const Param *find(const char *name);
static const Param *find_by_index(uint16_t idx);
static const Param *find_by_index_float(uint16_t idx);
void init(void);
bool have_basic_id_info(void) const;
bool have_basic_id_2_info(void) const;
bool set_by_name_uint8(const char *name, uint8_t v);
bool set_by_name_int8(const char *name, int8_t v);
bool set_by_name_char64(const char *name, const char *s);
bool set_by_name_string(const char *name, const char *s);
/*
return a public key
*/
bool get_public_key(uint8_t i, uint8_t key[32]) const;
bool set_public_key(uint8_t i, const uint8_t key[32]);
bool remove_public_key(uint8_t i);
bool no_public_keys(void) const;
static uint16_t param_count_float(void);
static int16_t param_index_float(const Param *p);
// get the REG_REQUIRE features for the region
uint32_t get_required_features(void) const;
private:
void load_defaults(void);
};
// bits for OPTIONS parameter
#define OPTIONS_FORCE_ARM_OK 1U<<0
#define OPTIONS_DONT_SAVE_BASIC_ID_TO_PARAMETERS 1U<<1
extern Parameters g;