Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
fce0036a
Commit
fce0036a
authored
Dec 27, 2015
by
Paul Sokolovsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
esp8266: mac() function belongs to network module per the latest API.
parent
1aa4599d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
22 deletions
+22
-22
esp8266/modesp.c
esp8266/modesp.c
+0
-21
esp8266/modnetwork.c
esp8266/modnetwork.c
+21
-0
esp8266/qstrdefsport.h
esp8266/qstrdefsport.h
+1
-1
No files found.
esp8266/modesp.c
View file @
fce0036a
...
...
@@ -538,26 +538,6 @@ STATIC mp_obj_t esp_sleep_type(mp_uint_t n_args, const mp_obj_t *args) {
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN
(
esp_sleep_type_obj
,
0
,
1
,
esp_sleep_type
);
STATIC
mp_obj_t
esp_mac
(
mp_uint_t
n_args
,
const
mp_obj_t
*
args
)
{
uint8_t
mac
[
6
];
if
(
n_args
==
0
)
{
wifi_get_macaddr
(
STATION_IF
,
mac
);
return
mp_obj_new_bytes
(
mac
,
sizeof
(
mac
));
}
else
{
mp_buffer_info_t
bufinfo
;
mp_get_buffer_raise
(
args
[
0
],
&
bufinfo
,
MP_BUFFER_READ
);
if
(
bufinfo
.
len
!=
6
)
{
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_ValueError
,
"invalid buffer length"
));
}
wifi_set_macaddr
(
STATION_IF
,
bufinfo
.
buf
);
return
mp_const_none
;
}
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN
(
esp_mac_obj
,
0
,
1
,
esp_mac
);
STATIC
mp_obj_t
esp_deepsleep
(
mp_uint_t
n_args
,
const
mp_obj_t
*
args
)
{
system_deep_sleep
(
n_args
>
0
?
mp_obj_get_int
(
args
[
0
])
:
0
);
return
mp_const_none
;
...
...
@@ -586,7 +566,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(esp_flash_read_obj, esp_flash_read);
STATIC
const
mp_map_elem_t
esp_module_globals_table
[]
=
{
{
MP_OBJ_NEW_QSTR
(
MP_QSTR___name__
),
MP_OBJ_NEW_QSTR
(
MP_QSTR_esp
)
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_mac
),
(
mp_obj_t
)
&
esp_mac_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_getaddrinfo
),
(
mp_obj_t
)
&
esp_getaddrinfo_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_wifi_mode
),
(
mp_obj_t
)
&
esp_wifi_mode_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_phy_mode
),
(
mp_obj_t
)
&
esp_phy_mode_obj
},
...
...
esp8266/modnetwork.c
View file @
fce0036a
...
...
@@ -116,6 +116,26 @@ STATIC mp_obj_t esp_isconnected() {
STATIC
MP_DEFINE_CONST_FUN_OBJ_0
(
esp_isconnected_obj
,
esp_isconnected
);
STATIC
mp_obj_t
esp_mac
(
mp_uint_t
n_args
,
const
mp_obj_t
*
args
)
{
uint8_t
mac
[
6
];
if
(
n_args
==
0
)
{
wifi_get_macaddr
(
STATION_IF
,
mac
);
return
mp_obj_new_bytes
(
mac
,
sizeof
(
mac
));
}
else
{
mp_buffer_info_t
bufinfo
;
mp_get_buffer_raise
(
args
[
0
],
&
bufinfo
,
MP_BUFFER_READ
);
if
(
bufinfo
.
len
!=
6
)
{
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_ValueError
,
"invalid buffer length"
));
}
wifi_set_macaddr
(
STATION_IF
,
bufinfo
.
buf
);
return
mp_const_none
;
}
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN
(
esp_mac_obj
,
0
,
1
,
esp_mac
);
STATIC
const
mp_map_elem_t
mp_module_network_globals_table
[]
=
{
{
MP_OBJ_NEW_QSTR
(
MP_QSTR___name__
),
MP_OBJ_NEW_QSTR
(
MP_QSTR_network
)
},
// MicroPython "network" module interface requires it to contains classes
...
...
@@ -128,6 +148,7 @@ STATIC const mp_map_elem_t mp_module_network_globals_table[] = {
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_status
),
(
mp_obj_t
)
&
esp_status_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_scan
),
(
mp_obj_t
)
&
esp_scan_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_isconnected
),
(
mp_obj_t
)
&
esp_isconnected_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_mac
),
(
mp_obj_t
)
&
esp_mac_obj
},
#if MODNETWORK_INCLUDE_CONSTANTS
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_STAT_IDLE
),
...
...
esp8266/qstrdefsport.h
View file @
fce0036a
...
...
@@ -66,7 +66,6 @@ Q(chip_id)
Q
(
flash_id
)
Q
(
flash_read
)
Q
(
sdk_version
)
Q
(
mac
)
Q
(
getaddrinfo
)
Q
(
send
)
Q
(
sendto
)
...
...
@@ -101,6 +100,7 @@ Q(WLAN)
Q
(
scan
)
Q
(
status
)
Q
(
isconnected
)
Q
(
mac
)
Q
(
STAT_IDLE
)
Q
(
STAT_CONNECTING
)
Q
(
STAT_WRONG_PASSWORD
)
...
...
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