diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f37df27f45..b6feaafdca 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,6 +12,10 @@ on: check_suite: types: [rerequested] +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: test: runs-on: ubuntu-20.04 diff --git a/.github/workflows/ports_windows.yml b/.github/workflows/ports_windows.yml index 6339746066..cb78632e83 100644 --- a/.github/workflows/ports_windows.yml +++ b/.github/workflows/ports_windows.yml @@ -12,6 +12,10 @@ on: - 'ports/unix/**' - 'ports/windows/**' +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: build: runs-on: windows-2019 diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 02db3b2c61..52e2d2b714 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -8,6 +8,10 @@ on: pull_request: push: +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: pre-commit: runs-on: ubuntu-20.04 diff --git a/devices/ble_hci/common-hal/_bleio/__init__.h b/devices/ble_hci/common-hal/_bleio/__init__.h index f9caf7c5b5..5c9bbcc979 100644 --- a/devices/ble_hci/common-hal/_bleio/__init__.h +++ b/devices/ble_hci/common-hal/_bleio/__init__.h @@ -35,7 +35,6 @@ #include "hci.h" void bleio_hci_background(void); -void bleio_reset(void); typedef struct { // ble_gap_enc_key_t own_enc; diff --git a/locale/ID.po b/locale/ID.po index d93756faef..67168ffb13 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -454,6 +454,7 @@ msgstr "Semua timer untuk pin ini sedang digunakan" msgid "All timers in use" msgstr "Semua timer sedang digunakan" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Sudah disebarkan." @@ -927,10 +928,12 @@ msgstr "Data 0 pin harus byte disejajarkan" msgid "Data chunk must follow fmt chunk" msgstr "Potongan data harus mengikuti fmt chunk" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Data terlalu besar untuk paket advertisment" @@ -1011,6 +1014,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "Diharapkan tuple dengan panjang %d, didapatkan %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "Penyebaran yang diperluas dengan respon pindai tidak didukung." @@ -1064,6 +1068,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Gagal terhubung: kesalahan internal" @@ -1297,6 +1302,7 @@ msgstr "Nilai Unit ADC tidak valid" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1605,6 +1611,10 @@ msgstr "" msgid "Name too long" msgstr "Nama terlalu panjang" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Tidak ada CCCD untuk Karakteristik ini" @@ -1752,6 +1762,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2145,6 +2156,7 @@ msgstr "Nilai sampel terlalu tinggi. Nilai harus kurang dari %d" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Pindai sudah dalam proses. Hentikan dengan stop_scan." @@ -2303,6 +2315,7 @@ msgstr "Lebar ubin harus persis membagi lebar bitmap" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2325,6 +2338,7 @@ msgstr "Terlalu banyak tampilan bus" msgid "Too many displays" msgstr "Terlalu banyak tampilan" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2456,11 +2470,21 @@ msgstr "Alasan yang tidak diketahui." msgid "Unknown security error: 0x%04x" msgstr "Kesalahan keamanan tidak dikenal: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2500,11 +2524,13 @@ msgstr "Operasi yang tidak didukung" msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Panjang nilai != Panjang tetap yang dibutuhkan" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2562,6 +2588,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "Menulis tidak didukung pada Karakteristik" @@ -3629,6 +3656,7 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index cfab5d02e2..a99a733595 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -446,6 +446,7 @@ msgstr "" msgid "All timers in use" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "" @@ -908,10 +909,12 @@ msgstr "" msgid "Data chunk must follow fmt chunk" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "" @@ -992,6 +995,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1045,6 +1049,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "" @@ -1276,6 +1281,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1584,6 +1590,10 @@ msgstr "" msgid "Name too long" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1731,6 +1741,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2110,6 +2121,7 @@ msgstr "" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2268,6 +2280,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2290,6 +2303,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2421,11 +2435,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2463,11 +2487,13 @@ msgstr "" msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2525,6 +2551,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -3592,6 +3619,7 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format diff --git a/locale/cs.po b/locale/cs.po index b25302e388..4547f2f9f5 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -453,6 +453,7 @@ msgstr "" msgid "All timers in use" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "" @@ -917,10 +918,12 @@ msgstr "" msgid "Data chunk must follow fmt chunk" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "" @@ -1001,6 +1004,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1054,6 +1058,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "" @@ -1285,6 +1290,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1593,6 +1599,10 @@ msgstr "" msgid "Name too long" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1740,6 +1750,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2121,6 +2132,7 @@ msgstr "" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2279,6 +2291,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2301,6 +2314,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2432,11 +2446,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2474,11 +2498,13 @@ msgstr "" msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2536,6 +2562,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -3603,6 +3630,7 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format diff --git a/locale/de_DE.po b/locale/de_DE.po index 1d2c2437f9..f6a769a258 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -455,6 +455,7 @@ msgstr "Alle timer für diesen Pin werden bereits benutzt" msgid "All timers in use" msgstr "Alle timer werden benutzt" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Bereits am anbieten (advertising)." @@ -923,10 +924,12 @@ msgstr "Data 0 pin muss am Byte ausgerichtet sein" msgid "Data chunk must follow fmt chunk" msgstr "Dem fmt Block muss ein Datenblock folgen" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Zu vielen Daten für das advertisement packet" @@ -1007,6 +1010,7 @@ msgstr "Alarm erwartet" msgid "Expected tuple of length %d, got %d" msgstr "Habe ein Tupel der Länge %d erwartet aber %d erhalten" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1061,6 +1065,7 @@ msgstr "Zuweisung des Wifi Scan Speichers ist fehlgeschlagen" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Verbindung fehlgeschlagen: interner Fehler" @@ -1296,6 +1301,7 @@ msgstr "Ungültiger ADC-Einheitenwert" msgid "Invalid AuthMode" msgstr "Ungültiges AuthMode" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "Ungültiges BLE Parameter" @@ -1605,6 +1611,10 @@ msgstr "NVS Fehler" msgid "Name too long" msgstr "Name zu lang" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Kein CCCD für diese Charakteristik" @@ -1752,6 +1762,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2142,6 +2153,7 @@ msgstr "Abtastrate zu hoch. Wert muss unter %d liegen" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Scannen Sie bereits in Bearbeitung. Stoppen Sie mit stop_scan." @@ -2302,6 +2314,7 @@ msgstr "Die Kachelbreite muss die Bitmap-Breite genau teilen" msgid "Time is in the past." msgstr "Zeit liegt in der Vergangenheit" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2325,6 +2338,7 @@ msgstr "Zu viele Display Busse" msgid "Too many displays" msgstr "Zu viele displays" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "Gesamte zu schreibende Datenmenge ist größer als %q" @@ -2456,11 +2470,21 @@ msgstr "Unbekannter Grund." msgid "Unknown security error: 0x%04x" msgstr "Unbekannter Sicherheitsfehler: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "Unbekannter Systemfirmware Fehler: %04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2502,11 +2526,13 @@ msgstr "Nicht unterstützte Operation" msgid "Update Failed" msgstr "Update fehlgeschlagen" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Wert Länge != Erforderliche feste Länge" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2567,6 +2593,7 @@ msgstr "WiFi Passwort muss zwischen 8 und 63 Zeichen lang sein" msgid "Woken up by alarm.\n" msgstr "Aufgeweckt durch Alarm.\n" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "Schreiben nicht unterstüzt für diese Charakteristik" @@ -3654,6 +3681,7 @@ msgstr "Mathe-Domain-Fehler" msgid "matrix is not positive definite" msgstr "Matrix ist nicht positiv definitiv" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format diff --git a/locale/el.po b/locale/el.po index 216679c9bc..7062fa1c20 100644 --- a/locale/el.po +++ b/locale/el.po @@ -446,6 +446,7 @@ msgstr "" msgid "All timers in use" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "" @@ -908,10 +909,12 @@ msgstr "" msgid "Data chunk must follow fmt chunk" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "" @@ -992,6 +995,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1045,6 +1049,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "" @@ -1276,6 +1281,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1584,6 +1590,10 @@ msgstr "" msgid "Name too long" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1731,6 +1741,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2110,6 +2121,7 @@ msgstr "" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2268,6 +2280,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2290,6 +2303,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2421,11 +2435,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2463,11 +2487,13 @@ msgstr "" msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2525,6 +2551,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -3592,6 +3619,7 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format diff --git a/locale/en_GB.po b/locale/en_GB.po index 0e3612c41f..3503498392 100644 --- a/locale/en_GB.po +++ b/locale/en_GB.po @@ -455,6 +455,7 @@ msgstr "All timers for this pin are in use" msgid "All timers in use" msgstr "All timers in use" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Already advertising." @@ -921,10 +922,12 @@ msgstr "Data 0 pin must be byte aligned" msgid "Data chunk must follow fmt chunk" msgstr "Data chunk must follow fmt chunk" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "Data not supported with directed advertising" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Data too large for advertisement packet" @@ -1005,6 +1008,7 @@ msgstr "Expected an alarm" msgid "Expected tuple of length %d, got %d" msgstr "Expected tuple of length %d, got %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "Extended advertisements with scan response not supported." @@ -1058,6 +1062,7 @@ msgstr "Failed to allocate WiFi scan memory" msgid "Failed to buffer the sample" msgstr "Failed to buffer the sample" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Failed to connect: internal error" @@ -1291,6 +1296,7 @@ msgstr "Invalid ADC unit value" msgid "Invalid AuthMode" msgstr "Invalid AuthMode" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "Invalid BLE parameter" @@ -1599,6 +1605,10 @@ msgstr "NVS Error" msgid "Name too long" msgstr "Name too long" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "No CCCD for this Characteristic" @@ -1746,6 +1756,7 @@ msgstr "Nordic system firmware out of memory" msgid "Not a valid IP string" msgstr "Not a valid IP string" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2134,6 +2145,7 @@ msgstr "Sample rate too high. It must be less than %d" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Scan already in progess. Stop with stop_scan." @@ -2299,6 +2311,7 @@ msgstr "Tile width must exactly divide bitmap width" msgid "Time is in the past." msgstr "Time is in the past." +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2321,6 +2334,7 @@ msgstr "Too many display busses" msgid "Too many displays" msgstr "Too many displays" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "Total data to write is larger than %q" @@ -2452,11 +2466,21 @@ msgstr "Unknown reason." msgid "Unknown security error: 0x%04x" msgstr "Unknown security error: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "Unknown system firmware error: %04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2496,11 +2520,13 @@ msgstr "Unsupported operation" msgid "Update Failed" msgstr "Update failed" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Value length != required fixed length" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2558,6 +2584,7 @@ msgstr "WiFi password must be between 8 and 63 characters" msgid "Woken up by alarm.\n" msgstr "Woken up by alarm.\n" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "Writes not supported on Characteristic" @@ -3629,6 +3656,7 @@ msgstr "math domain error" msgid "matrix is not positive definite" msgstr "matrix is not positive definite" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format diff --git a/locale/es.po b/locale/es.po index 8eb3848fcd..d44e35f76d 100644 --- a/locale/es.po +++ b/locale/es.po @@ -459,6 +459,7 @@ msgstr "Todos los timers para este pin están siendo utilizados" msgid "All timers in use" msgstr "Todos los timers en uso" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Ya se encuentra publicando." @@ -930,10 +931,12 @@ msgstr "El pin Data 0 debe estar alineado a bytes" msgid "Data chunk must follow fmt chunk" msgstr "Trozo de datos debe seguir fmt chunk" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "Datos sin capacidad de anuncio dirigido" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Data es muy grande para el paquete de anuncio" @@ -1015,6 +1018,7 @@ msgstr "Un objecto alarm era esperado" msgid "Expected tuple of length %d, got %d" msgstr "Se esperaba un tuple de %d, se obtuvo %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "No se admiten anuncios extendidos con respuesta de escaneo." @@ -1068,6 +1072,7 @@ msgstr "Fallo al tomar memoria para búsqueda wifi" msgid "Failed to buffer the sample" msgstr "Fallo al hacer el búfer de la muestra" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Error al conectar: error interno" @@ -1309,6 +1314,7 @@ msgstr "Valor de unidad de ADC no válido" msgid "Invalid AuthMode" msgstr "AuthMode invalido" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "Parámetro BLE invalido" @@ -1621,6 +1627,10 @@ msgstr "Error NVS" msgid "Name too long" msgstr "Nombre muy largo" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "No hay CCCD para esta característica" @@ -1768,6 +1778,7 @@ msgstr "El firmware del sistema Nordic no tiene memoria" msgid "Not a valid IP string" msgstr "No es una cadena de IP válida" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2162,6 +2173,7 @@ msgstr "Frecuencia de muestreo demasiado alta. Debe ser menor a %d" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Escaneo en progreso. Usa stop_scan para detener." @@ -2328,6 +2340,7 @@ msgstr "Ancho del Tile debe dividir exactamente el ancho de mapa de bits" msgid "Time is in the past." msgstr "Tiempo suministrado esta en el pasado." +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2352,6 +2365,7 @@ msgstr "Demasiados buses de pantalla" msgid "Too many displays" msgstr "Muchos displays" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "La cantidad total de datos es mas grande que %q" @@ -2483,11 +2497,21 @@ msgstr "Razón desconocida." msgid "Unknown security error: 0x%04x" msgstr "Error de seguridad desconocido: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "Error desconocido en el firmware sistema: %04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2527,11 +2551,13 @@ msgstr "Operación no soportada" msgid "Update Failed" msgstr "La actualización fallo" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Tamaño del valor != del tamaño fijo requerido" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2592,6 +2618,7 @@ msgstr "La clave de WiFi debe ser entre 8 y 63 caracteres" msgid "Woken up by alarm.\n" msgstr "Despertado por la alarma.\n" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "Escrituras no admitidas en Characteristic" @@ -3671,6 +3698,7 @@ msgstr "error de dominio matemático" msgid "matrix is not positive definite" msgstr "matrix no es definida positiva" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format diff --git a/locale/fil.po b/locale/fil.po index f6dbe03030..0bcc72c933 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -451,6 +451,7 @@ msgstr "Lahat ng timers para sa pin na ito ay ginagamit" msgid "All timers in use" msgstr "Lahat ng timer ginagamit" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "" @@ -919,10 +920,12 @@ msgstr "graphic ay dapat 2048 bytes ang haba" msgid "Data chunk must follow fmt chunk" msgstr "Dapat sunurin ng Data chunk ang fmt chunk" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, fuzzy msgid "Data too large for advertisement packet" @@ -1005,6 +1008,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1058,6 +1062,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "" @@ -1291,6 +1296,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1599,6 +1605,10 @@ msgstr "" msgid "Name too long" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1746,6 +1756,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c #, fuzzy @@ -2130,6 +2141,7 @@ msgstr "Sample rate ay masyadong mataas. Ito ay dapat hindi hiigit sa %d" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2288,6 +2300,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2310,6 +2323,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2442,11 +2456,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2485,11 +2509,13 @@ msgstr "Hindi sinusuportahang operasyon" msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2547,6 +2573,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -3631,6 +3658,7 @@ msgstr "may pagkakamali sa math domain" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format diff --git a/locale/fr.po b/locale/fr.po index 8c4a077157..354b93183c 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -457,6 +457,7 @@ msgstr "Tous les minuteurs pour cette broche sont utilisés" msgid "All timers in use" msgstr "Tous les minuteurs sont utilisés" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "S'annonce déjà." @@ -936,10 +937,12 @@ msgstr "La broche 'Data 0' doit être aligné sur l'octet" msgid "Data chunk must follow fmt chunk" msgstr "Un bloc de données doit suivre un bloc fmt" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "Les données ne sont pas supportées avec les annonces directes" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Données trop volumineuses pour un paquet d'avertissement" @@ -1022,6 +1025,7 @@ msgstr "Une alarme était prévue" msgid "Expected tuple of length %d, got %d" msgstr "Tuple de longueur %d attendu, obtenu %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1076,6 +1080,7 @@ msgstr "Impossible d'allouer la mémoire pour le scan wifi" msgid "Failed to buffer the sample" msgstr "Échec du tamponage de l'échantillon" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Impossible de se connecter : erreur interne" @@ -1322,6 +1327,7 @@ msgstr "Valeur d'unité ADC non valide" msgid "Invalid AuthMode" msgstr "AuthMode invalide" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "Paramètre BLE invalide" @@ -1632,6 +1638,10 @@ msgstr "Erreur NVS" msgid "Name too long" msgstr "Nom trop long" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Pas de CCCD pour cette caractéristique" @@ -1779,6 +1789,7 @@ msgstr "Logiciel systême Nordic hors de mémoire" msgid "Not a valid IP string" msgstr "Chaîne IP non valide" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2174,6 +2185,7 @@ msgstr "Taux d'échantillonage trop élevé. Doit être inférieur à %d" msgid "Scale dimensions must divide by 3" msgstr "La dimension d'échelle doit être un multiple de 3" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Scan déjà en cours. Arrêtez avec stop_scan." @@ -2343,6 +2355,7 @@ msgstr "La largeur de la tuile doit diviser exactement la largeur de l'image" msgid "Time is in the past." msgstr "L'heure est dans le passé." +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2365,6 +2378,7 @@ msgstr "Trop de bus d'affichage" msgid "Too many displays" msgstr "Trop d'affichages" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "Quantité de données à écrire est plus que %q" @@ -2499,11 +2513,21 @@ msgstr "Raison inconnue." msgid "Unknown security error: 0x%04x" msgstr "Erreur de sécurité inconnue : 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "Faute inconnue du logiciel systême : %04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2544,11 +2568,13 @@ msgstr "Opération non supportée" msgid "Update Failed" msgstr "Mise-à-jour échouée" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Longueur de valeur != Longueur fixe requise" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2615,6 +2641,7 @@ msgstr "Le mot de passe WiFi doit faire entre 8 et 63 caractères" msgid "Woken up by alarm.\n" msgstr "Réveil par alarme.\n" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "Écritures non supporté vers les Characteristic" @@ -3701,6 +3728,7 @@ msgstr "erreur de domaine math" msgid "matrix is not positive definite" msgstr "la matrice n'est pas définie positive" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format diff --git a/locale/hi.po b/locale/hi.po index 4030db6510..e586d3d510 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -446,6 +446,7 @@ msgstr "" msgid "All timers in use" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "" @@ -908,10 +909,12 @@ msgstr "" msgid "Data chunk must follow fmt chunk" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "" @@ -992,6 +995,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1045,6 +1049,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "" @@ -1276,6 +1281,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1584,6 +1590,10 @@ msgstr "" msgid "Name too long" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1731,6 +1741,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2110,6 +2121,7 @@ msgstr "" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2268,6 +2280,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2290,6 +2303,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2421,11 +2435,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2463,11 +2487,13 @@ msgstr "" msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2525,6 +2551,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -3592,6 +3619,7 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format diff --git a/locale/it_IT.po b/locale/it_IT.po index c97b1f8910..8f68054e19 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -458,6 +458,7 @@ msgstr "Tutti i timer per questo pin sono in uso" msgid "All timers in use" msgstr "Tutti i timer utilizzati" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "" @@ -927,10 +928,12 @@ msgstr "graphic deve essere lunga 2048 byte" msgid "Data chunk must follow fmt chunk" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, fuzzy msgid "Data too large for advertisement packet" @@ -1012,6 +1015,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1065,6 +1069,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "" @@ -1298,6 +1303,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1610,6 +1616,10 @@ msgstr "" msgid "Name too long" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1757,6 +1767,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c #, fuzzy @@ -2149,6 +2160,7 @@ msgstr "" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2307,6 +2319,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2329,6 +2342,7 @@ msgstr "" msgid "Too many displays" msgstr "Troppi schermi" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2461,11 +2475,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2504,11 +2528,13 @@ msgstr "Operazione non supportata" msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2566,6 +2592,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -3649,6 +3676,7 @@ msgstr "errore di dominio matematico" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format diff --git a/locale/ja.po b/locale/ja.po index abd69060ea..d03ef7f900 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -451,6 +451,7 @@ msgstr "このピン用の全てのタイマが使用中" msgid "All timers in use" msgstr "全てのタイマーが使用中" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "すでにアドバータイズ中" @@ -917,10 +918,12 @@ msgstr "Data 0 ピンは、バイト整列されていなければなりませ msgid "Data chunk must follow fmt chunk" msgstr "fmtチャンクの後にdataチャンクが続かなければなりません" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "データが、アドバタイズメントパケットには大きすぎます" @@ -1001,6 +1004,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1054,6 +1058,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "接続失敗: 内部エラー" @@ -1287,6 +1292,7 @@ msgstr "不正なADCユニット値" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1595,6 +1601,10 @@ msgstr "" msgid "Name too long" msgstr "名前が長すぎます" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1742,6 +1752,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "不正なIP文字列です" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2124,6 +2135,7 @@ msgstr "サンプルレートは%d以下でなければなりません" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "既にスキャン進行中。stop_scanで停止してください" @@ -2282,6 +2294,7 @@ msgstr "タイルの幅はビットマップの幅を割り切れる値でなけ msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2304,6 +2317,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2436,11 +2450,21 @@ msgstr "理由不明" msgid "Unknown security error: 0x%04x" msgstr "不明なセキュリティエラー: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2478,11 +2502,13 @@ msgstr "非対応の操作" msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2540,6 +2566,7 @@ msgstr "WiFiパスワードは8〜63文字でなければなりません" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -3612,6 +3639,7 @@ msgstr "定義域エラー" msgid "matrix is not positive definite" msgstr "正定値行列ではありません" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format diff --git a/locale/ko.po b/locale/ko.po index 0de21ab65f..0bf2e97a0b 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -447,6 +447,7 @@ msgstr "핀의 모든 타이머가 사용 중입니다" msgid "All timers in use" msgstr "모든 타이머가 사용 중입니다" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "" @@ -911,10 +912,12 @@ msgstr "" msgid "Data chunk must follow fmt chunk" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "광고 (브로드 캐스트) 패킷에 대한 데이터가 너무 큽니다" @@ -995,6 +998,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1048,6 +1052,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "" @@ -1279,6 +1284,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1587,6 +1593,10 @@ msgstr "" msgid "Name too long" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1734,6 +1744,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2113,6 +2124,7 @@ msgstr "" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2271,6 +2283,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2293,6 +2306,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2425,11 +2439,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2467,11 +2491,13 @@ msgstr "" msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2529,6 +2555,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -3596,6 +3623,7 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format diff --git a/locale/nl.po b/locale/nl.po index 9a0b40799f..317e56d951 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -449,6 +449,7 @@ msgstr "Alle timers voor deze pin zijn in gebruik" msgid "All timers in use" msgstr "Alle timers zijn in gebruik" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Advertising is al bezig." @@ -917,10 +918,12 @@ msgstr "Data 0 pin moet byte uitgelijnd zijn" msgid "Data chunk must follow fmt chunk" msgstr "Data chunk moet gevolgd worden door fmt chunk" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Data te groot voor advertisement pakket" @@ -1001,6 +1004,7 @@ msgstr "Verwachtte een alarm" msgid "Expected tuple of length %d, got %d" msgstr "Verwachtte een tuple met lengte %d, maar kreeg %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "Extended advertisements met scan antwoord niet ondersteund." @@ -1054,6 +1058,7 @@ msgstr "Kon WiFi scan geheugen niet toewijzen" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Verbinding mislukt: interne fout" @@ -1288,6 +1293,7 @@ msgstr "Ongeldige ADC Unit waarde" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1596,6 +1602,10 @@ msgstr "NVS-fout" msgid "Name too long" msgstr "Naam te lang" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Geen CCCD voor deze Characteristic" @@ -1743,6 +1753,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "Geen geldige IP string" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2136,6 +2147,7 @@ msgstr "Sample rate is te hoog. Moet minder dan %d zijn" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Scan wordt al uitvoerd. Stop met stop_scan." @@ -2294,6 +2306,7 @@ msgstr "Tile breedte moet exact de bitmap breedte verdelen" msgid "Time is in the past." msgstr "Tijdstip ligt in het verleden." +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2316,6 +2329,7 @@ msgstr "Teveel beeldscherm bussen" msgid "Too many displays" msgstr "Teveel beeldschermen" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2447,11 +2461,21 @@ msgstr "Onbekende reden." msgid "Unknown security error: 0x%04x" msgstr "Onbekende veiligheidsfout: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2491,11 +2515,13 @@ msgstr "Niet-ondersteunde operatie" msgid "Update Failed" msgstr "Update Mislukt" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Waarde lengte != vereist vaste lengte" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2557,6 +2583,7 @@ msgstr "WiFi wachtwoord moet tussen 8 en 63 karakters bevatten" msgid "Woken up by alarm.\n" msgstr "Gewekt door alarm.\n" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "Schrijven niet ondersteund op Characteristic" @@ -3632,6 +3659,7 @@ msgstr "fout in het wiskundig domein (math domain error)" msgid "matrix is not positive definite" msgstr "matrix is niet positief-definiet" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format diff --git a/locale/pl.po b/locale/pl.po index 4c2b1782ce..1a7760d797 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -451,6 +451,7 @@ msgstr "Wszystkie timery tej nóżki w użyciu" msgid "All timers in use" msgstr "Wszystkie timery w użyciu" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "" @@ -917,10 +918,12 @@ msgstr "Nóżka data 0 musi być wyrównana do bajtu" msgid "Data chunk must follow fmt chunk" msgstr "Fragment danych musi następować po fragmencie fmt" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Zbyt dużo danych pakietu rozgłoszeniowego" @@ -1001,6 +1004,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "Oczekiwano krotkę długości %d, otrzymano %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1054,6 +1058,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Nie udało się połączyć: błąd wewnętrzny" @@ -1287,6 +1292,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1595,6 +1601,10 @@ msgstr "" msgid "Name too long" msgstr "Za długa nazwa" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1742,6 +1752,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2121,6 +2132,7 @@ msgstr "Zbyt wysoka częstotliwość próbkowania. Musi być mniejsza niż %d" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Skanuj już w toku. Zatrzymaj za pomocą stop_scan." @@ -2279,6 +2291,7 @@ msgstr "Szerokość bitmapy musi być wielokrotnością szerokości kafelka" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2301,6 +2314,7 @@ msgstr "Zbyt wiele magistrali" msgid "Too many displays" msgstr "Zbyt wiele wyświetlaczy" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2432,11 +2446,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2474,11 +2498,13 @@ msgstr "Zła operacja" msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2536,6 +2562,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -3604,6 +3631,7 @@ msgstr "błąd domeny" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format diff --git a/locale/pt_BR.po b/locale/pt_BR.po index f1b3179768..e463546b2e 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -459,6 +459,7 @@ msgstr "Todos os temporizadores para este pino estão em uso" msgid "All timers in use" msgstr "Todos os temporizadores em uso" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Já está anunciando." @@ -935,10 +936,12 @@ msgstr "O pino de dados 0 deve ser alinhado por bytes" msgid "Data chunk must follow fmt chunk" msgstr "Pedaço de dados deve seguir o pedaço de cortes" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "Os dados não são compatíveis com publicidade direcionada" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Os dados são grandes demais para o pacote de publicidade" @@ -1019,6 +1022,7 @@ msgstr "Um alarme era esperado" msgid "Expected tuple of length %d, got %d" msgstr "Tupla esperada com comprimento %d, obteve %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "Anúncios estendidos não compatíveis com a resposta da varredura." @@ -1072,6 +1076,7 @@ msgstr "Houve uma falha na alocação da memória para a varredura do Wifi" msgid "Failed to buffer the sample" msgstr "Houve uma falha ao fazer uma memória prévia (buffer) da amostra" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Falha ao conectar: erro interno" @@ -1313,6 +1318,7 @@ msgstr "Valor inválido da unidade ADC" msgid "Invalid AuthMode" msgstr "AuthMode inválido" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "Parâmetro BLE inválido" @@ -1621,6 +1627,10 @@ msgstr "Erro NVS" msgid "Name too long" msgstr "Nome muito longo" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Não há nenhum CCCD para esta característica" @@ -1770,6 +1780,7 @@ msgstr "O firmware do sistema nórdico está sem memória" msgid "Not a valid IP string" msgstr "Não é uma sequência válida de IP" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2166,6 +2177,7 @@ msgstr "Taxa de amostragem muito alta. Deve ser menor que %d" msgid "Scale dimensions must divide by 3" msgstr "As dimensões da escala devem ser poder ser divididas por 3" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "O escaneamento já está em andamento. Interrompa com stop_scan." @@ -2336,6 +2348,7 @@ msgstr "A largura do bloco deve dividir exatamente com a largura do bitmap" msgid "Time is in the past." msgstr "O tempo está no passado." +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2360,6 +2373,7 @@ msgstr "Muitos barramentos estão sendo exibidos" msgid "Too many displays" msgstr "Exibições demais" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "O total dos dados que serão escritos é maior do que %q" @@ -2492,11 +2506,21 @@ msgstr "Motivo desconhecido." msgid "Unknown security error: 0x%04x" msgstr "Erro de segurança desconhecido: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "Erro desconhecido do firmware: %04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2536,11 +2560,13 @@ msgstr "Operação não suportada" msgid "Update Failed" msgstr "A atualização falou" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Comprimento do valor != comprimento fixo necessário" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2607,6 +2633,7 @@ msgstr "A senha do Wi-Fi deve ter entre 8 e 63 caracteres" msgid "Woken up by alarm.\n" msgstr "Foi despertado através do alarme.\n" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "A escrita não é compatível na Característica" @@ -3689,6 +3716,7 @@ msgstr "erro de domínio matemático" msgid "matrix is not positive definite" msgstr "a matriz não é definitiva positiva" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format diff --git a/locale/ru.po b/locale/ru.po index 5a6bbc5626..a21964734c 100644 --- a/locale/ru.po +++ b/locale/ru.po @@ -458,6 +458,7 @@ msgstr "Все таймеры для этого Пина уже использу msgid "All timers in use" msgstr "Все таймеры уже используются" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Уже объявляемся (advertising)." @@ -935,10 +936,12 @@ msgstr "Вывод data 0 должен быть выровнен по байта msgid "Data chunk must follow fmt chunk" msgstr "Блок данных должен следовать за блоком fmt" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "Данные не поддерживаются направленным объявлением" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Данные слишком велики для пакета объявления" @@ -1021,6 +1024,7 @@ msgstr "Ожидался сигнал" msgid "Expected tuple of length %d, got %d" msgstr "Ожидался кортеж длины %d, получен %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "Расширенные объявления с ответом сканирования не поддерживаются." @@ -1074,6 +1078,7 @@ msgstr "Не удалось выделить память для сканиро msgid "Failed to buffer the sample" msgstr "Не удалось выполнить буферизацию образца" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Не удалось подключиться: внутренняя ошибка" @@ -1319,6 +1324,7 @@ msgstr "Недопустимое значение единицы АЦП" msgid "Invalid AuthMode" msgstr "Недопустимый AuthMode" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "Недопустимый параметр BLE" @@ -1629,6 +1635,10 @@ msgstr "Ошибка NVS" msgid "Name too long" msgstr "Имя слишком длинное" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Нет CCCD для этой Characteristic" @@ -1778,6 +1788,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "Недействительная строка IP" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2165,6 +2176,7 @@ msgstr "" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2323,6 +2335,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2345,6 +2358,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2476,11 +2490,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2518,11 +2542,13 @@ msgstr "" msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2580,6 +2606,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -3647,6 +3674,7 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format diff --git a/locale/sv.po b/locale/sv.po index 2adbcf4f78..3f0c1a096d 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2022-01-23 15:53+0000\n" +"PO-Revision-Date: 2022-01-29 07:53+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" "Language: sv\n" @@ -454,6 +454,7 @@ msgstr "Alla timers för denna pinne är i bruk" msgid "All timers in use" msgstr "Alla timers används" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Annonserar redan." @@ -923,10 +924,12 @@ msgstr "Datapinne 0 måste vara bytejusterad" msgid "Data chunk must follow fmt chunk" msgstr "Datasegmentet måste följa fmt-segmentet" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "Data stöds inte med riktad annonsering" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Data för stor för annonseringspaket" @@ -1007,6 +1010,7 @@ msgstr "Förväntade ett larm" msgid "Expected tuple of length %d, got %d" msgstr "Förväntad tupel med längd %d, fick %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "Utökad annonsering i kombination med skanningssvar stöds inte." @@ -1060,6 +1064,7 @@ msgstr "Det gick inte att allokera minne för WiFi-scanning" msgid "Failed to buffer the sample" msgstr "Det gick inte att buffra samplingen" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Det gick inte att ansluta: internt fel" @@ -1295,6 +1300,7 @@ msgstr "Ogiltigt ADC-enhetsvärde" msgid "Invalid AuthMode" msgstr "Ogiltig AuthMode" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "Ogiltig BLE-parameter" @@ -1604,6 +1610,10 @@ msgstr "NVS-fel" msgid "Name too long" msgstr "Name är för långt" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "Nimble har inget minne kvar" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Ingen CCCD för denna karaktäristik" @@ -1751,6 +1761,7 @@ msgstr "Nordic systemfirmware fick slut på minne" msgid "Not a valid IP string" msgstr "Inte en giltig IP-sträng" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2142,6 +2153,7 @@ msgstr "Samplingsfrekvensen är för hög. Den måste vara mindre än %d" msgid "Scale dimensions must divide by 3" msgstr "Skaldimension måste vara delbar med 3" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Skanning pågår redan. Avsluta med stop_scan." @@ -2310,6 +2322,7 @@ msgstr "Tile-bredd måste vara jämnt delbar med bredd på bitmap" msgid "Time is in the past." msgstr "Tid har passerats." +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2332,6 +2345,7 @@ msgstr "För många display-bussar" msgid "Too many displays" msgstr "För många displayer" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "Totala data att skriva är större än %q" @@ -2463,11 +2477,21 @@ msgstr "Okänd anledning." msgid "Unknown security error: 0x%04x" msgstr "Okänt säkerhetsfel: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "Okänt fel i systemets firmware vid %s:%d: %d" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "Okänt systemfirmwarefel: %04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "Okänt fel i systemets firmware: %d" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2507,11 +2531,13 @@ msgstr "Åtgärd som inte stöds" msgid "Update Failed" msgstr "Uppdateringen misslyckades" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Värdets längde ! = krävd fast längd" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2575,6 +2601,7 @@ msgstr "WiFi-lösenord måste vara mellan 8 och 63 tecken" msgid "Woken up by alarm.\n" msgstr "Vaknade av larm.\n" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "Skrivning stöds inte på karaktäristik" @@ -3652,6 +3679,7 @@ msgstr "matematikdomänfel" msgid "matrix is not positive definite" msgstr "matrisen är inte positiv bestämd" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format diff --git a/locale/tr.po b/locale/tr.po index d7b6067b80..b07b88c00a 100644 --- a/locale/tr.po +++ b/locale/tr.po @@ -459,6 +459,7 @@ msgstr "Bu pin için tüm zamanlayıcılar kullanımda" msgid "All timers in use" msgstr "Tüm zamanlayıcılar kullanımda" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Halihazırda duyuruluyor." @@ -923,10 +924,12 @@ msgstr "" msgid "Data chunk must follow fmt chunk" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "" @@ -1007,6 +1010,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1060,6 +1064,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "" @@ -1291,6 +1296,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1599,6 +1605,10 @@ msgstr "" msgid "Name too long" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1746,6 +1756,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2128,6 +2139,7 @@ msgstr "" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2286,6 +2298,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2308,6 +2321,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2439,11 +2453,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2481,11 +2505,13 @@ msgstr "" msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2543,6 +2569,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -3610,6 +3637,7 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 2547284021..917889be52 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -457,6 +457,7 @@ msgstr "cǐ yǐnjiǎo de suǒyǒu jìshíqì dōu zài shǐyòng zhōng" msgid "All timers in use" msgstr "suǒyǒu jìshí qì dōu zài shǐyòng zhōng" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Mùqián zhèngzài guǎngbō." @@ -930,10 +931,12 @@ msgstr "Shùjù 0 de yǐn jiǎo bìxū shì zì jié duìqí" msgid "Data chunk must follow fmt chunk" msgstr "Shùjù kuài bìxū zūnxún fmt qū kuài" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "bù zhī chí dìng xiàng guǎng gào de shù jù" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Guǎnggào bāo de shùjù tài dà" @@ -1015,6 +1018,7 @@ msgstr "yù qī yǒu jǐng bào" msgid "Expected tuple of length %d, got %d" msgstr "Qīwàng de chángdù wèi %d de yuán zǔ, dédào %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "Bù zhīchí dài yǒu sǎomiáo xiǎngyìng de kuòzhǎn guǎngbò." @@ -1068,6 +1072,7 @@ msgstr "Wúfǎ fēnpèi wifi sǎomiáo nèicún" msgid "Failed to buffer the sample" msgstr "wèi néng huǎn chōng yàng běn" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Liánjiē shībài: Nèibù cuòwù" @@ -1309,6 +1314,7 @@ msgstr "Wúxiào de ADC dānwèi zhí" msgid "Invalid AuthMode" msgstr "wú xiào AuthMode" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "wú xiào BLE cān shù" @@ -1618,6 +1624,10 @@ msgstr "NVS cuò wù" msgid "Name too long" msgstr "Míngchēng tài zhǎng" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Zhège tèzhēng méiyǒu CCCD" @@ -1765,6 +1775,7 @@ msgstr "běi ōu xì tǒng gù jiàn chū nèi cún" msgid "Not a valid IP string" msgstr "Wúxiào de IP zìfú chuàn" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2155,6 +2166,7 @@ msgstr "Cǎiyàng lǜ tài gāo. Tā bìxū xiǎoyú %d" msgid "Scale dimensions must divide by 3" msgstr "bǐ lì chǐ cùn bì xū chú yǐ 3" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Zhèngzài jìn háng sǎomiáo. Shǐyòng stop_scan tíngzhǐ." @@ -2322,6 +2334,7 @@ msgstr "Píng pū kuāndù bìxū huàfēn wèi tú kuāndù" msgid "Time is in the past." msgstr "shí jiān yǐ jīng guò qù." +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2344,6 +2357,7 @@ msgstr "Xiǎnshì zǒngxiàn tài duōle" msgid "Too many displays" msgstr "Xiǎnshì tài duō" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "yào biān xiě de zǒng shù jù dà yú %q" @@ -2475,11 +2489,21 @@ msgstr "Yuányīn bùmíng." msgid "Unknown security error: 0x%04x" msgstr "Wèizhī de ānquán cuòwù: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "wèi zhī xì tǒng gù jiàn cuò wù: %04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2519,11 +2543,13 @@ msgstr "Bù zhīchí de cāozuò" msgid "Update Failed" msgstr "gēng xīn shī bài" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Zhí chángdù != Suǒ xū de gùdìng chángdù" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2587,6 +2613,7 @@ msgstr "WiFi mìmǎ bìxū jiè yú 8 dào 63 gè zìfú zhī jiān" msgid "Woken up by alarm.\n" msgstr "bèi jǐng bào chǎo xǐng.\n" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "Tèzhēng bù zhīchí xiě rù" @@ -3663,6 +3690,7 @@ msgstr "shùxué yù cuòwù" msgid "matrix is not positive definite" msgstr "jǔzhèn bùshì zhèngdìng de" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index 9d238834fe..9ba16321ca 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -20,6 +20,7 @@ ifeq ($(CHIP_FAMILY),samd21) # fit in 256kB of flash CIRCUITPY_AESIO ?= 0 +CIRCUITPY_ATEXIT ?= 0 CIRCUITPY_AUDIOMIXER ?= 0 CIRCUITPY_BINASCII ?= 0 CIRCUITPY_BITBANGIO ?= 0 @@ -33,6 +34,7 @@ CIRCUITPY_COUNTIO ?= 0 # Not enough RAM for framebuffers CIRCUITPY_FRAMEBUFFERIO ?= 0 CIRCUITPY_FREQUENCYIO ?= 0 +CIRCUITPY_GETPASS ?= 0 CIRCUITPY_GIFIO ?= 0 CIRCUITPY_I2CPERIPHERAL ?= 0 CIRCUITPY_JSON ?= 0 diff --git a/ports/espressif/CMakeLists.txt b/ports/espressif/CMakeLists.txt index 6ad33282f8..afbb51bbad 100644 --- a/ports/espressif/CMakeLists.txt +++ b/ports/espressif/CMakeLists.txt @@ -6,7 +6,7 @@ set(ENV{IDF_PATH} ${CMAKE_SOURCE_DIR}/esp-idf) # The component list here determines what options we get in menuconfig and what the ninja file # can build. -set(COMPONENTS esptool_py soc driver log main esp-tls mbedtls esp_event esp_adc_cal esp_netif esp_wifi lwip wpa_supplicant freertos) +set(COMPONENTS esptool_py soc driver log main esp-tls mbedtls esp_event esp_adc_cal esp_netif esp_wifi lwip wpa_supplicant freertos bt) include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(circuitpython) diff --git a/ports/espressif/Makefile b/ports/espressif/Makefile index acc8ec5720..d95812ad63 100644 --- a/ports/espressif/Makefile +++ b/ports/espressif/Makefile @@ -86,6 +86,16 @@ INC += \ -isystem esp-idf \ -isystem esp-idf/components/app_update/include \ -isystem esp-idf/components/bootloader_support/include \ + -isystem esp-idf/components/bt/include/$(IDF_TARGET)/include \ + -isystem esp-idf/components/bt/host/nimble/esp-hci/include \ + -isystem esp-idf/components/bt/host/nimble/nimble/nimble/controller/include \ + -isystem esp-idf/components/bt/host/nimble/nimble/nimble/host/include \ + -isystem esp-idf/components/bt/host/nimble/nimble/nimble/host/services/gap/include \ + -isystem esp-idf/components/bt/host/nimble/nimble/nimble/include \ + -isystem esp-idf/components/bt/host/nimble/nimble/nimble/host/util/include \ + -isystem esp-idf/components/bt/host/nimble/nimble/porting/nimble/include \ + -isystem esp-idf/components/bt/host/nimble/nimble/porting/npl/freertos/include \ + -isystem esp-idf/components/bt/host/nimble/port/include \ -isystem esp-idf/components/driver/include \ -isystem esp-idf/components/driver/$(IDF_TARGET)/include \ -isystem esp-idf/components/$(IDF_TARGET)/include \ @@ -133,6 +143,7 @@ endif CFLAGS += \ -DHAVE_CONFIG_H \ + -DESP_PLATFORM=1 \ -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" \ -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX @@ -148,7 +159,12 @@ ifeq ($(DEBUG), 1) # CFLAGS += -fno-inline -fno-ipa-sra else CFLAGS += -DNDEBUG -ggdb3 - OPTIMIZATION_FLAGS ?= -O2 + ifeq ($(IDF_TARGET_ARCH),xtensa) + OPTIMIZATION_FLAGS ?= -O2 + else + # RISC-V is larger than xtensa so do -Os for it + OPTIMIZATION_FLAGS ?= -Os + endif # TODO: Test with -flto ### CFLAGS += -flto endif @@ -298,8 +314,10 @@ else DEBUG_SDKCONFIG = esp-idf-config/sdkconfig-opt.defaults endif -SDKCONFIGS = esp-idf-config/sdkconfig.defaults;$(DEBUG_SDKCONFIG);$(FLASH_SDKCONFIG);$(TARGET_SDKCONFIG);boards/$(BOARD)/sdkconfig - +SDKCONFIGS := esp-idf-config/sdkconfig.defaults;$(DEBUG_SDKCONFIG);$(FLASH_SDKCONFIG);$(TARGET_SDKCONFIG);boards/$(BOARD)/sdkconfig +ifneq ($(CIRCUITPY_BLEIO),0) + SDKCONFIGS := esp-idf-config/sdkconfig-ble.defaults;$(SDKCONFIGS) +endif # create the config headers $(BUILD)/esp-idf/config/sdkconfig.h: boards/$(BOARD)/sdkconfig | $(BUILD)/esp-idf IDF_PATH=$(IDF_PATH) cmake -S . -B $(BUILD)/esp-idf -DSDKCONFIG=$(BUILD)/esp-idf/sdkconfig -DSDKCONFIG_DEFAULTS="$(SDKCONFIGS)" -DCMAKE_TOOLCHAIN_FILE=$(IDF_PATH)/tools/cmake/toolchain-$(IDF_TARGET).cmake -DIDF_TARGET=$(IDF_TARGET) -GNinja @@ -332,6 +350,12 @@ BINARY_WIFI_BLOBS = libcoexist.a libcore.a libespnow.a libmesh.a libnet80211.a l BINARY_BLOBS = esp-idf/components/esp_phy/lib/$(IDF_TARGET)/libphy.a $(addprefix esp-idf/components/esp_wifi/lib/$(IDF_TARGET)/, $(BINARY_WIFI_BLOBS)) ESP_IDF_COMPONENTS_LINK = $(IDF_TARGET_ARCH) app_update bootloader_support driver efuse esp_adc_cal esp_common esp_event esp_hw_support esp_ipc esp_netif esp_pm esp_phy esp_ringbuf esp_rom esp_system esp_timer esp-tls esp_wifi freertos hal heap log lwip mbedtls newlib nvs_flash pthread soc spi_flash vfs wpa_supplicant +ifneq ($(CIRCUITPY_BLEIO),0) + ESP_IDF_COMPONENTS_LINK += bt + BINARY_BLOBS += esp-idf/components/esp_phy/lib/$(IDF_TARGET)/libbtbb.a \ + esp-idf/components/bt/controller/lib_esp32c3_family/$(IDF_TARGET)/libbtdm_app.a +endif + ESP_IDF_COMPONENTS_EXPANDED = $(foreach component, $(ESP_IDF_COMPONENTS_LINK), $(BUILD)/esp-idf/esp-idf/$(component)/lib$(component).a) MBEDTLS_COMPONENTS_LINK = crypto tls x509 @@ -350,6 +374,11 @@ else BOOTLOADER_OFFSET = 0x1000 endif +IDF_CMAKE_TARGETS = \ + bootloader/bootloader.bin \ + esp-idf/esp_system/__ldgen_output_sections.ld \ + $(foreach component, $(ESP_IDF_COMPONENTS_LINK), esp-idf/$(component)/lib$(component).a) + PARTITION_TABLE_OFFSET = 0x8000 FIRMWARE_OFFSET = 0x10000 @@ -367,41 +396,7 @@ endif .PHONY: esp-idf-stamp esp-idf-stamp: $(BUILD)/esp-idf/config/sdkconfig.h - $(Q)ninja -C $(BUILD)/esp-idf \ - bootloader/bootloader.bin \ - esp-idf/esp_system/__ldgen_output_sections.ld \ - esp-idf/app_update/libapp_update.a \ - esp-idf/bootloader_support/libbootloader_support.a \ - esp-idf/driver/libdriver.a \ - esp-idf/efuse/libefuse.a \ - esp-idf/esp_adc_cal/libesp_adc_cal.a \ - esp-idf/esp_common/libesp_common.a \ - esp-idf/esp_event/libesp_event.a \ - esp-idf/esp_hw_support/libesp_hw_support.a \ - esp-idf/esp_ipc/libesp_ipc.a \ - esp-idf/esp_netif/libesp_netif.a \ - esp-idf/esp_phy/libesp_phy.a \ - esp-idf/esp_pm/libesp_pm.a \ - esp-idf/esp_ringbuf/libesp_ringbuf.a \ - esp-idf/esp_rom/libesp_rom.a \ - esp-idf/esp_system/libesp_system.a \ - esp-idf/esp_timer/libesp_timer.a \ - esp-idf/esp-tls/libesp-tls.a \ - esp-idf/esp_wifi/libesp_wifi.a \ - esp-idf/freertos/libfreertos.a \ - esp-idf/hal/libhal.a \ - esp-idf/heap/libheap.a \ - esp-idf/log/liblog.a \ - esp-idf/lwip/liblwip.a \ - esp-idf/mbedtls/libmbedtls.a \ - esp-idf/newlib/libnewlib.a \ - esp-idf/nvs_flash/libnvs_flash.a \ - esp-idf/pthread/libpthread.a \ - esp-idf/soc/libsoc.a \ - esp-idf/spi_flash/libspi_flash.a \ - esp-idf/vfs/libvfs.a \ - esp-idf/wpa_supplicant/libwpa_supplicant.a \ - esp-idf/$(IDF_TARGET_ARCH)/lib$(IDF_TARGET_ARCH).a + $(Q)ninja -C $(BUILD)/esp-idf $(IDF_CMAKE_TARGETS) $(BUILD)/firmware.elf: $(OBJ) | esp-idf-stamp $(STEPECHO) "LINK $@" diff --git a/ports/espressif/boards/unexpectedmaker_feathers3/board.c b/ports/espressif/boards/unexpectedmaker_feathers3/board.c new file mode 100644 index 0000000000..0432485111 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_feathers3/board.c @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO43); + common_hal_never_reset_pin(&pin_GPIO44); + #endif /* DEBUG */ +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h b/ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h new file mode 100644 index 0000000000..3c9f8f25c1 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h @@ -0,0 +1,49 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "FeatherS3" +#define MICROPY_HW_MCU_NAME "ESP32S3" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO40) +#define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO39) +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") + +#define AUTORESET_DELAY_MS 500 + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO9) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO8) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO44) +#define DEFAULT_UART_BUS_TX (&pin_GPIO43) + +#define DOUBLE_TAP_PIN (&pin_GPIO47) diff --git a/ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.mk b/ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.mk new file mode 100644 index 0000000000..866bd15ffa --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.mk @@ -0,0 +1,22 @@ +USB_VID = 0x303A +USB_PID = 0x80D7 +USB_PRODUCT = "FeatherS3" +USB_MANUFACTURER = "UnexpectedMaker" + +IDF_TARGET = esp32s3 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=16MB + +#CIRCUITPY_BITBANG_NEOPIXEL = 1 + +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/espressif/boards/unexpectedmaker_feathers3/pins.c b/ports/espressif/boards/unexpectedmaker_feathers3/pins.c new file mode 100644 index 0000000000..8f7ac81261 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_feathers3/pins.c @@ -0,0 +1,119 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO17) }, + + { MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO14) }, + + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO12) }, + + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO6) }, + + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D19), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_D25), MP_ROM_PTR(&pin_GPIO36) }, + + { MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_D24), MP_ROM_PTR(&pin_GPIO35) }, + + { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_D23), MP_ROM_PTR(&pin_GPIO37) }, + + { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + + { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + + // { MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) }, + // { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO42) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_A11), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D21), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_A12), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D22), MP_ROM_PTR(&pin_GPIO9) }, + + { MP_ROM_QSTR(MP_QSTR_IO33), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO33) }, + + { MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO38) }, + + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_GPIO10) }, + + { MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_A10), MP_ROM_PTR(&pin_GPIO11) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO13) }, // Blue LED + + // Battery voltage sense pin + // I really don't know what name to use here. Adafruit use BATTERY & VOLTAGE_MONITOR + // I prefer VBAT or VBAT_SENSE + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_VBAT), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_VBAT_SENSE), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_GPIO2) }, + + // 5V present sense pin + { MP_ROM_QSTR(MP_QSTR_VBUS), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_VBUS_SENSE), MP_ROM_PTR(&pin_GPIO34) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO40) }, + + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, // Ambient Light Sensor + { MP_ROM_QSTR(MP_QSTR_AMB), MP_ROM_PTR(&pin_GPIO4) }, // Ambient Light Sensor + + { MP_ROM_QSTR(MP_QSTR_LDO2), MP_ROM_PTR(&pin_GPIO39) }, // Second LDO Enable control + { MP_ROM_QSTR(MP_QSTR_I39), MP_ROM_PTR(&pin_GPIO39) }, // Second LDO Enable control + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/unexpectedmaker_feathers3/sdkconfig b/ports/espressif/boards/unexpectedmaker_feathers3/sdkconfig new file mode 100644 index 0000000000..ec989c08fc --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_feathers3/sdkconfig @@ -0,0 +1,39 @@ +CONFIG_ESP32S3_SPIRAM_SUPPORT=y + +# +# SPI RAM config +# +# CONFIG_SPIRAM_TYPE_AUTO is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set +CONFIG_SPIRAM_TYPE_ESPPSRAM64=y +CONFIG_SPIRAM_SIZE=8388608 + +# +# PSRAM clock and cs IO for ESP32S2 +# +CONFIG_DEFAULT_PSRAM_CLK_IO=30 +CONFIG_DEFAULT_PSRAM_CS_IO=26 +# end of PSRAM clock and cs IO for ESP32S2 + +# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set +# CONFIG_SPIRAM_RODATA is not set +CONFIG_SPIRAM_SPEED_80M=y +# CONFIG_SPIRAM_SPEED_40M is not set +# CONFIG_SPIRAM_SPEED_26M is not set +# CONFIG_SPIRAM_SPEED_20M is not set +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set +CONFIG_SPIRAM_USE_MEMMAP=y +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +# CONFIG_SPIRAM_USE_MALLOC is not set +# CONFIG_SPIRAM_MEMTEST=y +# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set +# end of SPI RAM config + +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="UMFeatherS3" +# end of LWIP diff --git a/ports/espressif/boards/unexpectedmaker_pros3/board.c b/ports/espressif/boards/unexpectedmaker_pros3/board.c new file mode 100644 index 0000000000..0432485111 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_pros3/board.c @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO43); + common_hal_never_reset_pin(&pin_GPIO44); + #endif /* DEBUG */ +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h b/ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h new file mode 100644 index 0000000000..8c578e5e49 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h @@ -0,0 +1,49 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "ProS3" +#define MICROPY_HW_MCU_NAME "ESP32S3" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO18) +#define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO17) +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") + +#define AUTORESET_DELAY_MS 500 + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO9) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO8) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO44) +#define DEFAULT_UART_BUS_TX (&pin_GPIO43) + +#define DOUBLE_TAP_PIN (&pin_GPIO47) diff --git a/ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.mk b/ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.mk new file mode 100644 index 0000000000..3b50324d3c --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.mk @@ -0,0 +1,22 @@ +USB_VID = 0x303A +USB_PID = 0x80D4 +USB_PRODUCT = "ProS3" +USB_MANUFACTURER = "UnexpectedMaker" + +IDF_TARGET = esp32s3 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=qio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=16MB + +# CIRCUITPY_BITBANG_NEOPIXEL = 1 + +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/espressif/boards/unexpectedmaker_pros3/pins.c b/ports/espressif/boards/unexpectedmaker_pros3/pins.c new file mode 100644 index 0000000000..0bf4bca35d --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_pros3/pins.c @@ -0,0 +1,139 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO2) }, + + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) }, + + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, + + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) }, + + + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_A11), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) }, + + { MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_A12), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) }, + + { MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_A13), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO14) }, + + { MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_A14), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO15) }, + + { MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_A15), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO16) }, + + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_D21), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_IO34), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_D34), MP_ROM_PTR(&pin_GPIO34) }, + + { MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_MO), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_SDO), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO35) }, + + { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_MI), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_SDI), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_D37), MP_ROM_PTR(&pin_GPIO37) }, + + { MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_D36), MP_ROM_PTR(&pin_GPIO36) }, + + { MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_D38), MP_ROM_PTR(&pin_GPIO38) }, + + { MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_MTCK), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_D39), MP_ROM_PTR(&pin_GPIO39) }, + + { MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_MTDO), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_D40), MP_ROM_PTR(&pin_GPIO40) }, + + { MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_MTDI), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_D41), MP_ROM_PTR(&pin_GPIO41) }, + + { MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) }, + { MP_ROM_QSTR(MP_QSTR_MTMS), MP_ROM_PTR(&pin_GPIO42) }, + { MP_ROM_QSTR(MP_QSTR_D42), MP_ROM_PTR(&pin_GPIO42) }, + + { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + + { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + + // Battery voltage sense pin + // I really don't know what name to use here. Adafruit use BATTERY & VOLTAGE_MONITOR + // I prefer VBAT or VBAT_SENSE + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_VBAT), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_VBAT_SENSE), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_GPIO10) }, + + // 5V present sense pin + { MP_ROM_QSTR(MP_QSTR_VBUS), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_VBUS_SENSE), MP_ROM_PTR(&pin_GPIO33) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_LDO2), MP_ROM_PTR(&pin_GPIO17) }, // Second LDO Enable control + { MP_ROM_QSTR(MP_QSTR_I17), MP_ROM_PTR(&pin_GPIO17) }, // Second LDO Enable control + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/unexpectedmaker_pros3/sdkconfig b/ports/espressif/boards/unexpectedmaker_pros3/sdkconfig new file mode 100644 index 0000000000..eeb103fb7d --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_pros3/sdkconfig @@ -0,0 +1,39 @@ +CONFIG_ESP32S3_SPIRAM_SUPPORT=y + +# +# SPI RAM config +# +# CONFIG_SPIRAM_TYPE_AUTO is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set +CONFIG_SPIRAM_TYPE_ESPPSRAM64=y +CONFIG_SPIRAM_SIZE=8388608 + +# +# PSRAM clock and cs IO for ESP32S2 +# +CONFIG_DEFAULT_PSRAM_CLK_IO=30 +CONFIG_DEFAULT_PSRAM_CS_IO=26 +# end of PSRAM clock and cs IO for ESP32S2 + +# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set +# CONFIG_SPIRAM_RODATA is not set +CONFIG_SPIRAM_SPEED_80M=y +# CONFIG_SPIRAM_SPEED_40M is not set +# CONFIG_SPIRAM_SPEED_26M is not set +# CONFIG_SPIRAM_SPEED_20M is not set +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set +CONFIG_SPIRAM_USE_MEMMAP=y +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +# CONFIG_SPIRAM_USE_MALLOC is not set +# CONFIG_SPIRAM_MEMTEST=y +# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set +# end of SPI RAM config + +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="UMProS3" +# end of LWIP diff --git a/ports/espressif/boards/unexpectedmaker_tinys3/board.c b/ports/espressif/boards/unexpectedmaker_tinys3/board.c new file mode 100644 index 0000000000..0432485111 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_tinys3/board.c @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO43); + common_hal_never_reset_pin(&pin_GPIO44); + #endif /* DEBUG */ +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h b/ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h new file mode 100644 index 0000000000..c4853f4709 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h @@ -0,0 +1,49 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "TinyS3" +#define MICROPY_HW_MCU_NAME "ESP32S3" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO18) +#define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO17) +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") + +#define AUTORESET_DELAY_MS 500 + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO9) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO8) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO44) +#define DEFAULT_UART_BUS_TX (&pin_GPIO43) + +#define DOUBLE_TAP_PIN (&pin_GPIO47) diff --git a/ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.mk b/ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.mk new file mode 100644 index 0000000000..32a711c257 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.mk @@ -0,0 +1,24 @@ +USB_VID = 0x303A +USB_PID = 0x80D1 +USB_PRODUCT = "TinyS3" +USB_MANUFACTURER = "UnexpectedMaker" + +IDF_TARGET = esp32s3 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=8MB + +# CIRCUITPY_BITBANG_NEOPIXEL = 1 + +CIRCUITPY_STAGE = 1 + +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/espressif/boards/unexpectedmaker_tinys3/pins.c b/ports/espressif/boards/unexpectedmaker_tinys3/pins.c new file mode 100644 index 0000000000..f1c429bf99 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_tinys3/pins.c @@ -0,0 +1,96 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO2) }, + + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) }, + + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, + + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) }, + + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_D21), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_IO34), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_D34), MP_ROM_PTR(&pin_GPIO34) }, + + { MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_MO), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_SDO), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO35) }, + + { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_MI), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_SDI), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_D37), MP_ROM_PTR(&pin_GPIO37) }, + + { MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_D36), MP_ROM_PTR(&pin_GPIO36) }, + + { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + + { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + + // Battery voltage sense pin + // I really don't know what name to use here. Adafruit use BATTERY & VOLTAGE_MONITOR + // I prefer VBAT or VBAT_SENSE + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_VBAT), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_VBAT_SENSE), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_GPIO10) }, + + // 5V present sense pin + { MP_ROM_QSTR(MP_QSTR_VBUS), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_VBUS_SENSE), MP_ROM_PTR(&pin_GPIO33) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/unexpectedmaker_tinys3/sdkconfig b/ports/espressif/boards/unexpectedmaker_tinys3/sdkconfig new file mode 100644 index 0000000000..0ac438450d --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_tinys3/sdkconfig @@ -0,0 +1,41 @@ +CONFIG_ESP32S3_SPIRAM_SUPPORT=y + +# +# SPI RAM config +# +# CONFIG_SPIRAM_MODE_OCT is not set +CONFIG_SPIRAM_MODE_QUAD=y +# CONFIG_SPIRAM_TYPE_AUTO is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set +CONFIG_SPIRAM_TYPE_ESPPSRAM64=y +CONFIG_SPIRAM_SIZE=8388608 + +# +# PSRAM clock and cs IO for ESP32S3 +# +CONFIG_DEFAULT_PSRAM_CLK_IO=30 +CONFIG_DEFAULT_PSRAM_CS_IO=26 +# end of PSRAM clock and cs IO for ESP32S3 + +# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set +# CONFIG_SPIRAM_RODATA is not set +CONFIG_SPIRAM_SPEED_80M=y +# CONFIG_SPIRAM_SPEED_40M is not set +# CONFIG_SPIRAM_SPEED_26M is not set +# CONFIG_SPIRAM_SPEED_20M is not set +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set +CONFIG_SPIRAM_USE_MEMMAP=y +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +# CONFIG_SPIRAM_USE_MALLOC is not set +# CONFIG_SPIRAM_MEMTEST=y +# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set +# end of SPI RAM config + +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="UMTinyS3" +# end of LWIP diff --git a/ports/espressif/common-hal/_bleio/Adapter.c b/ports/espressif/common-hal/_bleio/Adapter.c new file mode 100644 index 0000000000..1927d6da62 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Adapter.c @@ -0,0 +1,567 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2016 Glenn Ruben Bakke + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include +#include + +#include "py/gc.h" +#include "py/objstr.h" +#include "py/runtime.h" +#include "supervisor/shared/bluetooth/bluetooth.h" +#include "supervisor/shared/safe_mode.h" +#include "supervisor/shared/tick.h" +#include "supervisor/usb.h" +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Adapter.h" +#include "shared-bindings/_bleio/Address.h" +#include "shared-bindings/nvm/ByteArray.h" +#include "shared-bindings/_bleio/Connection.h" +#include "shared-bindings/_bleio/ScanEntry.h" +#include "shared-bindings/time/__init__.h" + +#include "controller/ble_ll_adv.h" +#include "nimble/hci_common.h" +#include "nimble/nimble_port.h" +#include "nimble/nimble_port_freertos.h" +#include "host/ble_gap.h" +#include "host/util/util.h" +#include "services/gap/ble_svc_gap.h" + +#include "common-hal/_bleio/Connection.h" + +#include "esp_bt.h" +#include "esp_nimble_hci.h" + +bleio_connection_internal_t bleio_connections[BLEIO_TOTAL_CONNECTION_COUNT]; + +// static void bluetooth_adapter_background(void *data) { +// supervisor_bluetooth_background(); +// bleio_background(); +// } + +bool ble_active = false; + +static void nimble_host_task(void *param) { + nimble_port_run(); + nimble_port_freertos_deinit(); +} + +static TaskHandle_t cp_task = NULL; + +static void _on_sync(void) { + int rc = ble_hs_util_ensure_addr(0); + assert(rc == 0); + + xTaskNotifyGive(cp_task); +} + +void common_hal_bleio_adapter_set_enabled(bleio_adapter_obj_t *self, bool enabled) { + const bool is_enabled = common_hal_bleio_adapter_get_enabled(self); + + // Don't enable or disable twice + if (is_enabled == enabled) { + return; + } + + if (enabled) { + esp_nimble_hci_and_controller_init(); + nimble_port_init(); + // ble_hs_cfg.reset_cb = blecent_on_reset; + ble_hs_cfg.sync_cb = _on_sync; + // ble_hs_cfg.store_status_cb = ble_store_util_status_rr; + ble_svc_gap_device_name_set("CIRCUITPY"); + + // Clear all of the internal connection objects. + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + bleio_connection_internal_t *connection = &bleio_connections[i]; + // Reset connection. + connection->conn_handle = BLEIO_HANDLE_INVALID; + } + + cp_task = xTaskGetCurrentTaskHandle(); + + nimble_port_freertos_init(nimble_host_task); + // Wait for sync. + ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(200)); + } else { + nimble_port_stop(); + } +} + +bool common_hal_bleio_adapter_get_enabled(bleio_adapter_obj_t *self) { + return xTaskGetHandle("ble") != NULL; +} + +bleio_address_obj_t *common_hal_bleio_adapter_get_address(bleio_adapter_obj_t *self) { + uint8_t address_bytes[6]; + uint8_t address_type = BLE_ADDR_RANDOM; + ble_hs_id_infer_auto(0, &address_type); + int result = ble_hs_id_copy_addr(address_type, address_bytes, NULL); + if (result != 0) { + return NULL; + } + + bleio_address_obj_t *address = m_new_obj(bleio_address_obj_t); + address->base.type = &bleio_address_type; + common_hal_bleio_address_construct(address, address_bytes, BLEIO_ADDRESS_TYPE_RANDOM_STATIC); + return address; +} + +bool common_hal_bleio_adapter_set_address(bleio_adapter_obj_t *self, bleio_address_obj_t *address) { + if (address->type != BLEIO_ADDRESS_TYPE_RANDOM_STATIC) { + return false; + } + mp_buffer_info_t bufinfo; + if (!mp_get_buffer(address->bytes, &bufinfo, MP_BUFFER_READ)) { + return false; + } + int result = ble_hs_id_set_rnd(bufinfo.buf); + return result == 0; +} + +mp_obj_str_t *common_hal_bleio_adapter_get_name(bleio_adapter_obj_t *self) { + const char *name = ble_svc_gap_device_name(); + + return mp_obj_new_str(name, strlen(name)); +} + +void common_hal_bleio_adapter_set_name(bleio_adapter_obj_t *self, const char *name) { + ble_svc_gap_device_name_set(name); +} + +static int _scan_event(struct ble_gap_event *event, void *scan_results_in) { + bleio_scanresults_obj_t *scan_results = (bleio_scanresults_obj_t *)scan_results_in; + + if (event->type == BLE_GAP_EVENT_DISC_COMPLETE) { + shared_module_bleio_scanresults_set_done(scan_results, true); + return 0; + } + + if (event->type != BLE_GAP_EVENT_DISC && event->type != BLE_GAP_EVENT_EXT_DISC) { + #if CIRCUITPY_VERBOSE_BLE + mp_printf(&mp_plat_print, "Unsupported scan event %d\n", event->type); + #endif + return 0; + } + + if (event->type == BLE_GAP_EVENT_DISC) { + // Legacy advertisement + struct ble_gap_disc_desc *disc = &event->disc; + bool connectable = disc->event_type == BLE_HCI_ADV_RPT_EVTYPE_ADV_IND || + disc->event_type == BLE_HCI_ADV_RPT_EVTYPE_DIR_IND; + shared_module_bleio_scanresults_append(scan_results, + supervisor_ticks_ms64(), + connectable, + disc->event_type == BLE_HCI_ADV_RPT_EVTYPE_SCAN_RSP, + disc->rssi, + disc->addr.val, + disc->addr.type, + disc->data, + disc->length_data); + } else { + // Extended advertisement + struct ble_gap_ext_disc_desc *disc = &event->ext_disc; + shared_module_bleio_scanresults_append(scan_results, + supervisor_ticks_ms64(), + (disc->props & BLE_HCI_ADV_CONN_MASK) != 0, + (disc->props & BLE_HCI_ADV_SCAN_MASK) != 0, + disc->rssi, + disc->addr.val, + disc->addr.type, + disc->data, + disc->length_data); + } + + return 0; +} + +mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t *prefixes, + size_t prefix_length, bool extended, mp_int_t buffer_size, mp_float_t timeout, + mp_float_t interval, mp_float_t window, mp_int_t minimum_rssi, bool active) { + if (self->scan_results != NULL) { + if (!shared_module_bleio_scanresults_get_done(self->scan_results)) { + mp_raise_bleio_BluetoothError(translate("Scan already in progess. Stop with stop_scan.")); + } + self->scan_results = NULL; + } + + self->scan_results = shared_module_bleio_new_scanresults(buffer_size, prefixes, prefix_length, minimum_rssi); + // size_t max_packet_size = extended ? BLE_HCI_MAX_EXT_ADV_DATA_LEN : BLE_HCI_MAX_ADV_DATA_LEN; + + uint8_t own_addr_type; + struct ble_gap_disc_params disc_params; + + /* Figure out address to use while advertising (no privacy for now) */ + int privacy = 0; + CHECK_NIMBLE_ERROR(ble_hs_id_infer_auto(privacy, &own_addr_type)); + + disc_params.filter_duplicates = 0; + disc_params.passive = !active; + disc_params.itvl = interval / 0.625; + disc_params.window = window / 0.625; + disc_params.filter_policy = 0; + disc_params.limited = 0; + + CHECK_NIMBLE_ERROR(ble_gap_disc(own_addr_type, timeout * 1000, &disc_params, + _scan_event, self->scan_results)); + + return MP_OBJ_FROM_PTR(self->scan_results); +} + +void common_hal_bleio_adapter_stop_scan(bleio_adapter_obj_t *self) { + if (self->scan_results == NULL) { + return; + } + ble_gap_disc_cancel(); + shared_module_bleio_scanresults_set_done(self->scan_results, true); + self->scan_results = NULL; +} + +STATIC void _convert_address(const bleio_address_obj_t *address, ble_addr_t *nimble_address) { + nimble_address->type = address->type; + mp_buffer_info_t address_buf_info; + mp_get_buffer_raise(address->bytes, &address_buf_info, MP_BUFFER_READ); + memcpy(nimble_address->val, (uint8_t *)address_buf_info.buf, NUM_BLEIO_ADDRESS_BYTES); +} + +STATIC void _new_connection(uint16_t conn_handle) { + // Set the tx_power for the connection higher than the advertisement. + esp_ble_tx_power_set(conn_handle, ESP_PWR_LVL_N0); + + + // Find an empty connection. One must always be available because the SD has the same + // total connection limit. + bleio_connection_internal_t *connection; + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + connection = &bleio_connections[i]; + if (connection->conn_handle == BLEIO_HANDLE_INVALID) { + break; + } + } + connection->conn_handle = conn_handle; + connection->connection_obj = mp_const_none; + connection->pair_status = PAIR_NOT_PAIRED; + connection->mtu = 0; + + // Change the callback for the connection. + ble_gap_set_event_cb(conn_handle, bleio_connection_event_cb, connection); +} + +mp_obj_t common_hal_bleio_adapter_connect(bleio_adapter_obj_t *self, bleio_address_obj_t *address, mp_float_t timeout) { + mp_raise_NotImplementedError(NULL); + + mp_raise_bleio_BluetoothError(translate("Failed to connect: internal error")); + + return mp_const_none; +} + +typedef struct { + struct os_mbuf mbuf; + struct os_mbuf_pkthdr hdr; +} os_mbuf_t; + +STATIC void _wrap_in_mbuf(const uint8_t *data, uint16_t len, os_mbuf_t *buf) { + struct os_mbuf *mbuf = &buf->mbuf; + mbuf->om_data = (uint8_t *)data, + mbuf->om_flags = 0; + mbuf->om_pkthdr_len = 0; + mbuf->om_len = len; + mbuf->om_next.sle_next = NULL; + + buf->hdr.omp_len = len; + + // Setting the pool to NULL will cause frees to fail. Hopefully that failure + // is ignored. + mbuf->om_omp = NULL; +} + +static int _advertising_event(struct ble_gap_event *event, void *self_in) { + bleio_adapter_obj_t *self = (bleio_adapter_obj_t *)self_in; + + #if CIRCUITPY_VERBOSE_BLE + mp_printf(&mp_plat_print, "Advertising event: %d\n", event->type); + #endif + switch (event->type) { + case BLE_GAP_EVENT_CONNECT: + // Spurious connect events can happen. + break; + + case BLE_GAP_EVENT_ADV_COMPLETE: + if (event->adv_complete.reason == NIMBLE_OK) { + _new_connection(event->adv_complete.conn_handle); + // Set connections objs back to NULL since we have a new + // connection and need a new tuple. + self->connection_objs = NULL; + } + // Other statuses indicate timeout or preemption. + common_hal_bleio_adapter_stop_advertising(self); + break; + + default: + #if CIRCUITPY_VERBOSE_BLE + // For debugging. + mp_printf(&mp_plat_print, "Unhandled advertising event: %d\n", event->type); + #endif + break; + } + return 0; +} + +uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, + bool connectable, bool anonymous, uint32_t timeout, float interval, + const uint8_t *advertising_data, uint16_t advertising_data_len, + const uint8_t *scan_response_data, uint16_t scan_response_data_len, + mp_int_t tx_power, const bleio_address_obj_t *directed_to) { + + if (ble_gap_adv_active() && !self->user_advertising) { + return BLE_HS_EBUSY; + } + + uint32_t rc; + bool extended = advertising_data_len > BLE_ADV_LEGACY_DATA_MAX_LEN || + scan_response_data_len > BLE_ADV_LEGACY_DATA_MAX_LEN; + + ble_addr_t peer; + if (directed_to != NULL) { + _convert_address(directed_to, &peer); + } + + uint8_t own_addr_type; + // Anonymous addresses are still resolvable. (Following what the NRF + // implementation does.) + rc = ble_hs_id_infer_auto(anonymous, &own_addr_type); + if (rc != NIMBLE_OK) { + return rc; + } + + bool high_duty_directed = directed_to != NULL && interval <= 3.5 && timeout <= 1.3; + + struct ble_gap_ext_adv_params adv_params = { + .connectable = connectable, + .scannable = scan_response_data_len > 0, + .directed = directed_to != NULL, + .high_duty_directed = high_duty_directed, + .legacy_pdu = !extended, + .anonymous = anonymous, + .include_tx_power = extended, + .scan_req_notif = false, + .itvl_min = SEC_TO_UNITS(interval, UNIT_0_625_MS) + 0.5f, + .itvl_max = SEC_TO_UNITS(interval, UNIT_0_625_MS) + 0.5f, + .channel_map = 0, + .own_addr_type = own_addr_type, + .peer = peer, + .filter_policy = BLE_HCI_CONN_FILT_NO_WL, + .primary_phy = BLE_HCI_LE_PHY_1M, + .secondary_phy = BLE_HCI_LE_PHY_1M, + .tx_power = tx_power, + .sid = 0, + }; + + // Configure must come before setting payloads. + rc = ble_gap_ext_adv_configure(0, + &adv_params, + NULL, + _advertising_event, self); + if (rc != NIMBLE_OK) { + return rc; + } + + os_mbuf_t buf; + _wrap_in_mbuf(advertising_data, advertising_data_len, &buf); + // This copies the advertising data into buffers to send to the controller. + // Therefore, we don't need to worry about the lifetime of our copy. + rc = ble_gap_ext_adv_set_data(0, &buf.mbuf); + if (rc != NIMBLE_OK) { + return rc; + } + + if (scan_response_data_len > 0) { + _wrap_in_mbuf(scan_response_data, scan_response_data_len, &buf); + // This copies the advertising data into buffers to send to the controller. + // Therefore, we don't need to worry about the lifetime of our copy. + rc = ble_gap_ext_adv_rsp_set_data(0, &buf.mbuf); + if (rc != NIMBLE_OK) { + return rc; + } + } + + rc = ble_gap_ext_adv_start(0, timeout / 10, 0); + if (rc != NIMBLE_OK) { + return rc; + } + + return NIMBLE_OK; +} + +STATIC void check_data_fit(size_t data_len, bool connectable) { + if (data_len > MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE) || + (connectable && data_len > MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE))) { + mp_raise_ValueError(translate("Data too large for advertisement packet")); + } +} + +void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool connectable, + bool anonymous, uint32_t timeout, mp_float_t interval, + mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo, + mp_int_t tx_power, const bleio_address_obj_t *directed_to) { + if (self->user_advertising) { + mp_raise_bleio_BluetoothError(translate("Already advertising.")); + } else { + // If the user isn't advertising, then the background is. So, stop the + // background advertising so the user can. + common_hal_bleio_adapter_stop_advertising(self); + } + // interval value has already been validated. + + check_data_fit(advertising_data_bufinfo->len, connectable); + check_data_fit(scan_response_data_bufinfo->len, connectable); + + if (advertising_data_bufinfo->len > 31 && scan_response_data_bufinfo->len > 0) { + mp_raise_bleio_BluetoothError(translate("Extended advertisements with scan response not supported.")); + } + + + if (advertising_data_bufinfo->len > 0 && directed_to != NULL) { + mp_raise_bleio_BluetoothError(translate("Data not supported with directed advertising")); + } + + if (anonymous) { + mp_raise_NotImplementedError(NULL); + } + + if (!timeout) { + timeout = BLE_HS_FOREVER; + } else if (timeout > INT32_MAX) { + mp_raise_bleio_BluetoothError(translate("Timeout is too long: Maximum timeout length is %d seconds"), + INT32_MAX / 1000); + } + + CHECK_NIMBLE_ERROR(_common_hal_bleio_adapter_start_advertising(self, connectable, anonymous, timeout, interval, + advertising_data_bufinfo->buf, + advertising_data_bufinfo->len, + scan_response_data_bufinfo->buf, + scan_response_data_bufinfo->len, + tx_power, + directed_to)); + self->user_advertising = true; +} + +void common_hal_bleio_adapter_stop_advertising(bleio_adapter_obj_t *self) { + int err_code = ble_gap_ext_adv_stop(0); + self->user_advertising = false; + + if ((err_code != NIMBLE_OK) && + (err_code != BLE_HS_EALREADY) && + (err_code != BLE_HS_EINVAL)) { + CHECK_NIMBLE_ERROR(err_code); + } +} + +bool common_hal_bleio_adapter_get_advertising(bleio_adapter_obj_t *self) { + return ble_gap_adv_active(); +} + +bool common_hal_bleio_adapter_get_connected(bleio_adapter_obj_t *self) { + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + bleio_connection_internal_t *connection = &bleio_connections[i]; + if (connection->conn_handle != BLEIO_HANDLE_INVALID) { + return true; + } + } + return false; +} + +mp_obj_t common_hal_bleio_adapter_get_connections(bleio_adapter_obj_t *self) { + if (self->connection_objs != NULL) { + return self->connection_objs; + } + size_t total_connected = 0; + mp_obj_t items[BLEIO_TOTAL_CONNECTION_COUNT]; + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + bleio_connection_internal_t *connection = &bleio_connections[i]; + if (connection->conn_handle != BLEIO_HANDLE_INVALID) { + if (connection->connection_obj == mp_const_none) { + connection->connection_obj = bleio_connection_new_from_internal(connection); + } + items[total_connected] = connection->connection_obj; + total_connected++; + } + } + self->connection_objs = mp_obj_new_tuple(total_connected, items); + return self->connection_objs; +} + +void common_hal_bleio_adapter_erase_bonding(bleio_adapter_obj_t *self) { + mp_raise_NotImplementedError(NULL); + // bonding_erase_storage(); +} + +bool common_hal_bleio_adapter_is_bonded_to_central(bleio_adapter_obj_t *self) { + mp_raise_NotImplementedError(NULL); + // return bonding_peripheral_bond_count() > 0; + return false; +} + +void bleio_adapter_gc_collect(bleio_adapter_obj_t *adapter) { + // We divide by size_t so that we can scan each 32-bit aligned value to see + // if it is a pointer. This allows us to change the structs without worrying + // about collecting new pointers. + gc_collect_root((void **)adapter, sizeof(bleio_adapter_obj_t) / (sizeof(size_t))); + gc_collect_root((void **)bleio_connections, sizeof(bleio_connections) / (sizeof(size_t))); +} + +void bleio_adapter_reset(bleio_adapter_obj_t *adapter) { + common_hal_bleio_adapter_stop_scan(adapter); + if (common_hal_bleio_adapter_get_advertising(adapter)) { + common_hal_bleio_adapter_stop_advertising(adapter); + } + + adapter->connection_objs = NULL; + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + bleio_connection_internal_t *connection = &bleio_connections[i]; + // Disconnect all connections cleanly. + if (connection->conn_handle != BLEIO_HANDLE_INVALID) { + common_hal_bleio_connection_disconnect(connection); + } + connection->connection_obj = mp_const_none; + } + + // Wait up to 125 ms (128 ticks) for disconnect to complete. This should be + // greater than most connection intervals. + bool any_connected = false; + uint64_t start_ticks = supervisor_ticks_ms64(); + while (any_connected && supervisor_ticks_ms64() - start_ticks < 128) { + any_connected = false; + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + bleio_connection_internal_t *connection = &bleio_connections[i]; + any_connected |= connection->conn_handle != BLEIO_HANDLE_INVALID; + } + } +} diff --git a/ports/espressif/common-hal/_bleio/Adapter.h b/ports/espressif/common-hal/_bleio/Adapter.h new file mode 100644 index 0000000000..3534c79809 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Adapter.h @@ -0,0 +1,60 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_ADAPTER_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_ADAPTER_H + +#include "py/obj.h" +#include "py/objtuple.h" + +#include "shared-bindings/_bleio/Connection.h" +#include "shared-bindings/_bleio/ScanResults.h" + +#include "supervisor/background_callback.h" + +#ifndef BLEIO_TOTAL_CONNECTION_COUNT +#define BLEIO_TOTAL_CONNECTION_COUNT 5 +#endif + +#define BLEIO_HANDLE_INVALID 0xffff + +extern bleio_connection_internal_t bleio_connections[BLEIO_TOTAL_CONNECTION_COUNT]; + +typedef struct { + mp_obj_base_t base; + bleio_scanresults_obj_t *scan_results; + mp_obj_t name; + mp_obj_tuple_t *connection_objs; + background_callback_t background_callback; + bool user_advertising; +} bleio_adapter_obj_t; + +void bleio_adapter_gc_collect(bleio_adapter_obj_t *adapter); +void bleio_adapter_reset(bleio_adapter_obj_t *adapter); + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_ADAPTER_H diff --git a/ports/espressif/common-hal/_bleio/Attribute.c b/ports/espressif/common-hal/_bleio/Attribute.c new file mode 100644 index 0000000000..179a3b58aa --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Attribute.c @@ -0,0 +1,29 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/_bleio/Attribute.h" + +// Convert a _bleio security mode to a ble_gap_conn_sec_mode_t setting. diff --git a/shared-module/busio/I2C.h b/ports/espressif/common-hal/_bleio/Attribute.h similarity index 74% rename from shared-module/busio/I2C.h rename to ports/espressif/common-hal/_bleio/Attribute.h index e089ea367b..4612b6c6dd 100644 --- a/shared-module/busio/I2C.h +++ b/ports/espressif/common-hal/_bleio/Attribute.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * Copyright (c) 2018 Dan Halbert for Adafruit Industries * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -24,16 +24,9 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSIO_I2C_H -#define MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSIO_I2C_H +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_ATTRIBUTE_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_ATTRIBUTE_H -#include "shared-module/bitbangio/I2C.h" +#include "shared-module/_bleio/Attribute.h" -#include "py/obj.h" - -typedef struct { - mp_obj_base_t base; - bitbangio_i2c_obj_t bitbang; -} busio_i2c_obj_t; - -#endif // MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSIO_I2C_H +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_ATTRIBUTE_H diff --git a/ports/espressif/common-hal/_bleio/Characteristic.c b/ports/espressif/common-hal/_bleio/Characteristic.c new file mode 100644 index 0000000000..161e17ea1a --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Characteristic.c @@ -0,0 +1,127 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include "py/runtime.h" + +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Characteristic.h" +#include "shared-bindings/_bleio/Descriptor.h" +#include "shared-bindings/_bleio/Service.h" + +#include "common-hal/_bleio/Adapter.h" +// #include "common-hal/_bleio/bonding.h" + +void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, bleio_service_obj_t *service, + uint16_t handle, bleio_uuid_obj_t *uuid, bleio_characteristic_properties_t props, + bleio_attribute_security_mode_t read_perm, bleio_attribute_security_mode_t write_perm, + mp_int_t max_length, bool fixed_length, mp_buffer_info_t *initial_value_bufinfo, + const char *user_description) { + mp_raise_NotImplementedError(NULL); + self->service = service; + self->uuid = uuid; + self->handle = BLEIO_HANDLE_INVALID; + self->props = props; + self->read_perm = read_perm; + self->write_perm = write_perm; + self->initial_value_len = 0; + self->initial_value = NULL; + if (initial_value_bufinfo != NULL) { + // Copy the initial value if it's on the heap. Otherwise it's internal and we may not be able + // to allocate. + self->initial_value_len = initial_value_bufinfo->len; + if (gc_alloc_possible()) { + if (gc_nbytes(initial_value_bufinfo->buf) > 0) { + uint8_t *initial_value = m_malloc(self->initial_value_len, false); + memcpy(initial_value, initial_value_bufinfo->buf, self->initial_value_len); + self->initial_value = initial_value; + } else { + self->initial_value = initial_value_bufinfo->buf; + } + self->descriptor_list = mp_obj_new_list(0, NULL); + } else { + self->initial_value = initial_value_bufinfo->buf; + self->descriptor_list = NULL; + } + } + + // const mp_int_t max_length_max = fixed_length ? BLE_GATTS_FIX_ATTR_LEN_MAX : BLE_GATTS_VAR_ATTR_LEN_MAX; + // if (max_length < 0 || max_length > max_length_max) { + // mp_raise_ValueError_varg(translate("max_length must be 0-%d when fixed_length is %s"), + // max_length_max, fixed_length ? "True" : "False"); + // } + // TODO: Implement this. + self->max_length = max_length; + self->fixed_length = fixed_length; + + if (service->is_remote) { + self->handle = handle; + } else { + common_hal_bleio_service_add_characteristic(self->service, self, initial_value_bufinfo, user_description); + } +} + +mp_obj_tuple_t *common_hal_bleio_characteristic_get_descriptors(bleio_characteristic_obj_t *self) { + if (self->descriptor_list == NULL) { + return mp_const_empty_tuple; + } + return mp_obj_new_tuple(self->descriptor_list->len, self->descriptor_list->items); +} + +bleio_service_obj_t *common_hal_bleio_characteristic_get_service(bleio_characteristic_obj_t *self) { + return self->service; +} + +size_t common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self, uint8_t *buf, size_t len) { + // TODO: Implement this. + return 0; +} + +size_t common_hal_bleio_characteristic_get_max_length(bleio_characteristic_obj_t *self) { + return self->max_length; +} + +void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, mp_buffer_info_t *bufinfo) { + // TODO: Implement this. +} + +bleio_uuid_obj_t *common_hal_bleio_characteristic_get_uuid(bleio_characteristic_obj_t *self) { + return self->uuid; +} + +bleio_characteristic_properties_t common_hal_bleio_characteristic_get_properties(bleio_characteristic_obj_t *self) { + return self->props; +} + +void common_hal_bleio_characteristic_add_descriptor(bleio_characteristic_obj_t *self, bleio_descriptor_obj_t *descriptor) { + // TODO: Implement this. +} + +void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, bool notify, bool indicate) { + // TODO: Implement this. +} diff --git a/ports/espressif/common-hal/_bleio/Characteristic.h b/ports/espressif/common-hal/_bleio/Characteristic.h new file mode 100644 index 0000000000..57195ea265 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Characteristic.h @@ -0,0 +1,56 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CHARACTERISTIC_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CHARACTERISTIC_H + +#include "shared-bindings/_bleio/Attribute.h" +#include "common-hal/_bleio/Descriptor.h" +#include "shared-module/_bleio/Characteristic.h" +#include "common-hal/_bleio/Service.h" +#include "common-hal/_bleio/UUID.h" + +typedef struct _bleio_characteristic_obj { + mp_obj_base_t base; + // Will be MP_OBJ_NULL before being assigned to a Service. + bleio_service_obj_t *service; + bleio_uuid_obj_t *uuid; + const uint8_t *initial_value; + uint16_t initial_value_len; + uint16_t max_length; + uint16_t handle; + bleio_characteristic_properties_t props; + bleio_attribute_security_mode_t read_perm; + bleio_attribute_security_mode_t write_perm; + mp_obj_list_t *descriptor_list; + uint16_t user_desc_handle; + uint16_t cccd_handle; + uint16_t sccd_handle; + bool fixed_length; +} bleio_characteristic_obj_t; + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CHARACTERISTIC_H diff --git a/ports/espressif/common-hal/_bleio/CharacteristicBuffer.c b/ports/espressif/common-hal/_bleio/CharacteristicBuffer.c new file mode 100644 index 0000000000..bc6619cef4 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/CharacteristicBuffer.c @@ -0,0 +1,95 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include + +#include "shared/runtime/interrupt_char.h" +#include "py/runtime.h" +#include "py/stream.h" + +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Connection.h" +#include "supervisor/shared/tick.h" +#include "common-hal/_bleio/CharacteristicBuffer.h" +#include "shared-bindings/_bleio/CharacteristicBuffer.h" + +void _common_hal_bleio_characteristic_buffer_construct(bleio_characteristic_buffer_obj_t *self, + bleio_characteristic_obj_t *characteristic, + mp_float_t timeout, + uint8_t *buffer, size_t buffer_size, + void *static_handler_entry) { + + mp_raise_NotImplementedError(NULL); + + self->characteristic = characteristic; + self->timeout_ms = timeout * 1000; + + self->ringbuf.buf = (uint8_t *)buffer; + self->ringbuf.size = buffer_size; + self->ringbuf.iget = 0; + self->ringbuf.iput = 0; + +} + +// Assumes that timeout and buffer_size have been validated before call. +void common_hal_bleio_characteristic_buffer_construct(bleio_characteristic_buffer_obj_t *self, + bleio_characteristic_obj_t *characteristic, + mp_float_t timeout, + size_t buffer_size) { + uint8_t *buffer = m_malloc(buffer_size, true); + _common_hal_bleio_characteristic_buffer_construct(self, characteristic, timeout, buffer, buffer_size, NULL); +} + +uint32_t common_hal_bleio_characteristic_buffer_read(bleio_characteristic_buffer_obj_t *self, uint8_t *data, size_t len, int *errcode) { + // TODO: Implement this. + return 0; +} + +uint32_t common_hal_bleio_characteristic_buffer_rx_characters_available(bleio_characteristic_buffer_obj_t *self) { + // TODO: Implement this. + return 0; +} + +void common_hal_bleio_characteristic_buffer_clear_rx_buffer(bleio_characteristic_buffer_obj_t *self) { + // TODO: Implement this. +} + +bool common_hal_bleio_characteristic_buffer_deinited(bleio_characteristic_buffer_obj_t *self) { + return self->characteristic == NULL; +} + +void common_hal_bleio_characteristic_buffer_deinit(bleio_characteristic_buffer_obj_t *self) { + // TODO: Implement this. +} + +bool common_hal_bleio_characteristic_buffer_connected(bleio_characteristic_buffer_obj_t *self) { + return self->characteristic != NULL && + self->characteristic->service != NULL && + (!self->characteristic->service->is_remote || + (self->characteristic->service->connection != MP_OBJ_NULL && + common_hal_bleio_connection_get_connected(self->characteristic->service->connection))); +} diff --git a/ports/espressif/common-hal/_bleio/CharacteristicBuffer.h b/ports/espressif/common-hal/_bleio/CharacteristicBuffer.h new file mode 100644 index 0000000000..e5247c20f7 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/CharacteristicBuffer.h @@ -0,0 +1,41 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H + +#include "py/ringbuf.h" +#include "shared-bindings/_bleio/Characteristic.h" + +typedef struct { + mp_obj_base_t base; + bleio_characteristic_obj_t *characteristic; + uint32_t timeout_ms; + // Ring buffer storing consecutive incoming values. + ringbuf_t ringbuf; +} bleio_characteristic_buffer_obj_t; + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H diff --git a/ports/espressif/common-hal/_bleio/Connection.c b/ports/espressif/common-hal/_bleio/Connection.c new file mode 100644 index 0000000000..a3668073a8 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Connection.c @@ -0,0 +1,166 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/_bleio/Connection.h" + +#include +#include + +#include "shared/runtime/interrupt_char.h" +#include "py/gc.h" +#include "py/objlist.h" +#include "py/objstr.h" +#include "py/qstr.h" +#include "py/runtime.h" +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Adapter.h" +#include "shared-bindings/_bleio/Attribute.h" +#include "shared-bindings/_bleio/Characteristic.h" +#include "shared-bindings/_bleio/Service.h" +#include "shared-bindings/_bleio/UUID.h" +#include "supervisor/shared/tick.h" + +// #include "common-hal/_bleio/bonding.h" + +#include "host/ble_att.h" + +int bleio_connection_event_cb(struct ble_gap_event *event, void *connection_in) { + bleio_connection_internal_t *connection = (bleio_connection_internal_t *)connection_in; + + switch (event->type) { + case BLE_GAP_EVENT_DISCONNECT: { + connection->conn_handle = BLEIO_HANDLE_INVALID; + connection->pair_status = PAIR_NOT_PAIRED; + + #if CIRCUITPY_VERBOSE_BLE + mp_printf(&mp_plat_print, "disconnected %02x\n", event->disconnect.reason); + #endif + if (connection->connection_obj != mp_const_none) { + bleio_connection_obj_t *obj = connection->connection_obj; + obj->connection = NULL; + obj->disconnect_reason = event->disconnect.reason; + } + + break; + } + + case BLE_GAP_EVENT_PHY_UPDATE_COMPLETE: { + break; + } + + default: + #if CIRCUITPY_VERBOSE_BLE + mp_printf(&mp_plat_print, "Unhandled connection event: %d\n", event->type); + #endif + return 0; + } + return 0; +} + +bool common_hal_bleio_connection_get_paired(bleio_connection_obj_t *self) { + if (self->connection == NULL) { + return false; + } + return self->connection->pair_status == PAIR_PAIRED; +} + +bool common_hal_bleio_connection_get_connected(bleio_connection_obj_t *self) { + if (self->connection == NULL) { + return false; + } + return self->connection->conn_handle != BLEIO_HANDLE_INVALID; +} + +void common_hal_bleio_connection_disconnect(bleio_connection_internal_t *self) { + // TODO: Implement this. +} + +void common_hal_bleio_connection_pair(bleio_connection_internal_t *self, bool bond) { + // TODO: Implement this. +} + +mp_float_t common_hal_bleio_connection_get_connection_interval(bleio_connection_internal_t *self) { + // TODO: Implement this. + while (self->conn_params_updating && !mp_hal_is_interrupted()) { + RUN_BACKGROUND_TASKS; + } + return 0; +} + +// Return the current negotiated MTU length, minus overhead. +mp_int_t common_hal_bleio_connection_get_max_packet_length(bleio_connection_internal_t *self) { + return (self->mtu == 0 ? BLE_ATT_MTU_DFLT : self->mtu) - 3; +} + +void common_hal_bleio_connection_set_connection_interval(bleio_connection_internal_t *self, mp_float_t new_interval) { + self->conn_params_updating = true; + // TODO: Implement this. +} + +mp_obj_tuple_t *common_hal_bleio_connection_discover_remote_services(bleio_connection_obj_t *self, mp_obj_t service_uuids_whitelist) { + bleio_connection_ensure_connected(self); + // Convert to a tuple and then clear the list so the callee will take ownership. + mp_obj_tuple_t *services_tuple = + mp_obj_new_tuple(self->connection->remote_service_list->len, + self->connection->remote_service_list->items); + mp_obj_list_clear(MP_OBJ_FROM_PTR(self->connection->remote_service_list)); + + // TODO: Implement this. + return services_tuple; +} + +uint16_t bleio_connection_get_conn_handle(bleio_connection_obj_t *self) { + if (self == NULL || self->connection == NULL) { + return BLEIO_HANDLE_INVALID; + } + return self->connection->conn_handle; +} + +mp_obj_t bleio_connection_new_from_internal(bleio_connection_internal_t *internal) { + if (internal->connection_obj != mp_const_none) { + return internal->connection_obj; + } + bleio_connection_obj_t *connection = m_new_obj(bleio_connection_obj_t); + connection->base.type = &bleio_connection_type; + connection->connection = internal; + internal->connection_obj = connection; + + return MP_OBJ_FROM_PTR(connection); +} + +// Find the connection that uses the given conn_handle. Return NULL if not found. +bleio_connection_internal_t *bleio_conn_handle_to_connection(uint16_t conn_handle) { + bleio_connection_internal_t *connection; + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + connection = &bleio_connections[i]; + if (connection->conn_handle == conn_handle) { + return connection; + } + } + + return NULL; +} diff --git a/ports/espressif/common-hal/_bleio/Connection.h b/ports/espressif/common-hal/_bleio/Connection.h new file mode 100644 index 0000000000..73bfeff19c --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Connection.h @@ -0,0 +1,92 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CONNECTION_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CONNECTION_H + +#include + +#include "py/obj.h" +#include "py/objlist.h" + +#include "common-hal/_bleio/__init__.h" +// #include "common-hal/_bleio/bonding.h" +#include "shared-module/_bleio/Address.h" +#include "common-hal/_bleio/Service.h" + +#include "host/ble_gap.h" + +typedef enum { + PAIR_NOT_PAIRED, + PAIR_WAITING, + PAIR_PAIRED, +} pair_status_t; + +// We split the Connection object into two so that the internal mechanics can live outside of the +// VM. If it were one object, then we'd risk user code seeing a connection object of theirs be +// reused. +typedef struct { + uint16_t conn_handle; + bool is_central; + // Remote services discovered when this peripheral is acting as a client. + mp_obj_list_t *remote_service_list; + // The advertising data and scan response buffers are held by us, not by the SD, so we must + // maintain them and not change it. If we need to change the contents during advertising, + // there are tricks to get the SD to notice (see DevZone - TBS). + // bonding_keys_t bonding_keys; + // EDIV: Encrypted Diversifier: Identifies LTK during legacy pairing. + uint16_t ediv; + volatile pair_status_t pair_status; + uint8_t sec_status; // Internal security status. + mp_obj_t connection_obj; + volatile bool conn_params_updating; + uint16_t mtu; + // Request that CCCD values for this connection be saved, using sys_attr values. + volatile bool do_bond_cccds; + // Request that security key info for this connection be saved. + volatile bool do_bond_keys; + // Time of setting do_bond_ccds: we delay a bit to consolidate multiple CCCD changes + // into one write. Time is currently in ticks_ms. + uint64_t do_bond_cccds_request_time; +} bleio_connection_internal_t; + +typedef struct { + mp_obj_base_t base; + bleio_connection_internal_t *connection; + // The HCI disconnect reason. + uint8_t disconnect_reason; +} bleio_connection_obj_t; + +void bleio_connection_clear(bleio_connection_internal_t *self); + +int bleio_connection_event_cb(struct ble_gap_event *event, void *connection_in); + +uint16_t bleio_connection_get_conn_handle(bleio_connection_obj_t *self); +mp_obj_t bleio_connection_new_from_internal(bleio_connection_internal_t *connection); +bleio_connection_internal_t *bleio_conn_handle_to_connection(uint16_t conn_handle); + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CONNECTION_H diff --git a/ports/espressif/common-hal/_bleio/Descriptor.c b/ports/espressif/common-hal/_bleio/Descriptor.c new file mode 100644 index 0000000000..016626dbf9 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Descriptor.c @@ -0,0 +1,97 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/runtime.h" + +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Descriptor.h" +#include "shared-bindings/_bleio/Service.h" +#include "shared-bindings/_bleio/UUID.h" + +#include "host/ble_att.h" + +void common_hal_bleio_descriptor_construct(bleio_descriptor_obj_t *self, bleio_characteristic_obj_t *characteristic, bleio_uuid_obj_t *uuid, bleio_attribute_security_mode_t read_perm, bleio_attribute_security_mode_t write_perm, mp_int_t max_length, bool fixed_length, mp_buffer_info_t *initial_value_bufinfo) { + mp_raise_NotImplementedError(NULL); + self->characteristic = characteristic; + self->uuid = uuid; + self->handle = BLEIO_HANDLE_INVALID; + self->read_perm = read_perm; + self->write_perm = write_perm; + self->initial_value = mp_obj_new_bytes(initial_value_bufinfo->buf, initial_value_bufinfo->len); + + const mp_int_t max_length_max = BLE_ATT_ATTR_MAX_LEN; + if (max_length < 0 || max_length > max_length_max) { + mp_raise_ValueError_varg(translate("max_length must be 0-%d when fixed_length is %s"), + max_length_max, fixed_length ? "True" : "False"); + } + self->max_length = max_length; + self->fixed_length = fixed_length; +} + +bleio_uuid_obj_t *common_hal_bleio_descriptor_get_uuid(bleio_descriptor_obj_t *self) { + return self->uuid; +} + +bleio_characteristic_obj_t *common_hal_bleio_descriptor_get_characteristic(bleio_descriptor_obj_t *self) { + return self->characteristic; +} + +size_t common_hal_bleio_descriptor_get_value(bleio_descriptor_obj_t *self, uint8_t *buf, size_t len) { + // Do GATT operations only if this descriptor has been registered + if (self->handle != BLEIO_HANDLE_INVALID) { + uint16_t conn_handle = bleio_connection_get_conn_handle(self->characteristic->service->connection); + (void)conn_handle; + } + + // TODO: Implement this. + + return 0; +} + +void common_hal_bleio_descriptor_set_value(bleio_descriptor_obj_t *self, mp_buffer_info_t *bufinfo) { + // TODO: Implement this. + // Do GATT operations only if this descriptor has been registered. + if (self->handle != BLEIO_HANDLE_INVALID) { + // uint16_t conn_handle = bleio_connection_get_conn_handle(self->characteristic->service->connection); + if (common_hal_bleio_service_get_is_remote(self->characteristic->service)) { + // false means WRITE_REQ, not write-no-response + // common_hal_bleio_gattc_write(self->handle, conn_handle, bufinfo, false); + } else { + // Validate data length for local descriptors only. + if (self->fixed_length && bufinfo->len != self->max_length) { + mp_raise_ValueError(translate("Value length != required fixed length")); + } + if (bufinfo->len > self->max_length) { + mp_raise_ValueError(translate("Value length > max_length")); + } + + // common_hal_bleio_gatts_write(self->handle, conn_handle, bufinfo); + } + } + +} diff --git a/ports/espressif/common-hal/_bleio/Descriptor.h b/ports/espressif/common-hal/_bleio/Descriptor.h new file mode 100644 index 0000000000..4a2b298ca2 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Descriptor.h @@ -0,0 +1,52 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_DESCRIPTOR_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_DESCRIPTOR_H + +#include "py/obj.h" + +#include "common-hal/_bleio/UUID.h" + +// Forward declare characteristic because it includes a Descriptor. +struct _bleio_characteristic_obj; + +typedef struct _bleio_descriptor_obj { + mp_obj_base_t base; + // Will be MP_OBJ_NULL before being assigned to a Characteristic. + struct _bleio_characteristic_obj *characteristic; + bleio_uuid_obj_t *uuid; + mp_obj_t initial_value; + uint16_t max_length; + bool fixed_length; + uint16_t handle; + bleio_attribute_security_mode_t read_perm; + bleio_attribute_security_mode_t write_perm; +} bleio_descriptor_obj_t; + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_DESCRIPTOR_H diff --git a/ports/espressif/common-hal/_bleio/PacketBuffer.c b/ports/espressif/common-hal/_bleio/PacketBuffer.c new file mode 100644 index 0000000000..b318ad27d7 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/PacketBuffer.c @@ -0,0 +1,275 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019-2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include + +#include "shared/runtime/interrupt_char.h" +#include "py/runtime.h" +#include "py/stream.h" + +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Connection.h" +#include "shared-bindings/_bleio/PacketBuffer.h" +#include "supervisor/shared/tick.h" + +#include "supervisor/shared/bluetooth/serial.h" + +#include "host/ble_att.h" + +void _common_hal_bleio_packet_buffer_construct( + bleio_packet_buffer_obj_t *self, bleio_characteristic_obj_t *characteristic, + uint32_t *incoming_buffer, size_t incoming_buffer_size, + uint32_t *outgoing_buffer1, uint32_t *outgoing_buffer2, size_t max_packet_size, + void *static_handler_entry) { + + mp_raise_NotImplementedError(NULL); + self->characteristic = characteristic; + self->client = self->characteristic->service->is_remote; + self->max_packet_size = max_packet_size; + bleio_characteristic_properties_t incoming = self->characteristic->props & (CHAR_PROP_WRITE_NO_RESPONSE | CHAR_PROP_WRITE); + bleio_characteristic_properties_t outgoing = self->characteristic->props & (CHAR_PROP_NOTIFY | CHAR_PROP_INDICATE); + + if (self->client) { + // Swap if we're the client. + bleio_characteristic_properties_t temp = incoming; + incoming = outgoing; + outgoing = temp; + self->conn_handle = bleio_connection_get_conn_handle(MP_OBJ_TO_PTR(self->characteristic->service->connection)); + } else { + self->conn_handle = BLEIO_HANDLE_INVALID; + } + + if (incoming) { + self->ringbuf.buf = (uint8_t *)incoming_buffer; + self->ringbuf.size = incoming_buffer_size; + self->ringbuf.iget = 0; + self->ringbuf.iput = 0; + } + + self->packet_queued = false; + self->pending_index = 0; + self->pending_size = 0; + self->outgoing[0] = outgoing_buffer1; + self->outgoing[1] = outgoing_buffer2; + +} + +void common_hal_bleio_packet_buffer_construct( + bleio_packet_buffer_obj_t *self, bleio_characteristic_obj_t *characteristic, + size_t buffer_size, size_t max_packet_size) { + + // Cap the packet size to our implementation limits. + max_packet_size = MIN(max_packet_size, BLE_ATT_ATTR_MAX_LEN - 3); + + bleio_characteristic_properties_t incoming = characteristic->props & (CHAR_PROP_WRITE_NO_RESPONSE | CHAR_PROP_WRITE); + bleio_characteristic_properties_t outgoing = characteristic->props & (CHAR_PROP_NOTIFY | CHAR_PROP_INDICATE); + if (characteristic->service->is_remote) { + // Swap if we're the client. + bleio_characteristic_properties_t temp = incoming; + incoming = outgoing; + outgoing = temp; + } + size_t incoming_buffer_size = 0; + uint32_t *incoming_buffer = NULL; + if (incoming) { + incoming_buffer_size = buffer_size * (sizeof(uint16_t) + max_packet_size); + incoming_buffer = m_malloc(incoming_buffer_size, false); + } + + uint32_t *outgoing1 = NULL; + uint32_t *outgoing2 = NULL; + if (outgoing) { + outgoing1 = m_malloc(max_packet_size, false); + outgoing2 = m_malloc(max_packet_size, false); + } + _common_hal_bleio_packet_buffer_construct(self, characteristic, + incoming_buffer, incoming_buffer_size, + outgoing1, outgoing2, max_packet_size, + NULL); +} + +mp_int_t common_hal_bleio_packet_buffer_readinto(bleio_packet_buffer_obj_t *self, uint8_t *data, size_t len) { + if (ringbuf_num_filled(&self->ringbuf) < 2) { + return 0; + } + + // Copy received data. Lock out write interrupt handler while copying. + // TODO: Implement this. + return 0; +} + +mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, const uint8_t *data, size_t len, uint8_t *header, size_t header_len) { + if (self->outgoing[0] == NULL) { + mp_raise_bleio_BluetoothError(translate("Writes not supported on Characteristic")); + } + if (self->conn_handle == BLEIO_HANDLE_INVALID) { + return -1; + } + mp_int_t outgoing_packet_length = common_hal_bleio_packet_buffer_get_outgoing_packet_length(self); + if (outgoing_packet_length < 0) { + return -1; + } + + mp_int_t total_len = len + header_len; + if (total_len > outgoing_packet_length) { + // Supplied data will not fit in a single BLE packet. + mp_raise_ValueError_varg(translate("Total data to write is larger than %q"), MP_QSTR_outgoing_packet_length); + } + if (total_len > self->max_packet_size) { + // Supplied data will not fit in a single BLE packet. + mp_raise_ValueError_varg(translate("Total data to write is larger than %q"), MP_QSTR_max_packet_size); + } + outgoing_packet_length = MIN(outgoing_packet_length, self->max_packet_size); + + if (len + self->pending_size > (size_t)outgoing_packet_length) { + // No room to append len bytes to packet. Wait until we get a free buffer, + // and keep checking that we haven't been disconnected. + while (self->pending_size != 0 && + self->conn_handle != BLEIO_HANDLE_INVALID && + !mp_hal_is_interrupted()) { + RUN_BACKGROUND_TASKS; + } + } + if (self->conn_handle == BLEIO_HANDLE_INVALID || + mp_hal_is_interrupted()) { + return -1; + } + + size_t num_bytes_written = 0; + + uint32_t *pending = self->outgoing[self->pending_index]; + + if (self->pending_size == 0) { + memcpy(pending, header, header_len); + self->pending_size += header_len; + num_bytes_written += header_len; + } + memcpy(((uint8_t *)pending) + self->pending_size, data, len); + self->pending_size += len; + num_bytes_written += len; + + // TODO: Implement this. + + // If no writes are queued then sneak in this data. + if (!self->packet_queued) { + } + return num_bytes_written; +} + +mp_int_t common_hal_bleio_packet_buffer_get_incoming_packet_length(bleio_packet_buffer_obj_t *self) { + // If this PacketBuffer is coming from a remote service via NOTIFY or INDICATE + // the maximum size is what can be sent in one + // BLE packet. But we must be connected to know that value. + // + // Otherwise it can be as long as the characteristic + // will permit, whether or not we're connected. + + if (self->characteristic == NULL) { + return -1; + } + + if (self->characteristic->service != NULL && + self->characteristic->service->is_remote && + (common_hal_bleio_characteristic_get_properties(self->characteristic) & + (CHAR_PROP_INDICATE | CHAR_PROP_NOTIFY))) { + // We are talking to a remote service, and data is arriving via NOTIFY or INDICATE. + if (self->conn_handle != BLEIO_HANDLE_INVALID) { + bleio_connection_internal_t *connection = bleio_conn_handle_to_connection(self->conn_handle); + if (connection) { + return common_hal_bleio_connection_get_max_packet_length(connection); + } + } + // There's no current connection, so we don't know the MTU, and + // we can't tell what the largest incoming packet length would be. + return -1; + } + return self->characteristic->max_length; +} + +mp_int_t common_hal_bleio_packet_buffer_get_outgoing_packet_length(bleio_packet_buffer_obj_t *self) { + // If we are sending data via NOTIFY or INDICATE, the maximum size + // is what can be sent in one BLE packet. But we must be connected + // to know that value. + // + // Otherwise it can be as long as the characteristic + // will permit, whether or not we're connected. + + if (self->characteristic == NULL) { + return -1; + } + + if (self->characteristic->service != NULL && + !self->characteristic->service->is_remote && + (common_hal_bleio_characteristic_get_properties(self->characteristic) & + (CHAR_PROP_INDICATE | CHAR_PROP_NOTIFY))) { + // We are sending to a client, via NOTIFY or INDICATE. + if (self->conn_handle != BLEIO_HANDLE_INVALID) { + bleio_connection_internal_t *connection = bleio_conn_handle_to_connection(self->conn_handle); + if (connection) { + return MIN(MIN(common_hal_bleio_connection_get_max_packet_length(connection), + self->max_packet_size), + self->characteristic->max_length); + } + } + // There's no current connection, so we don't know the MTU, and + // we can't tell what the largest outgoing packet length would be. + return -1; + } + // If we are talking to a remote service, we'll be bound by the MTU. (We don't actually + // know the max size of the remote characteristic.) + if (self->characteristic->service != NULL && + self->characteristic->service->is_remote) { + // We are talking to a remote service so we're writing. + if (self->conn_handle != BLEIO_HANDLE_INVALID) { + bleio_connection_internal_t *connection = bleio_conn_handle_to_connection(self->conn_handle); + if (connection) { + return MIN(common_hal_bleio_connection_get_max_packet_length(connection), + self->max_packet_size); + } + } + } + return MIN(self->characteristic->max_length, self->max_packet_size); +} + +void common_hal_bleio_packet_buffer_flush(bleio_packet_buffer_obj_t *self) { + while ((self->pending_size != 0 || + self->packet_queued) && + self->conn_handle != BLEIO_HANDLE_INVALID && + !mp_hal_is_interrupted()) { + RUN_BACKGROUND_TASKS; + } +} + +bool common_hal_bleio_packet_buffer_deinited(bleio_packet_buffer_obj_t *self) { + return self->characteristic == NULL; +} + +void common_hal_bleio_packet_buffer_deinit(bleio_packet_buffer_obj_t *self) { + if (!common_hal_bleio_packet_buffer_deinited(self)) { + } + // TODO: Implement this. +} diff --git a/ports/espressif/common-hal/_bleio/PacketBuffer.h b/ports/espressif/common-hal/_bleio/PacketBuffer.h new file mode 100644 index 0000000000..6ecc1a69b2 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/PacketBuffer.h @@ -0,0 +1,52 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019-2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_PACKETBUFFER_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_PACKETBUFFER_H + +#include "py/ringbuf.h" +#include "shared-bindings/_bleio/Characteristic.h" + +typedef struct { + mp_obj_base_t base; + bleio_characteristic_obj_t *characteristic; + // Ring buffer storing consecutive incoming values. + ringbuf_t ringbuf; + // Two outgoing buffers to alternate between. One will be queued for transmission by the SD and + // the other is waiting to be queued and can be extended. + uint32_t *outgoing[2]; + volatile uint16_t pending_size; + // We remember the conn_handle so we can do a NOTIFY/INDICATE to a client. + // We can find out the conn_handle on a Characteristic write or a CCCD write (but not a read). + volatile uint16_t conn_handle; + uint16_t max_packet_size; + uint8_t pending_index; + uint8_t write_type; + bool client; + bool packet_queued; +} bleio_packet_buffer_obj_t; + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_PACKETBUFFER_H diff --git a/ports/espressif/common-hal/_bleio/Service.c b/ports/espressif/common-hal/_bleio/Service.c new file mode 100644 index 0000000000..beaf930136 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Service.c @@ -0,0 +1,94 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/runtime.h" +#include "common-hal/_bleio/__init__.h" +#include "shared-bindings/_bleio/Characteristic.h" +#include "shared-bindings/_bleio/Descriptor.h" +#include "shared-bindings/_bleio/Service.h" +#include "shared-bindings/_bleio/Adapter.h" + +#include "host/ble_gatt.h" + +uint32_t _common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_obj_t *uuid, bool is_secondary, mp_obj_list_t *characteristic_list) { + self->handle = 0xFFFF; + self->uuid = uuid; + self->characteristic_list = characteristic_list; + self->is_remote = false; + self->connection = NULL; + self->is_secondary = is_secondary; + + // uint8_t service_type = BLE_GATT_SVC_TYPE_PRIMARY; + // if (is_secondary) { + // service_type = BLE_GATT_SVC_TYPE_SECONDARY; + // } + + return 0; +} + +void common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_obj_t *uuid, bool is_secondary) { + mp_raise_NotImplementedError(NULL); + _common_hal_bleio_service_construct(self, uuid, is_secondary, + mp_obj_new_list(0, NULL)); +} + +void bleio_service_from_connection(bleio_service_obj_t *self, mp_obj_t connection) { + self->handle = 0xFFFF; + self->uuid = NULL; + self->characteristic_list = mp_obj_new_list(0, NULL); + self->is_remote = true; + self->is_secondary = false; + self->connection = connection; +} + +bleio_uuid_obj_t *common_hal_bleio_service_get_uuid(bleio_service_obj_t *self) { + return self->uuid; +} + +mp_obj_tuple_t *common_hal_bleio_service_get_characteristics(bleio_service_obj_t *self) { + return mp_obj_new_tuple(self->characteristic_list->len, self->characteristic_list->items); +} + +bool common_hal_bleio_service_get_is_remote(bleio_service_obj_t *self) { + return self->is_remote; +} + +bool common_hal_bleio_service_get_is_secondary(bleio_service_obj_t *self) { + return self->is_secondary; +} + +void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self, + bleio_characteristic_obj_t *characteristic, + mp_buffer_info_t *initial_value_bufinfo, + const char *user_description) { + + #if CIRCUITPY_VERBOSE_BLE + mp_printf(&mp_plat_print, "Char handle %x user %x cccd %x sccd %x\n", characteristic->handle, characteristic->user_desc_handle, characteristic->cccd_handle, characteristic->sccd_handle); + #endif + + mp_obj_list_append(self->characteristic_list, MP_OBJ_FROM_PTR(characteristic)); +} diff --git a/ports/espressif/common-hal/_bleio/Service.h b/ports/espressif/common-hal/_bleio/Service.h new file mode 100644 index 0000000000..6c1688df30 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Service.h @@ -0,0 +1,53 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_SERVICE_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_SERVICE_H + +#include "py/objlist.h" +#include "common-hal/_bleio/UUID.h" + +typedef struct bleio_service_obj { + mp_obj_base_t base; + // Handle for the local service. + uint16_t handle; + // True if created during discovery. + bool is_remote; + bool is_secondary; + bleio_uuid_obj_t *uuid; + // The connection object is set only when this is a remote service. + // A local service doesn't know the connection. + mp_obj_t connection; + mp_obj_list_t *characteristic_list; + // Range of attribute handles of this remote service. + uint16_t start_handle; + uint16_t end_handle; +} bleio_service_obj_t; + +void bleio_service_from_connection(bleio_service_obj_t *self, mp_obj_t connection); + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_SERVICE_H diff --git a/ports/espressif/common-hal/_bleio/UUID.c b/ports/espressif/common-hal/_bleio/UUID.c new file mode 100644 index 0000000000..8f0866412c --- /dev/null +++ b/ports/espressif/common-hal/_bleio/UUID.c @@ -0,0 +1,69 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include "py/runtime.h" +#include "common-hal/_bleio/UUID.h" +#include "shared-bindings/_bleio/UUID.h" +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Adapter.h" + +// If uuid128 is NULL, this is a Bluetooth SIG 16-bit UUID. +// If uuid128 is not NULL, it's a 128-bit (16-byte) UUID, with bytes 12 and 13 zero'd out, where +// the 16-bit part goes. Those 16 bits are passed in uuid16. +void common_hal_bleio_uuid_construct(bleio_uuid_obj_t *self, mp_int_t uuid16, const uint8_t uuid128[16]) { + if (uuid128 == NULL) { + ble_uuid_init_from_buf(&self->nimble_ble_uuid, (uint8_t *)&uuid16, 2); + } else { + ble_uuid_init_from_buf(&self->nimble_ble_uuid, uuid128, 16); + self->nimble_ble_uuid.u128.value[12] = uuid16 & 0xff; + self->nimble_ble_uuid.u128.value[13] = (uuid16 >> 8) & 0xff; + } +} + +uint32_t common_hal_bleio_uuid_get_size(bleio_uuid_obj_t *self) { + return self->nimble_ble_uuid.u.type == BLE_UUID_TYPE_16 ? 16 : 128; +} + +uint32_t common_hal_bleio_uuid_get_uuid16(bleio_uuid_obj_t *self) { + return self->nimble_ble_uuid.u16.value; +} + +void common_hal_bleio_uuid_get_uuid128(bleio_uuid_obj_t *self, uint8_t uuid128[16]) { + memcpy(uuid128, self->nimble_ble_uuid.u128.value, 16); +} + +void common_hal_bleio_uuid_pack_into(bleio_uuid_obj_t *self, uint8_t *buf) { + if (self->nimble_ble_uuid.u.type == BLE_UUID_TYPE_16) { + buf[0] = self->nimble_ble_uuid.u16.value & 0xff; + buf[1] = self->nimble_ble_uuid.u16.value >> 8; + } else { + common_hal_bleio_uuid_get_uuid128(self, buf); + } +} diff --git a/ports/espressif/common-hal/_bleio/UUID.h b/ports/espressif/common-hal/_bleio/UUID.h new file mode 100644 index 0000000000..166088ed96 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/UUID.h @@ -0,0 +1,49 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_UUID_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_UUID_H + +#include "py/obj.h" + +#include "host/ble_uuid.h" + +typedef struct { + mp_obj_base_t base; + // Use the native way of storing UUID's: + // - ble_uuid_t.uuid is a 16-bit uuid. + // - ble_uuid_t.type is BLE_UUID_TYPE_BLE if it's a 16-bit Bluetooth SIG UUID. + // or is BLE_UUID_TYPE_VENDOR_BEGIN and higher, which indexes into a table of registered + // 128-bit UUIDs. + ble_uuid_any_t nimble_ble_uuid; +} bleio_uuid_obj_t; + +void bleio_uuid_construct_from_nrf_ble_uuid(bleio_uuid_obj_t *self, ble_uuid_t *nrf_uuid); +void bleio_uuid_convert_to_nrf_ble_uuid(bleio_uuid_obj_t *self, ble_uuid_t *nrf_uuid); + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_UUID_H diff --git a/ports/espressif/common-hal/_bleio/__init__.c b/ports/espressif/common-hal/_bleio/__init__.c new file mode 100644 index 0000000000..bd10b0a519 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/__init__.c @@ -0,0 +1,99 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include "py/runtime.h" +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Adapter.h" +#include "shared-bindings/_bleio/Characteristic.h" +#include "shared-bindings/_bleio/Connection.h" +#include "shared-bindings/_bleio/Descriptor.h" +#include "shared-bindings/_bleio/Service.h" +#include "shared-bindings/_bleio/UUID.h" +#include "supervisor/shared/bluetooth/bluetooth.h" + +#include "common-hal/_bleio/__init__.h" +// #include "common-hal/_bleio/bonding.h" + +// Turn off BLE on a reset or reload. +void bleio_reset() { + // Set this explicitly to save data. + common_hal_bleio_adapter_obj.base.type = &bleio_adapter_type; + if (!common_hal_bleio_adapter_get_enabled(&common_hal_bleio_adapter_obj)) { + return; + } + + supervisor_stop_bluetooth(); + bleio_adapter_reset(&common_hal_bleio_adapter_obj); + common_hal_bleio_adapter_set_enabled(&common_hal_bleio_adapter_obj, false); + supervisor_start_bluetooth(); +} + +// The singleton _bleio.Adapter object, bound to _bleio.adapter +// It currently only has properties and no state. Inited by bleio_reset +bleio_adapter_obj_t common_hal_bleio_adapter_obj; + +void bleio_background(void) { +} + +void common_hal_bleio_gc_collect(void) { + bleio_adapter_gc_collect(&common_hal_bleio_adapter_obj); +} + +void check_nimble_error(int rc, const char *file, size_t line) { + if (rc == NIMBLE_OK) { + return; + } + switch (rc) { + case BLE_HS_ENOMEM: + mp_raise_msg(&mp_type_MemoryError, translate("Nimble out of memory")); + return; + case BLE_HS_ETIMEOUT: + mp_raise_msg(&mp_type_TimeoutError, NULL); + return; + case BLE_HS_EINVAL: + mp_raise_ValueError(translate("Invalid BLE parameter")); + return; + case BLE_HS_ENOTCONN: + mp_raise_ConnectionError(translate("Not connected")); + return; + default: + #if CIRCUITPY_VERBOSE_BLE + if (file) { + mp_raise_bleio_BluetoothError(translate("Unknown system firmware error at %s:%d: %d"), file, line, rc); + } + #else + (void)file; + (void)line; + mp_raise_bleio_BluetoothError(translate("Unknown system firmware error: %d"), rc); + #endif + + break; + } +} diff --git a/ports/espressif/common-hal/_bleio/__init__.h b/ports/espressif/common-hal/_bleio/__init__.h new file mode 100644 index 0000000000..6c32bd5d4e --- /dev/null +++ b/ports/espressif/common-hal/_bleio/__init__.h @@ -0,0 +1,57 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_INIT_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_INIT_H + +void bleio_background(void); + +// typedef struct { +// ble_gap_enc_key_t own_enc; +// ble_gap_enc_key_t peer_enc; +// ble_gap_id_key_t peer_id; +// } bonding_keys_t; + +// We assume variable length data. +// 20 bytes max (23 - 3). +#define GATT_MAX_DATA_LENGTH (BLE_GATT_ATT_MTU_DEFAULT - 3) + +#define NIMBLE_OK (0) + +void check_nimble_error(int rc, const char *file, size_t line); +#define CHECK_NIMBLE_ERROR(rc) check_nimble_error(rc, __FILE__, __LINE__) + +#define MSEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000) / (RESOLUTION)) +#define SEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000000) / (RESOLUTION)) +#define UNITS_TO_SEC(TIME, RESOLUTION) (((TIME)*(RESOLUTION)) / 1000000) +// 0.625 msecs (625 usecs) +#define ADV_INTERVAL_UNIT_FLOAT_SECS (0.000625) +// Microseconds is the base unit. The macros above know that. +#define UNIT_0_625_MS (625) +#define UNIT_1_25_MS (1250) +#define UNIT_10_MS (10000) + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_INIT_H diff --git a/ports/espressif/common-hal/_bleio/bonding.c b/ports/espressif/common-hal/_bleio/bonding.c new file mode 100644 index 0000000000..e7dac3cb33 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/bonding.c @@ -0,0 +1,372 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include + +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Adapter.h" +#include "shared-bindings/nvm/ByteArray.h" +#include "supervisor/shared/tick.h" + +#include "bonding.h" + +// Internal flash area reserved for bonding storage. +#define BONDING_PAGES_START_ADDR CIRCUITPY_BLE_CONFIG_START_ADDR +#define BONDING_PAGES_END_ADDR (CIRCUITPY_BLE_CONFIG_START_ADDR + CIRCUITPY_BLE_CONFIG_SIZE) + +// First and last four bytes are magic bytes for id and version. Data is in between. +// 'BD01' +const uint32_t BONDING_FLAG = ('1' | '0' << 8 | 'D' << 16 | 'B' << 24); + +#define BONDING_DATA_START_ADDR (BONDING_PAGES_START_ADDR + sizeof(BONDING_FLAG)) +#define BONDING_DATA_END_ADDR (BONDING_PAGES_END_ADDR - sizeof(BONDING_FLAG)) + +#define BONDING_START_FLAG_ADDR BONDING_PAGES_START_ADDR +#define BONDING_END_FLAG_ADDR BONDING_DATA_END_ADDR + +// Save both system and user service info. +#define SYS_ATTR_FLAGS (BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS | BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS) + +#if BONDING_DEBUG +void bonding_print_block(bonding_block_t *block) { + printf("at 0x%08lx: is_central: %1d, type: 0x%x, ediv: 0x%04x, data_length: %d\n", + (uint32_t)block, block->is_central, block->type, block->ediv, block->data_length); +} + +void bonding_print_keys(bonding_keys_t *keys) { + for (size_t i = 0; i < sizeof(bonding_keys_t); i++) { + printf("%x", ((uint8_t *)keys)[i]); + } + printf("\n"); +} +#endif + +STATIC size_t compute_block_size(uint16_t data_length) { + // Round data size up to the nearest 32-bit address. + return sizeof(bonding_block_t) + ((data_length + 3) & ~0x3); +} + +void bonding_erase_storage(void) { + // Erase all pages in the bonding area. + for (uint32_t page_address = BONDING_PAGES_START_ADDR; + page_address < BONDING_PAGES_END_ADDR; + page_address += FLASH_PAGE_SIZE) { + // Argument is page number, not address. + sd_flash_page_erase_sync(page_address / FLASH_PAGE_SIZE); + } + // Write marker words at the beginning and the end of the bonding area. + uint32_t flag = BONDING_FLAG; + sd_flash_write_sync((uint32_t *)BONDING_START_FLAG_ADDR, &flag, 1); + sd_flash_write_sync((uint32_t *)BONDING_END_FLAG_ADDR, &flag, 1); +} + +// Given NULL to start or block address, return the address of the next valid block. +// The last block returned is the unused block at the end. +// Return NULL if we have run off the end of the bonding space. + +STATIC bonding_block_t *next_block(bonding_block_t *block) { + while (1) { + // Advance to next block. + if (block == NULL) { + return (bonding_block_t *)BONDING_DATA_START_ADDR; + } else if (block->type == BLOCK_UNUSED) { + // Already at last block (the unused block). + return NULL; + } + + // Advance to next block. + block = (bonding_block_t *)((uint8_t *)block + compute_block_size(block->data_length)); + + if (block >= (bonding_block_t *)BONDING_DATA_END_ADDR) { + // Went past end of bonding space. + return NULL; + } + if (block->type != BLOCK_INVALID) { + // Found an empty or a valid block. + return block; + } + // Invalid block (was erased); try again. + } +} + +// Find the block with given is_central, type and ediv value. +// If type == BLOCK_UNUSED, ediv is ignored and the the sole unused block at the end is returned. +// If not found, return NULL. +STATIC bonding_block_t *find_existing_block(bool is_central, bonding_block_type_t type, uint16_t ediv) { + bonding_block_t *block = NULL; + while (1) { + block = next_block(block); + if (block == NULL) { + return NULL; + } + // If types match, and block is unused, just return it. + // Otherwise check that is_central and ediv match. + if (type == block->type) { + if (type == BLOCK_UNUSED || + (is_central == block->is_central && ediv == block->ediv)) { + return block; + } + } + } +} + +size_t bonding_peripheral_bond_count(void) { + bonding_block_t *block = NULL; + size_t count = 0; + while (1) { + block = next_block(block); + if (block == NULL) { + return count; + } + if (block->type != BLOCK_UNUSED && block->type != BLOCK_INVALID && !block->is_central) { + count++; + } + } +} + +// Get an empty block large enough to store data_length data. +STATIC bonding_block_t *find_unused_block(uint16_t data_length) { + bonding_block_t *unused_block = find_existing_block(true, BLOCK_UNUSED, EDIV_INVALID); + // If no more room, erase all existing blocks and start over. + if (!unused_block || + (uint8_t *)unused_block + compute_block_size(data_length) >= (uint8_t *)BONDING_DATA_END_ADDR) { + bonding_erase_storage(); + unused_block = (bonding_block_t *)BONDING_DATA_START_ADDR; + } + return unused_block; +} + +// Set the header word to all 0's, to mark the block as invalid. +// We don't change data_length, so we can still skip over this block. +STATIC void invalidate_block(bonding_block_t *block) { + uint32_t zero = 0; + sd_flash_write_sync((uint32_t *)block, &zero, 1); +} + +// Write bonding block header. +STATIC void write_block_header(bonding_block_t *dest_block, bonding_block_t *source_block_header) { + sd_flash_write_sync((uint32_t *)dest_block, (uint32_t *)source_block_header, sizeof(bonding_block_t) / 4); +} + +// Write variable-length data at end of bonding block. +STATIC void write_block_data(bonding_block_t *dest_block, uint8_t *data, uint16_t data_length) { + // Minimize the number of writes. Datasheet says no more than two writes per word before erasing again. + + // Start writing after the current header. + uint32_t *flash_word_p = (uint32_t *)((uint8_t *)dest_block + sizeof(bonding_block_t)); + while (1) { + uint32_t word = 0xffffffff; + memcpy(&word, data, data_length >= 4 ? 4 : data_length); + sd_flash_write_sync(flash_word_p, &word, 1); + if (data_length <= 4) { + break; + } + data_length -= 4; + data += 4; + // Increment by word size. + flash_word_p++; + } +} + +STATIC void write_sys_attr_block(bleio_connection_internal_t *connection) { + uint16_t length = 0; + // First find out how big a buffer we need, then fetch the data. + if (sd_ble_gatts_sys_attr_get(connection->conn_handle, NULL, &length, SYS_ATTR_FLAGS) != NRF_SUCCESS) { + return; + } + uint8_t sys_attr[length]; + if (sd_ble_gatts_sys_attr_get(connection->conn_handle, sys_attr, &length, SYS_ATTR_FLAGS) != NRF_SUCCESS) { + return; + } + + // Is there an existing sys_attr block that matches the current sys_attr data? + bonding_block_t *existing_block = + find_existing_block(connection->is_central, BLOCK_SYS_ATTR, connection->ediv); + if (existing_block) { + if (length == existing_block->data_length && + memcmp(sys_attr, existing_block->data, length) == 0) { + // Identical block found. No need to store again. + return; + } + // Data doesn't match. Invalidate block and store a new one. + invalidate_block(existing_block); + } + + bonding_block_t block_header = { + .is_central = connection->is_central, + .type = BLOCK_SYS_ATTR, + .ediv = connection->ediv, + .conn_handle = connection->conn_handle, + .data_length = length, + }; + bonding_block_t *new_block = find_unused_block(length); + write_block_header(new_block, &block_header); + write_block_data(new_block, sys_attr, length); + return; +} + +STATIC void write_keys_block(bleio_connection_internal_t *connection) { + uint16_t const ediv = connection->is_central + ? connection->bonding_keys.peer_enc.master_id.ediv + : connection->bonding_keys.own_enc.master_id.ediv; + + // Is there an existing keys block that matches the ediv? + bonding_block_t *existing_block = find_existing_block(connection->is_central, BLOCK_KEYS, ediv); + if (existing_block) { + if (existing_block->data_length == sizeof(bonding_keys_t) && + memcmp(existing_block->data, &connection->bonding_keys, sizeof(bonding_keys_t)) == 0) { + // Identical block found. No need to store again. + return; + } + // Data doesn't match. Invalidate block and store a new one. + invalidate_block(existing_block); + } + // Invalidate any existing blocks that match the peer address. + existing_block = next_block(NULL); + while (existing_block != NULL) { + if (existing_block->type == BLOCK_KEYS && connection->is_central == existing_block->is_central && + existing_block->data_length == sizeof(bonding_keys_t)) { + const ble_gap_addr_t *existing_peer = &((const bonding_keys_t *)existing_block->data)->peer_id.id_addr_info; + const ble_gap_addr_t *connecting_peer = &connection->bonding_keys.peer_id.id_addr_info; + if (memcmp(existing_peer->addr, connecting_peer->addr, 6) == 0 && + memcmp(existing_block->data, &connection->bonding_keys, sizeof(bonding_keys_t)) != 0) { + // Mismatched block found. Invalidate it. + invalidate_block(existing_block); + } + } + existing_block = next_block(existing_block); + } + + bonding_block_t block_header = { + .is_central = connection->is_central, + .type = BLOCK_KEYS, + .ediv = ediv, + .conn_handle = connection->conn_handle, + .data_length = sizeof(bonding_keys_t), + }; + bonding_block_t *new_block = find_unused_block(sizeof(bonding_keys_t)); + write_block_header(new_block, &block_header); + write_block_data(new_block, (uint8_t *)&connection->bonding_keys, sizeof(bonding_keys_t)); +} + +void bonding_clear_keys(bonding_keys_t *bonding_keys) { + memset((uint8_t *)bonding_keys, 0, sizeof(bonding_keys_t)); +} + +void bonding_reset(void) { + if (BONDING_FLAG != *((uint32_t *)BONDING_START_FLAG_ADDR) || + BONDING_FLAG != *((uint32_t *)BONDING_END_FLAG_ADDR)) { + bonding_erase_storage(); + } +} + +// Write bonding blocks to flash. Requests have been queued during evt handlers. +void bonding_background(void) { + // A paired connection will request that its keys and CCCD values be stored. + // The CCCD store whenever a CCCD value is written. + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + bleio_connection_internal_t *connection = &bleio_connections[i]; + + // Wait at least one second before saving CCCD, to consolidate + // writes that involve multiple CCCDs. For instance, for HID, + // three CCCD's are set in short succession by the HID client. + if (connection->do_bond_cccds) { + uint64_t current_ticks_ms = supervisor_ticks_ms64(); + if (current_ticks_ms - connection->do_bond_cccds_request_time >= 1000) { + write_sys_attr_block(connection); + connection->do_bond_cccds = false; + } + } + + if (connection->do_bond_keys) { + write_keys_block(connection); + connection->do_bond_keys = false; + } + } +} + +bool bonding_load_cccd_info(bool is_central, uint16_t conn_handle, uint16_t ediv) { + bonding_block_t *block = find_existing_block(is_central, BLOCK_SYS_ATTR, ediv); + if (block == NULL) { + return false; + } + + return NRF_SUCCESS == + sd_ble_gatts_sys_attr_set(conn_handle, block->data, block->data_length, SYS_ATTR_FLAGS); +} + +bool bonding_load_keys(bool is_central, uint16_t ediv, bonding_keys_t *bonding_keys) { + bonding_block_t *block = find_existing_block(is_central, BLOCK_KEYS, ediv); + if (block == NULL) { + return false; + } + if (sizeof(bonding_keys_t) != block->data_length) { + // bonding_keys_t is a fixed length, so lengths should match. + return false; + } + + memcpy(bonding_keys, block->data, block->data_length); + return true; +} + +size_t bonding_load_identities(bool is_central, const ble_gap_id_key_t **keys, size_t max_length) { + bonding_block_t *block = NULL; + size_t len = 0; + while (len < max_length) { + block = next_block(block); + if (block == NULL) { + return len; + } + if (block->type != BLOCK_UNUSED && + block->type != BLOCK_INVALID && + block->is_central == is_central) { + if (sizeof(bonding_keys_t) != block->data_length) { + // bonding_keys_t is a fixed length, so lengths should match. + return len; + } + const bonding_keys_t *key_set = (const bonding_keys_t *)block->data; + keys[len] = &key_set->peer_id; + len++; + } + } + return len; +} + +const ble_gap_enc_key_t *bonding_load_peer_encryption_key(bool is_central, const ble_gap_addr_t *peer) { + bonding_block_t *block = next_block(NULL); + while (block != NULL) { + if (block->type == BLOCK_KEYS && block->is_central == is_central) { + const bonding_keys_t *key_set = (const bonding_keys_t *)block->data; + if (memcmp(key_set->peer_id.id_addr_info.addr, peer->addr, 6) == 0) { + return &key_set->peer_enc; + } + } + block = next_block(block); + } + return NULL; +} diff --git a/ports/espressif/common-hal/_bleio/bonding.h b/ports/espressif/common-hal/_bleio/bonding.h new file mode 100644 index 0000000000..9f04f10d4f --- /dev/null +++ b/ports/espressif/common-hal/_bleio/bonding.h @@ -0,0 +1,91 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_BONDING_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_BONDING_H + +#include +#include +#include + +#include "common-hal/_bleio/__init__.h" + +#define EDIV_INVALID (0xffff) + +#define BONDING_DEBUG (1) +#if BONDING_DEBUG + #define BONDING_DEBUG_PRINTF(...) printf(__VA_ARGS__) + #define BONDING_DEBUG_PRINT_BLOCK(block) bonding_print_block(block) + #define BONDING_DEBUG_PRINT_KEYS(keys) bonding_print_keys(keys) +#else + #define BONDING_DEBUG_PRINTF(...) + #define BONDING_DEBUG_PRINT_BLOCK(block) + #define BONDING_DEBUG_PRINT_KEYS(keys) +#endif + +// Bonding data is stored in variable-length blocks consecutively in +// erased flash (all 1's). The blocks are 32-bit aligned, though the +// data may be any number of bytes. We hop through the blocks using +// the size field to find the next block. When we hit a word that is +// all 1's, we have reached the end of the blocks. We can write a new +// block there. + +typedef enum { + BLOCK_INVALID = 0, // Ignore this block + BLOCK_KEYS = 1, // Block contains bonding keys. + BLOCK_SYS_ATTR = 2, // Block contains sys_attr values (CCCD settings, etc.). + BLOCK_UNUSED = 0xff, // Initial erased value. +} bonding_block_type_t; + +typedef struct { + bool is_central : 1; // 1 if data is for a central role. + uint16_t reserved : 7; // Not currently used + bonding_block_type_t type : 8; // What kind of data is stored in. + uint16_t ediv; // ediv value; used as a lookup key. + uint16_t conn_handle; // Connection handle: used when a BLOCK_SYS_ATTR is queued to write. + // Not used as a key, etc. + uint16_t data_length; // Length of data in bytes, including ediv, not including padding. + // End of block header. 32-bit boundary here. + uint8_t data[]; // Rest of data in the block. Needs to be 32-bit aligned. + // Block is padded to 32-bit alignment. +} bonding_block_t; + +void bonding_background(void); +void bonding_erase_storage(void); +void bonding_reset(void); +void bonding_clear_keys(bonding_keys_t *bonding_keys); +bool bonding_load_cccd_info(bool is_central, uint16_t conn_handle, uint16_t ediv); +bool bonding_load_keys(bool is_central, uint16_t ediv, bonding_keys_t *bonding_keys); +const ble_gap_enc_key_t *bonding_load_peer_encryption_key(bool is_central, const ble_gap_addr_t *peer); +size_t bonding_load_identities(bool is_central, const ble_gap_id_key_t **keys, size_t max_length); +size_t bonding_peripheral_bond_count(void); + +#if BONDING_DEBUG +void bonding_print_block(bonding_block_t *); +void bonding_print_keys(bonding_keys_t *); +#endif + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_BONDING_H diff --git a/ports/espressif/common-hal/microcontroller/Processor.c b/ports/espressif/common-hal/microcontroller/Processor.c index 500d1f6d3e..e4782c30ab 100644 --- a/ports/espressif/common-hal/microcontroller/Processor.c +++ b/ports/espressif/common-hal/microcontroller/Processor.c @@ -60,7 +60,13 @@ float common_hal_mcu_processor_get_voltage(void) { } uint32_t common_hal_mcu_processor_get_frequency(void) { - return 0; + #ifdef CONFIG_IDF_TARGET_ESP32C3 + return CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ * 1000000; + #elif defined(CONFIG_IDF_TARGET_ESP32S2) + return CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ * 1000000; + #elif defined(CONFIG_IDF_TARGET_ESP32S3) + return CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ * 1000000; + #endif } STATIC uint8_t swap_nibbles(uint8_t v) { diff --git a/ports/espressif/esp-idf-config/sdkconfig-ble.defaults b/ports/espressif/esp-idf-config/sdkconfig-ble.defaults new file mode 100644 index 0000000000..476b6a32d9 --- /dev/null +++ b/ports/espressif/esp-idf-config/sdkconfig-ble.defaults @@ -0,0 +1,171 @@ +# +# Bluetooth +# +CONFIG_BT_ENABLED=y +# end of Bluetooth + +CONFIG_BT_CTRL_MODE_EFF=1 +# +# Bluetooth controller +# +CONFIG_BT_CTRL_BLE_MAX_ACT=10 +CONFIG_BT_CTRL_BLE_MAX_ACT_EFF=10 +CONFIG_BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB=0 +CONFIG_BT_CTRL_PINNED_TO_CORE_0=y +# CONFIG_BT_CTRL_PINNED_TO_CORE_1 is not set +CONFIG_BT_CTRL_PINNED_TO_CORE=0 +CONFIG_BT_CTRL_HCI_MODE_VHCI=y +# CONFIG_BT_CTRL_HCI_MODE_UART_H4 is not set +CONFIG_BT_CTRL_HCI_TL=1 +CONFIG_BT_CTRL_ADV_DUP_FILT_MAX=30 +# CONFIG_BT_CTRL_HW_CCA is not set +CONFIG_BT_CTRL_HW_CCA_EFF=0 +CONFIG_BT_CTRL_CE_LENGTH_TYPE_ORIG=y +# CONFIG_BT_CTRL_CE_LENGTH_TYPE_CE is not set +# CONFIG_BT_CTRL_CE_LENGTH_TYPE_SD is not set +CONFIG_BT_CTRL_CE_LENGTH_TYPE_EFF=0 +CONFIG_BT_CTRL_TX_ANTENNA_INDEX_0=y +# CONFIG_BT_CTRL_TX_ANTENNA_INDEX_1 is not set +CONFIG_BT_CTRL_TX_ANTENNA_INDEX_EFF=0 +CONFIG_BT_CTRL_RX_ANTENNA_INDEX_0=y +# CONFIG_BT_CTRL_RX_ANTENNA_INDEX_1 is not set +CONFIG_BT_CTRL_RX_ANTENNA_INDEX_EFF=0 +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N27 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N24 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N21 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N18 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N15 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N12 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N9 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N6 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N3 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N0 is not set +CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P3=y +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P6 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P9 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P12 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P15 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P18 is not set +CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_EFF=10 +CONFIG_BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP=y +CONFIG_BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM=100 +CONFIG_BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD=20 +# CONFIG_BT_CTRL_BLE_SCAN_DUPL is not set +# CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EN is not set +CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_DIS=y +CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EFF=0 +# end of Bluetooth controller + +# CONFIG_BT_CTRL_MODEM_SLEEP is not set +# +# Bluetooth controller +# +CONFIG_BT_CTRL_SLEEP_MODE_EFF=0 +CONFIG_BT_CTRL_SLEEP_CLOCK_EFF=0 +CONFIG_BT_CTRL_HCI_TL_EFF=1 +# CONFIG_BT_CTRL_AGC_RECORRECT_EN is not set +# end of Bluetooth controller + +# CONFIG_BT_BLUEDROID_ENABLED is not set +# +# Bluetooth +# +CONFIG_BT_NIMBLE_ENABLED=y +# CONFIG_BT_CONTROLLER_ONLY is not set +# end of Bluetooth + +CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL=y +# +# NimBLE Options +# +# CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_DEFAULT is not set +# CONFIG_BT_NIMBLE_LOG_LEVEL_NONE is not set +# CONFIG_BT_NIMBLE_LOG_LEVEL_ERROR is not set +# CONFIG_BT_NIMBLE_LOG_LEVEL_WARNING is not set +CONFIG_BT_NIMBLE_LOG_LEVEL_INFO=y +# CONFIG_BT_NIMBLE_LOG_LEVEL_DEBUG is not set +CONFIG_BT_NIMBLE_LOG_LEVEL=1 +CONFIG_BT_NIMBLE_MAX_CONNECTIONS=3 +CONFIG_BT_NIMBLE_MAX_BONDS=3 +CONFIG_BT_NIMBLE_MAX_CCCDS=8 +CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM=0 +# CONFIG_BT_NIMBLE_PINNED_TO_CORE_0 is not set +CONFIG_BT_NIMBLE_PINNED_TO_CORE_1=y +CONFIG_BT_NIMBLE_PINNED_TO_CORE=1 +CONFIG_BT_NIMBLE_TASK_STACK_SIZE=4096 +CONFIG_BT_NIMBLE_ROLE_CENTRAL=y +CONFIG_BT_NIMBLE_ROLE_PERIPHERAL=y +CONFIG_BT_NIMBLE_ROLE_BROADCASTER=y +CONFIG_BT_NIMBLE_ROLE_OBSERVER=y +CONFIG_BT_NIMBLE_NVS_PERSIST=y +CONFIG_BT_NIMBLE_SM_LEGACY=y +CONFIG_BT_NIMBLE_SM_SC=y +# CONFIG_BT_NIMBLE_DEBUG is not set +# CONFIG_BT_NIMBLE_SM_SC_DEBUG_KEYS is not set +CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME="nimble" +CONFIG_BT_NIMBLE_GAP_DEVICE_NAME_MAX_LEN=31 +CONFIG_BT_NIMBLE_ATT_PREFERRED_MTU=256 +CONFIG_BT_NIMBLE_SVC_GAP_APPEARANCE=0 +CONFIG_BT_NIMBLE_ACL_BUF_COUNT=20 +CONFIG_BT_NIMBLE_ACL_BUF_SIZE=255 +CONFIG_BT_NIMBLE_HCI_EVT_BUF_SIZE=70 +CONFIG_BT_NIMBLE_HCI_EVT_HI_BUF_COUNT=30 +CONFIG_BT_NIMBLE_HCI_EVT_LO_BUF_COUNT=8 +CONFIG_BT_NIMBLE_MSYS1_BLOCK_COUNT=12 +# CONFIG_BT_NIMBLE_HS_FLOW_CTRL is not set +CONFIG_BT_NIMBLE_RPA_TIMEOUT=900 +# CONFIG_BT_NIMBLE_MESH is not set +CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS=y +CONFIG_BT_NIMBLE_HS_STOP_TIMEOUT_MS=2000 +# CONFIG_BT_NIMBLE_HOST_BASED_PRIVACY is not set +CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT=y +CONFIG_BT_NIMBLE_MAX_CONN_REATTEMPT=3 +CONFIG_BT_NIMBLE_EXT_ADV=y +CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES=1 +CONFIG_BT_NIMBLE_MAX_EXT_ADV_DATA_LEN=1650 +CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV=y +CONFIG_BT_NIMBLE_MAX_PERIODIC_SYNCS=1 +# CONFIG_BT_NIMBLE_BLUFI_ENABLE is not set +CONFIG_BT_NIMBLE_USE_ESP_TIMER=y +# end of NimBLE Options + +# CONFIG_BLUEDROID_ENABLED is not set +# +# Deprecated options for backward compatibility +# +CONFIG_NIMBLE_ENABLED=y +CONFIG_NIMBLE_MEM_ALLOC_MODE_INTERNAL=y +# CONFIG_NIMBLE_MEM_ALLOC_MODE_DEFAULT is not set +CONFIG_NIMBLE_MAX_CONNECTIONS=3 +CONFIG_NIMBLE_MAX_BONDS=3 +CONFIG_NIMBLE_MAX_CCCDS=8 +CONFIG_NIMBLE_L2CAP_COC_MAX_NUM=0 +CONFIG_NIMBLE_PINNED_TO_CORE_0=y +# CONFIG_NIMBLE_PINNED_TO_CORE_1 is not set +CONFIG_NIMBLE_PINNED_TO_CORE=0 +CONFIG_NIMBLE_TASK_STACK_SIZE=4096 +CONFIG_NIMBLE_ROLE_CENTRAL=y +CONFIG_NIMBLE_ROLE_PERIPHERAL=y +CONFIG_NIMBLE_ROLE_BROADCASTER=y +CONFIG_NIMBLE_ROLE_OBSERVER=y +CONFIG_NIMBLE_NVS_PERSIST=y +CONFIG_NIMBLE_SM_LEGACY=y +CONFIG_NIMBLE_SM_SC=y +# CONFIG_NIMBLE_DEBUG is not set +# CONFIG_NIMBLE_SM_SC_DEBUG_KEYS is not set +CONFIG_NIMBLE_SVC_GAP_DEVICE_NAME="nimble" +CONFIG_NIMBLE_GAP_DEVICE_NAME_MAX_LEN=31 +CONFIG_NIMBLE_ATT_PREFERRED_MTU=256 +CONFIG_NIMBLE_SVC_GAP_APPEARANCE=0 +CONFIG_NIMBLE_ACL_BUF_COUNT=20 +CONFIG_NIMBLE_ACL_BUF_SIZE=255 +CONFIG_NIMBLE_HCI_EVT_BUF_SIZE=70 +CONFIG_NIMBLE_HCI_EVT_HI_BUF_COUNT=30 +CONFIG_NIMBLE_HCI_EVT_LO_BUF_COUNT=8 +CONFIG_NIMBLE_MSYS1_BLOCK_COUNT=12 +# CONFIG_NIMBLE_HS_FLOW_CTRL is not set +CONFIG_NIMBLE_RPA_TIMEOUT=900 +# CONFIG_NIMBLE_MESH is not set +CONFIG_NIMBLE_CRYPTO_STACK_MBEDTLS=y +CONFIG_SW_COEXIST_ENABLE=y +# end of Deprecated options for backward compatibility diff --git a/ports/espressif/esp-idf-config/sdkconfig-esp32s3.defaults b/ports/espressif/esp-idf-config/sdkconfig-esp32s3.defaults index e655f4ceb1..9b1c9f4263 100644 --- a/ports/espressif/esp-idf-config/sdkconfig-esp32s3.defaults +++ b/ports/espressif/esp-idf-config/sdkconfig-esp32s3.defaults @@ -14,7 +14,7 @@ CONFIG_SDK_TOOLPREFIX="xtensa-esp32s3-elf-" CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x0 # end of Bootloader config -# CONFIG_ESP32S3_DEFAULT_CPU_FREQ_80 is not set +CONFIG_BT_SOC_SUPPORT_5_0=y # # ESP32S3-Specific # diff --git a/ports/espressif/mpconfigport.mk b/ports/espressif/mpconfigport.mk index 0f297b9989..46e5bd3bb7 100644 --- a/ports/espressif/mpconfigport.mk +++ b/ports/espressif/mpconfigport.mk @@ -36,6 +36,8 @@ CIRCUITPY_MODULE ?= none ifeq ($(IDF_TARGET),esp32c3) CIRCUITPY_USB = 0 CIRCUITPY_ALARM = 0 +CIRCUITPY_BLEIO = 1 +CIRCUITPY_BLEIO_HCI = 0 CIRCUITPY_COUNTIO = 0 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_AUDIOBUSIO = 0 @@ -45,8 +47,14 @@ CIRCUITPY_PARALLELDISPLAY = 0 CIRCUITPY_TOUCHIO ?= 1 CIRCUITPY_TOUCHIO_USE_NATIVE = 0 else ifeq ($(IDF_TARGET),esp32s3) +CIRCUITPY_BLEIO = 1 +CIRCUITPY_BLEIO_HCI = 0 CIRCUITPY_IMAGECAPTURE = 0 CIRCUITPY_PARALLELDISPLAY = 0 +else ifeq ($(IDF_TARGET),esp32s2) +# No BLE on S2 +CIRCUITPY_BLEIO = 0 +CIRCUITPY_BLEIO_HCI = 0 endif # From ESP32-S2/S3 Technical Reference Manual: diff --git a/ports/espressif/supervisor/port.c b/ports/espressif/supervisor/port.c index 5567f83c0c..11709eda40 100644 --- a/ports/espressif/supervisor/port.c +++ b/ports/espressif/supervisor/port.c @@ -70,6 +70,10 @@ #include "common-hal/audiobusio/__init__.h" #endif +#if CIRCUITPY_BLEIO +#include "shared-bindings/_bleio/__init__.h" +#endif + #if CIRCUITPY_IMAGECAPTURE #include "cam.h" #endif @@ -279,6 +283,10 @@ void reset_port(void) { watchdog_reset(); #endif + #if CIRCUITPY_BLEIO + bleio_reset(); + #endif + #if CIRCUITPY_WIFI wifi_reset(); #endif diff --git a/ports/espressif/tools/update_sdkconfig.py b/ports/espressif/tools/update_sdkconfig.py index ce174fd12a..e89f7ab00d 100644 --- a/ports/espressif/tools/update_sdkconfig.py +++ b/ports/espressif/tools/update_sdkconfig.py @@ -49,6 +49,7 @@ TARGET_SETTINGS = [ "CONFIG_TOOLPREFIX", "ESP_SLEEP_GPIO_RESET_WORKAROUND", "CONFIG_ESP_PHY_ENABLE_USB", + "CONFIG_BT_SOC_SUPPORT_5_0", ] BOARD_SETTINGS = [ @@ -65,6 +66,8 @@ FLASH_SETTINGS = [ "CONFIG_PARTITION_TABLE_FILENAME", ] +BLE_SETTINGS = ["CONFIG_BT_", "CONFIG_BLUEDROID_", "CONFIG_NIMBLE_", "CONFIG_SW_COEXIST_ENABLE"] + # boards/lilygo_ttgo_t8_s2_st7789/sdkconfig # CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y @@ -80,16 +83,17 @@ def matches_group(line, group): def add_group(lines, last_group, current_group): - if last_group != current_group: + # TODO: Properly handle nested groups + if last_group != current_group[-1]: if last_group: lines.append("# end of " + last_group) lines.append("") return None if current_group: lines.append("#") - lines.append("# " + current_group) + lines.append("# " + current_group[-1]) lines.append("#") - return current_group + return current_group[-1] return last_group @@ -120,12 +124,14 @@ def update(debug, board, update_all): opt_config = pathlib.Path("esp-idf-config/sdkconfig-opt.defaults") flash_config = pathlib.Path(f"esp-idf-config/sdkconfig-{flash}.defaults") target_config = pathlib.Path(f"esp-idf-config/sdkconfig-{target}.defaults") + ble_config = pathlib.Path(f"esp-idf-config/sdkconfig-ble.defaults") board_config = pathlib.Path(f"boards/{board}/sdkconfig") defaults = default_config.read_text().split("\n") defaults.extend(opt_config.read_text().split("\n")) defaults.extend(flash_config.read_text().split("\n")) defaults.extend(target_config.read_text().split("\n")) + defaults.extend(ble_config.read_text().split("\n")) board_settings = [] last_board_group = None @@ -135,15 +141,17 @@ def update(debug, board, update_all): last_opt_group = None target_settings = [] last_target_group = None + ble_settings = [] + last_ble_group = None default_settings = [] last_default_group = None - current_group = None + current_group = [] for line in input_config.read_text().split("\n"): if line.startswith("# ") and "CONFIG_" not in line and len(line) > 3: if line.startswith("# end of"): - current_group = None + current_group.pop() else: - current_group = line[2:] + current_group.append(line[2:]) elif (not update_all and line not in defaults) or ( update_all and matches_group(line, BOARD_SETTINGS) ): @@ -159,6 +167,9 @@ def update(debug, board, update_all): elif matches_group(line, TARGET_SETTINGS): last_target_group = add_group(target_settings, last_target_group, current_group) target_settings.append(line) + elif matches_group(line, BLE_SETTINGS): + last_ble_group = add_group(ble_settings, last_ble_group, current_group) + ble_settings.append(line) elif "CONFIG_" in line: last_default_group = add_group(default_settings, last_default_group, current_group) default_settings.append(line) @@ -167,6 +178,7 @@ def update(debug, board, update_all): add_group(opt_settings, last_opt_group, current_group) add_group(flash_settings, last_flash_group, current_group) add_group(target_settings, last_target_group, current_group) + add_group(ble_settings, last_ble_group, current_group) add_group(default_settings, last_default_group, current_group) board_config.write_text("\n".join(board_settings)) @@ -175,6 +187,7 @@ def update(debug, board, update_all): opt_config.write_text("\n".join(opt_settings)) default_config.write_text("\n".join(default_settings)) target_config.write_text("\n".join(target_settings)) + ble_config.write_text("\n".join(ble_settings)) if __name__ == "__main__": diff --git a/ports/nrf/common-hal/_bleio/__init__.h b/ports/nrf/common-hal/_bleio/__init__.h index d94267dd3c..f10001f662 100644 --- a/ports/nrf/common-hal/_bleio/__init__.h +++ b/ports/nrf/common-hal/_bleio/__init__.h @@ -28,7 +28,6 @@ #define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_INIT_H void bleio_background(void); -void bleio_reset(void); typedef struct { ble_gap_enc_key_t own_enc; diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index a1eb973b83..5c1139271d 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -45,7 +45,6 @@ #include "nrf_nvic.h" #include "common-hal/microcontroller/Pin.h" -#include "common-hal/_bleio/__init__.h" #include "common-hal/alarm/time/TimeAlarm.h" #include "common-hal/analogio/AnalogIn.h" #include "common-hal/busio/I2C.h" @@ -59,6 +58,7 @@ #include "common-hal/watchdog/WatchDogTimer.h" #include "common-hal/alarm/__init__.h" +#include "shared-bindings/_bleio/__init__.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/rtc/__init__.h" diff --git a/ports/stm/common-hal/busio/SPI.c b/ports/stm/common-hal/busio/SPI.c index 77f2b53706..047d59556d 100644 --- a/ports/stm/common-hal/busio/SPI.c +++ b/ports/stm/common-hal/busio/SPI.c @@ -250,7 +250,7 @@ void common_hal_busio_spi_never_reset(busio_spi_obj_t *self) { } bool common_hal_busio_spi_deinited(busio_spi_obj_t *self) { - return self->sck->pin == NULL; + return self->sck == NULL; } void common_hal_busio_spi_deinit(busio_spi_obj_t *self) { diff --git a/ports/stm/common-hal/busio/UART.c b/ports/stm/common-hal/busio/UART.c index d8677126ef..dc37a4e7c8 100644 --- a/ports/stm/common-hal/busio/UART.c +++ b/ports/stm/common-hal/busio/UART.c @@ -259,7 +259,7 @@ void common_hal_busio_uart_never_reset(busio_uart_obj_t *self) { } bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) { - return self->tx->pin == NULL && self->rx->pin == NULL; + return self->tx == NULL && self->rx == NULL; } void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { diff --git a/py/ringbuf.c b/py/ringbuf.c index 2003cc97d5..72e164946a 100644 --- a/py/ringbuf.c +++ b/py/ringbuf.c @@ -114,7 +114,7 @@ size_t ringbuf_num_filled(ringbuf_t *r) { // If the ring buffer fills up, not all bytes will be written. // Returns how many bytes were successfully written. -size_t ringbuf_put_n(ringbuf_t *r, uint8_t *buf, size_t bufsize) { +size_t ringbuf_put_n(ringbuf_t *r, const uint8_t *buf, size_t bufsize) { for (size_t i = 0; i < bufsize; i++) { if (ringbuf_put(r, buf[i]) < 0) { // If ringbuf is full, give up and return how many bytes diff --git a/py/ringbuf.h b/py/ringbuf.h index 6ed72dcf1a..8f7e7b1760 100644 --- a/py/ringbuf.h +++ b/py/ringbuf.h @@ -52,7 +52,7 @@ int ringbuf_put(ringbuf_t *r, uint8_t v); void ringbuf_clear(ringbuf_t *r); size_t ringbuf_num_empty(ringbuf_t *r); size_t ringbuf_num_filled(ringbuf_t *r); -size_t ringbuf_put_n(ringbuf_t *r, uint8_t *buf, size_t bufsize); +size_t ringbuf_put_n(ringbuf_t *r, const uint8_t *buf, size_t bufsize); size_t ringbuf_get_n(ringbuf_t *r, uint8_t *buf, size_t bufsize); // Note: big-endian. No-op if not enough room available for both bytes. diff --git a/shared-bindings/_bleio/__init__.h b/shared-bindings/_bleio/__init__.h index 7f251ef188..55b527cfa5 100644 --- a/shared-bindings/_bleio/__init__.h +++ b/shared-bindings/_bleio/__init__.h @@ -54,6 +54,8 @@ extern const mp_obj_type_t mp_type_bleio_BluetoothError; extern const mp_obj_type_t mp_type_bleio_RoleError; extern const mp_obj_type_t mp_type_bleio_SecurityError; +void bleio_reset(void); + extern mp_obj_t bleio_set_adapter(mp_obj_t adapter_obj); NORETURN void mp_raise_bleio_BluetoothError(const compressed_string_t *msg, ...); diff --git a/shared-bindings/audiobusio/I2SOut.c b/shared-bindings/audiobusio/I2SOut.c index c9910427f3..6254f7cde2 100644 --- a/shared-bindings/audiobusio/I2SOut.c +++ b/shared-bindings/audiobusio/I2SOut.c @@ -72,7 +72,6 @@ //| Playing a wave file from flash:: //| //| import board -//| import audioio //| import audiocore //| import audiobusio //| import digitalio diff --git a/shared-bindings/neopixel_write/__init__.c b/shared-bindings/neopixel_write/__init__.c index 6895813db5..a95020ad46 100644 --- a/shared-bindings/neopixel_write/__init__.c +++ b/shared-bindings/neopixel_write/__init__.c @@ -29,8 +29,15 @@ #include "py/mphal.h" #include "py/runtime.h" #include "shared-bindings/digitalio/DigitalInOut.h" +#include "shared-bindings/util.h" #include "supervisor/shared/translate.h" +STATIC void check_for_deinit(digitalio_digitalinout_obj_t *self) { + if (common_hal_digitalio_digitalinout_deinited(self)) { + raise_deinited_error(); + } +} + //| """Low-level neopixel implementation //| //| The `neopixel_write` module contains a helper method to write out bytes in @@ -60,8 +67,13 @@ STATIC mp_obj_t neopixel_write_neopixel_write_(mp_obj_t digitalinout_obj, mp_obj if (!mp_obj_is_type(digitalinout_obj, &digitalio_digitalinout_type)) { mp_raise_TypeError_varg(translate("Expected a %q"), digitalio_digitalinout_type.name); } + // Convert parameters into expected types. const digitalio_digitalinout_obj_t *digitalinout = MP_OBJ_TO_PTR(digitalinout_obj); + + // Check to see if the NeoPixel has been deinited before writing to it. + check_for_deinit(digitalinout_obj); + mp_buffer_info_t bufinfo; mp_get_buffer_raise(buf, &bufinfo, MP_BUFFER_READ); // Call platform's neopixel write function with provided buffer and options. diff --git a/shared-bindings/wifi/Radio.c b/shared-bindings/wifi/Radio.c index 93d92630ca..7701b1ff33 100644 --- a/shared-bindings/wifi/Radio.c +++ b/shared-bindings/wifi/Radio.c @@ -304,7 +304,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_stop_ap_obj, wifi_radio_stop_ap); //| *, //| channel: Optional[int] = 0, //| bssid: Optional[ReadableBuffer] = b"", -//| timeout: Optional[float] = None) -> bool: +//| timeout: Optional[float] = None) -> None: //| """Connects to the given ssid and waits for an ip address. Reconnections are handled //| automatically once one connection succeeds. //| @@ -507,7 +507,7 @@ const mp_obj_property_t wifi_radio_ap_info_obj = { MP_ROM_NONE }, }; -//| def ping(self, ip: ipaddress.IPv4Address, *, timeout: Optional[float] = 0.5) -> float: +//| def ping(self, ip: ipaddress.IPv4Address, *, timeout: Optional[float] = 0.5) -> Optional[float]: //| """Ping an IP to test connectivity. Returns echo time in seconds. //| Returns None when it times out.""" //| ... diff --git a/shared-module/_bleio/ScanResults.c b/shared-module/_bleio/ScanResults.c index e5b5525579..1f4dbff310 100644 --- a/shared-module/_bleio/ScanResults.c +++ b/shared-module/_bleio/ScanResults.c @@ -91,9 +91,9 @@ void shared_module_bleio_scanresults_append(bleio_scanresults_obj_t *self, bool connectable, bool scan_response, int8_t rssi, - uint8_t *peer_addr, + const uint8_t *peer_addr, uint8_t addr_type, - uint8_t *data, + const uint8_t *data, uint16_t len) { int32_t packet_size = sizeof(uint8_t) + sizeof(ticks_ms) + sizeof(rssi) + NUM_BLEIO_ADDRESS_BYTES + sizeof(addr_type) + sizeof(len) + len; diff --git a/shared-module/_bleio/ScanResults.h b/shared-module/_bleio/ScanResults.h index fa181aabee..945809c8d9 100644 --- a/shared-module/_bleio/ScanResults.h +++ b/shared-module/_bleio/ScanResults.h @@ -56,9 +56,9 @@ void shared_module_bleio_scanresults_append(bleio_scanresults_obj_t *self, bool connectable, bool scan_result, int8_t rssi, - uint8_t *peer_addr, + const uint8_t *peer_addr, uint8_t addr_type, - uint8_t *data, + const uint8_t *data, uint16_t len); #endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_SCANRESULTS_H diff --git a/shared-module/busio/I2C.c b/shared-module/busio/I2C.c deleted file mode 100644 index d3db18e3ad..0000000000 --- a/shared-module/busio/I2C.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "shared-bindings/busio/I2C.h" -#include "shared-bindings/bitbangio/I2C.h" -#include "py/mperrno.h" -#include "py/nlr.h" - -void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, - const mcu_pin_obj_t *scl, const mcu_pin_obj_t *sda, uint32_t freq, uint32_t timeout) { - shared_module_bitbangio_i2c_construct(&self->bitbang, scl, sda, freq, timeout); -} - -bool common_hal_busio_i2c_deinited(busio_i2c_obj_t *self) { - return shared_module_bitbangio_i2c_deinited(&self->bitbang); -} - -void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) { - shared_module_bitbangio_i2c_deinit(&self->bitbang); -} - -bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) { - return shared_module_bitbangio_i2c_probe(&self->bitbang, addr); -} - -bool common_hal_busio_i2c_try_lock(busio_i2c_obj_t *self) { - return shared_module_bitbangio_i2c_try_lock(&self->bitbang); -} - -bool common_hal_busio_i2c_has_lock(busio_i2c_obj_t *self) { - return shared_module_bitbangio_i2c_has_lock(&self->bitbang); -} - -void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) { - shared_module_bitbangio_i2c_unlock(&self->bitbang); -} - -uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, - const uint8_t *data, size_t len, bool transmit_stop_bit) { - return shared_module_bitbangio_i2c_write(&self->bitbang, addr, data, len, - transmit_stop_bit); -} - -uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, - uint8_t *data, size_t len) { - return shared_module_bitbangio_i2c_read(&self->bitbang, addr, data, len); -} diff --git a/tests/circuitpython-manual/audiobusio/i2s_sample_loop.py b/tests/circuitpython-manual/audiobusio/i2s_sample_loop.py index 8b40e916dc..75ed4c7ae6 100644 --- a/tests/circuitpython-manual/audiobusio/i2s_sample_loop.py +++ b/tests/circuitpython-manual/audiobusio/i2s_sample_loop.py @@ -19,7 +19,7 @@ length = 8000 // 440 # signed 16 bit s16 = array.array("h", [0] * length) for i in range(length): - s16[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 15)) + s16[i] = int(math.sin(math.pi * 2 * i / length) * (2**15)) print(s16[i]) sample = audiocore.RawSample(s16, sample_rate=8000) diff --git a/tests/circuitpython-manual/audiopwmio/single_buffer_loop.py b/tests/circuitpython-manual/audiopwmio/single_buffer_loop.py index 6013892a95..ffacb6f1d6 100644 --- a/tests/circuitpython-manual/audiopwmio/single_buffer_loop.py +++ b/tests/circuitpython-manual/audiopwmio/single_buffer_loop.py @@ -19,21 +19,21 @@ sample_names = ["unsigned 8 bit", "signed 8 bit", "unsigned 16 bit", "signed 16 # unsigned 8 bit u8 = array.array("B", [0] * length) for i in range(length): - u8[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 7) + 2 ** 7) + u8[i] = int(math.sin(math.pi * 2 * i / length) * (2**7) + 2**7) samples.append(audiocore.RawSample(u8, sample_rate=4000)) # signed 8 bit s8 = array.array("b", [0] * length) for i in range(length): - s8[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 7)) + s8[i] = int(math.sin(math.pi * 2 * i / length) * (2**7)) samples.append(audiocore.RawSample(s8, sample_rate=16000)) # unsigned 16 bit u16 = array.array("H", [0] * length) for i in range(length): - u16[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 15) + 2 ** 15) + u16[i] = int(math.sin(math.pi * 2 * i / length) * (2**15) + 2**15) samples.append(audiocore.RawSample(u16, sample_rate=8000)) @@ -41,7 +41,7 @@ samples.append(audiocore.RawSample(u16, sample_rate=8000)) # signed 16 bit s16 = array.array("h", [0] * length) for i in range(length): - s16[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 15)) + s16[i] = int(math.sin(math.pi * 2 * i / length) * (2**15)) samples.append(audiocore.RawSample(s16, sample_rate=8000)) diff --git a/tests/cpydiff/modules_random_randint.py b/tests/cpydiff/modules_random_randint.py index b05908a157..90607400cd 100644 --- a/tests/cpydiff/modules_random_randint.py +++ b/tests/cpydiff/modules_random_randint.py @@ -8,5 +8,5 @@ workaround: If you need integers larger than native wordsize use the random modu import random -x = random.randint(2 ** 128 - 1, 2 ** 128) +x = random.randint(2**128 - 1, 2**128) print("x={}".format(x)) diff --git a/tests/extmod/uhashlib_sha1.py b/tests/extmod/uhashlib_sha1.py index a0ad8473a1..e6e6e30dc1 100644 --- a/tests/extmod/uhashlib_sha1.py +++ b/tests/extmod/uhashlib_sha1.py @@ -22,7 +22,7 @@ print(sha1.digest()) sha1 = hashlib.sha1(b"hello") try: - sha1.update(u"world") + sha1.update("world") except TypeError as e: print("TypeError") print(sha1.digest()) diff --git a/tests/extmod/uhashlib_sha256.py b/tests/extmod/uhashlib_sha256.py index ad5aa124cb..5c6dfd0a75 100644 --- a/tests/extmod/uhashlib_sha256.py +++ b/tests/extmod/uhashlib_sha256.py @@ -28,7 +28,7 @@ print(hashlib.sha256(b"\xff" * 56).digest()) sha256 = hashlib.sha256(b"hello") try: - sha256.update(u"world") + sha256.update("world") except TypeError as e: print("TypeError") print(sha256.digest()) diff --git a/tests/float/complex1.py b/tests/float/complex1.py index a510ffc830..139bb0c509 100644 --- a/tests/float/complex1.py +++ b/tests/float/complex1.py @@ -27,15 +27,15 @@ print(1j * 2j) print(1j / 2) print((1j / 2j).real) print(1j / (1 + 2j)) -ans = 0j ** 0 +ans = 0j**0 print("%.5g %.5g" % (ans.real, ans.imag)) -ans = 0j ** 1 +ans = 0j**1 print("%.5g %.5g" % (ans.real, ans.imag)) -ans = 0j ** 0j +ans = 0j**0j print("%.5g %.5g" % (ans.real, ans.imag)) -ans = 1j ** 2.5 +ans = 1j**2.5 print("%.5g %.5g" % (ans.real, ans.imag)) -ans = 1j ** 2.5j +ans = 1j**2.5j print("%.5g %.5g" % (ans.real, ans.imag)) # comparison @@ -116,10 +116,10 @@ except ZeroDivisionError: # zero division via power try: - 0j ** -1 + 0j**-1 except ZeroDivisionError: print("ZeroDivisionError") try: - 0j ** 1j + 0j**1j except ZeroDivisionError: print("ZeroDivisionError") diff --git a/tests/float/float1.py b/tests/float/float1.py index efde5146be..37f8b3face 100644 --- a/tests/float/float1.py +++ b/tests/float/float1.py @@ -88,7 +88,7 @@ except ZeroDivisionError: print("ZeroDivisionError") try: - 0.0 ** -1 + 0.0**-1 except ZeroDivisionError: print("ZeroDivisionError") diff --git a/tests/float/float2int_doubleprec_intbig.py b/tests/float/float2int_doubleprec_intbig.py index 84fa2d2536..1226b39ca9 100644 --- a/tests/float/float2int_doubleprec_intbig.py +++ b/tests/float/float2int_doubleprec_intbig.py @@ -35,8 +35,8 @@ if ll_type != 0: print(int(1418774543.0)) print("%d" % 1418774543.0) if ll_type == 3: - print(int(2.0 ** 100)) - print("%d" % 2.0 ** 100) + print(int(2.0**100)) + print("%d" % 2.0**100) else: print(int(1073741823.0)) print("%d" % 1073741823.0) @@ -44,7 +44,7 @@ else: testpass = True p2_rng = ((30, 63, 1024), (62, 63, 1024))[is_64bit][ll_type] for i in range(0, p2_rng): - bitcnt = len(bin(int(2.0 ** i))) - 3 + bitcnt = len(bin(int(2.0**i))) - 3 if i != bitcnt: print("fail: 2**%u was %u bits long" % (i, bitcnt)) testpass = False @@ -53,7 +53,7 @@ print("power of 2 test: %s" % (testpass and "passed" or "failed")) testpass = True p10_rng = ((9, 18, 23), (18, 18, 23))[is_64bit][ll_type] for i in range(0, p10_rng): - digcnt = len(str(int(10.0 ** i))) - 1 + digcnt = len(str(int(10.0**i))) - 1 if i != digcnt: print("fail: 10**%u was %u digits long" % (i, digcnt)) testpass = False @@ -72,28 +72,28 @@ def fp2int_test(num, name, should_fail): if ll_type != 2: if ll_type == 0: if is_64bit: - neg_bad_fp = -1.00000005 * 2.0 ** 62.0 - pos_bad_fp = 2.0 ** 62.0 - neg_good_fp = -(2.0 ** 62.0) - pos_good_fp = 0.99999993 * 2.0 ** 62.0 + neg_bad_fp = -1.00000005 * 2.0**62.0 + pos_bad_fp = 2.0**62.0 + neg_good_fp = -(2.0**62.0) + pos_good_fp = 0.99999993 * 2.0**62.0 else: - neg_bad_fp = -1.00000005 * 2.0 ** 30.0 - pos_bad_fp = 2.0 ** 30.0 - neg_good_fp = -(2.0 ** 30.0) - pos_good_fp = 0.9999999499 * 2.0 ** 30.0 + neg_bad_fp = -1.00000005 * 2.0**30.0 + pos_bad_fp = 2.0**30.0 + neg_good_fp = -(2.0**30.0) + pos_good_fp = 0.9999999499 * 2.0**30.0 else: - neg_bad_fp = -0.51 * 2.0 ** 64.0 - pos_bad_fp = 2.0 ** 63.0 - neg_good_fp = -(2.0 ** 63.0) - pos_good_fp = 1.9999998 * 2.0 ** 62.0 + neg_bad_fp = -0.51 * 2.0**64.0 + pos_bad_fp = 2.0**63.0 + neg_good_fp = -(2.0**63.0) + pos_good_fp = 1.9999998 * 2.0**62.0 fp2int_test(neg_bad_fp, "neg bad", True) fp2int_test(pos_bad_fp, "pos bad", True) fp2int_test(neg_good_fp, "neg good", False) fp2int_test(pos_good_fp, "pos good", False) else: - fp2int_test(-1.9999999999999981 * 2.0 ** 1023.0, "large neg", False) - fp2int_test(1.9999999999999981 * 2.0 ** 1023.0, "large pos", False) + fp2int_test(-1.9999999999999981 * 2.0**1023.0, "large neg", False) + fp2int_test(1.9999999999999981 * 2.0**1023.0, "large pos", False) fp2int_test(float("inf"), "inf test", True) fp2int_test(float("-inf"), "inf test", True) diff --git a/tests/float/float2int_fp30_intbig.py b/tests/float/float2int_fp30_intbig.py index 75ff52f39d..a1bfe67046 100644 --- a/tests/float/float2int_fp30_intbig.py +++ b/tests/float/float2int_fp30_intbig.py @@ -34,13 +34,13 @@ if ll_type is None: print(int(14187744.0)) print("%d" % 14187744.0) if ll_type == 2: - print(int(2.0 ** 100)) - print("%d" % 2.0 ** 100) + print(int(2.0**100)) + print("%d" % 2.0**100) testpass = True p2_rng = ((30, 63, 127), (62, 63, 127))[is_64bit][ll_type] for i in range(0, p2_rng): - bitcnt = len(bin(int(2.0 ** i))) - 3 + bitcnt = len(bin(int(2.0**i))) - 3 if i != bitcnt: print("fail: 2.**%u was %u bits long" % (i, bitcnt)) testpass = False @@ -50,7 +50,7 @@ print("power of 2 test: %s" % (testpass and "passed" or "failed")) testpass = True p10_rng = 9 for i in range(0, p10_rng): - digcnt = len(str(int(10.0 ** i))) - 1 + digcnt = len(str(int(10.0**i))) - 1 if i != digcnt: print("fail: 10.**%u was %u digits long" % (i, digcnt)) testpass = False @@ -69,28 +69,28 @@ def fp2int_test(num, name, should_fail): if ll_type != 2: if ll_type == 0: if is_64bit: - neg_bad_fp = -1.00000005 * 2.0 ** 62.0 - pos_bad_fp = 2.0 ** 62.0 - neg_good_fp = -(2.0 ** 62.0) - pos_good_fp = 0.99999993 * 2.0 ** 62.0 + neg_bad_fp = -1.00000005 * 2.0**62.0 + pos_bad_fp = 2.0**62.0 + neg_good_fp = -(2.0**62.0) + pos_good_fp = 0.99999993 * 2.0**62.0 else: - neg_bad_fp = -1.00000005 * 2.0 ** 30.0 - pos_bad_fp = 2.0 ** 30.0 - neg_good_fp = -(2.0 ** 30.0) - pos_good_fp = 0.9999999499 * 2.0 ** 30.0 + neg_bad_fp = -1.00000005 * 2.0**30.0 + pos_bad_fp = 2.0**30.0 + neg_good_fp = -(2.0**30.0) + pos_good_fp = 0.9999999499 * 2.0**30.0 else: - neg_bad_fp = -0.51 * 2.0 ** 64.0 - pos_bad_fp = 2.0 ** 63.0 - neg_good_fp = -(2.0 ** 63.0) - pos_good_fp = 1.9999998 * 2.0 ** 62.0 + neg_bad_fp = -0.51 * 2.0**64.0 + pos_bad_fp = 2.0**63.0 + neg_good_fp = -(2.0**63.0) + pos_good_fp = 1.9999998 * 2.0**62.0 fp2int_test(neg_bad_fp, "neg bad", True) fp2int_test(pos_bad_fp, "pos bad", True) fp2int_test(neg_good_fp, "neg good", False) fp2int_test(pos_good_fp, "pos good", False) else: - fp2int_test(-1.999999879 * 2.0 ** 126.0, "large neg", False) - fp2int_test(1.999999879 * 2.0 ** 126.0, "large pos", False) + fp2int_test(-1.999999879 * 2.0**126.0, "large neg", False) + fp2int_test(1.999999879 * 2.0**126.0, "large pos", False) fp2int_test(float("inf"), "inf test", True) fp2int_test(float("-inf"), "inf test", True) diff --git a/tests/float/float2int_intbig.py b/tests/float/float2int_intbig.py index 62aca39634..06b651bb72 100644 --- a/tests/float/float2int_intbig.py +++ b/tests/float/float2int_intbig.py @@ -37,13 +37,13 @@ print(int(14187745.)) print("%d" % 14187745.) # fmt: on if ll_type == 2: - print(int(2.0 ** 100)) - print("%d" % 2.0 ** 100) + print(int(2.0**100)) + print("%d" % 2.0**100) testpass = True p2_rng = ((30, 63, 127), (62, 63, 127))[is_64bit][ll_type] for i in range(0, p2_rng): - bitcnt = len(bin(int(2.0 ** i))) - 3 + bitcnt = len(bin(int(2.0**i))) - 3 if i != bitcnt: print("fail: 2.**%u was %u bits long" % (i, bitcnt)) testpass = False @@ -53,7 +53,7 @@ print("power of 2 test: %s" % (testpass and "passed" or "failed")) testpass = True p10_rng = 9 if (ll_type == 0 and ~is_64bit) else 11 for i in range(0, p10_rng): - digcnt = len(str(int(10.0 ** i))) - 1 + digcnt = len(str(int(10.0**i))) - 1 if i != digcnt: print("fail: 10.**%u was %u digits long" % (i, digcnt)) testpass = False @@ -72,28 +72,28 @@ def fp2int_test(num, name, should_fail): if ll_type != 2: if ll_type == 0: if is_64bit: - neg_bad_fp = -1.00000005 * 2.0 ** 62.0 - pos_bad_fp = 2.0 ** 62.0 - neg_good_fp = -(2.0 ** 62.0) - pos_good_fp = 0.99999993 * 2.0 ** 62.0 + neg_bad_fp = -1.00000005 * 2.0**62.0 + pos_bad_fp = 2.0**62.0 + neg_good_fp = -(2.0**62.0) + pos_good_fp = 0.99999993 * 2.0**62.0 else: - neg_bad_fp = -1.00000005 * 2.0 ** 30.0 - pos_bad_fp = 2.0 ** 30.0 - neg_good_fp = -(2.0 ** 30.0) - pos_good_fp = 0.9999999499 * 2.0 ** 30.0 + neg_bad_fp = -1.00000005 * 2.0**30.0 + pos_bad_fp = 2.0**30.0 + neg_good_fp = -(2.0**30.0) + pos_good_fp = 0.9999999499 * 2.0**30.0 else: - neg_bad_fp = -0.51 * 2.0 ** 64.0 - pos_bad_fp = 2.0 ** 63.0 - neg_good_fp = -(2.0 ** 63.0) - pos_good_fp = 1.9999998 * 2.0 ** 62.0 + neg_bad_fp = -0.51 * 2.0**64.0 + pos_bad_fp = 2.0**63.0 + neg_good_fp = -(2.0**63.0) + pos_good_fp = 1.9999998 * 2.0**62.0 fp2int_test(neg_bad_fp, "neg bad", True) fp2int_test(pos_bad_fp, "pos bad", True) fp2int_test(neg_good_fp, "neg good", False) fp2int_test(pos_good_fp, "pos good", False) else: - fp2int_test(-1.999999879 * 2.0 ** 127.0, "large neg", False) - fp2int_test(1.999999879 * 2.0 ** 127.0, "large pos", False) + fp2int_test(-1.999999879 * 2.0**127.0, "large neg", False) + fp2int_test(1.999999879 * 2.0**127.0, "large pos", False) fp2int_test(float("inf"), "inf test", True) fp2int_test(float("nan"), "NaN test", True) diff --git a/tests/float/inf_nan_arith.py b/tests/float/inf_nan_arith.py index c27e38bc52..d1a6b18872 100644 --- a/tests/float/inf_nan_arith.py +++ b/tests/float/inf_nan_arith.py @@ -14,7 +14,7 @@ for x in values: except ZeroDivisionError: print(" / ZeroDivisionError") try: - print(" ** pow", x ** y, pow(x, y)) + print(" ** pow", x**y, pow(x, y)) except ZeroDivisionError: print(" ** pow ZeroDivisionError") print(" == != < <= > >=", x == y, x != y, x < y, x <= y, x > y, x >= y) diff --git a/tests/float/int_big_float.py b/tests/float/int_big_float.py index 0bd1662186..dc13e8e0dd 100644 --- a/tests/float/int_big_float.py +++ b/tests/float/int_big_float.py @@ -19,7 +19,7 @@ print("%.5g" % (i / 1.2)) print("%.5g" % (i * 1.2j).imag) # negative power should produce float -print("%.5g" % (i ** -1)) +print("%.5g" % (i**-1)) print("%.5g" % ((2 + i - i) ** -3)) try: diff --git a/tests/float/int_divzero.py b/tests/float/int_divzero.py index b311a1dbcf..ef3531bee8 100644 --- a/tests/float/int_divzero.py +++ b/tests/float/int_divzero.py @@ -4,6 +4,6 @@ except ZeroDivisionError: print("ZeroDivisionError") try: - 0 ** -1 + 0**-1 except ZeroDivisionError: print("ZeroDivisionError") diff --git a/tests/float/int_power.py b/tests/float/int_power.py index ba79247a56..bcda0f98ed 100644 --- a/tests/float/int_power.py +++ b/tests/float/int_power.py @@ -1,7 +1,7 @@ # negative power should produce float x = 2 -print(x ** -2) +print(x**-2) x = 3 x **= -2 diff --git a/tests/import/mpy_native.py b/tests/import/mpy_native.py index bab5f91d53..db7881df43 100644 --- a/tests/import/mpy_native.py +++ b/tests/import/mpy_native.py @@ -11,7 +11,7 @@ except (ImportError, AttributeError): print("SKIP") raise SystemExit -if not (sys.platform == "linux" and sys.maxsize > 2 ** 32): +if not (sys.platform == "linux" and sys.maxsize > 2**32): print("SKIP") raise SystemExit diff --git a/tests/micropython/import_mpy_native_x64.py b/tests/micropython/import_mpy_native_x64.py index 7597843220..c0203cb61c 100644 --- a/tests/micropython/import_mpy_native_x64.py +++ b/tests/micropython/import_mpy_native_x64.py @@ -9,7 +9,7 @@ except (ImportError, AttributeError): print("SKIP") raise SystemExit -if not (sys.platform == "linux" and sys.maxsize > 2 ** 32): +if not (sys.platform == "linux" and sys.maxsize > 2**32): print("SKIP") raise SystemExit diff --git a/tests/misc/rge_sm.py b/tests/misc/rge_sm.py index f3bb4189f7..00b0a7a021 100644 --- a/tests/misc/rge_sm.py +++ b/tests/misc/rge_sm.py @@ -52,12 +52,12 @@ class RungeKutta(object): # couplings are: g1, g2, g3 of U(1), SU(2), SU(3); yt (top Yukawa), lambda (Higgs quartic) # see arxiv.org/abs/0812.4950, eqs 10-15 sysSM = ( - lambda *a: 41.0 / 96.0 / math.pi ** 2 * a[1] ** 3, # g1 - lambda *a: -19.0 / 96.0 / math.pi ** 2 * a[2] ** 3, # g2 - lambda *a: -42.0 / 96.0 / math.pi ** 2 * a[3] ** 3, # g3 + lambda *a: 41.0 / 96.0 / math.pi**2 * a[1] ** 3, # g1 + lambda *a: -19.0 / 96.0 / math.pi**2 * a[2] ** 3, # g2 + lambda *a: -42.0 / 96.0 / math.pi**2 * a[3] ** 3, # g3 lambda *a: 1.0 / 16.0 - / math.pi ** 2 + / math.pi**2 * ( 9.0 / 2.0 * a[4] ** 3 - 8.0 * a[3] ** 2 * a[4] @@ -66,7 +66,7 @@ sysSM = ( ), # yt lambda *a: 1.0 / 16.0 - / math.pi ** 2 + / math.pi**2 * ( 24.0 * a[5] ** 2 + 12.0 * a[4] ** 2 * a[5] @@ -137,5 +137,5 @@ def singleTraj(system, trajStart, h=0.02, tend=1.0): # initial conditions at M_Z singleTraj( - sysSM, [0.354, 0.654, 1.278, 0.983, 0.131], h=0.5, tend=math.log(10 ** 17) + sysSM, [0.354, 0.654, 1.278, 0.983, 0.131], h=0.5, tend=math.log(10**17) ) # true values diff --git a/tests/perf_bench/bm_chaos.py b/tests/perf_bench/bm_chaos.py index 55d282561f..d0f1337db7 100644 --- a/tests/perf_bench/bm_chaos.py +++ b/tests/perf_bench/bm_chaos.py @@ -15,7 +15,7 @@ class GVector(object): self.z = z def Mag(self): - return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2) + return math.sqrt(self.x**2 + self.y**2 + self.z**2) def dist(self, other): return math.sqrt( diff --git a/tests/perf_bench/misc_raytrace.py b/tests/perf_bench/misc_raytrace.py index b51acaccac..a729af99c2 100644 --- a/tests/perf_bench/misc_raytrace.py +++ b/tests/perf_bench/misc_raytrace.py @@ -22,7 +22,7 @@ class Vec: return Vec(self.x * rhs, self.y * rhs, self.z * rhs) def length(self): - return (self.x ** 2 + self.y ** 2 + self.z ** 2) ** 0.5 + return (self.x**2 + self.y**2 + self.z**2) ** 0.5 def normalise(self): l = self.length() @@ -87,12 +87,12 @@ class Sphere: def __init__(self, surface, centre, radius): self.surface = surface self.centre = centre - self.radsq = radius ** 2 + self.radsq = radius**2 def intersect(self, ray): v = self.centre - ray.p b = v.dot(ray.d) - det = b ** 2 - v.dot(v) + self.radsq + det = b**2 - v.dot(v) + self.radsq if det > 0: det **= 0.5 t1 = b - det @@ -180,7 +180,7 @@ def trace_ray(scene, ray, depth): if ndotl > 0: col += light_col * surf.diffuse * ndotl if ldotv > 0: - col += light_col * surf.specular * ldotv ** surf.spec_idx + col += light_col * surf.specular * ldotv**surf.spec_idx # Reflections if depth > 0 and surf.reflect > 0: diff --git a/tests/run-perfbench.py b/tests/run-perfbench.py index bcdbe69abb..5f299281fd 100755 --- a/tests/run-perfbench.py +++ b/tests/run-perfbench.py @@ -33,8 +33,8 @@ def compute_stats(lst): avg += x var += x * x avg /= len(lst) - var = max(0, var / len(lst) - avg ** 2) - return avg, var ** 0.5 + var = max(0, var / len(lst) - avg**2) + return avg, var**0.5 def run_script_on_target(target, script): @@ -201,7 +201,7 @@ def compute_diff(file1, file2, diff_score): sd1 *= av1 / 100 # convert from percent sd to absolute sd sd2 *= av2 / 100 # convert from percent sd to absolute sd av_diff = av2 - av1 - sd_diff = (sd1 ** 2 + sd2 ** 2) ** 0.5 + sd_diff = (sd1**2 + sd2**2) ** 0.5 percent = 100 * av_diff / av1 percent_sd = 100 * sd_diff / av1 print( diff --git a/tools/chart_code_size.py b/tools/chart_code_size.py index 2328edd72f..cefe3b8094 100644 --- a/tools/chart_code_size.py +++ b/tools/chart_code_size.py @@ -446,7 +446,7 @@ def do_all_the_things(elf_filename): if "size" not in symbol: print(symbol) size = symbol["size"] / 8 - square_size = size ** 0.5 + square_size = size**0.5 if text_width_ish > square_size: w = text_width_ish h = size / text_width_ish