Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
36ae417c
Commit
36ae417c
authored
Oct 19, 2015
by
danicampora
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs: Add wipy and network.server documentation.
parent
2e0cd20a
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
95 additions
and
27 deletions
+95
-27
cc3200/mods/modnetwork.c
cc3200/mods/modnetwork.c
+8
-6
cc3200/qstrdefsport.h
cc3200/qstrdefsport.h
+1
-1
docs/library/index.rst
docs/library/index.rst
+1
-0
docs/library/network.rst
docs/library/network.rst
+41
-4
docs/library/wipy.rst
docs/library/wipy.rst
+15
-0
docs/wipy/general.rst
docs/wipy/general.rst
+3
-2
docs/wipy/quickref.rst
docs/wipy/quickref.rst
+21
-9
tests/wipy/wlan/server.py
tests/wipy/wlan/server.py
+5
-5
No files found.
cc3200/mods/modnetwork.c
View file @
36ae417c
...
...
@@ -91,10 +91,12 @@ STATIC const mp_arg_t network_server_args[] = {
{
MP_QSTR_login
,
MP_ARG_KW_ONLY
|
MP_ARG_OBJ
,
{.
u_obj
=
MP_OBJ_NULL
}
},
{
MP_QSTR_timeout
,
MP_ARG_KW_ONLY
|
MP_ARG_OBJ
,
{.
u_obj
=
MP_OBJ_NULL
}
},
};
STATIC
mp_obj_t
network_server_
new
(
mp_uint_t
n_args
,
const
mp_obj_t
*
pos_args
,
mp_map_t
*
kw
_args
)
{
STATIC
mp_obj_t
network_server_
make_new
(
mp_obj_t
type_in
,
mp_uint_t
n_args
,
mp_uint_t
n_kw
,
const
mp_obj_t
*
all
_args
)
{
// parse args
mp_map_t
kw_args
;
mp_map_init_fixed_table
(
&
kw_args
,
n_kw
,
all_args
+
n_args
);
mp_arg_val_t
args
[
MP_ARRAY_SIZE
(
network_server_args
)];
mp_arg_parse_all
(
n_args
,
pos_args
,
kw_args
,
MP_ARRAY_SIZE
(
args
),
network_server_args
,
args
);
mp_arg_parse_all
(
n_args
,
all_args
,
&
kw_args
,
MP_ARRAY_SIZE
(
args
),
network_server_args
,
args
);
// check the server id
if
(
args
[
0
].
u_obj
!=
MP_OBJ_NULL
)
{
...
...
@@ -108,9 +110,8 @@ STATIC mp_obj_t network_server_new (mp_uint_t n_args, const mp_obj_t *pos_args,
self
->
base
.
type
=
&
network_server_type
;
network_server_init_helper
(
self
,
&
args
[
1
]);
return
self
;
return
(
mp_obj_t
)
self
;
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_KW
(
network_server_new_obj
,
0
,
network_server_new
);
STATIC
mp_obj_t
network_server_init
(
mp_uint_t
n_args
,
const
mp_obj_t
*
pos_args
,
mp_map_t
*
kw_args
)
{
// parse args
...
...
@@ -152,7 +153,7 @@ STATIC const mp_map_elem_t mp_module_network_globals_table[] = {
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_WLAN
),
(
mp_obj_t
)
&
mod_network_nic_type_wlan
},
#if (MICROPY_PORT_HAS_TELNET || MICROPY_PORT_HAS_FTP)
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_server
),
(
mp_obj_t
)
&
network_server_
new_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_server
),
(
mp_obj_t
)
&
network_server_
type
},
#endif
};
...
...
@@ -169,7 +170,7 @@ STATIC const mp_map_elem_t network_server_locals_dict_table[] = {
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_init
),
(
mp_obj_t
)
&
network_server_init_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_deinit
),
(
mp_obj_t
)
&
network_server_deinit_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_timeout
),
(
mp_obj_t
)
&
network_server_timeout_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_
running
),
(
mp_obj_t
)
&
network_server_running_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_
isrunning
),
(
mp_obj_t
)
&
network_server_running_obj
},
};
STATIC
MP_DEFINE_CONST_DICT
(
network_server_locals_dict
,
network_server_locals_dict_table
);
...
...
@@ -177,6 +178,7 @@ STATIC MP_DEFINE_CONST_DICT(network_server_locals_dict, network_server_locals_di
STATIC
const
mp_obj_type_t
network_server_type
=
{
{
&
mp_type_type
},
.
name
=
MP_QSTR_server
,
.
make_new
=
network_server_make_new
,
.
locals_dict
=
(
mp_obj_t
)
&
network_server_locals_dict
,
};
#endif
cc3200/qstrdefsport.h
View file @
36ae417c
...
...
@@ -283,7 +283,7 @@ Q(init)
Q
(
deinit
)
Q
(
login
)
Q
(
timeout
)
Q
(
running
)
Q
(
is
running
)
// for WLAN class
Q
(
WLAN
)
...
...
docs/library/index.rst
View file @
36ae417c
...
...
@@ -105,6 +105,7 @@ it will fallback to loading the built-in ``ujson`` module.
machine.rst
network.rst
wipy.rst
.. only:: port_esp8266
...
...
docs/library/network.rst
View file @
36ae417c
...
...
@@ -27,6 +27,40 @@ For example::
data = s.recv(1000)
s.close()
.. only:: port_wipy
.. _network.server:
class server
============
Constructors
------------
.. class:: server(id, ...)
Create a server instance, see ``init`` for parameters of initialization.
Methods
-------
.. method:: server.init(\*, login=('micro', 'python'), timeout=300)
Init (and effectively start the server). Optionally a new ``user``, ``password``
and ``timeout`` (in seconds) can be passed.
.. method:: server.deinit()
Stop the server
.. method:: server.timeout([timeout_in_seconds])
Get or set the server timeout.
.. method:: server.isrunning()
Returns ``True`` is the server is running, ``False`` otherwise.
.. only:: port_pyboard
class CC3K
...
...
@@ -178,13 +212,13 @@ For example::
Dump the WIZnet5x00 registers. Useful for debugging.
class WLAN
==========
.. _network.WLAN:
.. only:: port_esp8266
class WLAN
==========
This class provides a driver for WiFi network processor in the ESP8266. Example usage::
import network
...
...
@@ -258,6 +292,9 @@ class WLAN
.. only:: port_wipy
class WLAN
==========
This class provides a driver for WiFi network processor in the WiPy. Example usage::
import network
...
...
@@ -282,7 +319,7 @@ class WLAN
Methods
-------
.. method:: init(mode, \*, ssid, security, key, channel, antenna)
.. method::
wlan.
init(mode, \*, ssid, security, key, channel, antenna)
Set or get the WiFi network processor configuration.
...
...
docs/library/wipy.rst
0 → 100644
View file @
36ae417c
:mod:`wipy` -- WiPy specific features
=====================================
.. module:: wipy
:synopsis: WiPy specific features
The ``wipy`` module contains functions to control specific features of the
WiPy, such as the heartbeat LED.
Functions
---------
.. function:: heartbeat([enable])
Get or set the state (enabled or disabled) of the heartbeat LED.
docs/wipy/general.rst
View file @
36ae417c
...
...
@@ -119,9 +119,10 @@ The heart beat LED
------------------
By default the heart beat LED flashes once every 4s to signal that the system is
alive. This can be overridden through the
HeartBeat class
:
alive. This can be overridden through the
:mod:`wipy` module:
:
``machine.HeartBeat().disable()``
import wipy
wipy.heartbeat(False)
There are currently 2 kinds of errors that you might see:
...
...
docs/wipy/quickref.rst
View file @
36ae417c
...
...
@@ -10,7 +10,7 @@ Quick reference for the WiPy
General board control (including sleep modes)
---------------------------------------------
See
:mod:`machine`.
::
See
the :mod:`machine` module
::
import machine
...
...
@@ -198,14 +198,26 @@ See :ref:`network.WLAN <network.WLAN>` and :mod:`machine`. ::
machine.sleep()
# now, connect to the FTP or the Telnet server and the WiPy will wake-up
Heart beat LED
--------------
Telnet and FTP server
---------------------
See :ref:`network.server <network.server>` ::
from network import network
# init with new user, pass word and seconds timeout
server = server.init(login=('user', 'password'), timeout=60)
server.timeout(300) # change the timeout
server.timeout() # get the timeout
server.isrunning() # check wether the server is running or not
HeartBeat LED
-------------
See :
ref:`machine.HeartBeat <machine.HeartBeat>
`. ::
See :
mod:`wipy
`. ::
from machine import HeartBeat
import wipy
# disable the heart beat indication (you are free to use this LED connected to GP25)
HeartBeat().disable()
# enable the heart beat again
HeartBeat().enable()
wipy.heartbeat(False) # disable the heartbeat LED
wipy.heartbeat(True) # enable the heartbeat LED
wipy.heartbeat() # get the heartbeat state
tests/wipy/wlan/server.py
View file @
36ae417c
...
...
@@ -12,18 +12,18 @@ if not 'LaunchPad' in mch and not'WiPy' in mch:
server
=
network
.
server
()
print
(
server
.
timeout
()
==
300
)
print
(
server
.
running
()
==
True
)
print
(
server
.
is
running
()
==
True
)
server
.
deinit
()
print
(
server
.
running
()
==
False
)
print
(
server
.
is
running
()
==
False
)
server
.
init
(
login
=
(
'test-user'
,
'test-password'
),
timeout
=
60
)
print
(
server
.
running
()
==
True
)
print
(
server
.
is
running
()
==
True
)
print
(
server
.
timeout
()
==
60
)
server
.
deinit
()
print
(
server
.
running
()
==
False
)
print
(
server
.
is
running
()
==
False
)
server
.
init
()
print
(
server
.
running
()
==
True
)
print
(
server
.
is
running
()
==
True
)
try
:
server
.
init
(
1
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment