Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel
ampel-firmware
Commits
31c74498
Commit
31c74498
authored
Feb 15, 2022
by
Eric Duminil
Browse files
Starting to parse Lora config
parent
fcee9d6d
Changes
1
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/lorawan.cpp
View file @
31c74498
...
...
@@ -65,11 +65,43 @@ namespace lorawan {
bool
connected
=
false
;
char
last_transmission
[
23
]
=
""
;
uint8_t
hexToByte
(
char
c
)
{
int
v
=
-
1
;
if
((
c
>=
'0'
)
&&
(
c
<=
'9'
))
{
v
=
(
c
-
'0'
);
}
else
if
((
c
>=
'A'
)
&&
(
c
<=
'F'
))
{
v
=
(
c
-
'A'
+
10
);
}
else
if
((
c
>=
'a'
)
&&
(
c
<=
'f'
))
{
v
=
(
c
-
'a'
+
10
);
}
return
v
;
}
void
parseConfig
(
const
char
*
hex
)
{
int
n
=
strlen
(
hex
);
Serial
.
println
(
hex
);
Serial
.
print
(
"Size : "
);
Serial
.
println
(
n
);
for
(
int
i
=
0
;
i
<
n
;
i
=
i
+
2
)
{
uint8_t
r
=
hexToByte
(
hex
[
i
])
<<
4
|
hexToByte
(
hex
[
i
+
1
]);
Serial
.
print
(
r
,
HEX
);
Serial
.
print
(
" "
);
}
Serial
.
println
();
Serial
.
println
(
"-----"
);
}
void
initialize
()
{
Serial
.
print
(
F
(
"Starting LoRaWAN. Frequency plan : "
));
Serial
.
print
(
config
::
lorawan_frequency_plan
);
Serial
.
println
(
F
(
" MHz."
));
parseConfig
(
config
::
lorawan_device_eui
);
parseConfig
(
config
::
lorawan_app_eui
);
parseConfig
(
config
::
lorawan_app_key
);
// More info about pin mapping : https://github.com/mcci-catena/arduino-lmic#pin-mapping
// Has been tested successfully with ESP32 TTGO LoRa32 V1, and might work with other ESP32+LoRa boards.
const
lmic_pinmap
*
pPinMap
=
Arduino_LMIC
::
GetPinmap_ThisBoard
();
...
...
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