Skip to content

Commit bb47484

Browse files
committed
Merge remote-tracking branch 'adafruit/main' into from_bytes-check-parameters
2 parents 1cdf325 + c105ec9 commit bb47484

File tree

212 files changed

+5414
-990
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

212 files changed

+5414
-990
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,13 @@ jobs:
287287
fetch-depth: 1
288288
- name: Get CP deps
289289
run: python tools/ci_fetch_deps.py ${{ matrix.board }} ${{ github.sha }}
290+
- uses: carlosperate/arm-none-eabi-gcc-action@v1
291+
with:
292+
release: '10-2020-q4'
290293
- name: Install dependencies
291294
run: |
292295
sudo apt-get install -y gettext
293296
pip install -r requirements-ci.txt -r requirements-dev.txt
294-
wget --no-verbose https://adafruit-circuit-python.s3.amazonaws.com/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
295-
sudo tar -C /usr --strip-components=1 -xaf gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
296297
- name: Versions
297298
run: |
298299
gcc --version
@@ -487,8 +488,9 @@ jobs:
487488
pip install -r requirements-ci.txt -r requirements-dev.txt
488489
wget --no-verbose https://adafruit-circuit-python.s3.amazonaws.com/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz
489490
sudo tar -C /usr --strip-components=1 -xaf gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz
490-
wget --no-verbose https://adafruit-circuit-python.s3.amazonaws.com/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
491-
sudo tar -C /usr --strip-components=1 -xaf gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
491+
- uses: carlosperate/arm-none-eabi-gcc-action@v1
492+
with:
493+
release: '10-2020-q4'
492494
- name: Install mkfs.fat
493495
run: |
494496
wget https://github.com/dosfstools/dosfstools/releases/download/v4.2/dosfstools-4.2.tar.gz

BUILDING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ The test suite in the top level `tests` directory. It needs the unix port to ru
7070
Then you can run the test suite:
7171

7272
cd ../../tests
73-
./run-tests
73+
./run-tests.py
7474

7575
A successful run will say something like
7676

README.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,11 @@ If you'd like to use the term "CircuitPython" and Blinka for your product here i
9090
* Your product is listed on `circuitpython.org <https://circuitpython.org>`__ (source
9191
`here <https://github.com/adafruit/circuitpython-org/>`_). This is to ensure that a user of your
9292
product can always download the latest version of CircuitPython from the standard place.
93-
* Your product has a user accessible USB plug which appears as a CIRCUITPY drive when plugged in
94-
AND/OR provides file and serial access over Bluetooth Low Energy. Boards that do not support USB
95-
should be clearly marked as BLE-only CircuitPython.
93+
* Your product supports at least one standard "`Workflow <https://docs.circuitpython.org/en/latest/docs/workflows.html>`__" for serial and file access:
94+
* With a user accessible USB plug which appears as a CIRCUITPY drive when plugged in.
95+
* With file and serial access over Bluetooth Low Energy using the BLE Workflow.
96+
* With file access over WiFi using the WiFi Workflow with serial access over USB and/or WebSocket.
97+
* Boards that do not support the USB Workflow should be clearly marked.
9698

9799
If you choose not to meet these requirements, then we ask you call your version of CircuitPython
98100
something else (for example, SuperDuperPython) and not use the Blinka logo. You can say it is

devices/ble_hci/common-hal/_bleio/Adapter.c

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
#include "shared-bindings/_bleio/ScanEntry.h"
5050
#include "shared-bindings/time/__init__.h"
5151

