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
1264c29c
Commit
1264c29c
authored
2 years ago
by
Eric Duminil
Browse files
Options
Download
Email Patches
Plain Diff
Trying StateChangedCallback
parent
90f80906
master
develop
senseair_s8
v0.3.0
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ampel-firmware/src/lib/IotWebConf/src/IotWebConf.cpp
+11
-1
ampel-firmware/src/lib/IotWebConf/src/IotWebConf.cpp
ampel-firmware/src/lib/IotWebConf/src/IotWebConf.h
+9
-0
ampel-firmware/src/lib/IotWebConf/src/IotWebConf.h
with
20 additions
and
1 deletion
+20
-1
ampel-firmware/src/lib/IotWebConf/src/IotWebConf.cpp
+
11
-
1
View file @
1264c29c
...
...
@@ -246,6 +246,12 @@ void IotWebConf::setConfigSavedCallback(std::function<void()> func)
this
->
_configSavedCallback
=
func
;
}
void
IotWebConf
::
setStateChangedCallback
(
std
::
function
<
void
(
NetworkState
oldState
,
NetworkState
newState
)
>
func
)
{
this
->
_stateChangedCallback
=
func
;
}
void
IotWebConf
::
setFormValidator
(
std
::
function
<
bool
(
WebRequestWrapper
*
webRequestWrapper
)
>
func
)
{
...
...
@@ -617,6 +623,10 @@ void IotWebConf::changeState(NetworkState newState)
NetworkState
oldState
=
this
->
_state
;
this
->
_state
=
newState
;
this
->
stateChanged
(
oldState
,
newState
);
if
(
this
->
_stateChangedCallback
!=
nullptr
)
{
this
->
_stateChangedCallback
(
oldState
,
newState
);
}
#ifdef IOTWEBCONF_DEBUG_TO_SERIAL
Serial
.
print
(
"State changed from: "
);
Serial
.
print
(
oldState
);
...
...
@@ -983,4 +993,4 @@ WifiAuthInfo* IotWebConf::handleConnectWifiFailure()
return
nullptr
;
}
}
// end namespace
\ No newline at end of file
}
// end namespace
This diff is collapsed.
Click to expand it.
ampel-firmware/src/lib/IotWebConf/src/IotWebConf.h
+
9
-
0
View file @
1264c29c
...
...
@@ -293,6 +293,13 @@ public:
*/
void
setConfigSavedCallback
(
std
::
function
<
void
()
>
func
);
/**
* Specify a callback method, that will be called when ever the state is changed.
* See NetworkState enum for possible values
*/
void
setStateChangedCallback
(
std
::
function
<
void
(
NetworkState
oldState
,
NetworkState
newState
)
>
func
);
/**
* Specify a callback method, that will be called when form validation is required.
* If the method will return false, the configuration will not be saved.
...
...
@@ -600,6 +607,8 @@ private:
std
::
function
<
void
()
>
_wifiConnectionCallback
=
nullptr
;
std
::
function
<
void
(
int
)
>
_configSavingCallback
=
nullptr
;
std
::
function
<
void
()
>
_configSavedCallback
=
nullptr
;
std
::
function
<
void
(
NetworkState
oldState
,
NetworkState
newState
)
>
_stateChangedCallback
=
nullptr
;
std
::
function
<
bool
(
WebRequestWrapper
*
webRequestWrapper
)
>
_formValidator
=
nullptr
;
std
::
function
<
void
(
const
char
*
,
const
char
*
)
>
_apConnectionHandler
=
&
(
IotWebConf
::
connectAp
);
...
...
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