summaryrefslogtreecommitdiff
path: root/shared-bindings
diff options
context:
space:
mode:
authorNick Moore <nick@zoic.org>2018-10-09 12:24:24 +1100
committerNick Moore <nick@zoic.org>2018-10-09 12:24:24 +1100
commit4b767ff080964a0774d9a4cb373ede3e97f209f2 (patch)
tree32058f08f1a90dc5a8343179d1d8b0f366e6026d /shared-bindings
parent15b59bee1b04323365da58338a6a70f9dd51fc79 (diff)
Change WIZNET5K.isconnected to connected property
Diffstat (limited to 'shared-bindings')
-rw-r--r--shared-bindings/wiznet/__init__.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/shared-bindings/wiznet/__init__.c b/shared-bindings/wiznet/__init__.c
index 717ef4bc6..088335290 100644
--- a/shared-bindings/wiznet/__init__.c
+++ b/shared-bindings/wiznet/__init__.c
@@ -29,6 +29,7 @@
#include <string.h>
#include "py/objlist.h"
+#include "py/objproperty.h"
#include "py/runtime.h"
#include "py/stream.h"
#include "py/mperrno.h"
@@ -447,11 +448,22 @@ STATIC mp_obj_t wiznet5k_regs(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(wiznet5k_regs_obj, wiznet5k_regs);
-STATIC mp_obj_t wiznet5k_isconnected(mp_obj_t self_in) {
+STATIC mp_obj_t wiznet5k_connected_get_value(mp_obj_t self_in) {
(void)self_in;
return mp_obj_new_bool(wizphy_getphylink() == PHY_LINK_ON);
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_1(wiznet5k_isconnected_obj, wiznet5k_isconnected);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(wiznet5k_connected_get_value_obj, wiznet5k_connected_get_value);
+
+//| attribute:: connected
+//|
+//| is this device physically connected?
+
+const mp_obj_property_t wiznet5k_connected_obj = {
+ .base.type = &mp_type_property,
+ .proxy = {(mp_obj_t)&wiznet5k_connected_get_value_obj,
+ (mp_obj_t)&mp_const_none_obj,
+ (mp_obj_t)&mp_const_none_obj},
+};
/// \method ifconfig([(ip, subnet, gateway, dns)])
/// 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
STATIC const mp_rom_map_elem_t wiznet5k_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_regs), MP_ROM_PTR(&wiznet5k_regs_obj) },
{ MP_ROM_QSTR(MP_QSTR_ifconfig), MP_ROM_PTR(&wiznet5k_ifconfig_obj) },
- { MP_ROM_QSTR(MP_QSTR_isconnected), MP_ROM_PTR(&wiznet5k_isconnected_obj) },
+ { MP_ROM_QSTR(MP_QSTR_connected), MP_ROM_PTR(&wiznet5k_connected_obj) },
};
STATIC MP_DEFINE_CONST_DICT(wiznet5k_locals_dict, wiznet5k_locals_dict_table);