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
8ba21e5a
Commit
8ba21e5a
authored
Mar 07, 2022
by
Eric Duminil
Browse files
Some more doc
parent
53398ba9
Pipeline
#5996
failed with stage
in 20 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/ampel-firmware.ino
View file @
8ba21e5a
...
...
@@ -2,7 +2,7 @@
* Example: Shell commands
* Description:
* This example is a modified IotWebConf01Minimal.ino, with added shell commands.
*
*
* Simply type "help" via Serial in order to see the available commands:
> help
...
...
@@ -17,31 +17,51 @@
wifi 0/1 (Enables/disables WiFi).
wifi_pwd abc (Sets WiFi password to abc).
* The commands allow you to setup the thing directly via Serial:
* The commands allow you to setup the thing directly via Serial,
* without the need to type long passwords on a smartphone.
*
* You can copy-paste multiple commands at once, separated by a newline.
* They will be executed one after the other.
> name my_thing
Calling : name('my_thing')
Setting Thing name to my_thing
> ssid my_wifi
Calling : ssid('my_wifi')
Setting WiFi ssid to my_wifi
> wifi_pwd my_wifi_password
Calling : wifi_pwd('my_wifi_password')
Setting WiFi password to my_wifi_password
> ssid my_wifi
Calling : ssid('my_wifi')
Setting WiFi ssid to my_wifi
> ap_pwd p4ssw0rd
Calling : ap_pwd('p4ssw0rd')
Setting AP password to p4ssw0rd
State changing from: 1 to 3
> save_config
Calling : save_config()
Config version: init
Config size: 165
Saving configuration
[iwcAll]
|-- [iwcSys]
| |-- 'iwcThingName' with value: 'my_thing'
| |-- 'iwcApPassword' with value: <hidden>
| |-- [iwcWifi0]
| | |-- 'iwcWifiSsid' with value: 'my_wifi'
| | \-- 'iwcWifiPassword' with value: <hidden>
| \-- 'iwcApTimeout' with value: '30'
|-- [iwcCustom]
\-- [hidden]
State changing from: 2 to 3
Connecting to [my_wifi] (password is hidden)
WiFi timeout (ms): 30000
State changed from: 1 to 3
...
...
*
*
*/
#include <IotWebConf.h>
...
...
@@ -60,9 +80,11 @@ WebServer server(80);
IotWebConf
iotWebConf
(
thingName
,
&
dnsServer
,
&
server
,
wifiInitialApPassword
);
/***
* Shell interface. Could be moved to shell.h
*/
/*****************************************************************************
* Shell interface.
*
* (Could be moved to shell.h)
****************************************************************************/
namespace
shell
{
void
defineCommand
(
const
char
*
name
,
void
(
*
function
)(),
const
__FlashStringHelper
*
doc_fstring
);
void
defineIntCommand
(
const
char
*
name
,
void
(
*
function
)(
int32_t
),
const
__FlashStringHelper
*
doc_fstring
);
...
...
@@ -130,6 +152,9 @@ void wifiOnOff(int onOff){
/*****************************************************************************
* Define shell commands with name, function and documentation.
* The commands accept either 0 argument, one string or one integer.
*
* Feel free to add other commands, e.g. to set custom parameters.
* The second argument can be either a function name or a lambda.
****************************************************************************/
void
defineShellCommands
()
{
...
...
@@ -146,14 +171,16 @@ void defineShellCommands() {
shell
::
defineIntCommand
(
"wifi"
,
wifiOnOff
,
F
(
"0/1 (Enables/disables WiFi)"
));
}
void
setup
()
/*****************************************************************************
* Arduino sketch
****************************************************************************/
void
setup
()
{
Serial
.
begin
(
115200
);
Serial
.
println
();
Serial
.
println
(
"Starting up..."
);
// iotWebConf.getApTimeoutParameter()->defaultValue = "600";
// -- Initializing the configuration.
iotWebConf
.
init
();
...
...
@@ -164,10 +191,10 @@ void setup()
defineShellCommands
();
Serial
.
println
(
"Ready."
);
Serial
.
println
(
F
(
"Ready."
)
)
;
}
void
loop
()
void
loop
()
{
iotWebConf
.
doLoop
();
shell
::
checkSerialInput
();
...
...
@@ -192,9 +219,11 @@ void handleRoot()
server
.
send
(
200
,
"text/html"
,
s
);
}
/***
* Shell logic. Could be moved to shell.cpp
*/
/*****************************************************************************
* Shell logic.
*
* (Could be moved to shell.cpp)
****************************************************************************/
namespace
shell
{
const
uint8_t
MAX_COMMANDS
=
10
;
...
...
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