Commit fce0036a authored by Paul Sokolovsky's avatar Paul Sokolovsky

esp8266: mac() function belongs to network module per the latest API.

parent 1aa4599d
...@@ -538,26 +538,6 @@ STATIC mp_obj_t esp_sleep_type(mp_uint_t n_args, const mp_obj_t *args) { ...@@ -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_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) { 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); system_deep_sleep(n_args > 0 ? mp_obj_get_int(args[0]) : 0);
return mp_const_none; return mp_const_none;
...@@ -586,7 +566,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(esp_flash_read_obj, esp_flash_read); ...@@ -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[] = { 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___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_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_wifi_mode), (mp_obj_t)&esp_wifi_mode_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_phy_mode), (mp_obj_t)&esp_phy_mode_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_phy_mode), (mp_obj_t)&esp_phy_mode_obj },
......
...@@ -116,6 +116,26 @@ STATIC mp_obj_t esp_isconnected() { ...@@ -116,6 +116,26 @@ STATIC mp_obj_t esp_isconnected() {
STATIC MP_DEFINE_CONST_FUN_OBJ_0(esp_isconnected_obj, 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[] = { 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) }, { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_network) },
// MicroPython "network" module interface requires it to contains classes // MicroPython "network" module interface requires it to contains classes
...@@ -128,6 +148,7 @@ STATIC const mp_map_elem_t mp_module_network_globals_table[] = { ...@@ -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_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_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_isconnected), (mp_obj_t)&esp_isconnected_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_mac), (mp_obj_t)&esp_mac_obj },
#if MODNETWORK_INCLUDE_CONSTANTS #if MODNETWORK_INCLUDE_CONSTANTS
{ MP_OBJ_NEW_QSTR(MP_QSTR_STAT_IDLE), { MP_OBJ_NEW_QSTR(MP_QSTR_STAT_IDLE),
......
...@@ -66,7 +66,6 @@ Q(chip_id) ...@@ -66,7 +66,6 @@ Q(chip_id)
Q(flash_id) Q(flash_id)
Q(flash_read) Q(flash_read)
Q(sdk_version) Q(sdk_version)
Q(mac)
Q(getaddrinfo) Q(getaddrinfo)
Q(send) Q(send)
Q(sendto) Q(sendto)
...@@ -101,6 +100,7 @@ Q(WLAN) ...@@ -101,6 +100,7 @@ Q(WLAN)
Q(scan) Q(scan)
Q(status) Q(status)
Q(isconnected) Q(isconnected)
Q(mac)
Q(STAT_IDLE) Q(STAT_IDLE)
Q(STAT_CONNECTING) Q(STAT_CONNECTING)
Q(STAT_WRONG_PASSWORD) Q(STAT_WRONG_PASSWORD)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment