Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel
ampel-firmware
Commits
dfc57250
Commit
dfc57250
authored
3 years ago
by
Eric Duminil
Browse files
Options
Download
Email Patches
Plain Diff
Not sure about this, let's try
parent
16097a29
archive/experimental/save_lora_session
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ampel-firmware/lorawan.cpp
+6
-0
ampel-firmware/lorawan.cpp
ampel-firmware/web_config.cpp
+31
-0
ampel-firmware/web_config.cpp
ampel-firmware/web_config.h
+6
-0
ampel-firmware/web_config.h
with
43 additions
and
0 deletions
+43
-0
ampel-firmware/lorawan.cpp
+
6
-
0
View file @
dfc57250
...
...
@@ -98,6 +98,12 @@ namespace lorawan {
u1_t
nwkKey
[
16
];
u1_t
artKey
[
16
];
LMIC_getSessionKeys
(
&
netid
,
&
devaddr
,
nwkKey
,
artKey
);
config
::
lora_session_saved
=
true
;
config
::
lora_netid
=
netid
;
config
::
lora_devaddr
=
devaddr
;
memcpy
(
config
::
lorawan_nwk_key
,
nwkKey
,
16
);
memcpy
(
config
::
lorawan_art_key
,
artKey
,
16
);
config
::
save
();
//NOTE: Saving session to EEPROM seems like a good idea at first, but unfortunately: too much info is needed, and a counter would need to be save every single time data is sent.
Serial
.
print
(
F
(
" netid: "
));
Serial
.
println
(
netid
,
DEC
);
...
...
This diff is collapsed.
Click to expand it.
ampel-firmware/web_config.cpp
+
31
-
0
View file @
dfc57250
...
...
@@ -143,6 +143,22 @@ namespace web_config {
LORAWAN_APPLICATION_EUI
).
build
();
PasswordTParameter
<
33
>
appKeyParam
=
Builder
<
PasswordTParameter
<
33
>>
(
"app_key"
).
label
(
"App key (MSB)"
).
defaultValue
(
LORAWAN_APPLICATION_KEY
).
build
();
CheckboxTParameter
savedLoraSession
=
Builder
<
CheckboxTParameter
>
(
"lora_session"
).
label
(
"LoRa session has been saved?"
).
defaultValue
(
false
).
build
();
// u4_t netid = 0;
// devaddr_t devaddr = 0;
// u1_t nwkKey[16];
// u1_t artKey[16];
// LMIC_getSessionKeys(&netid, &devaddr, nwkKey, artKey);
IntTParameter
<
uint32_t
>
savedLoraNetIdParam
=
Builder
<
IntTParameter
<
uint32_t
>>
(
"netid"
).
label
(
"netid"
).
defaultValue
(
0
).
placeholder
(
"?"
).
build
();
IntTParameter
<
uint32_t
>
savedDevaddrParam
=
Builder
<
IntTParameter
<
uint32_t
>>
(
"devaddr"
).
label
(
"devaddr"
).
defaultValue
(
0
).
placeholder
(
"?"
).
build
();
PasswordTParameter
<
17
>
nwkKeyParam
=
Builder
<
PasswordTParameter
<
17
>>
(
"nwkKey"
).
label
(
"nwkKey"
).
defaultValue
(
""
).
build
();
PasswordTParameter
<
17
>
artKeyParam
=
Builder
<
PasswordTParameter
<
17
>>
(
"artKey"
).
label
(
"artKey"
).
defaultValue
(
""
).
build
();
#endif
OptionalGroupHtmlFormatProvider
optionalGroupHtmlFormatProvider
;
...
...
@@ -209,6 +225,15 @@ namespace web_config {
loraParams
.
addItem
(
&
deviceEUIParam
);
loraParams
.
addItem
(
&
appEUIParam
);
loraParams
.
addItem
(
&
appKeyParam
);
//TODO : Test
//TODO : Hide some.
//TODO : rename
loraParams
.
addItem
(
&
savedLoraSession
);
loraParams
.
addItem
(
&
savedLoraNetIdParam
);
loraParams
.
addItem
(
&
savedDevaddrParam
);
loraParams
.
addItem
(
&
nwkKeyParam
);
loraParams
.
addItem
(
&
artKeyParam
);
#endif
iotWebConf
->
addParameterGroup
(
&
co2Params
);
...
...
@@ -335,5 +360,11 @@ namespace config {
char
*
lorawan_device_eui
=
web_config
::
deviceEUIParam
.
value
();
char
*
lorawan_app_key
=
web_config
::
appKeyParam
.
value
();
char
*
lorawan_app_eui
=
web_config
::
appEUIParam
.
value
();
bool
&
lora_session_saved
=
web_config
::
savedLoraSession
.
value
();
uint32_t
&
lora_netid
=
web_config
::
savedLoraNetIdParam
.
value
();
uint32_t
&
lora_devaddr
=
web_config
::
savedDevaddrParam
.
value
();
char
*
lorawan_nwk_key
=
web_config
::
nwkKeyParam
.
value
();
char
*
lorawan_art_key
=
web_config
::
artKeyParam
.
value
();
#endif
}
This diff is collapsed.
Click to expand it.
ampel-firmware/web_config.h
+
6
-
0
View file @
dfc57250
...
...
@@ -58,6 +58,12 @@ namespace config {
extern
char
*
lorawan_device_eui
;
extern
char
*
lorawan_app_key
;
extern
char
*
lorawan_app_eui
;
extern
bool
&
lora_session_saved
;
extern
uint32_t
&
lora_netid
;
extern
uint32_t
&
lora_devaddr
;
extern
char
*
lorawan_nwk_key
;
extern
char
*
lorawan_art_key
;
#endif
// Transmission rate
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets