Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
6f3fc9bf
Commit
6f3fc9bf
authored
Apr 12, 2016
by
Paul Sokolovsky
Browse files
esp8266/modnetwork: .config(): Check interface whose config is requested.
parent
1a327c4f
Changes
1
Hide whitespace changes
Inline
Side-by-side
esp8266/modnetwork.c
View file @
6f3fc9bf
...
...
@@ -242,6 +242,8 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
error_check
(
wifi_softap_get_config
(
&
cfg
.
ap
),
"can't get AP config"
);
}
int
req_if
=
-
1
;
if
(
kwargs
->
used
!=
0
)
{
for
(
mp_uint_t
i
=
0
;
i
<
kwargs
->
alloc
;
i
++
)
{
...
...
@@ -249,6 +251,7 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
#define QS(x) (uintptr_t)MP_OBJ_NEW_QSTR(x)
switch
((
uintptr_t
)
kwargs
->
table
[
i
].
key
)
{
case
QS
(
MP_QSTR_essid
):
{
req_if
=
SOFTAP_IF
;
mp_uint_t
len
;
const
char
*
s
=
mp_obj_str_get_data
(
kwargs
->
table
[
i
].
value
,
&
len
);
len
=
MIN
(
len
,
sizeof
(
cfg
.
ap
.
ssid
));
...
...
@@ -263,6 +266,11 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
}
}
// We post-check interface requirements to save on code size
if
(
req_if
>=
0
)
{
require_if
(
args
[
0
],
req_if
);
}
if
(
self
->
if_id
==
STATION_IF
)
{
error_check
(
wifi_station_set_config
(
&
cfg
.
sta
),
"can't set STA config"
);
}
else
{
...
...
@@ -279,13 +287,26 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
"can query only one param"
));
}
mp_obj_t
val
;
#define QS(x) (uintptr_t)MP_OBJ_NEW_QSTR(x)
switch
((
uintptr_t
)
args
[
1
])
{
case
QS
(
MP_QSTR_essid
):
return
mp_obj_new_str
((
char
*
)
cfg
.
ap
.
ssid
,
cfg
.
ap
.
ssid_len
,
false
);
req_if
=
SOFTAP_IF
;
val
=
mp_obj_new_str
((
char
*
)
cfg
.
ap
.
ssid
,
cfg
.
ap
.
ssid_len
,
false
);
break
;
default:
goto
unknown
;
}
#undef QS
// We post-check interface requirements to save on code size
if
(
req_if
>=
0
)
{
require_if
(
args
[
0
],
req_if
);
}
return
val
;
unknown:
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_ValueError
,
"unknown config param"
));
...
...
Write
Preview
Supports
Markdown
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