52+
#if CIRCUITPY_DOTENV
53+
#include "shared-module/dotenv/__init__.h"
54+
#endif
55+
5256
#define MSEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000) / (RESOLUTION))
5357
#define SEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000000) / (RESOLUTION))
5458
#define UNITS_TO_SEC(TIME, RESOLUTION) (((TIME)*(RESOLUTION)) / 1000000)
@@ -278,17 +282,27 @@ char default_ble_name[] = { 'C', 'I', 'R', 'C', 'U', 'I', 'T', 'P', 'Y', 0, 0, 0
278282
// Get various values and limits set by the adapter.
279283
// Set event mask.
280284
STATIC void bleio_adapter_hci_init(bleio_adapter_obj_t *self) {
285+
mp_int_t name_len = 0;
281286

282-
const size_t len = sizeof(default_ble_name);
283-
284-
bt_addr_t addr;
285-
hci_check_error(hci_read_bd_addr(&addr));
286-
287-
default_ble_name[len - 4] = nibble_to_hex_lower[addr.val[1] >> 4 & 0xf];
288-
default_ble_name[len - 3] = nibble_to_hex_lower[addr.val[1] & 0xf];
289-
default_ble_name[len - 2] = nibble_to_hex_lower[addr.val[0] >> 4 & 0xf];
290-
default_ble_name[len - 1] = nibble_to_hex_lower[addr.val[0] & 0xf];
291-
self->name = mp_obj_new_str(default_ble_name, len);
287+
#if CIRCUITPY_DOTENV
288+
char ble_name[32];
289+
name_len = dotenv_get_key("/.env", "CIRCUITPY_BLE_NAME", ble_name, sizeof(ble_name) - 1);
290+
if (name_len > 0) {
291+
self->name = mp_obj_new_str(ble_name, (size_t)name_len);
292+
}
293+
#endif
294+
295+
if (name_len <= 0) {
296+
name_len = sizeof(default_ble_name);
297+
bt_addr_t addr;
298+
hci_check_error(hci_read_bd_addr(&addr));
299+
300+
default_ble_name[name_len - 4] = nibble_to_hex_lower[addr.val[1] >> 4 & 0xf];
301+
default_ble_name[name_len - 3] = nibble_to_hex_lower[addr.val[1] & 0xf];
302+
default_ble_name[name_len - 2] = nibble_to_hex_lower[addr.val[0] >> 4 & 0xf];
303+
default_ble_name[name_len - 1] = nibble_to_hex_lower[addr.val[0] & 0xf];
304+
self->name = mp_obj_new_str(default_ble_name, (uint8_t)name_len);
305+
}
292306

293307
// Get version information.
294308
if (hci_read_local_version(&self->hci_version, &self->hci_revision, &self->lmp_version,

docs/environment.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,17 @@ CircuitPython behavior
3131
CircuitPython will also read the environment to configure its behavior. Other
3232
keys are ignored by CircuitPython. Here are the keys it uses:
3333

34+
CIRCUITPY_BLE_NAME
35+
~~~~~~~~~~~~~~~~~~
36+
Default BLE name the board advertises as, including for the BLE workflow.
37+
38+
CIRCUITPY_WEB_API_PASSWORD
39+
~~~~~~~~~~~~~~~~~~~~~~~~~~
40+
Password required to make modifications to the board from the Web Workflow.
41+
3442
CIRCUITPY_WIFI_PASSWORD
3543
~~~~~~~~~~~~~~~~~~~~~~~
36-
Wi-Fi password used to auto connect to CIRCUITPY_WIFI_SSID
44+
Wi-Fi password used to auto connect to CIRCUITPY_WIFI_SSID.
3745

3846
CIRCUITPY_WIFI_SSID
3947
~~~~~~~~~~~~~~~~~~~

docs/library/hashlib.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
.. module:: hashlib
77
:synopsis: hashing algorithms
8+
:noindex:
89

910
|see_cpython_module| :mod:`cpython:hashlib`.
1011

docs/workflows.md

Lines changed: 51 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ using a rotating key rather than a static one. Non-bonded devices won't be able
4545
connection, the central device can discover two default services. One for file transfer and one for
4646
CircuitPython specifically that includes serial characteristics.
4747

48+
To change the default BLE advertising name without (or before) running user code, the desired name
49+
can be put in the `/.env` file. The key is `CIRCUITPY_BLE_NAME`. It's limited to approximately
50+
30 characters depending on the port's settings and will be truncated if longer.
51+
4852
### File Transfer API
4953

5054
CircuitPython uses [an open File Transfer API](https://github.com/adafruit/Adafruit_CircuitPython_BLE_File_Transfer)
@@ -286,6 +290,44 @@ not protected by basic auth in case the device is someone elses.
286290

287291
Only `GET` requests are supported and will return `405 Method Not Allowed` otherwise.
288292

293+
#### `/cp/devices.json`
294+
295+
Returns information about other devices found on the network using MDNS.
296+
297+
* `total`: Total MDNS response count. May be more than in `devices` if internal limits were hit.
298+
* `devices`: List of discovered devices.
299+
* `hostname`: MDNS hostname
300+
* `instance_name`: MDNS instance name. Defaults to human readable board name.
301+
* `port`: Port of CircuitPython Web API
302+
* `ip`: IP address
303+
304+
Example:
305+
```sh
306+
curl -v -L http://circuitpython.local/cp/devices.json
307+
```
308+
309+
```json
310+
{
311+
"total": 1,
312+
"devices": [
313+
{
314+
"hostname": "cpy-951032",
315+
"instance_name": "Adafruit Feather ESP32-S2 TFT",
316+
"port": 80,
317+
"ip": "192.168.1.235"
318+
}
319+
]
320+
}
321+
```
322+
323+
#### `/cp/serial/`
324+
325+
326+
Serves a basic serial terminal program when a `GET` request is received without the
327+
`Upgrade: websocket` header. Otherwise the socket is upgraded to a WebSocket. See WebSockets below for more detail.
328+
329+
This is an authenticated endpoint in both modes.
330+
289331
#### `/cp/version.json`
290332

291333
Returns information about the device.
@@ -323,36 +365,6 @@ curl -v -L http://circuitpython.local/cp/version.json
323365
}
324366
```
325367

326-
#### `/cp/devices.json`
327-
328-
Returns information about other devices found on the network using MDNS.
329-
330-
* `total`: Total MDNS response count. May be more than in `devices` if internal limits were hit.
331-
* `devices`: List of discovered devices.
332-
* `hostname`: MDNS hostname
333-
* `instance_name`: MDNS instance name. Defaults to human readable board name.
334-
* `port`: Port of CircuitPython Web API
335-
* `ip`: IP address
336-
337-
Example:
338-
```sh
339-
curl -v -L http://circuitpython.local/cp/devices.json
340-
```
341-
342-
```json
343-
{
344-
"total": 1,
345-
"devices": [
346-
{
347-
"hostname": "cpy-951032",
348-
"instance_name": "Adafruit Feather ESP32-S2 TFT",
349-
"port": 80,
350-
"ip": "192.168.1.235"
351-
}
352-
]
353-
}
354-
```
355-
356368
### Static files
357369

358370
* `/favicon.ico` - Blinka
@@ -361,4 +373,12 @@ curl -v -L http://circuitpython.local/cp/devices.json
361373

362374
### WebSocket
363375

364-
Coming soon!
376+
The CircuitPython serial interactions are available over a WebSocket. A WebSocket begins as a
377+
special HTTP request that gets upgraded to a WebSocket. Authentication happens before upgrading.
378+
379+
WebSockets are *not* bare sockets once upgraded. Instead they have their own framing format for data.
380+
CircuitPython can handle PING and CLOSE opcodes. All others are treated as TEXT. Data to
381+
CircuitPython is expected to be masked UTF-8, as the spec requires. Data from CircuitPython to the
382+
client is unmasked. It is also unbuffered so the client will get a variety of frame sizes.
383+
384+
Only one WebSocket at a time is supported.

extmod/ulab

Submodule ulab updated 109 files

0 commit comments

Comments
 (0)