|
29 | 29 | #include <string.h>
|
30 | 30 |
|
31 | 31 | #include "py/objlist.h"
|
| 32 | +#include "py/objproperty.h" |
32 | 33 | #include "py/runtime.h"
|
33 | 34 | #include "py/stream.h"
|
34 | 35 | #include "py/mperrno.h"
|
@@ -447,11 +448,22 @@ STATIC mp_obj_t wiznet5k_regs(mp_obj_t self_in) {
|
447 | 448 | }
|
448 | 449 | STATIC MP_DEFINE_CONST_FUN_OBJ_1(wiznet5k_regs_obj, wiznet5k_regs);
|
449 | 450 |
|
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) { |
451 | 452 | (void)self_in;
|
452 | 453 | return mp_obj_new_bool(wizphy_getphylink() == PHY_LINK_ON);
|
453 | 454 | }
|
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 | +}; |
455 | 467 |
|
456 | 468 | /// \method ifconfig([(ip, subnet, gateway, dns)])
|
457 | 469 | /// 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
|
484 | 496 | STATIC const mp_rom_map_elem_t wiznet5k_locals_dict_table[] = {
|
485 | 497 | { MP_ROM_QSTR(MP_QSTR_regs), MP_ROM_PTR(&wiznet5k_regs_obj) },
|
486 | 498 | { 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) }, |
488 | 500 | };
|
489 | 501 |
|
490 | 502 | STATIC MP_DEFINE_CONST_DICT(wiznet5k_locals_dict, wiznet5k_locals_dict_table);
|
|
0 commit comments