forked from ornea/slowcooker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_30_conf.ino
120 lines (98 loc) · 3.19 KB
/
_30_conf.ino
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
void InitAppConfig()
{
char s[16] = "";
Serial.println(F("Reading EEPROM signature"));
EEPROM.begin(512); delay(10);
for (int i = 0; i < sizeof(AppConfig.E_sign); ++i)
{
s[i] += char(EEPROM.read(i));
}
EEPROM.end();
Serial.print(F("Signature read: "));
Serial.println(s);
if (strcmp(AppConfig.E_sign, s) == 0) //if(AppConfig.E_sign == s)
{
EEPROM.begin(512); delay(10);
Serial.println(F("Signature verified. Initialising Config From EEPROM"));
EEPROM.get(0, AppConfig);
EEPROM.end();
}
else
{
Serial.println(F("Signature not verified. Initialising EEPROM "));
SaveAppConfig();
}
}
void SaveAppConfig()
{
EEPROM.begin(512);
delay(10);
EEPROM.put(0, AppConfig);
EEPROM.end();
Serial.println("Saving EEPROM");
}
void OutAppConfig()
{
Serial.println(AppConfig.E_sign);
Serial.print(F("End Point Hostname:"));
Serial.println(AppConfig.EpHostname);
Serial.print(F("End Point Control Hostname:"));
Serial.println(AppConfig.EpControlHostname);
Serial.print(F("Ep SSID0: "));
Serial.println(AppConfig.access_point[0][indx_SSID]);
Serial.print(F("Ep Key0: "));
Serial.println(AppConfig.access_point[0][indx_KEY]);
#if (numAccessPoints > 1)
Serial.print(F("Ep SSID1: "));
Serial.println(AppConfig.access_point[1][indx_SSID]);
Serial.print(F("Ep Key1: "));
Serial.println(AppConfig.access_point[1][indx_KEY]);
#endif
#if (numAccessPoints > 2)
Serial.print(F("Ep SSID2: "));
Serial.println(AppConfig.access_point[2][indx_SSID]);
Serial.print(F("Ep Key2: "));
Serial.println(AppConfig.access_point[2][indx_KEY]);
#endif
#if (numAccessPoints > 3)
Serial.print(F("Ep SSID3: "));
Serial.println(AppConfig.access_point[3][indx_SSID]);
Serial.print(F("Ep Key3: "));
Serial.println(AppConfig.access_point[3][indx_KEY]);
#endif
#if (numAccessPoints > 4)
Serial.print(F("Ep SSID4: "));
Serial.println(AppConfig.access_point[4][indx_SSID]);
Serial.print(F("Ep Key4: "));
Serial.println(AppConfig.access_point[4][indx_KEY]);
#endif
Serial.print(F("End Point IP:"));
Serial.println(IPAddress(AppConfig.EpIP));
Serial.print(F("End Point GW:"));
Serial.println(IPAddress(AppConfig.EpGW));
Serial.print(F("End Point Mask:"));
Serial.println(IPAddress(AppConfig.EpMASK));
Serial.print(F("Access Point SSID:"));
Serial.println(AppConfig.ApSSID);
Serial.print(F("Access Point Key:"));
Serial.println(AppConfig.ApKey);
Serial.print(F("Access Point IP:"));
Serial.println(IPAddress(AppConfig.ApIP));
Serial.print(F("Access Point GW:"));
Serial.println(IPAddress(AppConfig.ApGW));
Serial.print(F("Access Point Mask:"));
Serial.println(IPAddress(AppConfig.ApMASK));
Serial.print(F("DHCP Enabled:(not Used)"));
Serial.println(AppConfig.Flags.bIsDHCPEnabled);
}
void OutChAppConfig()
{
unsigned char *ptr = (unsigned char *)&AppConfig;
unsigned char k;
Serial.println(F("About to do lots of bytes out"));
for (int i = 0; i < sizeof(AppConfig); ++i)
{
k = *(ptr + i);
Serial.print(F("Index: ")); Serial.print(i); Serial.print(F("Char: ")); Serial.print(k); Serial.println(char(k));
}
}