stm32/modnwwiznet5k: Implement WIZNET5K.isconnected() method.
This commit is contained in:
parent
829c329daf
commit
65ba481cb0
|
@ -268,6 +268,11 @@ parameter should be `id`.
|
|||
Methods
|
||||
-------
|
||||
|
||||
.. method:: wiznet5k.isconnected()
|
||||
|
||||
Returns ``True`` if the physical Ethernet link is connected and up.
|
||||
Returns ``False`` otherwise.
|
||||
|
||||
.. method:: wiznet5k.ifconfig([(ip, subnet, gateway, dns)])
|
||||
|
||||
Get/set IP address, subnet mask, gateway and DNS.
|
||||
|
|
|
@ -414,6 +414,12 @@ 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) {
|
||||
(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);
|
||||
|
||||
/// \method ifconfig([(ip, subnet, gateway, dns)])
|
||||
/// Get/set IP address, subnet mask, gateway and DNS.
|
||||
STATIC mp_obj_t wiznet5k_ifconfig(size_t n_args, const mp_obj_t *args) {
|
||||
|
@ -445,6 +451,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) },
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(wiznet5k_locals_dict, wiznet5k_locals_dict_table);
|
||||
|
|
Loading…
Reference in New Issue