Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel
ampel-firmware
Commits
d016d7cd
Commit
d016d7cd
authored
Mar 05, 2022
by
Eric Duminil
Browse files
Refactor
parent
506cc7bf
Changes
1
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/ampel-firmware.ino
View file @
d016d7cd
...
...
@@ -37,11 +37,9 @@ namespace shell {
void
execute
(
const
char
*
command_line
);
}
/*****************************************************************************/
/***
* Define functions which can be called in Shell.
*/
/*****************************************************************************
* Define functions which can be called in the shell.
****************************************************************************/
void
resetConfig
(){
Serial
.
println
(
F
(
"Resetting config..."
));
...
...
@@ -60,54 +58,56 @@ void setWifiPassword(char *pwd){
Serial
.
println
(
pwd
);
strlcpy
(
iotWebConf
.
getWifiPasswordParameter
()
->
valueBuffer
,
pwd
,
iotWebConf
.
getWifiPasswordParameter
()
->
getLength
());
}
/*****************************************************************************/
/***
void
setApPassword
(
char
*
pwd
){
Serial
.
print
(
F
(
"Setting AP password to "
));
Serial
.
println
(
pwd
);
strlcpy
(
iotWebConf
.
getApPasswordParameter
()
->
valueBuffer
,
pwd
,
iotWebConf
.
getApPasswordParameter
()
->
getLength
());
}
void
setThingName
(
char
*
name
){
Serial
.
print
(
F
(
"Setting Thing name to "
));
Serial
.
println
(
name
);
strlcpy
(
iotWebConf
.
getThingNameParameter
()
->
valueBuffer
,
name
,
iotWebConf
.
getThingNameParameter
()
->
getLength
());
}
void
apOnOff
(
int
onOff
){
if
(
onOff
)
{
Serial
.
print
(
F
(
"Enable "
));
}
else
{
Serial
.
print
(
F
(
"Disable "
));
}
Serial
.
println
(
F
(
"AP mode!"
));
iotWebConf
.
forceApMode
(
onOff
);
}
void
wifiOnOff
(
int
onOff
){
if
(
onOff
)
{
Serial
.
print
(
F
(
"Enable Wifi!"
));
iotWebConf
.
goOnLine
();
}
else
{
Serial
.
print
(
F
(
"Disable Wifi!"
));
iotWebConf
.
goOffLine
();
}
}
/*****************************************************************************
* Define shell commands with name, function and documentation.
*/
* The commands accept either 0 argument, one string or one integer.
****************************************************************************/
void
defineShellCommands
()
{
shell
::
defineCommand
(
"reset"
,
[]()
{
ESP
.
restart
();
},
F
(
"(Restarts the ESP)"
));
shell
::
defineCommand
(
"save_config"
,
[]()
{
iotWebConf
.
saveConfig
();
},
F
(
"(Saves the config to EEPROM)"
));
shell
::
defineCommand
(
"reset_config"
,
resetConfig
,
F
(
"(Resets the complete IotWeb config)"
));
shell
::
defineStringCommand
(
"ssid"
,
setSSID
,
F
(
"name (Sets SSID to name)"
));
shell
::
defineStringCommand
(
"wifi_pwd"
,
setWifiPassword
,
F
(
"abc (Sets WiFi password to abc)"
));
shell
::
defineStringCommand
(
"ap_pwd"
,
setApPassword
,
F
(
"abc (Sets AP password to abc)"
));
shell
::
defineStringCommand
(
"name"
,
setThingName
,
F
(
"abc (Sets ThingName to abc)"
));
shell
::
defineStringCommand
(
"ap_pwd"
,
[](
char
*
pwd
)
{
Serial
.
print
(
F
(
"Setting AP password to "
));
Serial
.
println
(
pwd
);
strlcpy
(
iotWebConf
.
getApPasswordParameter
()
->
valueBuffer
,
pwd
,
iotWebConf
.
getApPasswordParameter
()
->
getLength
());
},
F
(
"abc (Sets AP password to abc)"
));
shell
::
defineStringCommand
(
"name"
,
[](
char
*
name
)
{
Serial
.
print
(
F
(
"Setting Thing name to "
));
Serial
.
println
(
name
);
strlcpy
(
iotWebConf
.
getThingNameParameter
()
->
valueBuffer
,
name
,
iotWebConf
.
getThingNameParameter
()
->
getLength
());
},
F
(
"abc (Sets AP password to abc)"
));
shell
::
defineIntCommand
(
"ap"
,
[](
int
onOff
)
{
if
(
onOff
)
{
Serial
.
print
(
F
(
"Enable "
));
}
else
{
Serial
.
print
(
F
(
"Disable "
));
}
Serial
.
println
(
F
(
"AP mode!"
));
iotWebConf
.
forceApMode
(
onOff
);
},
F
(
"0/1 (Enables/disables access point)"
));
shell
::
defineIntCommand
(
"wifi"
,
[](
int
onOff
)
{
if
(
onOff
)
{
Serial
.
print
(
F
(
"Enable Wifi!"
));
iotWebConf
.
goOnLine
();
}
else
{
Serial
.
print
(
F
(
"Disable Wifi!"
));
iotWebConf
.
goOffLine
();
}
},
F
(
"0/1 (Enables/disables WiFi)"
));
shell
::
defineIntCommand
(
"ap"
,
apOnOff
,
F
(
"0/1 (Enables/disables access point)"
));
shell
::
defineIntCommand
(
"wifi"
,
wifiOnOff
,
F
(
"0/1 (Enables/disables WiFi)"
));
}
void
setup
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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