From 82d7dcf2ff33b17753ca7a01937b65b90a0c803c Mon Sep 17 00:00:00 2001 From: Daniel Spindelbauer Date: Mon, 20 Aug 2018 10:02:34 +0000 Subject: [PATCH] GitBook: [master] 44 pages modified --- .../micropython/_thread.md | 14 ++--- .../micropython/array.md | 8 ++- .../micropython/cmath.md | 20 +++---- firmware-and-api-reference/micropython/gc.md | 12 ++-- .../micropython/micropython.md | 20 +++---- .../micropython/select.md | 6 +- firmware-and-api-reference/micropython/sys.md | 6 +- .../micropython/ubinascii.md | 10 ++-- .../micropython/ucrypto.md | 2 +- .../micropython/uctypes.md | 16 ++--- .../micropython/uhashlib.md | 18 +++--- .../micropython/ujson.md | 8 +-- firmware-and-api-reference/micropython/uos.md | 34 +++++------ firmware-and-api-reference/micropython/ure.md | 18 +++--- .../micropython/usocket.md | 6 +- .../micropython/ussl.md | 4 +- .../micropython/ustruct.md | 12 ++-- .../micropython/utime.md | 26 ++++----- firmware-and-api-reference/pycom/aes.md | 6 +- .../pycom/machine/can.md | 16 ++--- .../pycom/machine/i2c.md | 4 +- .../pycom/machine/pin.md | 24 ++++---- .../pycom/machine/rmt.md | 4 +- .../pycom/machine/rtc.md | 10 ++-- .../pycom/machine/sd.md | 6 +- .../pycom/machine/spi.md | 14 ++--- .../pycom/machine/uart.md | 22 +++---- .../pycom/machine/wdt.md | 6 +- .../pycom/network/bluetooth/README.md | 32 +++++----- .../network/bluetooth/gattccharacteristic.md | 16 ++--- .../network/bluetooth/gattcconnection.md | 8 ++- .../pycom/network/bluetooth/gattccservice.md | 10 ++-- .../network/bluetooth/gattscharacteristic.md | 8 ++- .../pycom/network/bluetooth/gattsservice.md | 8 ++- .../pycom/network/lora.md | 58 +++++++++---------- .../pycom/network/lte.md | 26 ++++----- .../pycom/network/server.md | 10 ++-- .../pycom/network/sigfox.md | 24 ++++---- .../pycom/network/wlan.md | 28 ++++----- firmware-and-api-reference/pycom/pycom.md | 28 ++++----- pybytes/add-device/README.md | 4 +- pytrack-pysense-pyscan/apireference/pyscan.md | 6 ++ .../apireference/pysense.md | 2 + tutorials-and-examples/all/rmt.md | 4 +- 44 files changed, 321 insertions(+), 303 deletions(-) diff --git a/firmware-and-api-reference/micropython/_thread.md b/firmware-and-api-reference/micropython/_thread.md index 7b5a52e..56edbef 100644 --- a/firmware-and-api-reference/micropython/_thread.md +++ b/firmware-and-api-reference/micropython/_thread.md @@ -19,31 +19,31 @@ for i in range(2): _thread.start_new_thread(th_func, (i + 1, i)) ``` -## Functions +## Methods -### \_thread.start\_new\_thread\(function, args\[, kwargs\]\) +#### \_thread.start\_new\_thread\(function, args\[, kwargs\]\) Start a new thread and return its identifier. The thread executes the function with the argument list args \(which must be a tuple\). The optional `kwargs` argument specifies a dictionary of keyword arguments. When the function returns, the thread silently exits. When the function terminates with an unhandled exception, a stack trace is printed and then the thread exits \(but other threads continue to run\). -### \_thread.exit\(\) +#### \_thread.exit\(\) Raise the `SystemExit` exception. When not caught, this will cause the thread to exit silently. -### \_thread.allocate\_lock\(\) +#### \_thread.allocate\_lock\(\) Return a new lock object. Methods of locks are described below. The lock is initially unlocked. -### \_thread.get\_ident\(\) +#### \_thread.get\_ident\(\) Return the `thread identifier` of the current thread. This is a nonzero integer. Its value has no direct meaning; it is intended as a magic cookie to be used e.g. to index a dictionary of thread-specific data. Thread identifiers may be recycled when a thread exits and another thread is created. -### \_thread.stack\_size\(\[size\]\) +#### \_thread.stack\_size\(\[size\]\) Return the thread stack size \(in bytes\) used when creating new threads. The optional size argument specifies the stack size to be used for subsequently created threads, and must be `0` \(use platform or configured default\) or a positive integer value of at least `4096` \(4KiB\). 4KiB is currently the minimum supported stack size value to guarantee sufficient stack space for the interpreter itself. ## Objects -### \_thread.LockType +#### \_thread.LockType This is the type of lock objects. diff --git a/firmware-and-api-reference/micropython/array.md b/firmware-and-api-reference/micropython/array.md index 16f75c0..5965fdc 100644 --- a/firmware-and-api-reference/micropython/array.md +++ b/firmware-and-api-reference/micropython/array.md @@ -6,15 +6,17 @@ Supported format codes: `b, B, h, H, i, I, l, L, q, Q, f, d` \(the latter 2 depe ## Classes -### class array.array\(typecode\[, iterable\]\) +#### class array.array\(typecode\[, iterable\]\) Create array with elements of given type. Initial contents of the array are given by an iterable. If it is not provided, an empty array is created. -### array.append\(val\) +## Methods + +#### array.append\(val\) Append new element to the end of array, growing it. -### array.extend\(iterable\) +#### array.extend\(iterable\) Append new elements as contained in an iterable to the end of array, growing it. diff --git a/firmware-and-api-reference/micropython/cmath.md b/firmware-and-api-reference/micropython/cmath.md index bae6213..8aa91e3 100644 --- a/firmware-and-api-reference/micropython/cmath.md +++ b/firmware-and-api-reference/micropython/cmath.md @@ -2,41 +2,41 @@ The `cmath` module provides some basic mathematical functions for working with complex numbers. Floating point support required for this module. -## Functions +## Methods -### cmath.cos\(z\) +#### cmath.cos\(z\) Return the cosine of `z`. -### cmath.exp\(z\) +#### cmath.exp\(z\) Return the exponential of `z`. -### cmath.log\(z\) +#### cmath.log\(z\) Return the natural logarithm of `z`. The branch cut is along the negative real axis. -### cmath.log10\(z\) +#### cmath.log10\(z\) Return the base-10 logarithm of `z`. The branch cut is along the negative real axis. -### cmath.phase\(z\) +#### cmath.phase\(z\) Returns the phase of the number `z`, in the range \(-pi, +pi\). -### cmath.polar\(z\) +#### cmath.polar\(z\) Returns, as a tuple, the polar form of `z`. -### cmath.rect\(r, phi\) +#### cmath.rect\(r, phi\) Returns the complex number with modulus `r` and phase `phi`. -### cmath.sin\(z\) +#### cmath.sin\(z\) Return the sine of `z`. -### cmath.sqrt\(z\) +#### cmath.sqrt\(z\) Return the square-root of `z`. diff --git a/firmware-and-api-reference/micropython/gc.md b/firmware-and-api-reference/micropython/gc.md index 4d49d83..008a2ba 100644 --- a/firmware-and-api-reference/micropython/gc.md +++ b/firmware-and-api-reference/micropython/gc.md @@ -1,24 +1,24 @@ # gc -## Functions +## Methods -### gc.enable\(\) +#### gc.enable\(\) Enable automatic garbage collection. -### gc.disable\(\) +#### gc.disable\(\) Disable automatic garbage collection. Heap memory can still be allocated, and garbage collection can still be initiated manually using `gc.collect()`. -### gc.collect\(\) +#### gc.collect\(\) Run a garbage collection. -### gc.mem\_alloc\(\) +#### gc.mem\_alloc\(\) Return the number of bytes of heap RAM that are allocated. -### gc.mem\_free\(\) +#### gc.mem\_free\(\) Return the number of bytes of available heap RAM. diff --git a/firmware-and-api-reference/micropython/micropython.md b/firmware-and-api-reference/micropython/micropython.md index 2b870fe..85818d6 100644 --- a/firmware-and-api-reference/micropython/micropython.md +++ b/firmware-and-api-reference/micropython/micropython.md @@ -1,14 +1,14 @@ # micropython -## Functions +## Methosd -### micropython.alloc\_emergency\_exception\_buf\(size\) +#### micropython.alloc\_emergency\_exception\_buf\(size\) Allocate size bytes of RAM for the emergency exception buffer \(a good size is around 100 bytes\). The buffer is used to create exceptions in cases when normal RAM allocation would fail \(eg within an interrupt handler\) and therefore give useful traceback information in these situations. A good way to use this function is to place it at the start of a main script \(e.g. `boot.py` or `main.py`\) and then the emergency exception buffer will be active for all the code following it. -### micropython.const\(expr\) +#### micropython.const\(expr\) Used to declare that the expression is a constant so that the compile can optimise it. The use of this function should be as follows: @@ -23,35 +23,35 @@ Constants declared this way are still accessible as global variables from outsid This const function is recognised directly by the MicroPython parser and is provided as part of the `micropython` module mainly so that scripts can be written which run under both CPython and MicroPython, by following the above pattern. -### micropython.opt\_level\(\[level\]\) +#### micropython.opt\_level\(\[level\]\) If `level` is given then this function sets the optimisation level for subsequent compilation of scripts, and returns `None`. Otherwise it returns the current optimisation level. -### micropython.mem\_info\(\[verbose\]\) +#### micropython.mem\_info\(\[verbose\]\) Print information about currently used memory. If the `verbose` argument is given then extra information is printed. The information that is printed is implementation dependent, but currently includes the amount of stack and heap used. In verbose mode it prints out the entire heap indicating which blocks are used and which are free. -### micropython.qstr\_info\(\[verbose\]\) +#### micropython.qstr\_info\(\[verbose\]\) Print information about currently interned strings. If the `verbose` argument is given then extra information is printed. The information that is printed is implementation dependent, but currently includes the number of interned strings and the amount of RAM they use. In verbose mode it prints out the names of all RAM-interned strings. -### micropython.stack\_use\(\) +#### micropython.stack\_use\(\) Return an integer representing the current amount of stack that is being used. The absolute value of this is not particularly useful, rather it should be used to compute differences in stack usage at different points. -### micropython.heap\_lock\(\) +#### micropython.heap\_lock\(\) -### micropython.heap\_unlock\(\) +#### micropython.heap\_unlock\(\) Lock or unlock the heap. When locked no memory allocation can occur and a `MemoryError` will be raised if any heap allocation is attempted. These functions can be nested, i.e. `heap_lock()` can be called multiple times in a row and the lock-depth will increase, and then `heap_unlock()` must be called the same number of times to make the heap available again. -### micropython.kbd\_intr\(chr\) +#### micropython.kbd\_intr\(chr\) Set the character that will raise a `KeyboardInterrupt` exception. By default this is set to 3 during script execution, corresponding to `Ctrl-C`. Passing `-1` to this function will disable capture of `Ctrl-C`, and passing `3` will restore it. diff --git a/firmware-and-api-reference/micropython/select.md b/firmware-and-api-reference/micropython/select.md index 7c90131..eb2ba32 100644 --- a/firmware-and-api-reference/micropython/select.md +++ b/firmware-and-api-reference/micropython/select.md @@ -6,13 +6,13 @@ This module provides functions to wait for events on streams \(select streams wh Polling is an efficient way of waiting for read/write activity on multiple objects. Current objects that support polling are: `pyb.UART`, `pyb.USB_VCP`. -## Functions +## Methods -### select.poll\(\) +#### select.poll\(\) Create an instance of the `Poll` class. -### select.select\(rlist, wlist, xlist\[, timeout\]\) +#### select.select\(rlist, wlist, xlist\[, timeout\]\) Wait for activity on a set of objects. diff --git a/firmware-and-api-reference/micropython/sys.md b/firmware-and-api-reference/micropython/sys.md index 7de4f97..61dae02 100644 --- a/firmware-and-api-reference/micropython/sys.md +++ b/firmware-and-api-reference/micropython/sys.md @@ -1,12 +1,12 @@ # sys -## Functions +## Methods -### sys.exit\(retval=0\) +#### sys.exit\(retval=0\) Terminate current program with a given exit code. Underlyingly, this function raise as `SystemExit` exception. If an argument is given, its value given as an argument to `SystemExit`. -### sys.print\_exception\(exc, file=sys.stdout\) +#### sys.print\_exception\(exc, file=sys.stdout\) Print exception with a traceback to a file-like object file \(or `sys.stdout` by default\). diff --git a/firmware-and-api-reference/micropython/ubinascii.md b/firmware-and-api-reference/micropython/ubinascii.md index 9e7871b..b492379 100644 --- a/firmware-and-api-reference/micropython/ubinascii.md +++ b/firmware-and-api-reference/micropython/ubinascii.md @@ -2,9 +2,9 @@ This module implements conversions between binary data and various encodings of it in ASCII form \(in both directions\). -## Functions +## Methods -### ubinascii.hexlify\(data\[, sep\]\) +#### ubinascii.hexlify\(data\[, sep\]\) Convert binary data to hexadecimal representation. Returns bytes string. @@ -14,15 +14,15 @@ Convert binary data to hexadecimal representation. Returns bytes string. If additional argument, `sep` is supplied, it is used as a separator between hexadecimal values. {% endhint %} -### ubinascii.unhexlify\(data\) +#### ubinascii.unhexlify\(data\) Convert hexadecimal data to binary representation. Returns bytes string. \(i.e. inverse of `hexlify`\) -### ubinascii.a2b\_base64\(data\) +#### ubinascii.a2b\_base64\(data\) Convert Base64-encoded data to binary representation. Returns bytes string. -### ubinascii.b2a\_base64\(data\) +#### ubinascii.b2a\_base64\(data\) Encode binary data in Base64 format. Returns string. diff --git a/firmware-and-api-reference/micropython/ucrypto.md b/firmware-and-api-reference/micropython/ucrypto.md index 33963fb..79a1f06 100644 --- a/firmware-and-api-reference/micropython/ucrypto.md +++ b/firmware-and-api-reference/micropython/ucrypto.md @@ -8,7 +8,7 @@ This module provides native support for cryptographic algorithms. It’s loosely ## **Methods** -### crypto.getrandbits\(bits\) +#### crypto.getrandbits\(bits\) Returns a bytes object filled with random bits obtained from the hardware random number generator. diff --git a/firmware-and-api-reference/micropython/uctypes.md b/firmware-and-api-reference/micropython/uctypes.md index 5cefc2a..4fe016c 100644 --- a/firmware-and-api-reference/micropython/uctypes.md +++ b/firmware-and-api-reference/micropython/uctypes.md @@ -77,35 +77,35 @@ Note that bitfield operations are independent of target byte endianness, in part ## Module Contents -### class uctypes.struct\(addr, descriptor, layout\_type=NATIVE\) +#### class uctypes.struct\(addr, descriptor, layout\_type=NATIVE\) Instantiate a "foreign data structure" object based on structure address in memory, descriptor \(encoded as a dictionary\), and layout type \(see below\). -### uctypes.LITTLE\_ENDIAN +#### uctypes.LITTLE\_ENDIAN Layout type for a little-endian packed structure. \(Packed means that every field occupies exactly as many bytes as defined in the descriptor, i.e. the alignment is 1\). -### uctypes.BIG\_ENDIAN +#### uctypes.BIG\_ENDIAN Layout type for a big-endian packed structure. -### uctypes.NATIVE +#### uctypes.NATIVE Layout type for a native structure - with data endianness and alignment conforming to the ABI of the system on which MicroPython runs. -### uctypes.sizeof\(struct\) +#### uctypes.sizeof\(struct\) Return size of data structure in bytes. Argument can be either structure class or specific instantiated structure object \(or its aggregate field\). -### uctypes.addressof\(obj\) +#### uctypes.addressof\(obj\) Return address of an object. Argument should be bytes, `bytearray` or other object supporting buffer protocol \(and address of this buffer is what actually returned\). -### uctypes.bytes\_at\(addr, size\) +#### uctypes.bytes\_at\(addr, size\) Capture memory at the given address and size as bytes object. As bytes object is immutable, memory is actually duplicated and copied into bytes object, so if memory contents change later, created object retains original value. -### uctypes.bytearray\_at\(addr, size\) +#### uctypes.bytearray\_at\(addr, size\) Capture memory at the given address and size as `bytearray` object. Unlike `bytes_at()` function above, memory is captured by reference, so it can be both written too, and you will access current value at the given memory address. diff --git a/firmware-and-api-reference/micropython/uhashlib.md b/firmware-and-api-reference/micropython/uhashlib.md index b6ac905..2aa8904 100644 --- a/firmware-and-api-reference/micropython/uhashlib.md +++ b/firmware-and-api-reference/micropython/uhashlib.md @@ -4,41 +4,41 @@ This module implements binary data hashing algorithms. MD5 and SHA are supported ## Constructors -### class uhashlib.md5\(\[data\]\) +#### class uhashlib.md5\(\[data\]\) Create a MD5 hasher object and optionally feed data into it. -### class uhashlib.sha1\(\[data\]\) +#### class uhashlib.sha1\(\[data\]\) Create a SHA-1 hasher object and optionally feed data into it. -### class uhashlib.sha224\(\[data\]\) +#### class uhashlib.sha224\(\[data\]\) Create a SHA-224 hasher object and optionally feed data into it. -### class uhashlib.sha256\(\[data\]\) +#### class uhashlib.sha256\(\[data\]\) Create a SHA-256 hasher object and optionally feed data into it. -### class uhashlib.sha384\(\[data\]\) +#### class uhashlib.sha384\(\[data\]\) Create a SHA-384 hasher object and optionally feed data into it. -### class uhashlib.sha512\(\[data\]\) +#### class uhashlib.sha512\(\[data\]\) Create a SHA-512 hasher object and optionally feed data into it. ## Methods -### hash.update\(data\) +#### hash.update\(data\) Feed more binary data into hash. -### hash.digest\(\) +#### hash.digest\(\) Return hash for all data passed through hash, as a bytes object. After this method is called, more data cannot be fed into hash any longer. -### hash.hexdigest\(\) +#### hash.hexdigest\(\) This method is NOT implemented. Use `ubinascii.hexlify(hash.digest())` to achieve a similar effect. diff --git a/firmware-and-api-reference/micropython/ujson.md b/firmware-and-api-reference/micropython/ujson.md index 54ff968..baed2e5 100644 --- a/firmware-and-api-reference/micropython/ujson.md +++ b/firmware-and-api-reference/micropython/ujson.md @@ -2,17 +2,17 @@ This modules allows to convert between Python objects and the JSON data format. -## Functions +## Methods -### ujson.dumps\(obj\) +#### ujson.dumps\(obj\) Return `obj` represented as a JSON string. -### ujson.loads\(str\) +#### ujson.loads\(str\) Parse the JSON `str` and return an object. Raises `ValueError` if the string is not correctly formed. -### ujson.load\(fp\) +#### ujson.load\(fp\) Parse contents of `fp` \(a `.read()`-supporting file-like object containing a JSON document\). Raises `ValueError` if the content is not correctly formed. diff --git a/firmware-and-api-reference/micropython/uos.md b/firmware-and-api-reference/micropython/uos.md index e053546..9326867 100644 --- a/firmware-and-api-reference/micropython/uos.md +++ b/firmware-and-api-reference/micropython/uos.md @@ -9,41 +9,41 @@ The filesystem has `/` as the root directory and the available physical drives a * `/flash` – the internal flash filesystem * `/sd` – the SD card \(if it exists\) -## Functions +## Methods -### uos.uname\(\) +#### uos.uname\(\) Return information about the system, firmware release version, and MicroPython interpreter version. -### uos.chdir\(path\) +#### uos.chdir\(path\) Change current directory. -### uos.getcwd\(\) +#### uos.getcwd\(\) Get the current directory. -### uos.listdir\(\[dir\]\) +#### uos.listdir\(\[dir\]\) With no argument, list the current directory. Otherwise list the given directory. -### uos.mkdir\(path\) +#### uos.mkdir\(path\) Create a new directory. -### uos.remove\(path\) +#### uos.remove\(path\) Remove a file. -### uos.rmdir\(path\) +#### uos.rmdir\(path\) Remove a directory. -### uos.rename\(old\_path, new\_path\) +#### uos.rename\(old\_path, new\_path\) Rename a file. -### uos.stat\(path\) +#### uos.stat\(path\) Get the status of a file or directory. @@ -60,23 +60,23 @@ The return value is a tuple with the following 10 values, in order: * `st_mtime`: time of most recent content modification. * `st_ctime`: time of most recent metadata change. -### uos.getfree\(path\) +#### uos.getfree\(path\) Returns the free space \(in KiB\) in the drive specified by path. -### uos.sync\(\) +#### uos.sync\(\) Sync all filesystems. -### uos.urandom\(n\) +#### uos.urandom\(n\) Return a bytes object with n random bytes. -### uos.unlink\(path\) +#### uos.unlink\(path\) Alias for the `remove()` method. -### uos.mount\(block\_device, mount\_point, \* , readonly=False\) +#### uos.mount\(block\_device, mount\_point, \* , readonly=False\) Mounts a block device \(like an SD object\) in the specified mount point. Example: @@ -87,11 +87,11 @@ uos.unmount(path) Unmounts a previously mounted block device from the given path. -### uos.mkfs\(block\_device or path\) +#### uos.mkfs\(block\_device or path\) Formats the specified path, must be either `/flash` or `/sd`. A block device can also be passed like an SD object before being mounted. -### uos.dupterm\(stream\_object\) +#### uos.dupterm\(stream\_object\) Duplicate the terminal \(the REPL\) on the passed stream-like object. The given object must at least implement the `read()` and `write()` methods. diff --git a/firmware-and-api-reference/micropython/ure.md b/firmware-and-api-reference/micropython/ure.md index 4d51e81..6885891 100644 --- a/firmware-and-api-reference/micropython/ure.md +++ b/firmware-and-api-reference/micropython/ure.md @@ -19,21 +19,21 @@ $ Counted repetitions `({m,n})`, more advanced assertions, named groups, etc. are not supported. -## Functions +## Methods -### ure.compile\(regex\) +#### ure.compile\(regex\) Compile regular expression, return `regex object`. -### ure.match\(regex, string\) +#### ure.match\(regex, string\) Match regex against `string`. Match always happens from starting position in a string. -### ure.search\(regex, string\) +#### ure.search\(regex, string\) Search regex in a string. Unlike match, this will search string for first position which matches regex \(which still may be 0 if regex is anchored\). -### ure.DEBUG +#### ure.DEBUG Flag value, display debug information about compiled expression. @@ -41,17 +41,17 @@ Flag value, display debug information about compiled expression. Compiled regular expression. Instances of this class are created using `ure.compile()`. -### regex.match\(string\) +#### regex.match\(string\) -### regex.search\(string\) +#### regex.search\(string\) -### regex.split\(string, max\_split=-1\) +#### regex.split\(string, max\_split=-1\) ## Match objects Match objects as returned by `match()` and `search()` methods. -### match.group\(\[index\]\) +#### match.group\(\[index\]\) Only numeric groups are supported. diff --git a/firmware-and-api-reference/micropython/usocket.md b/firmware-and-api-reference/micropython/usocket.md index 3bc7a9c..a5bb898 100644 --- a/firmware-and-api-reference/micropython/usocket.md +++ b/firmware-and-api-reference/micropython/usocket.md @@ -8,13 +8,13 @@ See corresponding CPython module for comparison. Functions below which expect a network address, accept it in the format of `(ipv4_address, port)`, where `ipv4_address` is a string with dot-notation numeric IPv4 address, e.g. `8.8.8.8`, and port is integer port number in the range 1-65535. Note the domain names are not accepted as `ipv4_address`, they should be resolved first using `socket.getaddrinfo()`. -## Functions +## Methods -### socket.socket\(socket.AF\_INET, socket.SOCK\_STREAM, socket.IPPROTO\_TCP\) +#### socket.socket\(socket.AF\_INET, socket.SOCK\_STREAM, socket.IPPROTO\_TCP\) Create a new socket using the given address family, socket type and protocol number. -### socket.getaddrinfo\(host, port\) +#### socket.getaddrinfo\(host, port\) Translate the host/port argument into a sequence of 5-tuples that contain all the necessary arguments for creating a socket connected to that service. The list of 5-tuples has following structure: diff --git a/firmware-and-api-reference/micropython/ussl.md b/firmware-and-api-reference/micropython/ussl.md index 0353455..1ee9327 100644 --- a/firmware-and-api-reference/micropython/ussl.md +++ b/firmware-and-api-reference/micropython/ussl.md @@ -2,9 +2,9 @@ This module provides access to Transport Layer Security \(often known as "Secure Sockets Layer"\) encryption and peer authentication facilities for network sockets, both client-side and server-side. -## Functions +## Methods -### ssl.wrap\_socket\(sock, keyfile=None, certfile=None, server\_side=False, cert\_reqs=CERT\_NONE, ca\_certs=None\) +#### ssl.wrap\_socket\(sock, keyfile=None, certfile=None, server\_side=False, cert\_reqs=CERT\_NONE, ca\_certs=None\) Takes an instance `sock` of `socket.socket`, and returns an instance of ssl.SSLSocket, a subtype of `socket.socket`, which wraps the underlying socket in an SSL context. Example: diff --git a/firmware-and-api-reference/micropython/ustruct.md b/firmware-and-api-reference/micropython/ustruct.md index f0f6a67..4f73e4f 100644 --- a/firmware-and-api-reference/micropython/ustruct.md +++ b/firmware-and-api-reference/micropython/ustruct.md @@ -6,25 +6,25 @@ Supported size/byte order prefixes: `@, <, >, !`. Supported format codes: `b, B, h, H, i, I, l, L, q, Q, s, P, f, d` \(the latter 2 depending on the floating-point support\). -## Functions +## Methods -### ustruct.calcsize\(fmt\) +#### ustruct.calcsize\(fmt\) Return the number of bytes needed to store the given `fmt`. -### ustruct.pack\(fmt, v1, v2, ...\) +#### ustruct.pack\(fmt, v1, v2, ...\) Pack the values `v1, v2, ...` according to the format string `fmt`. The return value is a bytes object encoding the values. -### ustruct.pack\_into\(fmt, buffer, offset, v1, v2, ...\) +#### ustruct.pack\_into\(fmt, buffer, offset, v1, v2, ...\) Pack the values `v1, v2, ...` according to the format string `fmt` into a buffer starting at `offset`. `offset` may be negative to count from the end of buffer. -### ustruct.unpack\(fmt, data\) +#### ustruct.unpack\(fmt, data\) Unpack from the `data` according to the format string `fmt`. The return value is a tuple of the unpacked values. -### ustruct.unpack\_from\(fmt, data, offset=0\) +#### ustruct.unpack\_from\(fmt, data, offset=0\) Unpack from the `data` starting at `offset` according to the format string `fmt`. `offset` may be negative to count from the end of buffer. The return value is a tuple of the unpacked values. diff --git a/firmware-and-api-reference/micropython/utime.md b/firmware-and-api-reference/micropython/utime.md index a06186d..6bec364 100644 --- a/firmware-and-api-reference/micropython/utime.md +++ b/firmware-and-api-reference/micropython/utime.md @@ -14,9 +14,9 @@ This requires a Real Time Clock \(RTC\). On systems with underlying OS \(includi If actual calendar time is not maintained with a system/MicroPython RTC, functions below which require reference to current absolute time may behave not as expected. -## Functions +## Methods -### utime.gmtime\(\[secs\]\) +#### utime.gmtime\(\[secs\]\) Convert a time expressed in seconds since the Epoch \(see above\) into an 8-tuple which contains: `(year, month, mday, hour, minute, second, weekday, yearday)` If `secs` is not provided or `None`, then the current time from the RTC is used. @@ -29,39 +29,39 @@ Convert a time expressed in seconds since the Epoch \(see above\) into an 8-tupl * `weekday` is 0-6 for Mon-Sun * `yearday` is 1-366 -### utime.localtime\(\[secs\]\) +#### utime.localtime\(\[secs\]\) Like `gmtime()` but converts to local time. If `secs` is not provided or `None`, the current time from the RTC is used. -### utime.mktime\(\) +#### utime.mktime\(\) This is inverse function of `localtime`. It’s argument is a full 8-tuple which expresses a time as per `localtime`. It returns an integer which is the number of seconds since `Jan 1, 2000`. -### utime.sleep\(seconds\) +#### utime.sleep\(seconds\) Sleep for the given number of `seconds`. `seconds` can be a floating-point number to sleep for a fractional number of seconds. Note that other MicroPython ports may not accept floating-point argument, for compatibility with them use `sleep_ms()` and `sleep_us()` functions. -### utime.sleep\_ms\(ms\) +#### utime.sleep\_ms\(ms\) Delay for given number of milliseconds, should be positive or 0. -### utime.sleep\_us\(us\) +#### utime.sleep\_us\(us\) Delay for given number of microseconds, should be positive or 0 -### utime.ticks\_ms\(\) +#### utime.ticks\_ms\(\) Returns uptime, in milliseconds. -### utime.ticks\_us\(\) +#### utime.ticks\_us\(\) Just like `ticks_ms` above, but in microseconds. -### utime.ticks\_cpu\(\) +#### utime.ticks\_cpu\(\) Same as `ticks_us`, but faster. -### utime.ticks\_diff\(old, new\) +#### utime.ticks\_diff\(old, new\) Measure period between consecutive calls to `ticks_ms()`, `ticks_us()`, or `ticks_cpu()`. The value returned by these functions may wrap around at any time, so directly subtracting them is not supported. `ticks_diff()` should be used instead. "old" value should actually precede "new" value in time, or result is undefined. This function should not be used to measure arbitrarily long periods of time \(because `ticks_*()` functions wrap around and usually would have short period\). The expected usage pattern is implementing event polling with timeout: @@ -73,11 +73,11 @@ while pin.value() == 0: raise TimeoutError ``` -### utime.time\(\) +#### utime.time\(\) Returns the number of seconds, as an integer, since the Epoch, assuming that underlying RTC is set. If an RTC is not set, this function returns number of seconds since power up or reset\). If you want to develop portable MicroPython application, you should not rely on this function to provide higher than second precision. If you need higher precision, use `ticks_ms()` and `ticks_us()` functions, if you need calendar time, `localtime()` without an argument is a better choice. -### utime.timezone\(\[secs\]\) +#### utime.timezone\(\[secs\]\) Set or get the timezone offset, in seconds. If `secs` is not provided, it returns the current value. diff --git a/firmware-and-api-reference/pycom/aes.md b/firmware-and-api-reference/pycom/aes.md index 9d6a391..633b023 100644 --- a/firmware-and-api-reference/pycom/aes.md +++ b/firmware-and-api-reference/pycom/aes.md @@ -26,7 +26,7 @@ print(original) ## Constructors -### class ucrypto.AES\(key, mode, IV, \* , counter, segment\_size\) +#### class ucrypto.AES\(key, mode, IV, \* , counter, segment\_size\) Create an AES object that will let you encrypt and decrypt messages. @@ -40,11 +40,11 @@ The arguments are: ## Methods -### ucrypto.encrypt\(\) +#### ucrypto.encrypt\(\) Encrypt data with the key and the parameters set at initialisation. -### ucrypto.decrypt\(\) +#### ucrypto.decrypt\(\) Decrypt data with the key and the parameters set at initialisation. diff --git a/firmware-and-api-reference/pycom/machine/can.md b/firmware-and-api-reference/pycom/machine/can.md index 2fee506..80f4882 100644 --- a/firmware-and-api-reference/pycom/machine/can.md +++ b/firmware-and-api-reference/pycom/machine/can.md @@ -16,7 +16,7 @@ can.recv() ## Constructors -### class machine.CAN\(bus=0, ...\) +#### class machine.CAN\(bus=0, ...\) Create an CAN object. See init for parameters of initialisation.: @@ -27,7 +27,7 @@ can = CAN(0, mode=CAN.NORMAL, baudrate=500000, pins=('P22', 'P23')) # pin ord ## Methods -### can.init\(mode=CAN.NORMAL, baudrate=500000, \*, frame\_format=CAN.FORMAT\_STD, rx\_queue\_len=128, pins=\('P22', 'P23'\)\) +#### can.init\(mode=CAN.NORMAL, baudrate=500000, \*, frame\_format=CAN.FORMAT\_STD, rx\_queue\_len=128, pins=\('P22', 'P23'\)\) Initialize the CAN controller. The arguments are: @@ -37,11 +37,11 @@ Initialize the CAN controller. The arguments are: * `rx_queue_len` defines the number of messages than can be queued by the receiver. Due to CAN being a high traffic bus, large values are recommended \(>= 128\), otherwise messages will be dropped specially when no filtering is applied. * `pins` selects the `Tx` and `Rx` pins \(in that order\). -### can.deinit\(\) +#### can.deinit\(\) Disables the CAN bus. -### can.send\(id, \* , data=None, rtr=False, extended=False\) +#### can.send\(id, \* , data=None, rtr=False, extended=False\) Send a CAN frame on the bus @@ -60,7 +60,7 @@ can.send(id=0x010, data=bytes([0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08])) can.send(id=0x012, rtr=True) # sends a remote request for message id=0x12 ``` -### can.recv\(timeout=0\) +#### can.recv\(timeout=0\) Get a message from the receive queue, and optionally specify a timeout value in **s** \(can be a floating point value e.g. `0.2`\). This function returns `None` if no messages available. If a message is present, it will be returned as a named tuple with the following form: @@ -71,7 +71,7 @@ Get a message from the receive queue, and optionally specify a timeout value in (id=0x012, data=b'123', rtr=False, extended=False) ``` -### can.soft\_filter\(mode, filter\_list\) +#### can.soft\_filter\(mode, filter\_list\) Specify a software filter accepting only the messages that pass the filter test. @@ -95,7 +95,7 @@ can.soft_filter(CAN.FILTER_MASK, [(0x100, 0x7FF), (0x200, 0x7FC)]) # more of the can.soft_filter(None) # disable soft filters, all messages are accepted ``` -### can.callback\(trigger, handler=None, arg=None\) +#### can.callback\(trigger, handler=None, arg=None\) Set a callback to be triggered when any of this 3 events are present: @@ -122,7 +122,7 @@ def can_cb(can_o): can.callback(handler=can_cb, trigger=CAN.RX_FRAME) ``` -### can.events\(\) +#### can.events\(\) This method returns a value with bits sets \(if any\) indicating the events that have occurred in the bus. Please note that by calling this function the internal events registry is cleared automatically, therefore calling it immediately for a second time will most likely return a value of 0. diff --git a/firmware-and-api-reference/pycom/machine/i2c.md b/firmware-and-api-reference/pycom/machine/i2c.md index 32ea48e..62b6462 100644 --- a/firmware-and-api-reference/pycom/machine/i2c.md +++ b/firmware-and-api-reference/pycom/machine/i2c.md @@ -122,7 +122,5 @@ The return value is the number of bytes written. ## Constants -#### `I2C.MASTER` - -Used to initialise the bus to master mode. +* `I2C.MASTER`: Used to initialise the bus to master mode. diff --git a/firmware-and-api-reference/pycom/machine/pin.md b/firmware-and-api-reference/pycom/machine/pin.md index 344c47d..04bec46 100644 --- a/firmware-and-api-reference/pycom/machine/pin.md +++ b/firmware-and-api-reference/pycom/machine/pin.md @@ -21,7 +21,7 @@ p_in() # get value, 0 or 1 ## Constructors -### class machine.Pin\(id, ...\) +#### class machine.Pin\(id, ...\) Create a new Pin object associated with the string `id`. If additional arguments are given, they are used to initialise the pin. [See pin.init\(\)](pin.md#pin-init-mode-pull-alt) @@ -32,7 +32,7 @@ p = Pin('P10', mode=Pin.OUT, pull=None, alt=-1) ## Methods -### pin.init\(mode, pull, \* , alt\) +#### pin.init\(mode, pull, \* , alt\) Initialise the pin: @@ -48,18 +48,18 @@ Initialise the pin: Returns: `None`. -### pin.id\(\) +#### pin.id\(\) Get the pin id. -### pin.value\(\[value\]\) +#### pin.value\(\[value\]\) Get or set the digital logic level of the pin: * With no argument, return 0 or 1 depending on the logic level of the pin. * With value given, set the logic level of the pin. value can be anything that converts to a boolean. If it converts to True, the pin is set high, otherwise it is set low. -### pin\(\[value\]\) +#### pin\(\[value\]\) Pin objects are callable. The call method provides a \(fast\) shortcut to set and get the value of the pin. @@ -73,25 +73,25 @@ pin() # fast method to get the value See `pin.value()` for more details. -### pin.toggle\(\) +#### pin.toggle\(\) Toggle the value of the pin. -### pin.mode\(\[mode\]\) +#### pin.mode\(\[mode\]\) Get or set the pin mode. -### pin.pull\(\[pull\]\) +#### pin.pull\(\[pull\]\) Get or set the pin pull. -### pin.hold\(\[hold\]\) +#### pin.hold\(\[hold\]\) Get or set the pin hold. You can apply a hold to a pin by passing `True` \(or clear it by passing `False`\). When a pin is held, its value cannot be changed by using `Pin.value()` or `Pin.toggle()` until the hold is released. This Can be used to retain the pin state through a core reset and system reset triggered by watchdog time-out or Deep-sleep events. Only pins in the RTC power domain can retain their value through deep sleep or reset. These are: `P2, P3, P4, P6, P8, P9, P10, P13, P14, P15, P16, P17, P18, P19, P20, P21, P22, P23` -### pin.callback\(trigger, handler=None, arg=None\) +#### pin.callback\(trigger, handler=None, arg=None\) Set a callback to be triggered when the input level at the pin changes. @@ -124,7 +124,7 @@ For more information on how Pycom’s products handle interrupts, see [here](../ ## Attributes -### class pin.exp\_board +#### class pin.exp\_board Contains all Pin objects supported by the expansion board. Examples: @@ -134,7 +134,7 @@ led = Pin(Pin.exp_board.G16, mode=Pin.OUT) Pin.exp_board.G16.id() ``` -### class pin.module +#### class pin.module Contains all `Pin` objects supported by the module. Examples: diff --git a/firmware-and-api-reference/pycom/machine/rmt.md b/firmware-and-api-reference/pycom/machine/rmt.md index eac97aa..cd710e2 100644 --- a/firmware-and-api-reference/pycom/machine/rmt.md +++ b/firmware-and-api-reference/pycom/machine/rmt.md @@ -46,8 +46,8 @@ Construct an RMT object on the given channel. `channel` can be 2-7. With no addi | Channel | Resolution | Maximum Pulse Width | | :--- | :--- | :--- | -| 0 Used by on-board LED | | | -| 1 Used by `pycom.pulses_get()` | | | +| 0 | Used by on-board LED | | +| 1 | Used by `pycom.pulses_get()` | | | 2 | 100nS | 3.2768 ms | | 3 | 100nS | 3.2768 ms | | 4 | 1000nS | 32.768 ms | diff --git a/firmware-and-api-reference/pycom/machine/rtc.md b/firmware-and-api-reference/pycom/machine/rtc.md index 547a13d..7e00e13 100644 --- a/firmware-and-api-reference/pycom/machine/rtc.md +++ b/firmware-and-api-reference/pycom/machine/rtc.md @@ -14,7 +14,7 @@ print(rtc.now()) ## Constructors -### class machine.RTC\(id=0, ...\) +#### class machine.RTC\(id=0, ...\) Create an RTC object. See init for parameters of initialisation. @@ -25,7 +25,7 @@ rtc = RTC(id=0) ## Methods -### rtc.init\(datetime=None, source=RTC.INTERNAL\_RC\) +#### rtc.init\(datetime=None, source=RTC.INTERNAL\_RC\) Initialise the RTC. The arguments are: @@ -43,7 +43,7 @@ rtc.init((2017, 2, 28, 10, 30, 0, 0, 0)) `tzinfo` is ignored by this method. Use `time.timezone` to achieve similar results. {% endhint %} -### rtc.now\(\) +#### rtc.now\(\) Get get the current `datetime` tuple: @@ -52,7 +52,7 @@ Get get the current `datetime` tuple: rtc.now() ``` -### rtc.ntp\_sync\(server, \* , update\_period=3600\) +#### rtc.ntp\_sync\(server, \* , update\_period=3600\) Set up automatic fetch and update the time using NTP \(SNTP\). @@ -65,7 +65,7 @@ Can be used like: rtc.ntp_sync("pool.ntp.org") # this is an example. You can select a more specific server according to your geographical location ``` -### rtc.synced\(\) +#### rtc.synced\(\) Returns `True` if the last `ntp_sync` has been completed, `False` otherwise: diff --git a/firmware-and-api-reference/pycom/machine/sd.md b/firmware-and-api-reference/pycom/machine/sd.md index b3fbec4..a5ee55f 100644 --- a/firmware-and-api-reference/pycom/machine/sd.md +++ b/firmware-and-api-reference/pycom/machine/sd.md @@ -33,17 +33,17 @@ f.close() ## Constructors -### class machine.SD\(id, ...\) +#### class machine.SD\(id, ...\) Create a SD card object. See [`sd.init()`](sd.md#sd-init-id-0) for parameters if initialisation. ## Methods -### sd.init\(id=0\) +#### sd.init\(id=0\) Enable the SD card. -### sd.deinit\(\) +#### sd.deinit\(\) Disable the SD card. diff --git a/firmware-and-api-reference/pycom/machine/spi.md b/firmware-and-api-reference/pycom/machine/spi.md index c3e4f78..d4f1382 100644 --- a/firmware-and-api-reference/pycom/machine/spi.md +++ b/firmware-and-api-reference/pycom/machine/spi.md @@ -41,13 +41,13 @@ spi.write_readinto(bytes([0x01, 0x02, 0x03, 0x04, 0x05]), rbuf) # send a receive ## Constructors -### class machine.SPI\(id, ...\) +#### class machine.SPI\(id, ...\) Construct an SPI object on the given bus. `id` can be only 0. With no additional parameters, the SPI object is created but not initialised \(it has the settings from the last initialisation of the bus, if any\). If extra arguments are given, the bus is initialised. See init for parameters of initialisation. ## Methods -### spi.init\(mode, baudrate=1000000, \* , polarity=0, phase=0, bits=8, firstbit=SPI.MSB, pins=\(CLK, MOSI, MISO\)\) +#### spi.init\(mode, baudrate=1000000, \* , polarity=0, phase=0, bits=8, firstbit=SPI.MSB, pins=\(CLK, MOSI, MISO\)\) Initialise the SPI bus with the given parameters: @@ -59,23 +59,23 @@ Initialise the SPI bus with the given parameters: * `firstbit` can be SPI.MSB or SPI.LSB. * `pins` is an optional tuple with the pins to assign to the SPI bus. If the pins argument is not given the default pins will be selected \(`P10` as CLK,`P11` as MOSI and `P14` as MISO\). If pins is passed as None then no pin assignment will be made. -### spi.deinit\(\) +#### spi.deinit\(\) Turn off the SPI bus. -### spi.write\(buf\) +#### spi.write\(buf\) Write the data contained in `buf`. Returns the number of bytes written. -### spi.read\(nbytes, \* , write=0x00\) +#### spi.read\(nbytes, \* , write=0x00\) Read the `nbytes` while writing the data specified by `write`. Returns the bytes read. -### spi.readinto\(buf, \* , write=0x00\) +#### spi.readinto\(buf, \* , write=0x00\) Read into the buffer specified by `buf` while writing the data specified by `write`. Return the number of bytes read. -### spi.write\_readinto\(write\_buf, read\_buf\) +#### spi.write\_readinto\(write\_buf, read\_buf\) Write from `write_buf` and read into `read_buf`. Both buffers must have the same length. Returns the number of bytes written diff --git a/firmware-and-api-reference/pycom/machine/uart.md b/firmware-and-api-reference/pycom/machine/uart.md index 215211d..32ccbcd 100644 --- a/firmware-and-api-reference/pycom/machine/uart.md +++ b/firmware-and-api-reference/pycom/machine/uart.md @@ -61,7 +61,7 @@ uart.read(5) # read up to 5 bytes ## Constructors -### class machine.UART\(bus, ...\) +#### class machine.UART\(bus, ...\) Construct a UART object on the given `bus`. `bus` can be `0, 1 or 2`. If the `bus` is not given, the default one will be selected \(`0`\) or the selection will be made based on the given pins. @@ -71,7 +71,7 @@ On the GPy/FiPy UART2 is unavailable because it is used to communicate with the ## Methods -### uart.init\(baudrate=9600, bits=8, parity=None, stop=1, \* , timeout\_chars=2, pins=\(TXD, RXD, RTS, CTS\)\) +#### uart.init\(baudrate=9600, bits=8, parity=None, stop=1, \* , timeout\_chars=2, pins=\(TXD, RXD, RTS, CTS\)\) Initialise the UART bus with the given parameters: @@ -82,49 +82,49 @@ Initialise the UART bus with the given parameters: * `timeout_chars` Rx timeout defined in number of characters. The value given here will be multiplied by the time a characters takes to be transmitted at the configured `baudrate`. * `pins` is a 4 or 2 item list indicating the TXD, RXD, RTS and CTS pins \(in that order\). Any of the pins can be `None` if one wants the UART to operate with limited functionality. If the RTS pin is given the the RX pin must be given as well. The same applies to CTS. When no pins are given, then the default set of TXD \(P1\) and RXD \(P0\) pins is taken, and hardware flow control will be disabled. If `pins=None`, no pin assignment will be made. -### uart.deinit\(\) +#### uart.deinit\(\) Turn off the UART bus. -### uart.any\(\) +#### uart.any\(\) Return the number of characters available for reading. -### uart.read\(\[nbytes\]\) +#### uart.read\(\[nbytes\]\) Read characters. If `nbytes` is specified then read at most that many bytes. Return value: a bytes object containing the bytes read in. Returns `None` on timeout. -### uart.readall\(\) +#### uart.readall\(\) Read as much data as possible. Return value: a bytes object or `None` on timeout. -### uart.readinto\(buf\[, nbytes\]\) +#### uart.readinto\(buf\[, nbytes\]\) Read bytes into the `buf`. If `nbytes` is specified then read at most that many bytes. Otherwise, read at most `len(buf)` bytes. Return value: number of bytes read and stored into `buf` or `None` on timeout. -### uart.readline\(\) +#### uart.readline\(\) Read a line, ending in a newline character. If such a line exists, return is immediate. If the timeout elapses, all available data is returned regardless of whether a newline exists. Return value: the line read or `None` on timeout if no data is available. -### uart.write\(buf\) +#### uart.write\(buf\) Write the buffer of bytes to the bus. Return value: number of bytes written or None on timeout. -### uart.sendbreak\(\) +#### uart.sendbreak\(\) Send a break condition on the bus. This drives the bus low for a duration of 13 bits. Return value: `None`. -### uart.wait\_tx\_done\(timeout\_ms\) +#### uart.wait\_tx\_done\(timeout\_ms\) Waits at most `timeout_ms` for the last Tx transaction to complete. Returns `True` if all data has been sent and the TX buffer has no data in it, otherwise returns `False`. diff --git a/firmware-and-api-reference/pycom/machine/wdt.md b/firmware-and-api-reference/pycom/machine/wdt.md index 73019f0..aecf6b7 100644 --- a/firmware-and-api-reference/pycom/machine/wdt.md +++ b/firmware-and-api-reference/pycom/machine/wdt.md @@ -12,17 +12,17 @@ wdt.feed() ## Constructors -### class machine.WDT\(id=0, timeout\) +#### class machine.WDT\(id=0, timeout\) Create a WDT object and start it. The `id` can only be `0`. See the init method for the parameters of initialisation. ## Methods -### wdt.init\(timeout\) +#### wdt.init\(timeout\) Initialises the watchdog timer. The timeout must be given in milliseconds. Once it is running the WDT cannot be stopped but the timeout can be re-configured at any point in time. -### wdt.feed\(\) +#### wdt.feed\(\) Feed the WDT to prevent it from resetting the system. The application should place this call in a sensible place ensuring that the WDT is only fed after verifying that everything is functioning correctly. diff --git a/firmware-and-api-reference/pycom/network/bluetooth/README.md b/firmware-and-api-reference/pycom/network/bluetooth/README.md index 1353ae3..17c9447 100644 --- a/firmware-and-api-reference/pycom/network/bluetooth/README.md +++ b/firmware-and-api-reference/pycom/network/bluetooth/README.md @@ -43,7 +43,7 @@ GAP allows for devices to take various roles but generic flow works with devices ## Constructors -### class network.Bluetooth\(id=0, ...\) +#### class network.Bluetooth\(id=0, ...\) Create a Bluetooth object, and optionally configure it. See init for params of configuration. @@ -56,7 +56,7 @@ bluetooth = Bluetooth() ## Methods -### bluetooth.init\(id=0, mode=Bluetooth.BLE, antenna=None\) +#### bluetooth.init\(id=0, mode=Bluetooth.BLE, antenna=None\) * `id` Only one Bluetooth peripheral available so must always be 0 * `mode` currently the only supported mode is `Bluetooth.BLE` @@ -72,11 +72,11 @@ bluetooth = Bluetooth() Initialises and enables the Bluetooth radio in BLE mode. -### bluetooth.deinit\(\) +#### bluetooth.deinit\(\) Disables the Bluetooth radio. -### bluetooth.start\_scan\(timeout\) +#### bluetooth.start\_scan\(timeout\) Starts performing a scan listening for BLE devices sending advertisements. This function always returns immediately, the scanning will be performed on the background. The return value is `None`. After starting the scan the function `get_adv()` can be used to retrieve the advertisements messages from the FIFO. The internal FIFO has space to cache 16 advertisements. @@ -91,15 +91,15 @@ bluetooth.start_scan(10) # starts scanning and stop after 10 seconds bluetooth.start_scan(-1) # starts scanning indefinitely until bluetooth.stop_scan() is called ``` -### bluetooth.stop\_scan\(\) +#### bluetooth.stop\_scan\(\) Stops an ongoing scanning process. Returns `None`. -### bluetooth.isscanning\(\) +#### bluetooth.isscanning\(\) Returns `True` if a Bluetooth scan is in progress. `False` otherwise. -### bluetooth.get\_adv\(\) +#### bluetooth.get\_adv\(\) Gets an named tuple with the advertisement data received during the scanning. The tuple has the following structure: `(mac, addr_type, adv_type, rssi, data)` @@ -121,11 +121,11 @@ adv = bluetooth.get_adv() # ubinascii.hexlify(adv.mac) # convert hexadecimal to ascii ``` -### bluetooth.get\_advertisements\(\) +#### bluetooth.get\_advertisements\(\) Same as the `get_adv()` method, but this one returns a list with all the advertisements received. -### bluetooth.resolve\_adv\_data\(data, data\_type\) +#### bluetooth.resolve\_adv\_data\(data, data\_type\) Parses the advertisement data and returns the requested `data_type` if present. If the data type is not present, the function returns `None`. @@ -155,7 +155,7 @@ while bluetooth.isscanning(): print(ubinascii.hexlify(mfg_data)) ``` -### bluetooth.connect\(mac\_addr\) +#### bluetooth.connect\(mac\_addr\) Opens a BLE connection with the device specified by the `mac_addr` argument. This function blocks until the connection succeeds or fails. If the connections succeeds it returns a object of type `GATTCConnection`. @@ -163,7 +163,7 @@ Opens a BLE connection with the device specified by the `mac_addr` argument. Thi bluetooth.connect('112233eeddff') # mac address is accepted as a string ``` -### bluetooth.callback\(trigger=None, handler=None, arg=None\) +#### bluetooth.callback\(trigger=None, handler=None, arg=None\) Creates a callback that will be executed when any of the triggers occurs. The arguments are: @@ -173,7 +173,7 @@ Creates a callback that will be executed when any of the triggers occurs. The ar An example of how this may be used can be seen in the [`bluetooth.events()`](./#bluetooth-events) method. -### bluetooth.events\(\) +#### bluetooth.events\(\) Returns a value with bit flags identifying the events that have occurred since the last call. Calling this function clears the events. @@ -197,7 +197,7 @@ bluetooth.callback(trigger=Bluetooth.CLIENT_CONNECTED | Bluetooth.CLIENT_DISCONN bluetooth.advertise(True) ``` -### bluetooth.set\_advertisement\(\* , name=None, manufacturer\_data=None, service\_data=None, service\_uuid=None\) +#### bluetooth.set\_advertisement\(\* , name=None, manufacturer\_data=None, service\_data=None, service\_uuid=None\) Configure the data to be sent while advertising. If left with the default of `None` the data won’t be part of the advertisement message. @@ -214,11 +214,11 @@ Example: bluetooth.set_advertisement(name="advert", manufacturer_data="lopy_v1") ``` -### bluetooth.advertise\(\[Enable\]\) +#### bluetooth.advertise\(\[Enable\]\) Start or stop sending advertisements. The `set_advertisement()` method must have been called prior to this one. -### bluetooth.service\(uuid, \* , isprimary=True, nbr\_chars=1, start=True\) +#### bluetooth.service\(uuid, \* , isprimary=True, nbr\_chars=1, start=True\) Create a new service on the internal GATT server. Returns a object of type `BluetoothServerService`. @@ -233,7 +233,7 @@ The arguments are: bluetooth.service('abc123') ``` -### bluetooth.disconnect\_client\(\) +#### bluetooth.disconnect\_client\(\) Closes the BLE connection with the client. diff --git a/firmware-and-api-reference/pycom/network/bluetooth/gattccharacteristic.md b/firmware-and-api-reference/pycom/network/bluetooth/gattccharacteristic.md index 380652b..2640e3b 100644 --- a/firmware-and-api-reference/pycom/network/bluetooth/gattccharacteristic.md +++ b/firmware-and-api-reference/pycom/network/bluetooth/gattccharacteristic.md @@ -4,27 +4,29 @@ The smallest concept in GATT is the Characteristic, which encapsulates a single The following class allows you to manage characteristics from a Client. -## characteristic.uuid\(\) +## Methods + +#### characteristic.uuid\(\) Returns the UUID of the service. In the case of 16-bit or 32-bit long UUIDs, the value returned is an integer, but for 128-bit long UUIDs the value returned is a bytes object. -## characteristic.instance\(\) +#### characteristic.instance\(\) Returns the instance ID of the service. -## characteristic.properties\(\) +#### characteristic.properties\(\) Returns an integer indicating the properties of the characteristic. Properties are represented by bit values that can be OR-ed together. See the constants section for more details. -## characteristic.read\(\) +#### characteristic.read\(\) Read the value of the characteristic, sending a request to the GATT server. Returns a bytes object representing the characteristic value. -## characteristic.value\(\) +#### characteristic.value\(\) Returns the locally stored value of the characteristic without sending a read request to the GATT server. If the characteristic value hasn't been read from the GATT server yet, the value returned will be 0. -## characteristic.write\(value\) +#### characteristic.write\(value\) Writes the given value on the characteristic. For now it only accepts bytes object representing the value to be written. @@ -32,7 +34,7 @@ Writes the given value on the characteristic. For now it only accepts bytes obje characteristic.write(b'x0f') ``` -## characteristic.callback\(trigger=None, handler=None, arg=None\) +#### characteristic.callback\(trigger=None, handler=None, arg=None\) This method allows to register for notifications on the characteristic. diff --git a/firmware-and-api-reference/pycom/network/bluetooth/gattcconnection.md b/firmware-and-api-reference/pycom/network/bluetooth/gattcconnection.md index c787c7f..c4523e0 100644 --- a/firmware-and-api-reference/pycom/network/bluetooth/gattcconnection.md +++ b/firmware-and-api-reference/pycom/network/bluetooth/gattcconnection.md @@ -2,11 +2,13 @@ The GATT Client is the device that requests data from the server, otherwise known as the master device \(commonly this might be a phone/tablet/PC\). All transactions are initiated by the master, which receives a response from the slave. -## connection.disconnect\(\) +## Methods + +#### connection.disconnect\(\) Closes the BLE connection. Returns `None`. -## connection.isconnected\(\) +#### connection.isconnected\(\) Returns `True` if the connection is still open. `False` otherwise. @@ -33,7 +35,7 @@ while True: print("Connected to device with addr = {}".format(ubinascii.hexlify(adv.mac))) ``` -## connection.services\(\) +#### connection.services\(\) Performs a service search on the connected BLE peripheral \(server\) a returns a list containing objects of the class GATTCService if the search succeeds. diff --git a/firmware-and-api-reference/pycom/network/bluetooth/gattccservice.md b/firmware-and-api-reference/pycom/network/bluetooth/gattccservice.md index 7813a39..dd5b0b5 100644 --- a/firmware-and-api-reference/pycom/network/bluetooth/gattccservice.md +++ b/firmware-and-api-reference/pycom/network/bluetooth/gattccservice.md @@ -4,19 +4,21 @@ Services are used to categorise data up into specific chunks of data known as ch The following class allows control over Client services. -## service.isprimary\(\) +## Methods + +#### service.isprimary\(\) Returns `True` if the service is a primary one. `False` otherwise. -## service.uuid\(\) +#### service.uuid\(\) Returns the UUID of the service. In the case of 16-bit or 32-bit long UUIDs, the value returned is an integer, but for 128-bit long UUIDs the value returned is a bytes object. -## service.instance\(\) +#### service.instance\(\) Returns the instance ID of the service. -## service.characteristics\(\) +#### service.characteristics\(\) Performs a get characteristics request on the connected BLE peripheral a returns a list containing objects of the class GATTCCharacteristic if the request succeeds. diff --git a/firmware-and-api-reference/pycom/network/bluetooth/gattscharacteristic.md b/firmware-and-api-reference/pycom/network/bluetooth/gattscharacteristic.md index 8861c86..a8f2b7e 100644 --- a/firmware-and-api-reference/pycom/network/bluetooth/gattscharacteristic.md +++ b/firmware-and-api-reference/pycom/network/bluetooth/gattscharacteristic.md @@ -4,7 +4,9 @@ The smallest concept in GATT is the Characteristic, which encapsulates a single The following class allows you to manage Server characteristics. -## characteristic.value\(\[value\]\) +## Methods + +#### characteristic.value\(\[value\]\) Gets or sets the value of the characteristic. Can take an integer, a string or a bytes object. @@ -13,7 +15,7 @@ characteristic.value(123) # set characteristic value to an integer with the valu characteristic.value() # get characteristic value ``` -## characteristic.callback\(trigger=None, handler=None, arg=None\) +#### characteristic.callback\(trigger=None, handler=None, arg=None\) Creates a callback that will be executed when any of the triggers occurs. The arguments are: @@ -23,7 +25,7 @@ Creates a callback that will be executed when any of the triggers occurs. The ar An example of how this could be implemented can be seen in the [`characteristic.events()` ](gattscharacteristic.md#characteristic-events)section. -## characteristic.events\(\) +#### characteristic.events\(\) Returns a value with bit flags identifying the events that have occurred since the last call. Calling this function clears the events. diff --git a/firmware-and-api-reference/pycom/network/bluetooth/gattsservice.md b/firmware-and-api-reference/pycom/network/bluetooth/gattsservice.md index 70e404a..31ec57c 100644 --- a/firmware-and-api-reference/pycom/network/bluetooth/gattsservice.md +++ b/firmware-and-api-reference/pycom/network/bluetooth/gattsservice.md @@ -6,15 +6,17 @@ Services are used to categorise data up into specific chunks of data known as ch The following class allows control over Server services. -## service.start\(\) +## Methods + +#### service.start\(\) Starts the service if not already started. -## service.stop\(\) +#### service.stop\(\) Stops the service if previously started. -## service.characteristic\(uuid, \* , permissions, properties, value\) +#### service.characteristic\(uuid, \* , permissions, properties, value\) Creates a new characteristic on the service. Returns an object of the class `GATTSCharacteristic`. The arguments are: diff --git a/firmware-and-api-reference/pycom/network/lora.md b/firmware-and-api-reference/pycom/network/lora.md index 3584248..c9396f3 100644 --- a/firmware-and-api-reference/pycom/network/lora.md +++ b/firmware-and-api-reference/pycom/network/lora.md @@ -51,7 +51,7 @@ For various other complete LoRa examples, check here for additional examples. ## Constructors -### class network.LoRa\(id=0, ...\) +#### class network.LoRa\(id=0, ...\) Create and configure a LoRa object. See init for params of configuration. @@ -61,7 +61,7 @@ lora = LoRa(mode=LoRa.LORAWAN, region=LoRa.EU868) ## Methods -### lora.init\(mode, \* ,region=LoRa.EU868, frequency=868000000, tx\_power=14, bandwidth=LoRa.BW\_125KHZ, sf=7, preamble=8, coding\_rate=LoRa.CODING\_4\_5, power\_mode=LoRa.ALWAYS\_ON, tx\_iq=False, rx\_iq=False, adr=False, public=True, tx\_retries=1, device\_class=LoRa.CLASS\_A\) +#### lora.init\(mode, \* ,region=LoRa.EU868, frequency=868000000, tx\_power=14, bandwidth=LoRa.BW\_125KHZ, sf=7, preamble=8, coding\_rate=LoRa.CODING\_4\_5, power\_mode=LoRa.ALWAYS\_ON, tx\_iq=False, rx\_iq=False, adr=False, public=True, tx\_retries=1, device\_class=LoRa.CLASS\_A\) This method is used to set the LoRa subsystem configuration and to specific raw LoRa or LoRaWAN. @@ -101,7 +101,7 @@ or lora.init(mode=LoRa.LORAWAN) ``` -### lora.join\(activation, auth, \* ,timeout=None, dr=None\) +#### lora.join\(activation, auth, \* ,timeout=None, dr=None\) Join a LoRaWAN network. Internally the stack will automatically retry every 15 seconds until a Join Accept message is received. @@ -178,7 +178,7 @@ app_swkey = ubinascii.unhexlify('2B7E151628AED2A6ABF7158809CF4F3C') lora.join(activation=LoRa.ABP, auth=(dev_addr, nwk_swkey, app_swkey)) ``` -### lora.bandwidth\(\[bandwidth\]\) +#### lora.bandwidth\(\[bandwidth\]\) Get or set the bandwidth in raw LoRa mode \(`LoRa.LORA`\). Can be either `LoRa.BW_125KHZ` \(0\), `LoRa.BW_250KHZ` \(1\) or `LoRa.BW_500KHZ` \(2\): @@ -190,7 +190,7 @@ lora.bandwidth() lora.bandwidth(LoRa.BW_125KHZ) ``` -### lora.frequency\(\[frequency\]\) +#### lora.frequency\(\[frequency\]\) Get or set the frequency in raw LoRa mode \(`LoRa.LORA`\). The allowed range is between `863000000` and `870000000` Hz for the 868 MHz band version or between `902000000` and `928000000` Hz for the 915 MHz band version. @@ -202,7 +202,7 @@ lora.frequency() lora.frequency(868000000) ``` -### lora.coding\_rate\(\[coding\_rate\]\) +#### lora.coding\_rate\(\[coding\_rate\]\) Get or set the coding rate in raw LoRa mode \(`LoRa.LORA`\). The allowed values are: `LoRa.CODING_4_5` \(1\), `LoRa.CODING_4_6` \(2\), `LoRa.CODING_4_7` \(3\) and `LoRa.CODING_4_8` \(4\). @@ -214,7 +214,7 @@ lora.coding_rate() lora.coding_rate(LoRa.CODING_4_5) ``` -### lora.preamble\(\[preamble\]\) +#### lora.preamble\(\[preamble\]\) Get or set the number of preamble symbols in raw LoRa mode \(`LoRa.LORA`\): @@ -226,7 +226,7 @@ lora.preamble() lora.preamble(LoRa.CODING_4_5) ``` -### lora.sf\(\[sf\]\) +#### lora.sf\(\[sf\]\) Get or set the spreading factor value in raw LoRa mode \(`LoRa.LORA`\). The minimum value is 7 and the maximum is 12: @@ -238,11 +238,11 @@ lora.sf() lora.sf(7) ``` -### lora.power\_mode\(\[power\_mode\]\) +#### lora.power\_mode\(\[power\_mode\]\) Get or set the power mode in raw LoRa mode \(`LoRa.LORA`\). The accepted values are: `LoRa.ALWAYS_ON`, `LoRa.TX_ONLY`, and `LoRa.SLEEP`: -### lora.stats\(\) +#### lora.stats\(\) Return a named tuple with useful information from the last received LoRa or LoRaWAN packet. The named tuple has the following form: @@ -267,11 +267,11 @@ Where: * `tx_counter` is the number of packets transmitted. * `tx_frequency` is the frequency used for the last transmission. -### lora.has\_joined\(\) +#### lora.has\_joined\(\) Returns `True` if a LoRaWAN network has been joined. `False` otherwise. -### lora.add\_channel\(index, \* , frequency, dr\_min, dr\_max\) +#### lora.add\_channel\(index, \* , frequency, dr\_min, dr\_max\) Add a LoRaWAN channel on the specified `index`. If there’s already a channel with that index it will be replaced with the new one. @@ -288,7 +288,7 @@ Examples: lora.add_channel(index=0, frequency=868000000, dr_min=5, dr_max=6) ``` -### lora.remove\_channel\(index\) +#### lora.remove\_channel\(index\) Removes the channel from the specified `index`. On the 868MHz band the channels 0 to 2 cannot be removed, they can only be replaced by other channels using the `lora.add_channel` method. A way to remove all channels except for one is to add the same channel, 3 times on indexes 0, 1 and 2. An example can be seen below: @@ -298,11 +298,11 @@ lora.remove_channel() On the 915MHz band there are no restrictions around this. -### lora.mac\(\) +#### lora.mac\(\) Returns a byte object with the 8-Byte MAC address of the LoRa radio. -### lora.callback\(trigger, handler=None, arg=None\) +#### lora.callback\(trigger, handler=None, arg=None\) Specify a callback handler for the LoRa radio. The `trigger` types are `LoRa.RX_PACKET_EVENT`, `LoRa.TX_PACKET_EVENT`, and `LoRa.TX_FAILED_EVENT` @@ -310,7 +310,7 @@ The `LoRa.RX_PACKET_EVENT` event is raised for every received packet. The `LoRa. An example of how this callback functions can be seen the in method [`lora.events()`](lora.md#lora-events). -### lora.ischannel\_free\(rssi\_threshold\) +#### lora.ischannel\_free\(rssi\_threshold\) This method is used to check for radio activity on the current LoRa channel, and if the `rssi` of the measured activity is lower than the `rssi_threshold` given, the return value will be `True`, otherwise `False`. Example: @@ -318,7 +318,7 @@ This method is used to check for radio activity on the current LoRa channel, and lora.ischannel_free(-100) ``` -### lora.set\_battery\_level\(level\) +#### lora.set\_battery\_level\(level\) Set the battery level value that will be sent when the LoRaWAN MAC command that retrieves the battery level is received. This command is sent by the network and handled automatically by the LoRaWAN stack. The values should be according to the LoRaWAN specification: @@ -330,7 +330,7 @@ Set the battery level value that will be sent when the LoRaWAN MAC command that lora.set_battery_level(127) # 50% battery ``` -### lora.events\(\) +#### lora.events\(\) This method returns a value with bits sets \(if any\) indicating the events that have triggered the callback. Please note that by calling this function the internal events registry is cleared automatically, therefore calling it immediately for a second time will most likely return a value of 0. @@ -347,7 +347,7 @@ def lora_cb(lora): lora.callback(trigger=(LoRa.RX_PACKET_EVENT | LoRa.TX_PACKET_EVENT), handler=lora_cb) ``` -### lora.nvram\_save\(\) +#### lora.nvram\_save\(\) Save the LoRaWAN state \(joined status, network keys, packet counters, etc\) in non-volatile memory in order to be able to restore the state when coming out of deepsleep or a power cycle. @@ -355,7 +355,7 @@ Save the LoRaWAN state \(joined status, network keys, packet counters, etc\) in lora.nvram_save() ``` -### lora.nvram\_restore\(\) +#### lora.nvram\_restore\(\) Restore the LoRaWAN state \(joined status, network keys, packet counters, etc\) from non-volatile memory. State must have been previously stored with a call to `nvram_save` before entering deepsleep. This is useful to be able to send a LoRaWAN message immediately after coming out of deepsleep without having to join the network again. This can only be used if the current region matches the one saved. @@ -363,7 +363,7 @@ Restore the LoRaWAN state \(joined status, network keys, packet counters, etc\) lora.nvram_restore() ``` -### lora.nvram\_erase\(\) +#### lora.nvram\_erase\(\) Remove the LoRaWAN state \(joined status, network keys, packet counters, etc\) from non-volatile memory. @@ -395,7 +395,7 @@ And they must be created after initialising the LoRa network card. LoRa sockets support the following standard methods from the socket module: -### socket.close\(\) +#### socket.close\(\) Usage: @@ -403,7 +403,7 @@ Usage: s.close() ``` -### socket.bind\(port\_number\) +#### socket.bind\(port\_number\) Usage: @@ -415,7 +415,7 @@ s.bind(1) The `bind()` method is only applicable when the radio is configured in `LoRa.LORAWAN` mode. {% endhint %} -### socket.send\(bytes\) +#### socket.send\(bytes\) Usage: @@ -429,7 +429,7 @@ or s.send('Hello') ``` -### socket.recv\(bufsize\) +#### socket.recv\(bufsize\) Usage: @@ -437,7 +437,7 @@ Usage: s.recv(128) ``` -### socket.recvfrom\(bufsize\) +#### socket.recvfrom\(bufsize\) This method is useful to know the destination port number of the message received. Returns a tuple of the form: `(data, port)` @@ -447,7 +447,7 @@ Usage: s.recvfrom(128) ``` -### socket.setsockopt\(level, optname, value\) +#### socket.setsockopt\(level, optname, value\) Set the value of the given socket option. The needed symbolic constants are defined in the socket module \(`SO_*` etc.\). In the case of LoRa the values are always integers. Examples: @@ -466,7 +466,7 @@ s.setsockopt(socket.SOL_LORA, socket.SO_CONFIRMED, True) Socket options are only applicable when the LoRa radio is used in LoRa.LORAWAN mode. When using the radio in LoRa.LORA mode, use the class methods to change the spreading factor, bandwidth and coding rate to the desired values. {% endhint %} -### socket.settimeout\(value\) +#### socket.settimeout\(value\) Sets the socket timeout value in seconds. Accepts floating point values. @@ -476,7 +476,7 @@ Usage: s.settimeout(5.5) ``` -### socket.setblocking\(flag\) +#### socket.setblocking\(flag\) Usage: diff --git a/firmware-and-api-reference/pycom/network/lte.md b/firmware-and-api-reference/pycom/network/lte.md index 68263fa..460b521 100644 --- a/firmware-and-api-reference/pycom/network/lte.md +++ b/firmware-and-api-reference/pycom/network/lte.md @@ -23,7 +23,7 @@ The AT commands for the Sequans Monarch modem on the GPy/FiPy are available in a ## Constructors -### class network.LTE\(id=0, ...\) +#### class network.LTE\(id=0, ...\) Create and configure a LTE object. See init for params of configuration. @@ -34,27 +34,27 @@ lte = LTE() ## Methods -### lte.init\(\*, carrier=None\) +#### lte.init\(\*, carrier=None\) This method is used to set up the LTE subsystem. After a `deinit()` this method can take several seconds to return waiting for the LTE modem to start-up. Optionally specify a carrier name. The available options are: `verizon, at&t, standard`. `standard` is generic for any carrier, and it's also the option used when no arguments are given. -### lte.deinit\(\) +#### lte.deinit\(\) Disables LTE modem completely. This reduces the power consumption to the minimum. Call this before entering deepsleep. -### lte.attach\(\*, band=None\) +#### lte.attach\(\*, band=None\) Enable radio functionality and attach to the LTE Cat M1 network authorised by the inserted SIM card. Optionally specify the band to scan for networks. If no band \(or `None`\) is specified, all 6 bands will be scanned. The possible values for the band are: `3, 4, 12, 13, 20 and 28`. -### lte.isattached\(\) +#### lte.isattached\(\) Returns `True` if the cellular mode is attached to the network. `False` otherwise. -### lte.dettach\(\) +#### lte.dettach\(\) Detach the modem from the LTE Cat M1 and disable the radio functionality. -### lte.connect\(\*, cid=1\) +#### lte.connect\(\*, cid=1\) Start a data session and obtain and IP address. Optionally specify a CID \(Connection ID\) for the data session. The arguments are: @@ -81,15 +81,15 @@ while not lte.isconnected(): # Now use sockets as usual... ``` -### lte.isconnected\(\) +#### lte.isconnected\(\) Returns `True` if there is an active LTE data session and IP address has been obtained. `False` otherwise. -### lte.disconnect\(\) +#### lte.disconnect\(\) End the data session with the network. -### lte.send\_at\_cmd\(cmd\) +#### lte.send\_at\_cmd\(cmd\) Send an AT command directly to the modem. Returns the raw response from the modem as a string object. **IMPORTANT:** If a data session is active \(i.e. the modem is _connected_\), sending the AT commands requires to pause and then resume the data session. This is all done automatically, but makes the whole request take around 2.5 seconds. @@ -111,15 +111,15 @@ send_at_cmd_pretty('AT!="showphy"') # get the PHY status send_at_cmd_pretty('AT!="fsm"') # get the System FSM ``` -### lte.imei\(\) +#### lte.imei\(\) Returns a string object with the IMEI number of the LTE modem. -### lte.iccid\(\) +#### lte.iccid\(\) Returns a string object with the ICCID number of the SIM card. -### lte.reset\(\) +#### lte.reset\(\) Perform a hardware reset on the cellular modem. This function can take up to 5 seconds to return as it waits for the modem to shutdown and reboot. diff --git a/firmware-and-api-reference/pycom/network/server.md b/firmware-and-api-reference/pycom/network/server.md index 2b6e1d8..a6c5e19 100644 --- a/firmware-and-api-reference/pycom/network/server.md +++ b/firmware-and-api-reference/pycom/network/server.md @@ -26,25 +26,25 @@ server.isrunning() # check whether the server is running or not ## Constructors -### class network.Server\(id, ...\) +#### class network.Server\(id, ...\) Create a server instance, see `init` for parameters of initialisation. ## Methods -### server.init\(\* , login=\('micro', 'python'\), timeout=300\) +#### 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. -### server.deinit\(\) +#### server.deinit\(\) Stop the server. -### server.timeout\(\[timeout\_in\_seconds\]\) +#### server.timeout\(\[timeout\_in\_seconds\]\) Get or set the server timeout. -### server.isrunning\(\) +#### server.isrunning\(\) Returns `True` if the server is running \(connected or accepting connections\), `False` otherwise. diff --git a/firmware-and-api-reference/pycom/network/sigfox.md b/firmware-and-api-reference/pycom/network/sigfox.md index ceece16..27bc7cc 100644 --- a/firmware-and-api-reference/pycom/network/sigfox.md +++ b/firmware-and-api-reference/pycom/network/sigfox.md @@ -46,7 +46,7 @@ Please ensure that there is an antenna connected to your device before sending/r ## Constructors -### class network.Sigfox\(id=0, ...\) +#### class network.Sigfox\(id=0, ...\) Create and configure a Sigfox object. See init for params of configuration. Examples: @@ -64,7 +64,7 @@ sigfox = Sigfox(mode=Sigfox.FSK, frequency=912000000) ## Methods -### sigfox.init\(mode=Sigfox.SIGFOX, rcz=Sigfox.RCZ1, \* , frequency=None\) +#### sigfox.init\(mode=Sigfox.SIGFOX, rcz=Sigfox.RCZ1, \* , frequency=None\) Set the Sigfox radio configuration. @@ -78,19 +78,19 @@ The arguments are: The SiPy comes in 2 different hardware flavours: a +14dBm Tx power version which can only work with `RCZ1` and `RCZ3` and a +22dBm version which works exclusively on `RCZ2` and `RCZ4`. {% endhint %} -### sigfox.mac\(\) +#### sigfox.mac\(\) Returns a byte object with the 8-Byte MAC address of the Sigfox radio. -### sigfox.id\(\) +#### sigfox.id\(\) Returns a byte object with the 4-Byte bytes object with the Sigfox ID. -### sigfox.rssi\(\) +#### sigfox.rssi\(\) Returns a signed integer with indicating the signal strength value of the last received packet. -### sigfox.pac\(\) +#### sigfox.pac\(\) Returns a byte object with the 8-Byte bytes object with the Sigfox PAC. @@ -102,11 +102,11 @@ print(ubinascii.hexlify(sigfox.mac())) ``` {% endhint %} -### sigfox.frequencies\(\) +#### sigfox.frequencies\(\) Returns a tuple of the form: `(uplink_frequency_hz, downlink_frequency_hz)` -### sigfox.public\_key\(\[public\]\) +#### sigfox.public\_key\(\[public\]\) Sets or gets the public key flag. When called passing a `True` value the Sigfox public key will be used to encrypt the packets. Calling it without arguments returns the state of the flag. @@ -142,11 +142,11 @@ And they must be created after initialising the Sigfox network card. Sigfox sockets support the following standard methods from the `socket` module: -### socket.close\(\) +#### socket.close\(\) Use it to close an existing socket. -### socket.send\(bytes\) +#### socket.send\(bytes\) In Sigfox mode the maximum data size is 12 bytes. In FSK the maximum is 64. @@ -158,7 +158,7 @@ s.send(bytes([1, 2, 3])) s.send('Hello') ``` -### socket.recv\(bufsize\) +#### socket.recv\(bufsize\) This method can be used to receive a Sigfox downlink or FSK message. @@ -167,7 +167,7 @@ This method can be used to receive a Sigfox downlink or FSK message. s.recv(64) ``` -### socket.setsockopt\(level, optname, value\) +#### socket.setsockopt\(level, optname, value\) Set the value of the given socket option. The needed symbolic constants are defined in the socket module \(`SO_*` etc.\). In the case of Sigfox the values are always an integer. Examples: diff --git a/firmware-and-api-reference/pycom/network/wlan.md b/firmware-and-api-reference/pycom/network/wlan.md index e835af6..07bc363 100644 --- a/firmware-and-api-reference/pycom/network/wlan.md +++ b/firmware-and-api-reference/pycom/network/wlan.md @@ -34,7 +34,7 @@ print(wlan.ifconfig()) ## Constructors -### class network.WLAN\(id=0, ...\) +#### class network.WLAN\(id=0, ...\) Create a WLAN object, and optionally configure it. See [`init`](wlan.md#wlan-init-mode-ssid-none-auth-none-channel-1-antenna-none-power_save-false-hidden-false) for params of configuration. @@ -44,7 +44,7 @@ The WLAN constructor is special in the sense that if no arguments besides the `i ## Methods -### wlan.init\(mode, \* , ssid=None, auth=None, channel=1, antenna=None, power\_save=False, hidden=False\) +#### wlan.init\(mode, \* , ssid=None, auth=None, channel=1, antenna=None, power\_save=False, hidden=False\) Set or get the WiFi network processor configuration. @@ -76,11 +76,11 @@ or wlan.init(mode=WLAN.STA) ``` -### wlan.deinit\(\) +#### wlan.deinit\(\) Disables the WiFi radio. -### wlan.connect\(ssid, \* , auth=None, bssid=None, timeout=None, ca\_certs=None, keyfile=None, certfile=None, identity=None\) +#### wlan.connect\(ssid, \* , auth=None, bssid=None, timeout=None, ca\_certs=None, keyfile=None, certfile=None, identity=None\) Connect to a wifi access point using the given SSID, and other security parameters. @@ -98,19 +98,19 @@ Connect to a wifi access point using the given SSID, and other security paramete The ESP32 only handles certificates with `pkcs8` format \(but not the "Traditional SSLeay RSAPrivateKey" format\). The private key should be RSA coded with 2048 bits at maximum. {% endhint %} -### wlan.scan\(\) +#### wlan.scan\(\) Performs a network scan and returns a list of named tuples with `(ssid, bssid, sec, channel, rssi)`. Note that channel is always `None` since this info is not provided by the WiPy. -### wlan.disconnect\(\) +#### wlan.disconnect\(\) Disconnect from the WiFi access point. -### wlan.isconnected\(\) +#### wlan.isconnected\(\) In case of STA mode, returns `True` if connected to a WiFi access point and has a valid IP address. In AP mode returns `True` when a station is connected, `False` otherwise. -### wlan.ifconfig\(id=0, config=\['dhcp' or configtuple\]\) +#### wlan.ifconfig\(id=0, config=\['dhcp' or configtuple\]\) When `id` is 0, the configuration will be get/set on the Station interface. When `id` is 1 the configuration will be done for the AP interface. @@ -124,27 +124,27 @@ If the 4-tuple config is given then a static IP is configured. For instance: wlan.ifconfig(config=('192.168.0.4', '255.255.255.0', '192.168.0.1', '8.8.8.8')) ``` -### wlan.mode\(\[mode\]\) +#### wlan.mode\(\[mode\]\) Get or set the WLAN mode. -### wlan.ssid\(\[ssid\]\) +#### wlan.ssid\(\[ssid\]\) Get or set the SSID when in AP mode. -### wlan.auth\(\[auth\]\) +#### wlan.auth\(\[auth\]\) Get or set the authentication type when in AP mode. -### wlan.channel\(\[channel\]\) +#### wlan.channel\(\[channel\]\) Get or set the channel \(only applicable in AP mode\). -### wlan.antenna\(\[antenna\]\) +#### wlan.antenna\(\[antenna\]\) Get or set the antenna type \(external or internal\). -### wlan.mac\(\) +#### wlan.mac\(\) Get a 6-byte long `bytes` object with the WiFI MAC address. diff --git a/firmware-and-api-reference/pycom/pycom.md b/firmware-and-api-reference/pycom/pycom.md index 335e6f4..8d18606 100644 --- a/firmware-and-api-reference/pycom/pycom.md +++ b/firmware-and-api-reference/pycom/pycom.md @@ -15,19 +15,19 @@ pycom.rgbled(0xff00) # make the LED light up in green color ## Functions -### pycom.heartbeat\(\[enable\]\) +#### pycom.heartbeat\(\[enable\]\) Get or set the state \(enabled or disabled\) of the heartbeat LED. Accepts and returns boolean values \(`True` or `False`\). -### pycom.heartbeat\_on\_boot\(\[enable\]\) +#### pycom.heartbeat\_on\_boot\(\[enable\]\) Allows you permanently disable or enable the heartbeat LED. Once this setting is set, it will persist between reboots. Note, this only comes into effect on the next boot, it does not stop the already running heartbeat. -### pycom.rgbled\(color\) +#### pycom.rgbled\(color\) Set the colour of the RGB LED. The colour is specified as 24 bit value representing red, green and blue, where the red colour is represented by the 8 most significant bits. For instance, passing the value `0x00FF00` will light up the LED in a very bright green. -### pycom.nvs\_set\(key, value\) +#### pycom.nvs\_set\(key, value\) Set the value of the specified key in the NVRAM memory area of the external flash. Data stored here is preserved across resets and power cycles. Value can only take 32-bit integers at the moment. Example: @@ -38,7 +38,7 @@ pycom.nvs_set('temp', 25) pycom.nvs_set('count', 10) ``` -### pycom.nvs\_get\(key\) +#### pycom.nvs\_get\(key\) Get the value the specified key from the NVRAM memory area of the external flash. Example: @@ -50,15 +50,15 @@ pulses = pycom.nvs_get('count') If a non-existing key is given the returned value will be `None`. -### pycom.nvs\_erase\(key\) +#### pycom.nvs\_erase\(key\) Erase the given key from the NVRAM memory area. -### pycom.nvs\_erase\_all\(\) +#### pycom.nvs\_erase\_all\(\) Erase the entire NVRAM memory area. -### pycom.wifi\_on\_boot\(\[enable\]\) +#### pycom.wifi\_on\_boot\(\[enable\]\) Get or set the WiFi on boot flag. When this flag is set to `True`, the AP with the default SSID \(`lopy-wlan-xxx` for example\) will be enabled as part of the boot process. If the flag is set to False, the module will boot with WiFi disabled until it's enabled by the script via the `WLAN` class. This setting is stored in non-volatile memory which preserves it across resets and power cycles. Example: @@ -69,7 +69,7 @@ pycom.wifi_on_boot(True) # enable WiFi on boot pycom.wifi_on_boot() # get the wifi on boot flag ``` -### pycom.wdt\_on\_boot\(\[enable\]\) +#### pycom.wdt\_on\_boot\(\[enable\]\) Enables the WDT at boot time with the timeout in ms set by the function `wdt_on_boot_timeout`. If this flag is set, the application needs to reconfigure the WDT with a new timeout and feed it regularly to avoid a reset. @@ -80,7 +80,7 @@ pycom.wdt_on_boot(True) # enable WDT on boot pycom.wdt_on_boot() # get the WDT on boot flag ``` -### pycom.wdt\_on\_boot\_timeout\(\[timeout\]\) +#### pycom.wdt\_on\_boot\_timeout\(\[timeout\]\) Sets or gets the WDT on boot timeout in milliseconds. The minimum value is 5000 ms. @@ -91,7 +91,7 @@ pycom.wdt_on_boot_timeout(10000) # set the timeout to 5000ms pycom.wdt_on_boot_timeout() # get the WDT timeout value ``` -### pycom.pulses\_get\(pin, timeout\) +#### pycom.pulses\_get\(pin, timeout\) Return a list of pulses at `pin`. The methods scans for transitions at `pin` and returns a list of tuples, each telling the pin value and the duration in microseconds of that value. `pin` is a pin object, which must have set to `INP` or `OPEN_DRAIN` mode. The scan stops if not transitions occurs within `timeout` milliseconds. @@ -110,11 +110,11 @@ pin(1) data = pulses_get(pin, 100) ``` -### pycom.ota\_start\(\) +#### pycom.ota\_start\(\) -### pycom.ota\_write\(buffer\) +#### pycom.ota\_write\(buffer\) -### pycom.ota\_finish\(\) +#### pycom.ota\_finish\(\) Perform a firmware update. These methods are internally used by a firmware update though FTP. The update starts with a call to `ota_start()`, followed by a series of calls to `ota_write(buffer)`, and is terminated with `ota_finish()`. After reset, the new image gets active. `buffer` shall hold the image data to be written, in arbitrary sizes. A block size of 4096 is recommended. diff --git a/pybytes/add-device/README.md b/pybytes/add-device/README.md index a6acb01..7173e5d 100644 --- a/pybytes/add-device/README.md +++ b/pybytes/add-device/README.md @@ -34,11 +34,11 @@ At the end of the "Add Device" wizard, Pybytes will give you two options for you Select how you would like to connect your device to Pybytes: -1. [CONNECT YOUR DEVICE _QUICKLY \(RECOMMENDED\)_](quick.md) +1. [Connect your device quickly \(Recommended\)](quick.md) {% page-ref page="quick.md" %} -2. [CONNECT YOUR DEVICE _BY FLASHING PYBYTES LIBRARY_](flash.md) +2. [Connect your device by flashing Pybytes Library](flash.md) {% page-ref page="flash.md" %} diff --git a/pytrack-pysense-pyscan/apireference/pyscan.md b/pytrack-pysense-pyscan/apireference/pyscan.md index c8af681..61df15c 100644 --- a/pytrack-pysense-pyscan/apireference/pyscan.md +++ b/pytrack-pysense-pyscan/apireference/pyscan.md @@ -139,3 +139,9 @@ Prints the bytes in `data` array in hexadecimal format, separated by spaces usin * `data` The array to be printed * `len` The number of bytes to print +{% hint style="info" %} +Please note that more functionality is being added weekly to these libraries. If a required feature is not available, feel free to contribute with a pull request at the [Libraries GitHub repository](https://github.com/pycom/pycom-libraries) +{% endhint %} + + + diff --git a/pytrack-pysense-pyscan/apireference/pysense.md b/pytrack-pysense-pyscan/apireference/pysense.md index 66345ba..df4d6be 100644 --- a/pytrack-pysense-pyscan/apireference/pysense.md +++ b/pytrack-pysense-pyscan/apireference/pysense.md @@ -104,3 +104,5 @@ The following arguments may be passed into the constructor. Please note that more functionality is being added weekly to these libraries. If a required feature is not available, feel free to contribute with a pull request at the [Libraries GitHub repository](https://github.com/pycom/pycom-libraries) {% endhint %} + + diff --git a/tutorials-and-examples/all/rmt.md b/tutorials-and-examples/all/rmt.md index b92af88..a44bc50 100644 --- a/tutorials-and-examples/all/rmt.md +++ b/tutorials-and-examples/all/rmt.md @@ -8,8 +8,8 @@ The RMT has 7 channels, of which 5 are available and can be mapped to any GPIO p | Channel | Resolution | Maximum Pulse Width | | :--- | :--- | :--- | -| 0 Used by on-board LED | | | -| 1 Used by `pycom.pulses_get()` | | | +| 0 | Used by on-board LED | | +| 1 | Used by `pycom.pulses_get()` | | | 2 | 100nS | 3.2768 ms | | 3 | 100nS | 3.2768 ms | | 4 | 1000nS | 32.768 ms |