Skip to content

Commit 4b767ff

Browse files
committed
Change WIZNET5K.isconnected to connected property
1 parent 15b59be commit 4b767ff

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

shared-bindings/wiznet/__init__.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <string.h>
3030

3131
#include "py/objlist.h"
32+
#include "py/objproperty.h"
3233
#include "py/runtime.h"
3334
#include "py/stream.h"
3435
#include "py/mperrno.h"
@@ -447,11 +448,22 @@ STATIC mp_obj_t wiznet5k_regs(mp_obj_t self_in) {
447448
}
448449
STATIC MP_DEFINE_CONST_FUN_OBJ_1(wiznet5k_regs_obj, wiznet5k_regs);
449450

450-
STATIC mp_obj_t wiznet5k_isconnected(mp_obj_t self_in) {
451+
STATIC mp_obj_t wiznet5k_connected_get_value(mp_obj_t self_in) {
451452
(void)self_in;
452453
return mp_obj_new_bool(wizphy_getphylink() == PHY_LINK_ON);
453454
}
454-
STATIC MP_DEFINE_CONST_FUN_OBJ_1(wiznet5k_isconnected_obj, wiznet5k_isconnected);
455+
STATIC MP_DEFINE_CONST_FUN_OBJ_1(wiznet5k_connected_get_value_obj, wiznet5k_connected_get_value);
456+
457+
//| attribute:: connected
458+
//|
459+
//| is this device physically connected?
460+
461+
const mp_obj_property_t wiznet5k_connected_obj = {
462+
.base.type = &mp_type_property,
463+
.proxy = {(mp_obj_t)&wiznet5k_connected_get_value_obj,
464+
(mp_obj_t)&mp_const_none_obj,
465+
(mp_obj_t)&mp_const_none_obj},
466+
};
455467

456468
/// \method ifconfig([(ip, subnet, gateway, dns)])
457469
/// Get/set IP address, subnet mask, gateway and DNS.
@@ -484,7 +496,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(wiznet5k_ifconfig_obj, 1, 2, wiznet5k
484496
STATIC const mp_rom_map_elem_t wiznet5k_locals_dict_table[] = {
485497
{ MP_ROM_QSTR(MP_QSTR_regs), MP_ROM_PTR(&wiznet5k_regs_obj) },
486498
{ MP_ROM_QSTR(MP_QSTR_ifconfig), MP_ROM_PTR(&wiznet5k_ifconfig_obj) },
487-
{ MP_ROM_QSTR(MP_QSTR_isconnected), MP_ROM_PTR(&wiznet5k_isconnected_obj) },
499+
{ MP_ROM_QSTR(MP_QSTR_connected), MP_ROM_PTR(&wiznet5k_connected_obj) },
488500
};
489501

490502
STATIC MP_DEFINE_CONST_DICT(wiznet5k_locals_dict, wiznet5k_locals_dict_table);

0 commit comments

Comments
 (0)