Merge pull request #1446 from dhalbert/bleio-rev

Initial rewrite of bleio
This commit is contained in:
Scott Shawcroft 2019-01-10 19:59:17 -08:00 committed by GitHub
commit 573c6d60ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
113 changed files with 4068 additions and 24484 deletions

View File

@ -66,9 +66,6 @@ before_script:
- (! var_search "${TRAVIS_SDK-}" arm || (wget https://s3.amazonaws.com/adafruit-circuit-python/gcc-arm-embedded_7-2018q2-1~xenial1_amd64.deb && sudo dpkg -i gcc-arm-embedded*_amd64.deb))
# For nrf builds
- (! var_search "${TRAVIS_SDK-}" nrf || sudo ports/nrf/bluetooth/download_ble_stack.sh)
# For huzzah builds
- (! var_search "${TRAVIS_SDK-}" esp8266 || (wget https://github.com/jepler/esp-open-sdk/releases/download/2018-06-10/xtensa-lx106-elf-standalone.tar.gz && tar -C .. -xaf xtensa-lx106-elf-standalone.tar.gz))
- if var_search "${TRAVIS_SDK-}" esp8266 ; then PATH=$(readlink -f ../xtensa-lx106-elf/bin):$PATH; fi

View File

@ -157,7 +157,7 @@ Behavior
API
~~~
- Unified hardware APIs: `audioio <https://circuitpython.readthedocs.io/en/latest/shared-bindings/audioio/__init__.html>`_, `analogio <https://circuitpython.readthedocs.io/en/latest/shared-bindings/analogio/__init__.html>`_, `busio <https://circuitpython.readthedocs.io/en/latest/shared-bindings/busio/__init__.html>`_, `digitalio <https://circuitpython.readthedocs.io/en/latest/shared-bindings/digitalio/__init__.html>`_, `pulseio <https://circuitpython.readthedocs.io/en/latest/shared-bindings/pulseio/__init__.html>`_, `touchio <https://circuitpython.readthedocs.io/en/latest/shared-bindings/touchio/__init__.html>`_, `microcontroller <https://circuitpython.readthedocs.io/en/latest/shared-bindings/microcontroller/__init__.html>`_, `board <https://circuitpython.readthedocs.io/en/latest/shared-bindings/board/__init__.html>`_, `bitbangio <https://circuitpython.readthedocs.io/en/latest/shared-bindings/bitbangio/__init__.html>`_
- Unified hardware APIs: `audioio <https://circuitpython.readthedocs.io/en/latest/shared-bindings/audioio/__init__.html>`_, `analogio <https://circuitpython.readthedocs.io/en/latest/shared-bindings/analogio/__init__.html>`_, `bleio <https://circuitpython.readthedocs.io/en/latest/shared-bindings/bleio/__init__.html>`_, `busio <https://circuitpython.readthedocs.io/en/latest/shared-bindings/busio/__init__.html>`_, `digitalio <https://circuitpython.readthedocs.io/en/latest/shared-bindings/digitalio/__init__.html>`_, `pulseio <https://circuitpython.readthedocs.io/en/latest/shared-bindings/pulseio/__init__.html>`_, `touchio <https://circuitpython.readthedocs.io/en/latest/shared-bindings/touchio/__init__.html>`_, `microcontroller <https://circuitpython.readthedocs.io/en/latest/shared-bindings/microcontroller/__init__.html>`_, `board <https://circuitpython.readthedocs.io/en/latest/shared-bindings/board/__init__.html>`_, `bitbangio <https://circuitpython.readthedocs.io/en/latest/shared-bindings/bitbangio/__init__.html>`_
- No ``machine`` API on Atmel SAMD21 port.
Modules

View File

@ -213,7 +213,7 @@ These provide functionality similar to `analogio`, `digitalio`, `pulseio`, and `
Adafruit SeeSaw <https://circuitpython.readthedocs.io/projects/seesaw/en/latest/>
ADS1x15 Analog-to-Digital Converter <https://circuitpython.readthedocs.io/projects/ads1x15/en/latest/>
Crickit Robotics Boards <<https://circuitpython.readthedocs.io/projects/crickit/en/latest/>
Crickit Robotics Boards <https://circuitpython.readthedocs.io/projects/crickit/en/latest/>
DS2413 OneWire GPIO Expander <https://circuitpython.readthedocs.io/projects/ds2413/en/latest/>
FocalTech Capacitive Touch <https://circuitpython.readthedocs.io/projects/focaltouch/en/latest/>
MCP230xx GPIO Expander <https://circuitpython.readthedocs.io/projects/mcp230xx/en/latest/>

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-01-10 11:05-0800\n"
"POT-Creation-Date: 2019-01-10 21:32-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -409,17 +409,20 @@ msgstr "Channel EXTINT sedang digunakan"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:118
#: ports/esp8266/common-hal/pulseio/PulseIn.c:86
#: ports/nrf/common-hal/pulseio/PulseIn.c:129
#, c-format
msgid "Failed to allocate RX buffer of %d bytes"
msgstr "Gagal untuk megalokasikan buffer RX dari %d byte"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:205
#: ports/esp8266/common-hal/pulseio/PulseIn.c:151
#: ports/nrf/common-hal/pulseio/PulseIn.c:254
msgid "pop from an empty PulseIn"
msgstr "Muncul dari PulseIn yang kosong"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:237
#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:422
#: ports/esp8266/common-hal/pulseio/PulseIn.c:182
#: ports/nrf/common-hal/pulseio/PulseIn.c:241 py/obj.c:422
msgid "index out of range"
msgstr "index keluar dari jangkauan"
@ -659,123 +662,185 @@ msgstr "fungsionalitas AnalogOut tidak didukung"
msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX"
msgstr "Dukungan soft device, id: 0x%08lX, pc: 0x%08l"
#: ports/nrf/common-hal/bleio/Adapter.c:125
#, c-format
msgid "Failed to change softdevice state, error: 0x%08lX"
#: ports/nrf/common-hal/bleio/Adapter.c:110
#, fuzzy
msgid "Failed to change softdevice state"
msgstr "Gagal untuk merubah status softdevice, error: 0x%08lX"
#: ports/nrf/common-hal/bleio/Adapter.c:135
#, c-format
msgid "Failed to get softdevice state, error: 0x%08lX"
#: ports/nrf/common-hal/bleio/Adapter.c:119
#, fuzzy
msgid "Failed to get softdevice state"
msgstr "Gagal untuk mendapatkan status softdevice, error: 0x%08lX"
#: ports/nrf/common-hal/bleio/Adapter.c:155
#, c-format
msgid "Failed to get local address, error: 0x%08lX"
#: ports/nrf/common-hal/bleio/Adapter.c:138
#, fuzzy
msgid "Failed to get local address"
msgstr "Gagal untuk mendapatkan alamat lokal, error: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:52
#, c-format
msgid "Failed to write gatts value, status: 0x%08lX"
msgstr "Gagal untuk menulis nilai gatts, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Broadcaster.c:48
msgid "interval not in range 0.0020 to 10.24"
msgstr ""
#: ports/nrf/common-hal/bleio/Characteristic.c:76
#, c-format
msgid "Failed to notify attribute value, status: 0x%08lX"
msgstr "Gagal untuk melaporkan nilai atribut, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:91
#, c-format
msgid "Failed to read attribute value, status: 0x%08lX"
msgstr "Gagal untuk membaca nilai atribut, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:119
#: ports/nrf/common-hal/bleio/Device.c:272
#: ports/nrf/common-hal/bleio/Device.c:307
#, c-format
msgid "Failed to acquire mutex, status: 0x%08lX"
msgstr "Gagal untuk mendapatkan mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:126
#, c-format
msgid "Failed to write attribute value, status: 0x%08lX"
msgstr "Gagal untuk menulis nilai atribut, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:138
#: ports/nrf/common-hal/bleio/Device.c:284
#: ports/nrf/common-hal/bleio/Device.c:319
#: ports/nrf/common-hal/bleio/Device.c:354
#: ports/nrf/common-hal/bleio/Device.c:391
#, c-format
msgid "Failed to release mutex, status: 0x%08lX"
msgstr "Gagal untuk melepaskan mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:81
#: ports/nrf/common-hal/bleio/Device.c:114
msgid "Can not fit data into the advertisment packet"
#: ports/nrf/common-hal/bleio/Broadcaster.c:58
#: ports/nrf/common-hal/bleio/Peripheral.c:56
#, fuzzy
msgid "Data too large for advertisement packet"
msgstr "Tidak bisa menyesuaikan data ke dalam paket advertisment"
#: ports/nrf/common-hal/bleio/Device.c:266
#: ports/nrf/common-hal/bleio/Broadcaster.c:83
#: ports/nrf/common-hal/bleio/Peripheral.c:324
#, fuzzy, c-format
msgid "Failed to discover serivices, status: 0x%08lX"
msgstr "Gagal untuk menemukan layanan, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:403
#: ports/nrf/common-hal/bleio/Scanner.c:76
#, c-format
msgid "Failed to continue scanning, status: 0x%0xlX"
msgstr "Gagal untuk melanjutkan scanning, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:436
#, c-format
msgid "Failed to connect, status: 0x%08lX"
msgstr "Gagal untuk menyambungkan, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:513
#, c-format
msgid "Failed to add service, status: 0x%08lX"
msgstr "Gagal untuk menambahkan layanan, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:531
#, c-format
msgid "Failed to start advertisment, status: 0x%08lX"
msgid "Failed to start advertising, err 0x%04x"
msgstr "Gagal untuk memulai advertisement, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:549
#, c-format
msgid "Failed to stop advertisment, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Broadcaster.c:96
#: ports/nrf/common-hal/bleio/Peripheral.c:336
#, fuzzy, c-format
msgid "Failed to stop advertising, err 0x%04x"
msgstr "Gagal untuk memberhentikan advertisement, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:575
#: ports/nrf/common-hal/bleio/Scanner.c:103
#, c-format
msgid "Failed to start scanning, status: 0x%0xlX"
#: ports/nrf/common-hal/bleio/Characteristic.c:59
#, fuzzy, c-format
msgid "Failed to read CCCD value, err 0x%04x"
msgstr "Gagal untuk membaca nilai atribut, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:89
#, fuzzy, c-format
msgid "Failed to read gatts value, err 0x%04x"
msgstr "Gagal untuk menulis nilai gatts, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:106
#, fuzzy, c-format
msgid "Failed to write gatts value, err 0x%04x"
msgstr "Gagal untuk menulis nilai gatts, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:132
#, fuzzy, c-format
msgid "Failed to notify or indicate attribute value, err %0x04x"
msgstr "Gagal untuk melaporkan nilai atribut, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:144
#, fuzzy, c-format
msgid "Failed to read attribute value, err %0x04x"
msgstr "Gagal untuk membaca nilai atribut, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:172
#, fuzzy, c-format
msgid "Failed to acquire mutex, err 0x%04x"
msgstr "Gagal untuk mendapatkan mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:178
#, fuzzy, c-format
msgid "Failed to write attribute value, err 0x%04x"
msgstr "Gagal untuk menulis nilai atribut, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:189
#, fuzzy, c-format
msgid "Failed to release mutex, err 0x%04x"
msgstr "Gagal untuk melepaskan mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:251
#: ports/nrf/common-hal/bleio/Characteristic.c:284
msgid "bad GATT role"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:80
#: ports/nrf/common-hal/bleio/Device.c:112
#, fuzzy
msgid "Data too large for the advertisement packet"
msgstr "Tidak bisa menyesuaikan data ke dalam paket advertisment"
#: ports/nrf/common-hal/bleio/Device.c:262
#, fuzzy
msgid "Failed to discover services"
msgstr "Gagal untuk menemukan layanan, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:267
#: ports/nrf/common-hal/bleio/Device.c:300
#, fuzzy
msgid "Failed to acquire mutex"
msgstr "Gagal untuk mendapatkan mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:278
#: ports/nrf/common-hal/bleio/Device.c:311
#: ports/nrf/common-hal/bleio/Device.c:342
#: ports/nrf/common-hal/bleio/Device.c:376
#, fuzzy
msgid "Failed to release mutex"
msgstr "Gagal untuk melepaskan mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:387
#, fuzzy
msgid "Failed to continue scanning"
msgstr "Gagal untuk melanjutkan scanning, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:419
#, fuzzy
msgid "Failed to connect:"
msgstr "Gagal untuk menyambungkan, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:489
#, fuzzy
msgid "Failed to add service"
msgstr "Gagal untuk menambahkan layanan, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:506
#, fuzzy
msgid "Failed to start advertising"
msgstr "Gagal untuk memulai advertisement, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:523
#, fuzzy
msgid "Failed to stop advertising"
msgstr "Gagal untuk memberhentikan advertisement, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:548
#, fuzzy
msgid "Failed to start scanning"
msgstr "Gagal untuk melakukan scanning, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:592
#, c-format
msgid "Failed to create mutex, status: 0x%0xlX"
#: ports/nrf/common-hal/bleio/Device.c:564
#, fuzzy
msgid "Failed to create mutex"
msgstr "Gagal untuk membuat mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Service.c:83
#, c-format
msgid "Failed to add characteristic, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Peripheral.c:304
#, fuzzy, c-format
msgid "Failed to add service, err 0x%04x"
msgstr "Gagal untuk menambahkan layanan, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Scanner.c:75
#, fuzzy, c-format
msgid "Failed to continue scanning, err 0x%04x"
msgstr "Gagal untuk melanjutkan scanning, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Scanner.c:101
#, fuzzy, c-format
msgid "Failed to start scanning, err 0x%04x"
msgstr "Gagal untuk melakukan scanning, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Service.c:88
#, fuzzy, c-format
msgid "Failed to add characteristic, err 0x%04x"
msgstr "Gagal untuk menambahkan karakteristik, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/UUID.c:97
#, c-format
msgid "Failed to add Vendor Specific UUID, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Service.c:92
msgid "Characteristic already in use by another Service."
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:54
#, fuzzy, c-format
msgid "Failed to register Vendor-Specific UUID, err 0x%04x"
msgstr "Gagal untuk menambahkan Vendor Spesific UUID, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/UUID.c:102
msgid "Invalid UUID string length"
msgstr "Panjang string UUID tidak valid"
#: ports/nrf/common-hal/bleio/UUID.c:73
#, c-format
msgid "Could not decode ble_uuid, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:109
#: shared-bindings/bleio/Characteristic.c:125
#: shared-bindings/bleio/Service.c:105
msgid "Invalid UUID parameter"
msgstr "Parameter UUID tidak valid"
#: ports/nrf/common-hal/bleio/UUID.c:88
msgid "Unexpected nrfx uuid type"
msgstr ""
#: ports/nrf/common-hal/busio/I2C.c:98
msgid "All I2C peripherals are in use"
@ -806,9 +871,9 @@ msgstr "Parity ganjil tidak didukung"
msgid "busio.UART not available"
msgstr "busio.UART tidak tersedia"
#: ports/nrf/common-hal/microcontroller/Processor.c:49
#, c-format
msgid "Can not get temperature. status: 0x%02x"
#: ports/nrf/common-hal/microcontroller/Processor.c:48
#, fuzzy
msgid "Cannot get temperature"
msgstr "Tidak bisa mendapatkan temperatur. status: 0x%02x"
#: ports/nrf/common-hal/pulseio/PWMOut.c:161
@ -1946,7 +2011,7 @@ msgstr ""
msgid "memory allocation failed, allocating %u bytes"
msgstr ""
#: py/runtime.c:1609
#: py/runtime.c:1620
msgid "maximum recursion depth exceeded"
msgstr ""
@ -2096,12 +2161,28 @@ msgstr ""
msgid "buffer slices must be of equal length"
msgstr ""
#: shared-bindings/bleio/Address.c:101
msgid "Wrong address length"
#: shared-bindings/bleio/Address.c:119
#, c-format
msgid "Address is not %d bytes long or is in wrong format"
msgstr ""
#: shared-bindings/bleio/Address.c:107
msgid "Wrong number of bytes provided"
#: shared-bindings/bleio/Address.c:126
#, fuzzy, c-format
msgid "Address must be %d bytes long"
msgstr "buffers harus mempunyai panjang yang sama"
#: shared-bindings/bleio/Characteristic.c:81
#: shared-bindings/bleio/Descriptor.c:93 shared-bindings/bleio/Service.c:78
msgid "Expected a UUID"
msgstr ""
#: shared-bindings/bleio/CharacteristicBuffer.c:68
#, fuzzy
msgid "buffer_size must be >= 1"
msgstr "buffers harus mempunyai panjang yang sama"
#: shared-bindings/bleio/CharacteristicBuffer.c:72
msgid "Expected a Characteristic"
msgstr ""
#: shared-bindings/bleio/Device.c:210
@ -2120,6 +2201,40 @@ msgstr ""
msgid "Can't advertise in Central mode"
msgstr ""
#: shared-bindings/bleio/Peripheral.c:111
msgid "services includes an object that is not a Service"
msgstr ""
#: shared-bindings/bleio/Peripheral.c:124
#, fuzzy
msgid "name must be a string"
msgstr "keyword harus berupa string"
#: shared-bindings/bleio/Service.c:90
msgid "characteristics includes an object that is not a Characteristic"
msgstr ""
#: shared-bindings/bleio/Service.c:96
msgid "Characteristic UUID doesn't match Service UUID"
msgstr ""
#: shared-bindings/bleio/UUID.c:66
msgid "UUID integer value not in range 0 to 0xffff"
msgstr ""
#: shared-bindings/bleio/UUID.c:75
msgid "UUID value is not int or byte buffer"
msgstr ""
#: shared-bindings/bleio/UUID.c:79
#, fuzzy
msgid "Byte buffer must be 16 bytes."
msgstr "buffers harus mempunyai panjang yang sama"
#: shared-bindings/bleio/UUID.c:120
msgid "not a 128-bit UUID"
msgstr ""
#: shared-bindings/busio/I2C.c:120
msgid "Function requires lock."
msgstr ""
@ -2570,6 +2685,12 @@ msgid ""
"exit safe mode.\n"
msgstr ""
#~ msgid "Invalid UUID string length"
#~ msgstr "Panjang string UUID tidak valid"
#~ msgid "Invalid UUID parameter"
#~ msgstr "Parameter UUID tidak valid"
#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n"
#~ msgstr ""
#~ "Sepertinya inti kode CircuitPython kita crash dengan sangat keras. Ups!\n"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-01-10 11:05-0800\n"
"POT-Creation-Date: 2019-01-10 21:32-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -400,17 +400,20 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:118
#: ports/esp8266/common-hal/pulseio/PulseIn.c:86
#: ports/nrf/common-hal/pulseio/PulseIn.c:129
#, c-format
msgid "Failed to allocate RX buffer of %d bytes"
msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:205
#: ports/esp8266/common-hal/pulseio/PulseIn.c:151
#: ports/nrf/common-hal/pulseio/PulseIn.c:254
msgid "pop from an empty PulseIn"
msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:237
#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:422
#: ports/esp8266/common-hal/pulseio/PulseIn.c:182
#: ports/nrf/common-hal/pulseio/PulseIn.c:241 py/obj.c:422
msgid "index out of range"
msgstr ""
@ -648,122 +651,169 @@ msgstr ""
msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Adapter.c:125
#: ports/nrf/common-hal/bleio/Adapter.c:110
msgid "Failed to change softdevice state"
msgstr ""
#: ports/nrf/common-hal/bleio/Adapter.c:119
msgid "Failed to get softdevice state"
msgstr ""
#: ports/nrf/common-hal/bleio/Adapter.c:138
msgid "Failed to get local address"
msgstr ""
#: ports/nrf/common-hal/bleio/Broadcaster.c:48
msgid "interval not in range 0.0020 to 10.24"
msgstr ""
#: ports/nrf/common-hal/bleio/Broadcaster.c:58
#: ports/nrf/common-hal/bleio/Peripheral.c:56
msgid "Data too large for advertisement packet"
msgstr ""
#: ports/nrf/common-hal/bleio/Broadcaster.c:83
#: ports/nrf/common-hal/bleio/Peripheral.c:324
#, c-format
msgid "Failed to change softdevice state, error: 0x%08lX"
msgid "Failed to start advertising, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Adapter.c:135
#: ports/nrf/common-hal/bleio/Broadcaster.c:96
#: ports/nrf/common-hal/bleio/Peripheral.c:336
#, c-format
msgid "Failed to get softdevice state, error: 0x%08lX"
msgid "Failed to stop advertising, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Adapter.c:155
#: ports/nrf/common-hal/bleio/Characteristic.c:59
#, c-format
msgid "Failed to get local address, error: 0x%08lX"
msgid "Failed to read CCCD value, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Characteristic.c:52
#: ports/nrf/common-hal/bleio/Characteristic.c:89
#, c-format
msgid "Failed to write gatts value, status: 0x%08lX"
msgid "Failed to read gatts value, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Characteristic.c:76
#: ports/nrf/common-hal/bleio/Characteristic.c:106
#, c-format
msgid "Failed to notify attribute value, status: 0x%08lX"
msgid "Failed to write gatts value, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Characteristic.c:91
#: ports/nrf/common-hal/bleio/Characteristic.c:132
#, c-format
msgid "Failed to read attribute value, status: 0x%08lX"
msgid "Failed to notify or indicate attribute value, err %0x04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Characteristic.c:119
#: ports/nrf/common-hal/bleio/Device.c:272
#: ports/nrf/common-hal/bleio/Device.c:307
#: ports/nrf/common-hal/bleio/Characteristic.c:144
#, c-format
msgid "Failed to acquire mutex, status: 0x%08lX"
msgid "Failed to read attribute value, err %0x04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Characteristic.c:126
#: ports/nrf/common-hal/bleio/Characteristic.c:172
#, c-format
msgid "Failed to write attribute value, status: 0x%08lX"
msgid "Failed to acquire mutex, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Characteristic.c:138
#: ports/nrf/common-hal/bleio/Device.c:284
#: ports/nrf/common-hal/bleio/Device.c:319
#: ports/nrf/common-hal/bleio/Device.c:354
#: ports/nrf/common-hal/bleio/Device.c:391
#: ports/nrf/common-hal/bleio/Characteristic.c:178
#, c-format
msgid "Failed to release mutex, status: 0x%08lX"
msgid "Failed to write attribute value, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:81
#: ports/nrf/common-hal/bleio/Device.c:114
msgid "Can not fit data into the advertisment packet"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:266
#: ports/nrf/common-hal/bleio/Characteristic.c:189
#, c-format
msgid "Failed to discover serivices, status: 0x%08lX"
msgid "Failed to release mutex, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:403
#: ports/nrf/common-hal/bleio/Scanner.c:76
#: ports/nrf/common-hal/bleio/Characteristic.c:251
#: ports/nrf/common-hal/bleio/Characteristic.c:284
msgid "bad GATT role"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:80
#: ports/nrf/common-hal/bleio/Device.c:112
msgid "Data too large for the advertisement packet"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:262
msgid "Failed to discover services"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:267
#: ports/nrf/common-hal/bleio/Device.c:300
msgid "Failed to acquire mutex"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:278
#: ports/nrf/common-hal/bleio/Device.c:311
#: ports/nrf/common-hal/bleio/Device.c:342
#: ports/nrf/common-hal/bleio/Device.c:376
msgid "Failed to release mutex"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:387
msgid "Failed to continue scanning"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:419
msgid "Failed to connect:"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:489
msgid "Failed to add service"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:506
msgid "Failed to start advertising"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:523
msgid "Failed to stop advertising"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:548
msgid "Failed to start scanning"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:564
msgid "Failed to create mutex"
msgstr ""
#: ports/nrf/common-hal/bleio/Peripheral.c:304
#, c-format
msgid "Failed to continue scanning, status: 0x%0xlX"
msgid "Failed to add service, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:436
#: ports/nrf/common-hal/bleio/Scanner.c:75
#, c-format
msgid "Failed to connect, status: 0x%08lX"
msgid "Failed to continue scanning, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:513
#: ports/nrf/common-hal/bleio/Scanner.c:101
#, c-format
msgid "Failed to add service, status: 0x%08lX"
msgid "Failed to start scanning, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:531
#: ports/nrf/common-hal/bleio/Service.c:88
#, c-format
msgid "Failed to start advertisment, status: 0x%08lX"
msgid "Failed to add characteristic, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:549
#: ports/nrf/common-hal/bleio/Service.c:92
msgid "Characteristic already in use by another Service."
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:54
#, c-format
msgid "Failed to stop advertisment, status: 0x%08lX"
msgid "Failed to register Vendor-Specific UUID, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:575
#: ports/nrf/common-hal/bleio/Scanner.c:103
#: ports/nrf/common-hal/bleio/UUID.c:73
#, c-format
msgid "Failed to start scanning, status: 0x%0xlX"
msgid "Could not decode ble_uuid, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:592
#, c-format
msgid "Failed to create mutex, status: 0x%0xlX"
msgstr ""
#: ports/nrf/common-hal/bleio/Service.c:83
#, c-format
msgid "Failed to add characteristic, status: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:97
#, c-format
msgid "Failed to add Vendor Specific UUID, status: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:102
msgid "Invalid UUID string length"
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:109
#: shared-bindings/bleio/Characteristic.c:125
#: shared-bindings/bleio/Service.c:105
msgid "Invalid UUID parameter"
#: ports/nrf/common-hal/bleio/UUID.c:88
msgid "Unexpected nrfx uuid type"
msgstr ""
#: ports/nrf/common-hal/busio/I2C.c:98
@ -795,9 +845,8 @@ msgstr ""
msgid "busio.UART not available"
msgstr ""
#: ports/nrf/common-hal/microcontroller/Processor.c:49
#, c-format
msgid "Can not get temperature. status: 0x%02x"
#: ports/nrf/common-hal/microcontroller/Processor.c:48
msgid "Cannot get temperature"
msgstr ""
#: ports/nrf/common-hal/pulseio/PWMOut.c:161
@ -1929,7 +1978,7 @@ msgstr ""
msgid "memory allocation failed, allocating %u bytes"
msgstr ""
#: py/runtime.c:1609
#: py/runtime.c:1620
msgid "maximum recursion depth exceeded"
msgstr ""
@ -2079,12 +2128,27 @@ msgstr ""
msgid "buffer slices must be of equal length"
msgstr ""
#: shared-bindings/bleio/Address.c:101
msgid "Wrong address length"
#: shared-bindings/bleio/Address.c:119
#, c-format
msgid "Address is not %d bytes long or is in wrong format"
msgstr ""
#: shared-bindings/bleio/Address.c:107
msgid "Wrong number of bytes provided"
#: shared-bindings/bleio/Address.c:126
#, c-format
msgid "Address must be %d bytes long"
msgstr ""
#: shared-bindings/bleio/Characteristic.c:81
#: shared-bindings/bleio/Descriptor.c:93 shared-bindings/bleio/Service.c:78
msgid "Expected a UUID"
msgstr ""
#: shared-bindings/bleio/CharacteristicBuffer.c:68
msgid "buffer_size must be >= 1"
msgstr ""
#: shared-bindings/bleio/CharacteristicBuffer.c:72
msgid "Expected a Characteristic"
msgstr ""
#: shared-bindings/bleio/Device.c:210
@ -2103,6 +2167,38 @@ msgstr ""
msgid "Can't advertise in Central mode"
msgstr ""
#: shared-bindings/bleio/Peripheral.c:111
msgid "services includes an object that is not a Service"
msgstr ""
#: shared-bindings/bleio/Peripheral.c:124
msgid "name must be a string"
msgstr ""
#: shared-bindings/bleio/Service.c:90
msgid "characteristics includes an object that is not a Characteristic"
msgstr ""
#: shared-bindings/bleio/Service.c:96
msgid "Characteristic UUID doesn't match Service UUID"
msgstr ""
#: shared-bindings/bleio/UUID.c:66
msgid "UUID integer value not in range 0 to 0xffff"
msgstr ""
#: shared-bindings/bleio/UUID.c:75
msgid "UUID value is not int or byte buffer"
msgstr ""
#: shared-bindings/bleio/UUID.c:79
msgid "Byte buffer must be 16 bytes."
msgstr ""
#: shared-bindings/bleio/UUID.c:120
msgid "not a 128-bit UUID"
msgstr ""
#: shared-bindings/busio/I2C.c:120
msgid "Function requires lock."
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-01-10 11:05-0800\n"
"POT-Creation-Date: 2019-01-10 21:32-0500\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: Sebastian Plamauer\n"
"Language-Team: \n"
@ -404,17 +404,20 @@ msgstr "EXTINT Kanal wird benutzt"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:118
#: ports/esp8266/common-hal/pulseio/PulseIn.c:86
#: ports/nrf/common-hal/pulseio/PulseIn.c:129
#, c-format
msgid "Failed to allocate RX buffer of %d bytes"
msgstr "Konnte keine RX Buffer mit %d allozieren"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:205
#: ports/esp8266/common-hal/pulseio/PulseIn.c:151
#: ports/nrf/common-hal/pulseio/PulseIn.c:254
msgid "pop from an empty PulseIn"
msgstr "pop von einem leeren PulseIn"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:237
#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:422
#: ports/esp8266/common-hal/pulseio/PulseIn.c:182
#: ports/nrf/common-hal/pulseio/PulseIn.c:241 py/obj.c:422
msgid "index out of range"
msgstr "index außerhalb der Reichweite"
@ -655,124 +658,184 @@ msgstr ""
msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Adapter.c:125
#, c-format
msgid "Failed to change softdevice state, error: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Adapter.c:135
#, c-format
msgid "Failed to get softdevice state, error: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Adapter.c:155
#, c-format
msgid "Failed to get local address, error: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Characteristic.c:52
#, fuzzy, c-format
msgid "Failed to write gatts value, status: 0x%08lX"
msgstr "Kann den Attributwert nicht schreiben. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:76
#, fuzzy, c-format
msgid "Failed to notify attribute value, status: 0x%08lX"
msgstr "Kann den Attributwert nicht mitteilen. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:91
#, fuzzy, c-format
msgid "Failed to read attribute value, status: 0x%08lX"
msgstr "Kann den Attributwert nicht lesen. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:119
#: ports/nrf/common-hal/bleio/Device.c:272
#: ports/nrf/common-hal/bleio/Device.c:307
#, c-format
msgid "Failed to acquire mutex, status: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Characteristic.c:126
#, fuzzy, c-format
msgid "Failed to write attribute value, status: 0x%08lX"
msgstr "Kann den Attributwert nicht schreiben. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:138
#: ports/nrf/common-hal/bleio/Device.c:284
#: ports/nrf/common-hal/bleio/Device.c:319
#: ports/nrf/common-hal/bleio/Device.c:354
#: ports/nrf/common-hal/bleio/Device.c:391
#, c-format
msgid "Failed to release mutex, status: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:81
#: ports/nrf/common-hal/bleio/Device.c:114
#: ports/nrf/common-hal/bleio/Adapter.c:110
#, fuzzy
msgid "Can not fit data into the advertisment packet"
msgid "Failed to change softdevice state"
msgstr "Kann advertisement nicht stoppen. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Adapter.c:119
#, fuzzy
msgid "Failed to get softdevice state"
msgstr "Kann advertisement nicht stoppen. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Adapter.c:138
msgid "Failed to get local address"
msgstr ""
#: ports/nrf/common-hal/bleio/Broadcaster.c:48
msgid "interval not in range 0.0020 to 10.24"
msgstr ""
#: ports/nrf/common-hal/bleio/Broadcaster.c:58
#: ports/nrf/common-hal/bleio/Peripheral.c:56
#, fuzzy
msgid "Data too large for advertisement packet"
msgstr "Daten können nicht in das advertisement packet eingefügt werden."
#: ports/nrf/common-hal/bleio/Device.c:266
#, c-format
msgid "Failed to discover serivices, status: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:403
#: ports/nrf/common-hal/bleio/Scanner.c:76
#: ports/nrf/common-hal/bleio/Broadcaster.c:83
#: ports/nrf/common-hal/bleio/Peripheral.c:324
#, fuzzy, c-format
msgid "Failed to continue scanning, status: 0x%0xlX"
msgstr "Der Scanvorgang kann nicht gestartet werden. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:436
#, fuzzy, c-format
msgid "Failed to connect, status: 0x%08lX"
msgstr "Kann nicht verbinden. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:513
#, fuzzy, c-format
msgid "Failed to add service, status: 0x%08lX"
msgstr "Kann advertisement nicht stoppen. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:531
#, fuzzy, c-format
msgid "Failed to start advertisment, status: 0x%08lX"
msgid "Failed to start advertising, err 0x%04x"
msgstr "Kann advertisement nicht starten. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:549
#: ports/nrf/common-hal/bleio/Broadcaster.c:96
#: ports/nrf/common-hal/bleio/Peripheral.c:336
#, fuzzy, c-format
msgid "Failed to stop advertisment, status: 0x%08lX"
msgid "Failed to stop advertising, err 0x%04x"
msgstr "Kann advertisement nicht stoppen. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:575
#: ports/nrf/common-hal/bleio/Scanner.c:103
#: ports/nrf/common-hal/bleio/Characteristic.c:59
#, fuzzy, c-format
msgid "Failed to start scanning, status: 0x%0xlX"
msgstr "Der Scanvorgang kann nicht gestartet werden. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:592
#, fuzzy, c-format
msgid "Failed to create mutex, status: 0x%0xlX"
msgid "Failed to read CCCD value, err 0x%04x"
msgstr "Kann den Attributwert nicht lesen. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Service.c:83
#, c-format
msgid "Failed to add characteristic, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:89
#, fuzzy, c-format
msgid "Failed to read gatts value, err 0x%04x"
msgstr "Kann den Attributwert nicht schreiben. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:106
#, fuzzy, c-format
msgid "Failed to write gatts value, err 0x%04x"
msgstr "Kann den Attributwert nicht schreiben. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:132
#, fuzzy, c-format
msgid "Failed to notify or indicate attribute value, err %0x04x"
msgstr "Kann den Attributwert nicht mitteilen. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:144
#, fuzzy, c-format
msgid "Failed to read attribute value, err %0x04x"
msgstr "Kann den Attributwert nicht lesen. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:172
#, fuzzy, c-format
msgid "Failed to acquire mutex, err 0x%04x"
msgstr "Kann den Attributwert nicht lesen. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:178
#, fuzzy, c-format
msgid "Failed to write attribute value, err 0x%04x"
msgstr "Kann den Attributwert nicht schreiben. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:189
#, fuzzy, c-format
msgid "Failed to release mutex, err 0x%04x"
msgstr "Kann den Attributwert nicht lesen. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:251
#: ports/nrf/common-hal/bleio/Characteristic.c:284
msgid "bad GATT role"
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:97
#: ports/nrf/common-hal/bleio/Device.c:80
#: ports/nrf/common-hal/bleio/Device.c:112
#, fuzzy
msgid "Data too large for the advertisement packet"
msgstr "Daten können nicht in das advertisement packet eingefügt werden."
#: ports/nrf/common-hal/bleio/Device.c:262
#, fuzzy
msgid "Failed to discover services"
msgstr "Kann advertisement nicht stoppen. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:267
#: ports/nrf/common-hal/bleio/Device.c:300
#, fuzzy
msgid "Failed to acquire mutex"
msgstr "Konnte keinen RX Buffer allozieren"
#: ports/nrf/common-hal/bleio/Device.c:278
#: ports/nrf/common-hal/bleio/Device.c:311
#: ports/nrf/common-hal/bleio/Device.c:342
#: ports/nrf/common-hal/bleio/Device.c:376
#, fuzzy
msgid "Failed to release mutex"
msgstr "Kann den Attributwert nicht lesen. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:387
#, fuzzy
msgid "Failed to continue scanning"
msgstr "Der Scanvorgang kann nicht gestartet werden. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:419
#, fuzzy
msgid "Failed to connect:"
msgstr "Kann nicht verbinden. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:489
#, fuzzy
msgid "Failed to add service"
msgstr "Kann advertisement nicht stoppen. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:506
#, fuzzy
msgid "Failed to start advertising"
msgstr "Kann advertisement nicht starten. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:523
#, fuzzy
msgid "Failed to stop advertising"
msgstr "Kann advertisement nicht stoppen. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:548
#, fuzzy
msgid "Failed to start scanning"
msgstr "Der Scanvorgang kann nicht gestartet werden. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:564
#, fuzzy
msgid "Failed to create mutex"
msgstr "Kann den Attributwert nicht lesen. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Peripheral.c:304
#, fuzzy, c-format
msgid "Failed to add Vendor Specific UUID, status: 0x%08lX"
msgid "Failed to add service, err 0x%04x"
msgstr "Kann advertisement nicht stoppen. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Scanner.c:75
#, fuzzy, c-format
msgid "Failed to continue scanning, err 0x%04x"
msgstr "Der Scanvorgang kann nicht gestartet werden. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Scanner.c:101
#, fuzzy, c-format
msgid "Failed to start scanning, err 0x%04x"
msgstr "Der Scanvorgang kann nicht gestartet werden. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Service.c:88
#, fuzzy, c-format
msgid "Failed to add characteristic, err 0x%04x"
msgstr "Kann advertisement nicht stoppen. Status: 0x%02x"
#: ports/nrf/common-hal/bleio/Service.c:92
msgid "Characteristic already in use by another Service."
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:54
#, fuzzy, c-format
msgid "Failed to register Vendor-Specific UUID, err 0x%04x"
msgstr "Kann keine herstellerspezifische 128-Bit-UUID hinzufügen."
#: ports/nrf/common-hal/bleio/UUID.c:102
msgid "Invalid UUID string length"
msgstr "Ungültige UUID-Stringlänge"
#: ports/nrf/common-hal/bleio/UUID.c:73
#, c-format
msgid "Could not decode ble_uuid, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:109
#: shared-bindings/bleio/Characteristic.c:125
#: shared-bindings/bleio/Service.c:105
msgid "Invalid UUID parameter"
msgstr "Ungültiger UUID-Parameter"
#: ports/nrf/common-hal/bleio/UUID.c:88
msgid "Unexpected nrfx uuid type"
msgstr ""
#: ports/nrf/common-hal/busio/I2C.c:98
#, fuzzy
@ -807,10 +870,10 @@ msgstr "bytes mit merh als 8 bits werden nicht unterstützt"
msgid "busio.UART not available"
msgstr ""
#: ports/nrf/common-hal/microcontroller/Processor.c:49
#, c-format
msgid "Can not get temperature. status: 0x%02x"
msgstr ""
#: ports/nrf/common-hal/microcontroller/Processor.c:48
#, fuzzy
msgid "Cannot get temperature"
msgstr "Kann PPCP Parameter nicht setzen."
#: ports/nrf/common-hal/pulseio/PWMOut.c:161
#, fuzzy
@ -1944,7 +2007,7 @@ msgstr ""
msgid "memory allocation failed, allocating %u bytes"
msgstr ""
#: py/runtime.c:1609
#: py/runtime.c:1620
msgid "maximum recursion depth exceeded"
msgstr ""
@ -2097,14 +2160,31 @@ msgstr ""
msgid "buffer slices must be of equal length"
msgstr ""
#: shared-bindings/bleio/Address.c:101
msgid "Wrong address length"
#: shared-bindings/bleio/Address.c:119
#, c-format
msgid "Address is not %d bytes long or is in wrong format"
msgstr ""
#: shared-bindings/bleio/Address.c:107
msgid "Wrong number of bytes provided"
#: shared-bindings/bleio/Address.c:126
#, fuzzy, c-format
msgid "Address must be %d bytes long"
msgstr "Buffer müssen gleich lang sein"
#: shared-bindings/bleio/Characteristic.c:81
#: shared-bindings/bleio/Descriptor.c:93 shared-bindings/bleio/Service.c:78
msgid "Expected a UUID"
msgstr ""
#: shared-bindings/bleio/CharacteristicBuffer.c:68
#, fuzzy
msgid "buffer_size must be >= 1"
msgstr "Buffer müssen gleich lang sein"
#: shared-bindings/bleio/CharacteristicBuffer.c:72
#, fuzzy
msgid "Expected a Characteristic"
msgstr "Kann das Merkmal nicht hinzufügen."
#: shared-bindings/bleio/Device.c:210
msgid "Can't add services in Central mode"
msgstr ""
@ -2121,6 +2201,40 @@ msgstr ""
msgid "Can't advertise in Central mode"
msgstr ""
#: shared-bindings/bleio/Peripheral.c:111
msgid "services includes an object that is not a Service"
msgstr ""
#: shared-bindings/bleio/Peripheral.c:124
#, fuzzy
msgid "name must be a string"
msgstr "heap muss eine Liste sein"
#: shared-bindings/bleio/Service.c:90
msgid "characteristics includes an object that is not a Characteristic"
msgstr ""
#: shared-bindings/bleio/Service.c:96
msgid "Characteristic UUID doesn't match Service UUID"
msgstr ""
#: shared-bindings/bleio/UUID.c:66
msgid "UUID integer value not in range 0 to 0xffff"
msgstr ""
#: shared-bindings/bleio/UUID.c:75
msgid "UUID value is not int or byte buffer"
msgstr ""
#: shared-bindings/bleio/UUID.c:79
#, fuzzy
msgid "Byte buffer must be 16 bytes."
msgstr "Buffer müssen gleich lang sein"
#: shared-bindings/bleio/UUID.c:120
msgid "not a 128-bit UUID"
msgstr ""
#: shared-bindings/busio/I2C.c:120
msgid "Function requires lock."
msgstr ""
@ -2571,6 +2685,12 @@ msgid ""
"exit safe mode.\n"
msgstr ""
#~ msgid "Invalid UUID string length"
#~ msgstr "Ungültige UUID-Stringlänge"
#~ msgid "Invalid UUID parameter"
#~ msgstr "Ungültiger UUID-Parameter"
#~ msgid "Invalid Service type"
#~ msgstr "Ungültiger Diensttyp"
@ -2591,9 +2711,6 @@ msgstr ""
#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n"
#~ msgstr "CircuitPython ist abgestürzt. Ups!\n"
#~ msgid "Cannot set PPCP parameters."
#~ msgstr "Kann PPCP Parameter nicht setzen."
#~ msgid "Cannot apply GAP parameters."
#~ msgstr "Kann GAP Parameter nicht anwenden."

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-01-10 11:05-0800\n"
"POT-Creation-Date: 2019-01-10 21:31-0500\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -400,17 +400,20 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:118
#: ports/esp8266/common-hal/pulseio/PulseIn.c:86
#: ports/nrf/common-hal/pulseio/PulseIn.c:129
#, c-format
msgid "Failed to allocate RX buffer of %d bytes"
msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:205
#: ports/esp8266/common-hal/pulseio/PulseIn.c:151
#: ports/nrf/common-hal/pulseio/PulseIn.c:254
msgid "pop from an empty PulseIn"
msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:237
#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:422
#: ports/esp8266/common-hal/pulseio/PulseIn.c:182
#: ports/nrf/common-hal/pulseio/PulseIn.c:241 py/obj.c:422
msgid "index out of range"
msgstr ""
@ -648,122 +651,169 @@ msgstr ""
msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Adapter.c:125
#: ports/nrf/common-hal/bleio/Adapter.c:110
msgid "Failed to change softdevice state"
msgstr ""
#: ports/nrf/common-hal/bleio/Adapter.c:119
msgid "Failed to get softdevice state"
msgstr ""
#: ports/nrf/common-hal/bleio/Adapter.c:138
msgid "Failed to get local address"
msgstr ""
#: ports/nrf/common-hal/bleio/Broadcaster.c:48
msgid "interval not in range 0.0020 to 10.24"
msgstr ""
#: ports/nrf/common-hal/bleio/Broadcaster.c:58
#: ports/nrf/common-hal/bleio/Peripheral.c:56
msgid "Data too large for advertisement packet"
msgstr ""
#: ports/nrf/common-hal/bleio/Broadcaster.c:83
#: ports/nrf/common-hal/bleio/Peripheral.c:324
#, c-format
msgid "Failed to change softdevice state, error: 0x%08lX"
msgid "Failed to start advertising, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Adapter.c:135
#: ports/nrf/common-hal/bleio/Broadcaster.c:96
#: ports/nrf/common-hal/bleio/Peripheral.c:336
#, c-format
msgid "Failed to get softdevice state, error: 0x%08lX"
msgid "Failed to stop advertising, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Adapter.c:155
#: ports/nrf/common-hal/bleio/Characteristic.c:59
#, c-format
msgid "Failed to get local address, error: 0x%08lX"
msgid "Failed to read CCCD value, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Characteristic.c:52
#: ports/nrf/common-hal/bleio/Characteristic.c:89
#, c-format
msgid "Failed to write gatts value, status: 0x%08lX"
msgid "Failed to read gatts value, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Characteristic.c:76
#: ports/nrf/common-hal/bleio/Characteristic.c:106
#, c-format
msgid "Failed to notify attribute value, status: 0x%08lX"
msgid "Failed to write gatts value, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Characteristic.c:91
#: ports/nrf/common-hal/bleio/Characteristic.c:132
#, c-format
msgid "Failed to read attribute value, status: 0x%08lX"
msgid "Failed to notify or indicate attribute value, err %0x04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Characteristic.c:119
#: ports/nrf/common-hal/bleio/Device.c:272
#: ports/nrf/common-hal/bleio/Device.c:307
#: ports/nrf/common-hal/bleio/Characteristic.c:144
#, c-format
msgid "Failed to acquire mutex, status: 0x%08lX"
msgid "Failed to read attribute value, err %0x04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Characteristic.c:126
#: ports/nrf/common-hal/bleio/Characteristic.c:172
#, c-format
msgid "Failed to write attribute value, status: 0x%08lX"
msgid "Failed to acquire mutex, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Characteristic.c:138
#: ports/nrf/common-hal/bleio/Device.c:284
#: ports/nrf/common-hal/bleio/Device.c:319
#: ports/nrf/common-hal/bleio/Device.c:354
#: ports/nrf/common-hal/bleio/Device.c:391
#: ports/nrf/common-hal/bleio/Characteristic.c:178
#, c-format
msgid "Failed to release mutex, status: 0x%08lX"
msgid "Failed to write attribute value, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:81
#: ports/nrf/common-hal/bleio/Device.c:114
msgid "Can not fit data into the advertisment packet"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:266
#: ports/nrf/common-hal/bleio/Characteristic.c:189
#, c-format
msgid "Failed to discover serivices, status: 0x%08lX"
msgid "Failed to release mutex, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:403
#: ports/nrf/common-hal/bleio/Scanner.c:76
#: ports/nrf/common-hal/bleio/Characteristic.c:251
#: ports/nrf/common-hal/bleio/Characteristic.c:284
msgid "bad GATT role"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:80
#: ports/nrf/common-hal/bleio/Device.c:112
msgid "Data too large for the advertisement packet"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:262
msgid "Failed to discover services"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:267
#: ports/nrf/common-hal/bleio/Device.c:300
msgid "Failed to acquire mutex"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:278
#: ports/nrf/common-hal/bleio/Device.c:311
#: ports/nrf/common-hal/bleio/Device.c:342
#: ports/nrf/common-hal/bleio/Device.c:376
msgid "Failed to release mutex"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:387
msgid "Failed to continue scanning"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:419
msgid "Failed to connect:"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:489
msgid "Failed to add service"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:506
msgid "Failed to start advertising"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:523
msgid "Failed to stop advertising"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:548
msgid "Failed to start scanning"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:564
msgid "Failed to create mutex"
msgstr ""
#: ports/nrf/common-hal/bleio/Peripheral.c:304
#, c-format
msgid "Failed to continue scanning, status: 0x%0xlX"
msgid "Failed to add service, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:436
#: ports/nrf/common-hal/bleio/Scanner.c:75
#, c-format
msgid "Failed to connect, status: 0x%08lX"
msgid "Failed to continue scanning, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:513
#: ports/nrf/common-hal/bleio/Scanner.c:101
#, c-format
msgid "Failed to add service, status: 0x%08lX"
msgid "Failed to start scanning, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:531
#: ports/nrf/common-hal/bleio/Service.c:88
#, c-format
msgid "Failed to start advertisment, status: 0x%08lX"
msgid "Failed to add characteristic, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:549
#: ports/nrf/common-hal/bleio/Service.c:92
msgid "Characteristic already in use by another Service."
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:54
#, c-format
msgid "Failed to stop advertisment, status: 0x%08lX"
msgid "Failed to register Vendor-Specific UUID, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:575
#: ports/nrf/common-hal/bleio/Scanner.c:103
#: ports/nrf/common-hal/bleio/UUID.c:73
#, c-format
msgid "Failed to start scanning, status: 0x%0xlX"
msgid "Could not decode ble_uuid, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:592
#, c-format
msgid "Failed to create mutex, status: 0x%0xlX"
msgstr ""
#: ports/nrf/common-hal/bleio/Service.c:83
#, c-format
msgid "Failed to add characteristic, status: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:97
#, c-format
msgid "Failed to add Vendor Specific UUID, status: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:102
msgid "Invalid UUID string length"
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:109
#: shared-bindings/bleio/Characteristic.c:125
#: shared-bindings/bleio/Service.c:105
msgid "Invalid UUID parameter"
#: ports/nrf/common-hal/bleio/UUID.c:88
msgid "Unexpected nrfx uuid type"
msgstr ""
#: ports/nrf/common-hal/busio/I2C.c:98
@ -795,9 +845,8 @@ msgstr ""
msgid "busio.UART not available"
msgstr ""
#: ports/nrf/common-hal/microcontroller/Processor.c:49
#, c-format
msgid "Can not get temperature. status: 0x%02x"
#: ports/nrf/common-hal/microcontroller/Processor.c:48
msgid "Cannot get temperature"
msgstr ""
#: ports/nrf/common-hal/pulseio/PWMOut.c:161
@ -1929,7 +1978,7 @@ msgstr ""
msgid "memory allocation failed, allocating %u bytes"
msgstr ""
#: py/runtime.c:1609
#: py/runtime.c:1620
msgid "maximum recursion depth exceeded"
msgstr ""
@ -2079,12 +2128,27 @@ msgstr ""
msgid "buffer slices must be of equal length"
msgstr ""
#: shared-bindings/bleio/Address.c:101
msgid "Wrong address length"
#: shared-bindings/bleio/Address.c:119
#, c-format
msgid "Address is not %d bytes long or is in wrong format"
msgstr ""
#: shared-bindings/bleio/Address.c:107
msgid "Wrong number of bytes provided"
#: shared-bindings/bleio/Address.c:126
#, c-format
msgid "Address must be %d bytes long"
msgstr ""
#: shared-bindings/bleio/Characteristic.c:81
#: shared-bindings/bleio/Descriptor.c:93 shared-bindings/bleio/Service.c:78
msgid "Expected a UUID"
msgstr ""
#: shared-bindings/bleio/CharacteristicBuffer.c:68
msgid "buffer_size must be >= 1"
msgstr ""
#: shared-bindings/bleio/CharacteristicBuffer.c:72
msgid "Expected a Characteristic"
msgstr ""
#: shared-bindings/bleio/Device.c:210
@ -2103,6 +2167,38 @@ msgstr ""
msgid "Can't advertise in Central mode"
msgstr ""
#: shared-bindings/bleio/Peripheral.c:111
msgid "services includes an object that is not a Service"
msgstr ""
#: shared-bindings/bleio/Peripheral.c:124
msgid "name must be a string"
msgstr ""
#: shared-bindings/bleio/Service.c:90
msgid "characteristics includes an object that is not a Characteristic"
msgstr ""
#: shared-bindings/bleio/Service.c:96
msgid "Characteristic UUID doesn't match Service UUID"
msgstr ""
#: shared-bindings/bleio/UUID.c:66
msgid "UUID integer value not in range 0 to 0xffff"
msgstr ""
#: shared-bindings/bleio/UUID.c:75
msgid "UUID value is not int or byte buffer"
msgstr ""
#: shared-bindings/bleio/UUID.c:79
msgid "Byte buffer must be 16 bytes."
msgstr ""
#: shared-bindings/bleio/UUID.c:120
msgid "not a 128-bit UUID"
msgstr ""
#: shared-bindings/busio/I2C.c:120
msgid "Function requires lock."
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-01-10 11:05-0800\n"
"POT-Creation-Date: 2019-01-10 21:32-0500\n"
"PO-Revision-Date: 2018-08-24 22:56-0500\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -406,17 +406,20 @@ msgstr "El canal EXTINT ya está siendo utilizado"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:118
#: ports/esp8266/common-hal/pulseio/PulseIn.c:86
#: ports/nrf/common-hal/pulseio/PulseIn.c:129
#, c-format
msgid "Failed to allocate RX buffer of %d bytes"
msgstr "Falló la asignación del buffer RX de %d bytes"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:205
#: ports/esp8266/common-hal/pulseio/PulseIn.c:151
#: ports/nrf/common-hal/pulseio/PulseIn.c:254
msgid "pop from an empty PulseIn"
msgstr "pop de un PulseIn vacío"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:237
#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:422
#: ports/esp8266/common-hal/pulseio/PulseIn.c:182
#: ports/nrf/common-hal/pulseio/PulseIn.c:241 py/obj.c:422
msgid "index out of range"
msgstr "index fuera de rango"
@ -655,124 +658,185 @@ msgstr "Funcionalidad AnalogOut no soportada"
msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Adapter.c:125
#, c-format
msgid "Failed to change softdevice state, error: 0x%08lX"
#: ports/nrf/common-hal/bleio/Adapter.c:110
#, fuzzy
msgid "Failed to change softdevice state"
msgstr "No se puede cambiar el estado del softdevice, error: 0x%08lX"
#: ports/nrf/common-hal/bleio/Adapter.c:135
#, c-format
msgid "Failed to get softdevice state, error: 0x%08lX"
#: ports/nrf/common-hal/bleio/Adapter.c:119
#, fuzzy
msgid "Failed to get softdevice state"
msgstr "No se puede obtener el estado del softdevice, error: 0x%08lX"
#: ports/nrf/common-hal/bleio/Adapter.c:155
#, c-format
msgid "Failed to get local address, error: 0x%08lX"
#: ports/nrf/common-hal/bleio/Adapter.c:138
#, fuzzy
msgid "Failed to get local address"
msgstr "No se puede obtener la dirección local, error: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:52
#, fuzzy, c-format
msgid "Failed to write gatts value, status: 0x%08lX"
msgstr "No se puede escribir el valor del atributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Broadcaster.c:48
msgid "interval not in range 0.0020 to 10.24"
msgstr ""
#: ports/nrf/common-hal/bleio/Characteristic.c:76
#, fuzzy, c-format
msgid "Failed to notify attribute value, status: 0x%08lX"
msgstr "No se puede notificar el valor del anuncio. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:91
#, fuzzy, c-format
msgid "Failed to read attribute value, status: 0x%08lX"
msgstr "No se puede leer el valor del atributo. status 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:119
#: ports/nrf/common-hal/bleio/Device.c:272
#: ports/nrf/common-hal/bleio/Device.c:307
#, c-format
msgid "Failed to acquire mutex, status: 0x%08lX"
msgstr "No se puede adquirir el mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:126
#, fuzzy, c-format
msgid "Failed to write attribute value, status: 0x%08lX"
msgstr "No se puede escribir el valor del atributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:138
#: ports/nrf/common-hal/bleio/Device.c:284
#: ports/nrf/common-hal/bleio/Device.c:319
#: ports/nrf/common-hal/bleio/Device.c:354
#: ports/nrf/common-hal/bleio/Device.c:391
#, c-format
msgid "Failed to release mutex, status: 0x%08lX"
msgstr "No se puede liberar el mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:81
#: ports/nrf/common-hal/bleio/Device.c:114
#: ports/nrf/common-hal/bleio/Broadcaster.c:58
#: ports/nrf/common-hal/bleio/Peripheral.c:56
#, fuzzy
msgid "Can not fit data into the advertisment packet"
msgid "Data too large for advertisement packet"
msgstr "Los datos no caben en el paquete de anuncio."
#: ports/nrf/common-hal/bleio/Device.c:266
#, c-format
msgid "Failed to discover serivices, status: 0x%08lX"
msgstr "No se puede descubrir servicios, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:403
#: ports/nrf/common-hal/bleio/Scanner.c:76
#: ports/nrf/common-hal/bleio/Broadcaster.c:83
#: ports/nrf/common-hal/bleio/Peripheral.c:324
#, fuzzy, c-format
msgid "Failed to continue scanning, status: 0x%0xlX"
msgstr "No se puede iniciar el escaneo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:436
#, fuzzy, c-format
msgid "Failed to connect, status: 0x%08lX"
msgstr "No se puede conectar. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:513
#, fuzzy, c-format
msgid "Failed to add service, status: 0x%08lX"
msgstr "No se puede detener el anuncio. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:531
#, fuzzy, c-format
msgid "Failed to start advertisment, status: 0x%08lX"
msgid "Failed to start advertising, err 0x%04x"
msgstr "No se puede inicar el anuncio. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:549
#: ports/nrf/common-hal/bleio/Broadcaster.c:96
#: ports/nrf/common-hal/bleio/Peripheral.c:336
#, fuzzy, c-format
msgid "Failed to stop advertisment, status: 0x%08lX"
msgid "Failed to stop advertising, err 0x%04x"
msgstr "No se puede detener el anuncio. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:575
#: ports/nrf/common-hal/bleio/Scanner.c:103
#: ports/nrf/common-hal/bleio/Characteristic.c:59
#, fuzzy, c-format
msgid "Failed to start scanning, status: 0x%0xlX"
msgstr "No se puede iniciar el escaneo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:592
#, fuzzy, c-format
msgid "Failed to create mutex, status: 0x%0xlX"
msgid "Failed to read CCCD value, err 0x%04x"
msgstr "No se puede leer el valor del atributo. status 0x%02x"
#: ports/nrf/common-hal/bleio/Service.c:83
#, c-format
msgid "Failed to add characteristic, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:89
#, fuzzy, c-format
msgid "Failed to read gatts value, err 0x%04x"
msgstr "No se puede escribir el valor del atributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:106
#, fuzzy, c-format
msgid "Failed to write gatts value, err 0x%04x"
msgstr "No se puede escribir el valor del atributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:132
#, fuzzy, c-format
msgid "Failed to notify or indicate attribute value, err %0x04x"
msgstr "No se puede notificar el valor del anuncio. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:144
#, fuzzy, c-format
msgid "Failed to read attribute value, err %0x04x"
msgstr "No se puede leer el valor del atributo. status 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:172
#, fuzzy, c-format
msgid "Failed to acquire mutex, err 0x%04x"
msgstr "No se puede adquirir el mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:178
#, fuzzy, c-format
msgid "Failed to write attribute value, err 0x%04x"
msgstr "No se puede escribir el valor del atributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:189
#, fuzzy, c-format
msgid "Failed to release mutex, err 0x%04x"
msgstr "No se puede liberar el mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:251
#: ports/nrf/common-hal/bleio/Characteristic.c:284
msgid "bad GATT role"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:80
#: ports/nrf/common-hal/bleio/Device.c:112
#, fuzzy
msgid "Data too large for the advertisement packet"
msgstr "Los datos no caben en el paquete de anuncio."
#: ports/nrf/common-hal/bleio/Device.c:262
#, fuzzy
msgid "Failed to discover services"
msgstr "No se puede descubrir servicios, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:267
#: ports/nrf/common-hal/bleio/Device.c:300
#, fuzzy
msgid "Failed to acquire mutex"
msgstr "No se puede adquirir el mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:278
#: ports/nrf/common-hal/bleio/Device.c:311
#: ports/nrf/common-hal/bleio/Device.c:342
#: ports/nrf/common-hal/bleio/Device.c:376
#, fuzzy
msgid "Failed to release mutex"
msgstr "No se puede liberar el mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:387
#, fuzzy
msgid "Failed to continue scanning"
msgstr "No se puede iniciar el escaneo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:419
#, fuzzy
msgid "Failed to connect:"
msgstr "No se puede conectar. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:489
#, fuzzy
msgid "Failed to add service"
msgstr "No se puede detener el anuncio. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:506
#, fuzzy
msgid "Failed to start advertising"
msgstr "No se puede inicar el anuncio. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:523
#, fuzzy
msgid "Failed to stop advertising"
msgstr "No se puede detener el anuncio. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:548
#, fuzzy
msgid "Failed to start scanning"
msgstr "No se puede iniciar el escaneo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:564
#, fuzzy
msgid "Failed to create mutex"
msgstr "No se puede leer el valor del atributo. status 0x%02x"
#: ports/nrf/common-hal/bleio/Peripheral.c:304
#, fuzzy, c-format
msgid "Failed to add service, err 0x%04x"
msgstr "No se puede detener el anuncio. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Scanner.c:75
#, fuzzy, c-format
msgid "Failed to continue scanning, err 0x%04x"
msgstr "No se puede iniciar el escaneo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Scanner.c:101
#, fuzzy, c-format
msgid "Failed to start scanning, err 0x%04x"
msgstr "No se puede iniciar el escaneo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Service.c:88
#, fuzzy, c-format
msgid "Failed to add characteristic, err 0x%04x"
msgstr "No se puede añadir caracteristica, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/UUID.c:97
#: ports/nrf/common-hal/bleio/Service.c:92
msgid "Characteristic already in use by another Service."
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:54
#, fuzzy, c-format
msgid "Failed to add Vendor Specific UUID, status: 0x%08lX"
msgid "Failed to register Vendor-Specific UUID, err 0x%04x"
msgstr "No se puede agregar el Vendor Specific 128-bit UUID."
#: ports/nrf/common-hal/bleio/UUID.c:102
msgid "Invalid UUID string length"
msgstr "Longitud de string UUID inválida"
#: ports/nrf/common-hal/bleio/UUID.c:73
#, c-format
msgid "Could not decode ble_uuid, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:109
#: shared-bindings/bleio/Characteristic.c:125
#: shared-bindings/bleio/Service.c:105
msgid "Invalid UUID parameter"
msgstr "Parámetro UUID inválido"
#: ports/nrf/common-hal/bleio/UUID.c:88
msgid "Unexpected nrfx uuid type"
msgstr ""
#: ports/nrf/common-hal/busio/I2C.c:98
msgid "All I2C peripherals are in use"
@ -803,9 +867,9 @@ msgstr "Paridad impar no soportada"
msgid "busio.UART not available"
msgstr "busio.UART no disponible"
#: ports/nrf/common-hal/microcontroller/Processor.c:49
#, c-format
msgid "Can not get temperature. status: 0x%02x"
#: ports/nrf/common-hal/microcontroller/Processor.c:48
#, fuzzy
msgid "Cannot get temperature"
msgstr "No se puede obtener la temperatura. status: 0x%02x"
#: ports/nrf/common-hal/pulseio/PWMOut.c:161
@ -1955,7 +2019,7 @@ msgstr "la asignación de memoria falló, el heap está bloqueado"
msgid "memory allocation failed, allocating %u bytes"
msgstr "la asignación de memoria falló, asignando %u bytes"
#: py/runtime.c:1609
#: py/runtime.c:1620
msgid "maximum recursion depth exceeded"
msgstr "profundidad máxima de recursión excedida"
@ -2109,13 +2173,31 @@ msgstr "Numero inválido de bits"
msgid "buffer slices must be of equal length"
msgstr ""
#: shared-bindings/bleio/Address.c:101
msgid "Wrong address length"
msgstr "Longitud de address erronea"
#: shared-bindings/bleio/Address.c:119
#, c-format
msgid "Address is not %d bytes long or is in wrong format"
msgstr ""
#: shared-bindings/bleio/Address.c:107
msgid "Wrong number of bytes provided"
msgstr "Numero erroneo de bytes dados"
#: shared-bindings/bleio/Address.c:126
#, fuzzy, c-format
msgid "Address must be %d bytes long"
msgstr "palette debe ser 32 bytes de largo"
#: shared-bindings/bleio/Characteristic.c:81
#: shared-bindings/bleio/Descriptor.c:93 shared-bindings/bleio/Service.c:78
#, fuzzy
msgid "Expected a UUID"
msgstr "Se espera un %q"
#: shared-bindings/bleio/CharacteristicBuffer.c:68
#, fuzzy
msgid "buffer_size must be >= 1"
msgstr "los buffers deben de tener la misma longitud"
#: shared-bindings/bleio/CharacteristicBuffer.c:72
#, fuzzy
msgid "Expected a Characteristic"
msgstr "No se puede agregar la Característica."
#: shared-bindings/bleio/Device.c:210
msgid "Can't add services in Central mode"
@ -2133,6 +2215,40 @@ msgstr "No se puede cambiar el nombre en modo Central"
msgid "Can't advertise in Central mode"
msgstr ""
#: shared-bindings/bleio/Peripheral.c:111
msgid "services includes an object that is not a Service"
msgstr ""
#: shared-bindings/bleio/Peripheral.c:124
#, fuzzy
msgid "name must be a string"
msgstr "palabras clave deben ser strings"
#: shared-bindings/bleio/Service.c:90
msgid "characteristics includes an object that is not a Characteristic"
msgstr ""
#: shared-bindings/bleio/Service.c:96
msgid "Characteristic UUID doesn't match Service UUID"
msgstr ""
#: shared-bindings/bleio/UUID.c:66
msgid "UUID integer value not in range 0 to 0xffff"
msgstr ""
#: shared-bindings/bleio/UUID.c:75
msgid "UUID value is not int or byte buffer"
msgstr ""
#: shared-bindings/bleio/UUID.c:79
#, fuzzy
msgid "Byte buffer must be 16 bytes."
msgstr "buffer debe de ser un objeto bytes-like"
#: shared-bindings/bleio/UUID.c:120
msgid "not a 128-bit UUID"
msgstr ""
#: shared-bindings/busio/I2C.c:120
msgid "Function requires lock."
msgstr "La función requiere lock"
@ -2585,8 +2701,17 @@ msgid ""
"exit safe mode.\n"
msgstr ""
#~ msgid "Can not add Characteristic."
#~ msgstr "No se puede agregar la Característica."
#~ msgid "Invalid UUID string length"
#~ msgstr "Longitud de string UUID inválida"
#~ msgid "Invalid UUID parameter"
#~ msgstr "Parámetro UUID inválido"
#~ msgid "Wrong address length"
#~ msgstr "Longitud de address erronea"
#~ msgid "Wrong number of bytes provided"
#~ msgstr "Numero erroneo de bytes dados"
#~ msgid "Cannot apply GAP parameters."
#~ msgstr "No se pueden aplicar los parámetros GAP."

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-01-10 11:05-0800\n"
"POT-Creation-Date: 2019-01-10 21:32-0500\n"
"PO-Revision-Date: 2018-12-20 22:15-0800\n"
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
"Language-Team: fil\n"
@ -404,17 +404,20 @@ msgstr "Ginagamit na ang EXTINT channel"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:118
#: ports/esp8266/common-hal/pulseio/PulseIn.c:86
#: ports/nrf/common-hal/pulseio/PulseIn.c:129
#, c-format
msgid "Failed to allocate RX buffer of %d bytes"
msgstr "Nabigong ilaan ang RX buffer ng %d bytes"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:205
#: ports/esp8266/common-hal/pulseio/PulseIn.c:151
#: ports/nrf/common-hal/pulseio/PulseIn.c:254
msgid "pop from an empty PulseIn"
msgstr "pop mula sa walang laman na PulseIn"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:237
#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:422
#: ports/esp8266/common-hal/pulseio/PulseIn.c:182
#: ports/nrf/common-hal/pulseio/PulseIn.c:241 py/obj.c:422
msgid "index out of range"
msgstr "index wala sa sakop"
@ -655,123 +658,186 @@ msgstr "Hindi supportado ang AnalogOut"
msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX"
msgstr "Soft device assert, id: 0x%08lX, pc: 0x%08lX"
#: ports/nrf/common-hal/bleio/Adapter.c:125
#, c-format
msgid "Failed to change softdevice state, error: 0x%08lX"
#: ports/nrf/common-hal/bleio/Adapter.c:110
#, fuzzy
msgid "Failed to change softdevice state"
msgstr "Nabigo sa pagbago ng softdevice state, error: 0x%08lX"
#: ports/nrf/common-hal/bleio/Adapter.c:135
#, c-format
msgid "Failed to get softdevice state, error: 0x%08lX"
#: ports/nrf/common-hal/bleio/Adapter.c:119
#, fuzzy
msgid "Failed to get softdevice state"
msgstr "Nabigo sa pagkuha ng softdevice state, error: 0x%08lX"
#: ports/nrf/common-hal/bleio/Adapter.c:155
#, c-format
msgid "Failed to get local address, error: 0x%08lX"
#: ports/nrf/common-hal/bleio/Adapter.c:138
#, fuzzy
msgid "Failed to get local address"
msgstr "Nabigo sa pagkuha ng local na address, , error: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:52
#, c-format
msgid "Failed to write gatts value, status: 0x%08lX"
msgstr "Hindi maisulat ang gatts value, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Broadcaster.c:48
msgid "interval not in range 0.0020 to 10.24"
msgstr ""
#: ports/nrf/common-hal/bleio/Characteristic.c:76
#, c-format
msgid "Failed to notify attribute value, status: 0x%08lX"
msgstr "Hindi mabalitaan ang attribute value, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:91
#, c-format
msgid "Failed to read attribute value, status: 0x%08lX"
msgstr "Hindi mabasa ang value ng attribute, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:119
#: ports/nrf/common-hal/bleio/Device.c:272
#: ports/nrf/common-hal/bleio/Device.c:307
#, c-format
msgid "Failed to acquire mutex, status: 0x%08lX"
msgstr "Nabigo sa pag kuha ng mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:126
#, c-format
msgid "Failed to write attribute value, status: 0x%08lX"
msgstr "Hindi maisulat ang attribute value, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:138
#: ports/nrf/common-hal/bleio/Device.c:284
#: ports/nrf/common-hal/bleio/Device.c:319
#: ports/nrf/common-hal/bleio/Device.c:354
#: ports/nrf/common-hal/bleio/Device.c:391
#, c-format
msgid "Failed to release mutex, status: 0x%08lX"
msgstr "Nabigo sa pagrelease ng mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:81
#: ports/nrf/common-hal/bleio/Device.c:114
msgid "Can not fit data into the advertisment packet"
#: ports/nrf/common-hal/bleio/Broadcaster.c:58
#: ports/nrf/common-hal/bleio/Peripheral.c:56
#, fuzzy
msgid "Data too large for advertisement packet"
msgstr "Hindi makasya ang data sa loob ng advertisement packet"
#: ports/nrf/common-hal/bleio/Device.c:266
#, c-format
msgid "Failed to discover serivices, status: 0x%08lX"
msgstr "Nabigo sa pagdiscover ng services, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:403
#: ports/nrf/common-hal/bleio/Scanner.c:76
#, c-format
msgid "Failed to continue scanning, status: 0x%0xlX"
msgstr "Hindi maituloy ang pag scan, status: 0x%0xlX"
#: ports/nrf/common-hal/bleio/Device.c:436
#, c-format
msgid "Failed to connect, status: 0x%08lX"
msgstr "Hindi makaconnect, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:513
#, c-format
msgid "Failed to add service, status: 0x%08lX"
msgstr "Hindi matagumpay ang paglagay ng service, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:531
#, c-format
msgid "Failed to start advertisment, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Broadcaster.c:83
#: ports/nrf/common-hal/bleio/Peripheral.c:324
#, fuzzy, c-format
msgid "Failed to start advertising, err 0x%04x"
msgstr "Hindi masimulaan ang advertisement, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:549
#, c-format
msgid "Failed to stop advertisment, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Broadcaster.c:96
#: ports/nrf/common-hal/bleio/Peripheral.c:336
#, fuzzy, c-format
msgid "Failed to stop advertising, err 0x%04x"
msgstr "Hindi mahinto ang advertisement, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:575
#: ports/nrf/common-hal/bleio/Scanner.c:103
#, c-format
msgid "Failed to start scanning, status: 0x%0xlX"
#: ports/nrf/common-hal/bleio/Characteristic.c:59
#, fuzzy, c-format
msgid "Failed to read CCCD value, err 0x%04x"
msgstr "Hindi mabasa ang value ng attribute, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:89
#, fuzzy, c-format
msgid "Failed to read gatts value, err 0x%04x"
msgstr "Hindi maisulat ang gatts value, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:106
#, fuzzy, c-format
msgid "Failed to write gatts value, err 0x%04x"
msgstr "Hindi maisulat ang gatts value, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:132
#, fuzzy, c-format
msgid "Failed to notify or indicate attribute value, err %0x04x"
msgstr "Hindi mabalitaan ang attribute value, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:144
#, fuzzy, c-format
msgid "Failed to read attribute value, err %0x04x"
msgstr "Hindi mabasa ang value ng attribute, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:172
#, fuzzy, c-format
msgid "Failed to acquire mutex, err 0x%04x"
msgstr "Nabigo sa pag kuha ng mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:178
#, fuzzy, c-format
msgid "Failed to write attribute value, err 0x%04x"
msgstr "Hindi maisulat ang attribute value, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:189
#, fuzzy, c-format
msgid "Failed to release mutex, err 0x%04x"
msgstr "Nabigo sa pagrelease ng mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:251
#: ports/nrf/common-hal/bleio/Characteristic.c:284
msgid "bad GATT role"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:80
#: ports/nrf/common-hal/bleio/Device.c:112
#, fuzzy
msgid "Data too large for the advertisement packet"
msgstr "Hindi makasya ang data sa loob ng advertisement packet"
#: ports/nrf/common-hal/bleio/Device.c:262
#, fuzzy
msgid "Failed to discover services"
msgstr "Nabigo sa pagdiscover ng services, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:267
#: ports/nrf/common-hal/bleio/Device.c:300
#, fuzzy
msgid "Failed to acquire mutex"
msgstr "Nabigo sa pag kuha ng mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:278
#: ports/nrf/common-hal/bleio/Device.c:311
#: ports/nrf/common-hal/bleio/Device.c:342
#: ports/nrf/common-hal/bleio/Device.c:376
#, fuzzy
msgid "Failed to release mutex"
msgstr "Nabigo sa pagrelease ng mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:387
#, fuzzy
msgid "Failed to continue scanning"
msgstr "Hindi maituloy ang pag scan, status: 0x%0xlX"
#: ports/nrf/common-hal/bleio/Device.c:419
#, fuzzy
msgid "Failed to connect:"
msgstr "Hindi makaconnect, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:489
#, fuzzy
msgid "Failed to add service"
msgstr "Hindi matagumpay ang paglagay ng service, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:506
#, fuzzy
msgid "Failed to start advertising"
msgstr "Hindi masimulaan ang advertisement, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:523
#, fuzzy
msgid "Failed to stop advertising"
msgstr "Hindi mahinto ang advertisement, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:548
#, fuzzy
msgid "Failed to start scanning"
msgstr "Hindi masimulaan mag i-scan, status: 0x%0xlX"
#: ports/nrf/common-hal/bleio/Device.c:592
#, c-format
msgid "Failed to create mutex, status: 0x%0xlX"
#: ports/nrf/common-hal/bleio/Device.c:564
#, fuzzy
msgid "Failed to create mutex"
msgstr "Hindi matagumpay ang pagbuo ng mutex, status: 0x%0xlX"
#: ports/nrf/common-hal/bleio/Service.c:83
#, c-format
msgid "Failed to add characteristic, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Peripheral.c:304
#, fuzzy, c-format
msgid "Failed to add service, err 0x%04x"
msgstr "Hindi matagumpay ang paglagay ng service, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Scanner.c:75
#, fuzzy, c-format
msgid "Failed to continue scanning, err 0x%04x"
msgstr "Hindi maituloy ang pag scan, status: 0x%0xlX"
#: ports/nrf/common-hal/bleio/Scanner.c:101
#, fuzzy, c-format
msgid "Failed to start scanning, err 0x%04x"
msgstr "Hindi masimulaan mag i-scan, status: 0x%0xlX"
#: ports/nrf/common-hal/bleio/Service.c:88
#, fuzzy, c-format
msgid "Failed to add characteristic, err 0x%04x"
msgstr "Nabigo sa paglagay ng characteristic, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/UUID.c:97
#, c-format
msgid "Failed to add Vendor Specific UUID, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Service.c:92
msgid "Characteristic already in use by another Service."
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:54
#, fuzzy, c-format
msgid "Failed to register Vendor-Specific UUID, err 0x%04x"
msgstr "Hindi matagumpay ang paglagay ng Vender Specific UUID, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/UUID.c:102
msgid "Invalid UUID string length"
msgstr "Mali ang UUID string length"
#: ports/nrf/common-hal/bleio/UUID.c:73
#, c-format
msgid "Could not decode ble_uuid, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:109
#: shared-bindings/bleio/Characteristic.c:125
#: shared-bindings/bleio/Service.c:105
msgid "Invalid UUID parameter"
msgstr "Mali ang UUID parameter"
#: ports/nrf/common-hal/bleio/UUID.c:88
#, fuzzy
msgid "Unexpected nrfx uuid type"
msgstr "hindi inaasahang indent"
#: ports/nrf/common-hal/busio/I2C.c:98
msgid "All I2C peripherals are in use"
@ -802,9 +868,9 @@ msgstr "Odd na parity ay hindi supportado"
msgid "busio.UART not available"
msgstr "busio.UART hindi available"
#: ports/nrf/common-hal/microcontroller/Processor.c:49
#, c-format
msgid "Can not get temperature. status: 0x%02x"
#: ports/nrf/common-hal/microcontroller/Processor.c:48
#, fuzzy
msgid "Cannot get temperature"
msgstr "Hindi makuha ang temperatura. status 0x%02x"
#: ports/nrf/common-hal/pulseio/PWMOut.c:161
@ -1958,7 +2024,7 @@ msgstr "abigo ang paglalaan ng memorya, ang heap ay naka-lock"
msgid "memory allocation failed, allocating %u bytes"
msgstr "nabigo ang paglalaan ng memorya, paglalaan ng %u bytes"
#: py/runtime.c:1609
#: py/runtime.c:1620
msgid "maximum recursion depth exceeded"
msgstr "lumagpas ang maximum recursion depth"
@ -2115,13 +2181,31 @@ msgstr "Mali ang bilang ng bits"
msgid "buffer slices must be of equal length"
msgstr "aarehas na haba dapat ang buffer slices"
#: shared-bindings/bleio/Address.c:101
msgid "Wrong address length"
msgstr "Mali ang address length"
#: shared-bindings/bleio/Address.c:119
#, c-format
msgid "Address is not %d bytes long or is in wrong format"
msgstr ""
#: shared-bindings/bleio/Address.c:107
msgid "Wrong number of bytes provided"
msgstr "Mali ang bilang ng bytes"
#: shared-bindings/bleio/Address.c:126
#, fuzzy, c-format
msgid "Address must be %d bytes long"
msgstr "ang palette ay dapat 32 bytes ang haba"
#: shared-bindings/bleio/Characteristic.c:81
#: shared-bindings/bleio/Descriptor.c:93 shared-bindings/bleio/Service.c:78
#, fuzzy
msgid "Expected a UUID"
msgstr "Umasa ng %q"
#: shared-bindings/bleio/CharacteristicBuffer.c:68
#, fuzzy
msgid "buffer_size must be >= 1"
msgstr "aarehas na haba dapat ang buffer slices"
#: shared-bindings/bleio/CharacteristicBuffer.c:72
#, fuzzy
msgid "Expected a Characteristic"
msgstr "Hindi mabasa and Characteristic."
#: shared-bindings/bleio/Device.c:210
msgid "Can't add services in Central mode"
@ -2139,6 +2223,40 @@ msgstr "Hindi mapalitan ang pangalan sa Central mode"
msgid "Can't advertise in Central mode"
msgstr "Hindi ma advertise habang nasa Central mode"
#: shared-bindings/bleio/Peripheral.c:111
msgid "services includes an object that is not a Service"
msgstr ""
#: shared-bindings/bleio/Peripheral.c:124
#, fuzzy
msgid "name must be a string"
msgstr "ang keywords dapat strings"
#: shared-bindings/bleio/Service.c:90
msgid "characteristics includes an object that is not a Characteristic"
msgstr ""
#: shared-bindings/bleio/Service.c:96
msgid "Characteristic UUID doesn't match Service UUID"
msgstr ""
#: shared-bindings/bleio/UUID.c:66
msgid "UUID integer value not in range 0 to 0xffff"
msgstr ""
#: shared-bindings/bleio/UUID.c:75
msgid "UUID value is not int or byte buffer"
msgstr ""
#: shared-bindings/bleio/UUID.c:79
#, fuzzy
msgid "Byte buffer must be 16 bytes."
msgstr "buffer ay dapat bytes-like object"
#: shared-bindings/bleio/UUID.c:120
msgid "not a 128-bit UUID"
msgstr ""
#: shared-bindings/busio/I2C.c:120
msgid "Function requires lock."
msgstr "Kailangan ng lock ang function."
@ -2600,8 +2718,17 @@ msgstr ""
"Ang reset button ay pinindot habang nag boot ang CircuitPython. Pindutin "
"ulit para lumabas sa safe mode.\n"
#~ msgid "Can not add Characteristic."
#~ msgstr "Hindi mabasa and Characteristic."
#~ msgid "Invalid UUID string length"
#~ msgstr "Mali ang UUID string length"
#~ msgid "Invalid UUID parameter"
#~ msgstr "Mali ang UUID parameter"
#~ msgid "Wrong address length"
#~ msgstr "Mali ang address length"
#~ msgid "Wrong number of bytes provided"
#~ msgstr "Mali ang bilang ng bytes"
#~ msgid "Cannot apply GAP parameters."
#~ msgstr "Hindi ma-apply ang GAP parameters."

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-01-10 11:05-0800\n"
"POT-Creation-Date: 2019-01-10 21:32-0500\n"
"PO-Revision-Date: 2018-12-23 20:05+0100\n"
"Last-Translator: Pierrick Couturier <arofarn@arofarn.info>\n"
"Language-Team: fr\n"
@ -402,17 +402,20 @@ msgstr "Canal EXTINT déjà utilisé"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:118
#: ports/esp8266/common-hal/pulseio/PulseIn.c:86
#: ports/nrf/common-hal/pulseio/PulseIn.c:129
#, c-format
msgid "Failed to allocate RX buffer of %d bytes"
msgstr "Echec de l'allocation de %d octets du tampon RX"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:205
#: ports/esp8266/common-hal/pulseio/PulseIn.c:151
#: ports/nrf/common-hal/pulseio/PulseIn.c:254
msgid "pop from an empty PulseIn"
msgstr "'pop' d'une entrée PulseIn vide"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:237
#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:422
#: ports/esp8266/common-hal/pulseio/PulseIn.c:182
#: ports/nrf/common-hal/pulseio/PulseIn.c:241 py/obj.c:422
msgid "index out of range"
msgstr "index hors gamme"
@ -653,123 +656,184 @@ msgstr "AnalogOut non supporté"
msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Adapter.c:125
#, c-format
msgid "Failed to change softdevice state, error: 0x%08lX"
#: ports/nrf/common-hal/bleio/Adapter.c:110
#, fuzzy
msgid "Failed to change softdevice state"
msgstr "Echec de la modification de l'état du périph., erreur: 0x%08lX"
#: ports/nrf/common-hal/bleio/Adapter.c:135
#, c-format
msgid "Failed to get softdevice state, error: 0x%08lX"
#: ports/nrf/common-hal/bleio/Adapter.c:119
#, fuzzy
msgid "Failed to get softdevice state"
msgstr "Echec de l'obtention de l'état du périph., erreur: 0x%08lX"
#: ports/nrf/common-hal/bleio/Adapter.c:155
#, c-format
msgid "Failed to get local address, error: 0x%08lX"
#: ports/nrf/common-hal/bleio/Adapter.c:138
#, fuzzy
msgid "Failed to get local address"
msgstr "Echec de l'obtention de l'adresse locale, erreur: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:52
#, fuzzy, c-format
msgid "Failed to write gatts value, status: 0x%08lX"
msgstr "Impossible d'écrire la valeur de gatts. status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:76
#, fuzzy, c-format
msgid "Failed to notify attribute value, status: 0x%08lX"
msgstr "Impossible de notifier la valeur de l'attribut. status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:91
#, fuzzy, c-format
msgid "Failed to read attribute value, status: 0x%08lX"
msgstr "Impossible de lire la valeur de l'attribut. status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:119
#: ports/nrf/common-hal/bleio/Device.c:272
#: ports/nrf/common-hal/bleio/Device.c:307
#, c-format
msgid "Failed to acquire mutex, status: 0x%08lX"
msgstr "Echec de l'obtention de mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:126
#, fuzzy, c-format
msgid "Failed to write attribute value, status: 0x%08lX"
msgstr "Impossible d'écrire la valeur de l'attribut. status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:138
#: ports/nrf/common-hal/bleio/Device.c:284
#: ports/nrf/common-hal/bleio/Device.c:319
#: ports/nrf/common-hal/bleio/Device.c:354
#: ports/nrf/common-hal/bleio/Device.c:391
#, c-format
msgid "Failed to release mutex, status: 0x%08lX"
msgstr "Impossible de libérer mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:81
#: ports/nrf/common-hal/bleio/Device.c:114
msgid "Can not fit data into the advertisment packet"
#: ports/nrf/common-hal/bleio/Broadcaster.c:48
msgid "interval not in range 0.0020 to 10.24"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:266
#, fuzzy, c-format
msgid "Failed to discover serivices, status: 0x%08lX"
msgstr "Echec de la découverte de services, statut: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:403
#: ports/nrf/common-hal/bleio/Scanner.c:76
#, fuzzy, c-format
msgid "Failed to continue scanning, status: 0x%0xlX"
msgstr "Impossible de commencer à scanner. statut: 0x%0xlX"
#: ports/nrf/common-hal/bleio/Device.c:436
#, fuzzy, c-format
msgid "Failed to connect, status: 0x%08lX"
msgstr "Connection impossible. statut: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:513
#, c-format
msgid "Failed to add service, status: 0x%08lX"
msgstr "Echec de l'ajout de service, statut: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:531
#, c-format
msgid "Failed to start advertisment, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Broadcaster.c:58
#: ports/nrf/common-hal/bleio/Peripheral.c:56
msgid "Data too large for advertisement packet"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:549
#: ports/nrf/common-hal/bleio/Broadcaster.c:83
#: ports/nrf/common-hal/bleio/Peripheral.c:324
#, fuzzy, c-format
msgid "Failed to stop advertisment, status: 0x%08lX"
msgstr "Echec de l'ajout de service, statut: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:575
#: ports/nrf/common-hal/bleio/Scanner.c:103
#, fuzzy, c-format
msgid "Failed to start scanning, status: 0x%0xlX"
msgid "Failed to start advertising, err 0x%04x"
msgstr "Impossible de commencer à scanner, statut: 0x%0xlX"
#: ports/nrf/common-hal/bleio/Device.c:592
#: ports/nrf/common-hal/bleio/Broadcaster.c:96
#: ports/nrf/common-hal/bleio/Peripheral.c:336
#, fuzzy, c-format
msgid "Failed to create mutex, status: 0x%0xlX"
msgid "Failed to stop advertising, err 0x%04x"
msgstr "Echec de l'ajout de service, statut: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:59
#, fuzzy, c-format
msgid "Failed to read CCCD value, err 0x%04x"
msgstr "Impossible de lire la valeur de l'attribut. status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:89
#, fuzzy, c-format
msgid "Failed to read gatts value, err 0x%04x"
msgstr "Impossible d'écrire la valeur de gatts. status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:106
#, fuzzy, c-format
msgid "Failed to write gatts value, err 0x%04x"
msgstr "Impossible d'écrire la valeur de gatts. status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:132
#, fuzzy, c-format
msgid "Failed to notify or indicate attribute value, err %0x04x"
msgstr "Impossible de notifier la valeur de l'attribut. status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:144
#, fuzzy, c-format
msgid "Failed to read attribute value, err %0x04x"
msgstr "Impossible de lire la valeur de l'attribut. status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:172
#, fuzzy, c-format
msgid "Failed to acquire mutex, err 0x%04x"
msgstr "Echec de l'obtention de mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:178
#, fuzzy, c-format
msgid "Failed to write attribute value, err 0x%04x"
msgstr "Impossible d'écrire la valeur de l'attribut. status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:189
#, fuzzy, c-format
msgid "Failed to release mutex, err 0x%04x"
msgstr "Impossible de libérer mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:251
#: ports/nrf/common-hal/bleio/Characteristic.c:284
msgid "bad GATT role"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:80
#: ports/nrf/common-hal/bleio/Device.c:112
msgid "Data too large for the advertisement packet"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:262
#, fuzzy
msgid "Failed to discover services"
msgstr "Echec de la découverte de services, statut: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:267
#: ports/nrf/common-hal/bleio/Device.c:300
#, fuzzy
msgid "Failed to acquire mutex"
msgstr "Echec de l'obtention de mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:278
#: ports/nrf/common-hal/bleio/Device.c:311
#: ports/nrf/common-hal/bleio/Device.c:342
#: ports/nrf/common-hal/bleio/Device.c:376
#, fuzzy
msgid "Failed to release mutex"
msgstr "Impossible de libérer mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:387
#, fuzzy
msgid "Failed to continue scanning"
msgstr "Impossible de commencer à scanner. statut: 0x%0xlX"
#: ports/nrf/common-hal/bleio/Device.c:419
#, fuzzy
msgid "Failed to connect:"
msgstr "Connection impossible. statut: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:489
#, fuzzy
msgid "Failed to add service"
msgstr "Echec de l'ajout de service, statut: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:506
#, fuzzy
msgid "Failed to start advertising"
msgstr "Echec de l'ajout de service, statut: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:523
#, fuzzy
msgid "Failed to stop advertising"
msgstr "Echec de l'ajout de service, statut: 0x%08lX"
#: ports/nrf/common-hal/bleio/Device.c:548
#, fuzzy
msgid "Failed to start scanning"
msgstr "Impossible de commencer à scanner, statut: 0x%0xlX"
#: ports/nrf/common-hal/bleio/Device.c:564
#, fuzzy
msgid "Failed to create mutex"
msgstr "Echec de la création de mutex, statut: 0x%0xlX"
#: ports/nrf/common-hal/bleio/Service.c:83
#, c-format
msgid "Failed to add characteristic, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Peripheral.c:304
#, fuzzy, c-format
msgid "Failed to add service, err 0x%04x"
msgstr "Echec de l'ajout de service, statut: 0x%08lX"
#: ports/nrf/common-hal/bleio/Scanner.c:75
#, fuzzy, c-format
msgid "Failed to continue scanning, err 0x%04x"
msgstr "Impossible de commencer à scanner. statut: 0x%0xlX"
#: ports/nrf/common-hal/bleio/Scanner.c:101
#, fuzzy, c-format
msgid "Failed to start scanning, err 0x%04x"
msgstr "Impossible de commencer à scanner, statut: 0x%0xlX"
#: ports/nrf/common-hal/bleio/Service.c:88
#, fuzzy, c-format
msgid "Failed to add characteristic, err 0x%04x"
msgstr "Echec de l'ajout de caractéristique, statut: 0x%08lX"
#: ports/nrf/common-hal/bleio/UUID.c:97
#: ports/nrf/common-hal/bleio/Service.c:92
msgid "Characteristic already in use by another Service."
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:54
#, fuzzy, c-format
msgid "Failed to add Vendor Specific UUID, status: 0x%08lX"
msgid "Failed to register Vendor-Specific UUID, err 0x%04x"
msgstr "Echec de l'ajout de l'UUID Vendor Specific, , statut: 0x%08lX"
#: ports/nrf/common-hal/bleio/UUID.c:102
msgid "Invalid UUID string length"
msgstr "Longeur de chaîne UUID invalide"
#: ports/nrf/common-hal/bleio/UUID.c:73
#, c-format
msgid "Could not decode ble_uuid, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:109
#: shared-bindings/bleio/Characteristic.c:125
#: shared-bindings/bleio/Service.c:105
msgid "Invalid UUID parameter"
msgstr "Paramètre UUID invalide"
#: ports/nrf/common-hal/bleio/UUID.c:88
#, fuzzy
msgid "Unexpected nrfx uuid type"
msgstr "indentation inattendue"
#: ports/nrf/common-hal/busio/I2C.c:98
#, fuzzy
@ -805,9 +869,9 @@ msgstr "parité impaire non supportée"
msgid "busio.UART not available"
msgstr "busio.UART n'est pas disponible"
#: ports/nrf/common-hal/microcontroller/Processor.c:49
#, c-format
msgid "Can not get temperature. status: 0x%02x"
#: ports/nrf/common-hal/microcontroller/Processor.c:48
#, fuzzy
msgid "Cannot get temperature"
msgstr "Impossible de lire la température. status: 0x%02x"
#: ports/nrf/common-hal/pulseio/PWMOut.c:161
@ -1960,7 +2024,7 @@ msgstr "l'allocation de mémoire a échoué, la pile est vérrouillé"
msgid "memory allocation failed, allocating %u bytes"
msgstr "l'allocation de mémoire a échoué en allouant %u octets"
#: py/runtime.c:1609
#: py/runtime.c:1620
msgid "maximum recursion depth exceeded"
msgstr "profondeur maximale de récursivité dépassée"
@ -2119,14 +2183,31 @@ msgstr "Nombre de bits invalide"
msgid "buffer slices must be of equal length"
msgstr "les slices de tampon doivent être de longueurs égales"
#: shared-bindings/bleio/Address.c:101
msgid "Wrong address length"
msgstr "Mauvaise longueur d'adresse"
#: shared-bindings/bleio/Address.c:119
#, c-format
msgid "Address is not %d bytes long or is in wrong format"
msgstr ""
#: shared-bindings/bleio/Address.c:107
#: shared-bindings/bleio/Address.c:126
#, fuzzy, c-format
msgid "Address must be %d bytes long"
msgstr "la palette doit être longue de 32 octets"
#: shared-bindings/bleio/Characteristic.c:81
#: shared-bindings/bleio/Descriptor.c:93 shared-bindings/bleio/Service.c:78
#, fuzzy
msgid "Wrong number of bytes provided"
msgstr "mauvais nombre d'octets fourni'"
msgid "Expected a UUID"
msgstr "Attendu : %q"
#: shared-bindings/bleio/CharacteristicBuffer.c:68
#, fuzzy
msgid "buffer_size must be >= 1"
msgstr "les slices de tampon doivent être de longueurs égales"
#: shared-bindings/bleio/CharacteristicBuffer.c:72
#, fuzzy
msgid "Expected a Characteristic"
msgstr "Impossible d'ajouter la Characteristic."
#: shared-bindings/bleio/Device.c:210
msgid "Can't add services in Central mode"
@ -2144,6 +2225,40 @@ msgstr "Modification du nom impossible en mode Central"
msgid "Can't advertise in Central mode"
msgstr ""
#: shared-bindings/bleio/Peripheral.c:111
msgid "services includes an object that is not a Service"
msgstr ""
#: shared-bindings/bleio/Peripheral.c:124
#, fuzzy
msgid "name must be a string"
msgstr "les noms doivent être des chaînes de caractère"
#: shared-bindings/bleio/Service.c:90
msgid "characteristics includes an object that is not a Characteristic"
msgstr ""
#: shared-bindings/bleio/Service.c:96
msgid "Characteristic UUID doesn't match Service UUID"
msgstr ""
#: shared-bindings/bleio/UUID.c:66
msgid "UUID integer value not in range 0 to 0xffff"
msgstr ""
#: shared-bindings/bleio/UUID.c:75
msgid "UUID value is not int or byte buffer"
msgstr ""
#: shared-bindings/bleio/UUID.c:79
#, fuzzy
msgid "Byte buffer must be 16 bytes."
msgstr "le tampon doit être un objet bytes-like"
#: shared-bindings/bleio/UUID.c:120
msgid "not a 128-bit UUID"
msgstr ""
#: shared-bindings/busio/I2C.c:120
msgid "Function requires lock."
msgstr "La fonction nécessite un verrou."
@ -2632,6 +2747,19 @@ msgstr ""
"Le bouton 'reset' a été appuyé pendant le démarrage de CircuitPython. "
"Appuyer denouveau pour quitter de le mode sans-échec.\n"
#~ msgid "Invalid UUID string length"
#~ msgstr "Longeur de chaîne UUID invalide"
#~ msgid "Invalid UUID parameter"
#~ msgstr "Paramètre UUID invalide"
#~ msgid "Wrong address length"
#~ msgstr "Mauvaise longueur d'adresse"
#, fuzzy
#~ msgid "Wrong number of bytes provided"
#~ msgstr "mauvais nombre d'octets fourni'"
#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n"
#~ msgstr ""
#~ "Il semblerait que votre code CircuitPython a durement planté. Oups!\n"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-01-10 11:05-0800\n"
"POT-Creation-Date: 2019-01-10 21:32-0500\n"
"PO-Revision-Date: 2018-10-02 16:27+0200\n"
"Last-Translator: Enrico Paganin <enrico.paganin@mail.com>\n"
"Language-Team: \n"
@ -406,17 +406,20 @@ msgstr "Canale EXTINT già in uso"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:118
#: ports/esp8266/common-hal/pulseio/PulseIn.c:86
#: ports/nrf/common-hal/pulseio/PulseIn.c:129
#, c-format
msgid "Failed to allocate RX buffer of %d bytes"
msgstr "Fallita allocazione del buffer RX di %d byte"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:205
#: ports/esp8266/common-hal/pulseio/PulseIn.c:151
#: ports/nrf/common-hal/pulseio/PulseIn.c:254
msgid "pop from an empty PulseIn"
msgstr "pop sun un PulseIn vuoto"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:237
#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:422
#: ports/esp8266/common-hal/pulseio/PulseIn.c:182
#: ports/nrf/common-hal/pulseio/PulseIn.c:241 py/obj.c:422
msgid "index out of range"
msgstr "indice fuori intervallo"
@ -655,124 +658,185 @@ msgstr "funzionalità AnalogOut non supportata"
msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Adapter.c:125
#, c-format
msgid "Failed to change softdevice state, error: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Adapter.c:135
#, c-format
msgid "Failed to get softdevice state, error: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Adapter.c:155
#, c-format
msgid "Failed to get local address, error: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Characteristic.c:52
#, fuzzy, c-format
msgid "Failed to write gatts value, status: 0x%08lX"
msgstr "Impossibile scrivere valore dell'attributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:76
#, fuzzy, c-format
msgid "Failed to notify attribute value, status: 0x%08lX"
msgstr "Impossibile notificare valore dell'attributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:91
#, fuzzy, c-format
msgid "Failed to read attribute value, status: 0x%08lX"
msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:119
#: ports/nrf/common-hal/bleio/Device.c:272
#: ports/nrf/common-hal/bleio/Device.c:307
#, c-format
msgid "Failed to acquire mutex, status: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Characteristic.c:126
#, fuzzy, c-format
msgid "Failed to write attribute value, status: 0x%08lX"
msgstr "Impossibile scrivere valore dell'attributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:138
#: ports/nrf/common-hal/bleio/Device.c:284
#: ports/nrf/common-hal/bleio/Device.c:319
#: ports/nrf/common-hal/bleio/Device.c:354
#: ports/nrf/common-hal/bleio/Device.c:391
#, c-format
msgid "Failed to release mutex, status: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:81
#: ports/nrf/common-hal/bleio/Device.c:114
#: ports/nrf/common-hal/bleio/Adapter.c:110
#, fuzzy
msgid "Can not fit data into the advertisment packet"
msgid "Failed to change softdevice state"
msgstr "Impossibile fermare advertisement. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Adapter.c:119
#, fuzzy
msgid "Failed to get softdevice state"
msgstr "Impossibile fermare advertisement. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Adapter.c:138
msgid "Failed to get local address"
msgstr ""
#: ports/nrf/common-hal/bleio/Broadcaster.c:48
msgid "interval not in range 0.0020 to 10.24"
msgstr ""
#: ports/nrf/common-hal/bleio/Broadcaster.c:58
#: ports/nrf/common-hal/bleio/Peripheral.c:56
#, fuzzy
msgid "Data too large for advertisement packet"
msgstr "Impossibile inserire dati nel pacchetto di advertisement."
#: ports/nrf/common-hal/bleio/Device.c:266
#, c-format
msgid "Failed to discover serivices, status: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:403
#: ports/nrf/common-hal/bleio/Scanner.c:76
#: ports/nrf/common-hal/bleio/Broadcaster.c:83
#: ports/nrf/common-hal/bleio/Peripheral.c:324
#, fuzzy, c-format
msgid "Failed to continue scanning, status: 0x%0xlX"
msgstr "Impossible iniziare la scansione. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:436
#, fuzzy, c-format
msgid "Failed to connect, status: 0x%08lX"
msgstr "Impossibile connettersi. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:513
#, fuzzy, c-format
msgid "Failed to add service, status: 0x%08lX"
msgstr "Impossibile fermare advertisement. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:531
#, fuzzy, c-format
msgid "Failed to start advertisment, status: 0x%08lX"
msgid "Failed to start advertising, err 0x%04x"
msgstr "Impossibile avviare advertisement. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:549
#: ports/nrf/common-hal/bleio/Broadcaster.c:96
#: ports/nrf/common-hal/bleio/Peripheral.c:336
#, fuzzy, c-format
msgid "Failed to stop advertisment, status: 0x%08lX"
msgid "Failed to stop advertising, err 0x%04x"
msgstr "Impossibile fermare advertisement. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:575
#: ports/nrf/common-hal/bleio/Scanner.c:103
#: ports/nrf/common-hal/bleio/Characteristic.c:59
#, fuzzy, c-format
msgid "Failed to start scanning, status: 0x%0xlX"
msgstr "Impossible iniziare la scansione. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:592
#, fuzzy, c-format
msgid "Failed to create mutex, status: 0x%0xlX"
msgid "Failed to read CCCD value, err 0x%04x"
msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Service.c:83
#, c-format
msgid "Failed to add characteristic, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:89
#, fuzzy, c-format
msgid "Failed to read gatts value, err 0x%04x"
msgstr "Impossibile scrivere valore dell'attributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:106
#, fuzzy, c-format
msgid "Failed to write gatts value, err 0x%04x"
msgstr "Impossibile scrivere valore dell'attributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:132
#, fuzzy, c-format
msgid "Failed to notify or indicate attribute value, err %0x04x"
msgstr "Impossibile notificare valore dell'attributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:144
#, fuzzy, c-format
msgid "Failed to read attribute value, err %0x04x"
msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:172
#, fuzzy, c-format
msgid "Failed to acquire mutex, err 0x%04x"
msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:178
#, fuzzy, c-format
msgid "Failed to write attribute value, err 0x%04x"
msgstr "Impossibile scrivere valore dell'attributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:189
#, fuzzy, c-format
msgid "Failed to release mutex, err 0x%04x"
msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:251
#: ports/nrf/common-hal/bleio/Characteristic.c:284
msgid "bad GATT role"
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:97
#: ports/nrf/common-hal/bleio/Device.c:80
#: ports/nrf/common-hal/bleio/Device.c:112
#, fuzzy
msgid "Data too large for the advertisement packet"
msgstr "Impossibile inserire dati nel pacchetto di advertisement."
#: ports/nrf/common-hal/bleio/Device.c:262
#, fuzzy
msgid "Failed to discover services"
msgstr "Impossibile fermare advertisement. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:267
#: ports/nrf/common-hal/bleio/Device.c:300
#, fuzzy
msgid "Failed to acquire mutex"
msgstr "Impossibile allocare buffer RX"
#: ports/nrf/common-hal/bleio/Device.c:278
#: ports/nrf/common-hal/bleio/Device.c:311
#: ports/nrf/common-hal/bleio/Device.c:342
#: ports/nrf/common-hal/bleio/Device.c:376
#, fuzzy
msgid "Failed to release mutex"
msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:387
#, fuzzy
msgid "Failed to continue scanning"
msgstr "Impossible iniziare la scansione. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:419
#, fuzzy
msgid "Failed to connect:"
msgstr "Impossibile connettersi. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:489
#, fuzzy
msgid "Failed to add service"
msgstr "Impossibile fermare advertisement. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:506
#, fuzzy
msgid "Failed to start advertising"
msgstr "Impossibile avviare advertisement. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:523
#, fuzzy
msgid "Failed to stop advertising"
msgstr "Impossibile fermare advertisement. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:548
#, fuzzy
msgid "Failed to start scanning"
msgstr "Impossible iniziare la scansione. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:564
#, fuzzy
msgid "Failed to create mutex"
msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Peripheral.c:304
#, fuzzy, c-format
msgid "Failed to add Vendor Specific UUID, status: 0x%08lX"
msgid "Failed to add service, err 0x%04x"
msgstr "Impossibile fermare advertisement. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Scanner.c:75
#, fuzzy, c-format
msgid "Failed to continue scanning, err 0x%04x"
msgstr "Impossible iniziare la scansione. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Scanner.c:101
#, fuzzy, c-format
msgid "Failed to start scanning, err 0x%04x"
msgstr "Impossible iniziare la scansione. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Service.c:88
#, fuzzy, c-format
msgid "Failed to add characteristic, err 0x%04x"
msgstr "Impossibile fermare advertisement. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Service.c:92
msgid "Characteristic already in use by another Service."
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:54
#, fuzzy, c-format
msgid "Failed to register Vendor-Specific UUID, err 0x%04x"
msgstr "Non è possibile aggiungere l'UUID del vendor specifico da 128-bit"
#: ports/nrf/common-hal/bleio/UUID.c:102
msgid "Invalid UUID string length"
msgstr "Lunghezza della stringa UUID non valida"
#: ports/nrf/common-hal/bleio/UUID.c:73
#, c-format
msgid "Could not decode ble_uuid, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:109
#: shared-bindings/bleio/Characteristic.c:125
#: shared-bindings/bleio/Service.c:105
msgid "Invalid UUID parameter"
msgstr "Parametro UUID non valido"
#: ports/nrf/common-hal/bleio/UUID.c:88
#, fuzzy
msgid "Unexpected nrfx uuid type"
msgstr "indentazione inaspettata"
#: ports/nrf/common-hal/busio/I2C.c:98
msgid "All I2C peripherals are in use"
@ -806,9 +870,9 @@ msgstr "operazione I2C non supportata"
msgid "busio.UART not available"
msgstr "busio.UART non ancora implementato"
#: ports/nrf/common-hal/microcontroller/Processor.c:49
#, c-format
msgid "Can not get temperature. status: 0x%02x"
#: ports/nrf/common-hal/microcontroller/Processor.c:48
#, fuzzy
msgid "Cannot get temperature"
msgstr "Impossibile leggere la temperatura. status: 0x%02x"
#: ports/nrf/common-hal/pulseio/PWMOut.c:161
@ -1956,7 +2020,7 @@ msgstr "allocazione di memoria fallita, l'heap è bloccato"
msgid "memory allocation failed, allocating %u bytes"
msgstr "allocazione di memoria fallita, allocando %u byte"
#: py/runtime.c:1609
#: py/runtime.c:1620
msgid "maximum recursion depth exceeded"
msgstr "profondità massima di ricorsione superata"
@ -2116,14 +2180,31 @@ msgstr "Numero di bit non valido"
msgid "buffer slices must be of equal length"
msgstr "slice del buffer devono essere della stessa lunghezza"
#: shared-bindings/bleio/Address.c:101
msgid "Wrong address length"
#: shared-bindings/bleio/Address.c:119
#, c-format
msgid "Address is not %d bytes long or is in wrong format"
msgstr ""
#: shared-bindings/bleio/Address.c:107
#: shared-bindings/bleio/Address.c:126
#, fuzzy, c-format
msgid "Address must be %d bytes long"
msgstr "la palette deve essere lunga 32 byte"
#: shared-bindings/bleio/Characteristic.c:81
#: shared-bindings/bleio/Descriptor.c:93 shared-bindings/bleio/Service.c:78
#, fuzzy
msgid "Wrong number of bytes provided"
msgstr "numero di argomenti errato"
msgid "Expected a UUID"
msgstr "Atteso un %q"
#: shared-bindings/bleio/CharacteristicBuffer.c:68
#, fuzzy
msgid "buffer_size must be >= 1"
msgstr "slice del buffer devono essere della stessa lunghezza"
#: shared-bindings/bleio/CharacteristicBuffer.c:72
#, fuzzy
msgid "Expected a Characteristic"
msgstr "Non è possibile aggiungere Characteristic."
#: shared-bindings/bleio/Device.c:210
msgid "Can't add services in Central mode"
@ -2141,6 +2222,40 @@ msgstr ""
msgid "Can't advertise in Central mode"
msgstr ""
#: shared-bindings/bleio/Peripheral.c:111
msgid "services includes an object that is not a Service"
msgstr ""
#: shared-bindings/bleio/Peripheral.c:124
#, fuzzy
msgid "name must be a string"
msgstr "argomenti nominati devono essere stringhe"
#: shared-bindings/bleio/Service.c:90
msgid "characteristics includes an object that is not a Characteristic"
msgstr ""
#: shared-bindings/bleio/Service.c:96
msgid "Characteristic UUID doesn't match Service UUID"
msgstr ""
#: shared-bindings/bleio/UUID.c:66
msgid "UUID integer value not in range 0 to 0xffff"
msgstr ""
#: shared-bindings/bleio/UUID.c:75
msgid "UUID value is not int or byte buffer"
msgstr ""
#: shared-bindings/bleio/UUID.c:79
#, fuzzy
msgid "Byte buffer must be 16 bytes."
msgstr "i buffer devono essere della stessa lunghezza"
#: shared-bindings/bleio/UUID.c:120
msgid "not a 128-bit UUID"
msgstr ""
#: shared-bindings/busio/I2C.c:120
msgid "Function requires lock."
msgstr ""
@ -2601,6 +2716,16 @@ msgid ""
"exit safe mode.\n"
msgstr ""
#~ msgid "Invalid UUID string length"
#~ msgstr "Lunghezza della stringa UUID non valida"
#~ msgid "Invalid UUID parameter"
#~ msgstr "Parametro UUID non valido"
#, fuzzy
#~ msgid "Wrong number of bytes provided"
#~ msgstr "numero di argomenti errato"
#~ msgid "Invalid Service type"
#~ msgstr "Tipo di servizio non valido"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-01-10 11:05-0800\n"
"POT-Creation-Date: 2019-01-10 21:32-0500\n"
"PO-Revision-Date: 2018-10-02 21:14-0000\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -400,17 +400,20 @@ msgstr "Canal EXTINT em uso"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:118
#: ports/esp8266/common-hal/pulseio/PulseIn.c:86
#: ports/nrf/common-hal/pulseio/PulseIn.c:129
#, c-format
msgid "Failed to allocate RX buffer of %d bytes"
msgstr "Falha ao alocar buffer RX de %d bytes"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:205
#: ports/esp8266/common-hal/pulseio/PulseIn.c:151
#: ports/nrf/common-hal/pulseio/PulseIn.c:254
msgid "pop from an empty PulseIn"
msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:237
#: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:422
#: ports/esp8266/common-hal/pulseio/PulseIn.c:182
#: ports/nrf/common-hal/pulseio/PulseIn.c:241 py/obj.c:422
msgid "index out of range"
msgstr "Índice fora do intervalo"
@ -648,124 +651,182 @@ msgstr "Funcionalidade AnalogOut não suportada"
msgid "Soft device assert, id: 0x%08lX, pc: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Adapter.c:125
#, c-format
msgid "Failed to change softdevice state, error: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Adapter.c:135
#, c-format
msgid "Failed to get softdevice state, error: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Adapter.c:155
#, c-format
msgid "Failed to get local address, error: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Characteristic.c:52
#, fuzzy, c-format
msgid "Failed to write gatts value, status: 0x%08lX"
msgstr "Não é possível gravar o valor do atributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:76
#, fuzzy, c-format
msgid "Failed to notify attribute value, status: 0x%08lX"
msgstr "Não é possível gravar o valor do atributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:91
#, fuzzy, c-format
msgid "Failed to read attribute value, status: 0x%08lX"
msgstr "Não é possível ler o valor do atributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:119
#: ports/nrf/common-hal/bleio/Device.c:272
#: ports/nrf/common-hal/bleio/Device.c:307
#, c-format
msgid "Failed to acquire mutex, status: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Characteristic.c:126
#, fuzzy, c-format
msgid "Failed to write attribute value, status: 0x%08lX"
msgstr "Não é possível gravar o valor do atributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:138
#: ports/nrf/common-hal/bleio/Device.c:284
#: ports/nrf/common-hal/bleio/Device.c:319
#: ports/nrf/common-hal/bleio/Device.c:354
#: ports/nrf/common-hal/bleio/Device.c:391
#, c-format
msgid "Failed to release mutex, status: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:81
#: ports/nrf/common-hal/bleio/Device.c:114
#: ports/nrf/common-hal/bleio/Adapter.c:110
#, fuzzy
msgid "Can not fit data into the advertisment packet"
msgid "Failed to change softdevice state"
msgstr "Não pode parar propaganda. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Adapter.c:119
#, fuzzy
msgid "Failed to get softdevice state"
msgstr "Não pode parar propaganda. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Adapter.c:138
msgid "Failed to get local address"
msgstr ""
#: ports/nrf/common-hal/bleio/Broadcaster.c:48
msgid "interval not in range 0.0020 to 10.24"
msgstr ""
#: ports/nrf/common-hal/bleio/Broadcaster.c:58
#: ports/nrf/common-hal/bleio/Peripheral.c:56
#, fuzzy
msgid "Data too large for advertisement packet"
msgstr "Não é possível ajustar dados no pacote de anúncios."
#: ports/nrf/common-hal/bleio/Device.c:266
#, c-format
msgid "Failed to discover serivices, status: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:403
#: ports/nrf/common-hal/bleio/Scanner.c:76
#, c-format
msgid "Failed to continue scanning, status: 0x%0xlX"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:436
#, c-format
msgid "Failed to connect, status: 0x%08lX"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:513
#: ports/nrf/common-hal/bleio/Broadcaster.c:83
#: ports/nrf/common-hal/bleio/Peripheral.c:324
#, fuzzy, c-format
msgid "Failed to add service, status: 0x%08lX"
msgstr "Não pode parar propaganda. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:531
#, fuzzy, c-format
msgid "Failed to start advertisment, status: 0x%08lX"
msgid "Failed to start advertising, err 0x%04x"
msgstr "Não é possível iniciar o anúncio. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:549
#: ports/nrf/common-hal/bleio/Broadcaster.c:96
#: ports/nrf/common-hal/bleio/Peripheral.c:336
#, fuzzy, c-format
msgid "Failed to stop advertisment, status: 0x%08lX"
msgid "Failed to stop advertising, err 0x%04x"
msgstr "Não pode parar propaganda. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:575
#: ports/nrf/common-hal/bleio/Scanner.c:103
#: ports/nrf/common-hal/bleio/Characteristic.c:59
#, fuzzy, c-format
msgid "Failed to start scanning, status: 0x%0xlX"
msgstr "Não é possível iniciar o anúncio. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:592
#, fuzzy, c-format
msgid "Failed to create mutex, status: 0x%0xlX"
msgid "Failed to read CCCD value, err 0x%04x"
msgstr "Não é possível ler o valor do atributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Service.c:83
#, c-format
msgid "Failed to add characteristic, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c:89
#, fuzzy, c-format
msgid "Failed to read gatts value, err 0x%04x"
msgstr "Não é possível gravar o valor do atributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:106
#, fuzzy, c-format
msgid "Failed to write gatts value, err 0x%04x"
msgstr "Não é possível gravar o valor do atributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:132
#, fuzzy, c-format
msgid "Failed to notify or indicate attribute value, err %0x04x"
msgstr "Não é possível gravar o valor do atributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:144
#, fuzzy, c-format
msgid "Failed to read attribute value, err %0x04x"
msgstr "Não é possível ler o valor do atributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:172
#, fuzzy, c-format
msgid "Failed to acquire mutex, err 0x%04x"
msgstr "Não é possível ler o valor do atributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:178
#, fuzzy, c-format
msgid "Failed to write attribute value, err 0x%04x"
msgstr "Não é possível gravar o valor do atributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:189
#, fuzzy, c-format
msgid "Failed to release mutex, err 0x%04x"
msgstr "Não é possível ler o valor do atributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c:251
#: ports/nrf/common-hal/bleio/Characteristic.c:284
msgid "bad GATT role"
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:97
#: ports/nrf/common-hal/bleio/Device.c:80
#: ports/nrf/common-hal/bleio/Device.c:112
#, fuzzy
msgid "Data too large for the advertisement packet"
msgstr "Não é possível ajustar dados no pacote de anúncios."
#: ports/nrf/common-hal/bleio/Device.c:262
#, fuzzy
msgid "Failed to discover services"
msgstr "Não pode parar propaganda. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:267
#: ports/nrf/common-hal/bleio/Device.c:300
#, fuzzy
msgid "Failed to acquire mutex"
msgstr "Falha ao alocar buffer RX"
#: ports/nrf/common-hal/bleio/Device.c:278
#: ports/nrf/common-hal/bleio/Device.c:311
#: ports/nrf/common-hal/bleio/Device.c:342
#: ports/nrf/common-hal/bleio/Device.c:376
#, fuzzy
msgid "Failed to release mutex"
msgstr "Não é possível ler o valor do atributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:387
msgid "Failed to continue scanning"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:419
msgid "Failed to connect:"
msgstr ""
#: ports/nrf/common-hal/bleio/Device.c:489
#, fuzzy
msgid "Failed to add service"
msgstr "Não pode parar propaganda. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:506
#, fuzzy
msgid "Failed to start advertising"
msgstr "Não é possível iniciar o anúncio. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:523
#, fuzzy
msgid "Failed to stop advertising"
msgstr "Não pode parar propaganda. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:548
#, fuzzy
msgid "Failed to start scanning"
msgstr "Não é possível iniciar o anúncio. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Device.c:564
#, fuzzy
msgid "Failed to create mutex"
msgstr "Não é possível ler o valor do atributo. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Peripheral.c:304
#, fuzzy, c-format
msgid "Failed to add Vendor Specific UUID, status: 0x%08lX"
msgid "Failed to add service, err 0x%04x"
msgstr "Não pode parar propaganda. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Scanner.c:75
#, fuzzy, c-format
msgid "Failed to continue scanning, err 0x%04x"
msgstr "Não é possível iniciar o anúncio. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Scanner.c:101
#, fuzzy, c-format
msgid "Failed to start scanning, err 0x%04x"
msgstr "Não é possível iniciar o anúncio. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Service.c:88
#, fuzzy, c-format
msgid "Failed to add characteristic, err 0x%04x"
msgstr "Não pode parar propaganda. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Service.c:92
msgid "Characteristic already in use by another Service."
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:54
#, fuzzy, c-format
msgid "Failed to register Vendor-Specific UUID, err 0x%04x"
msgstr "Não é possível adicionar o UUID de 128 bits específico do fornecedor."
#: ports/nrf/common-hal/bleio/UUID.c:102
msgid "Invalid UUID string length"
#: ports/nrf/common-hal/bleio/UUID.c:73
#, c-format
msgid "Could not decode ble_uuid, err 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/UUID.c:109
#: shared-bindings/bleio/Characteristic.c:125
#: shared-bindings/bleio/Service.c:105
msgid "Invalid UUID parameter"
msgstr "Parâmetro UUID inválido"
#: ports/nrf/common-hal/bleio/UUID.c:88
msgid "Unexpected nrfx uuid type"
msgstr ""
#: ports/nrf/common-hal/busio/I2C.c:98
msgid "All I2C peripherals are in use"
@ -798,9 +859,9 @@ msgstr "I2C operação não suportada"
msgid "busio.UART not available"
msgstr "busio.UART não disponível"
#: ports/nrf/common-hal/microcontroller/Processor.c:49
#, c-format
msgid "Can not get temperature. status: 0x%02x"
#: ports/nrf/common-hal/microcontroller/Processor.c:48
#, fuzzy
msgid "Cannot get temperature"
msgstr "Não pode obter a temperatura. status: 0x%02x"
#: ports/nrf/common-hal/pulseio/PWMOut.c:161
@ -1935,7 +1996,7 @@ msgstr ""
msgid "memory allocation failed, allocating %u bytes"
msgstr ""
#: py/runtime.c:1609
#: py/runtime.c:1620
msgid "maximum recursion depth exceeded"
msgstr ""
@ -2088,13 +2149,31 @@ msgstr "Número inválido de bits"
msgid "buffer slices must be of equal length"
msgstr ""
#: shared-bindings/bleio/Address.c:101
msgid "Wrong address length"
#: shared-bindings/bleio/Address.c:119
#, c-format
msgid "Address is not %d bytes long or is in wrong format"
msgstr ""
#: shared-bindings/bleio/Address.c:107
msgid "Wrong number of bytes provided"
msgstr ""
#: shared-bindings/bleio/Address.c:126
#, fuzzy, c-format
msgid "Address must be %d bytes long"
msgstr "buffers devem ser o mesmo tamanho"
#: shared-bindings/bleio/Characteristic.c:81
#: shared-bindings/bleio/Descriptor.c:93 shared-bindings/bleio/Service.c:78
#, fuzzy
msgid "Expected a UUID"
msgstr "Esperado um"
#: shared-bindings/bleio/CharacteristicBuffer.c:68
#, fuzzy
msgid "buffer_size must be >= 1"
msgstr "buffers devem ser o mesmo tamanho"
#: shared-bindings/bleio/CharacteristicBuffer.c:72
#, fuzzy
msgid "Expected a Characteristic"
msgstr "Não é possível adicionar Característica."
#: shared-bindings/bleio/Device.c:210
msgid "Can't add services in Central mode"
@ -2112,6 +2191,40 @@ msgstr ""
msgid "Can't advertise in Central mode"
msgstr ""
#: shared-bindings/bleio/Peripheral.c:111
msgid "services includes an object that is not a Service"
msgstr ""
#: shared-bindings/bleio/Peripheral.c:124
#, fuzzy
msgid "name must be a string"
msgstr "heap deve ser uma lista"
#: shared-bindings/bleio/Service.c:90
msgid "characteristics includes an object that is not a Characteristic"
msgstr ""
#: shared-bindings/bleio/Service.c:96
msgid "Characteristic UUID doesn't match Service UUID"
msgstr ""
#: shared-bindings/bleio/UUID.c:66
msgid "UUID integer value not in range 0 to 0xffff"
msgstr ""
#: shared-bindings/bleio/UUID.c:75
msgid "UUID value is not int or byte buffer"
msgstr ""
#: shared-bindings/bleio/UUID.c:79
#, fuzzy
msgid "Byte buffer must be 16 bytes."
msgstr "buffers devem ser o mesmo tamanho"
#: shared-bindings/bleio/UUID.c:120
msgid "not a 128-bit UUID"
msgstr ""
#: shared-bindings/busio/I2C.c:120
msgid "Function requires lock."
msgstr ""
@ -2557,32 +2670,32 @@ msgid ""
"exit safe mode.\n"
msgstr ""
#~ msgid "Can not add Service."
#~ msgstr "Não é possível adicionar o serviço."
#~ msgid "Can not apply advertisement data. status: 0x%02x"
#~ msgstr "Não é possível aplicar dados de anúncio. status: 0x%02x"
#~ msgid "Can not apply device name in the stack."
#~ msgstr "Não é possível aplicar o nome do dispositivo na pilha."
#~ msgid "Baud rate too high for this SPI peripheral"
#~ msgstr "Taxa de transmissão muito alta para esse periférico SPI"
#~ msgid "Cannot apply GAP parameters."
#~ msgstr "Não é possível aplicar parâmetros GAP."
#~ msgid "Invalid Service type"
#~ msgstr "Tipo de serviço inválido"
#~ msgid "Can encode UUID into the advertisement packet."
#~ msgstr "Pode codificar o UUID no pacote de anúncios."
#~ msgid "Can not add Characteristic."
#~ msgstr "Não é possível adicionar Característica."
#~ msgid "Can not query for the device address."
#~ msgstr "Não é possível consultar o endereço do dispositivo."
#~ msgid "Can not add Characteristic."
#~ msgstr "Não é possível adicionar Característica."
#~ msgid "Cannot set PPCP parameters."
#~ msgstr "Não é possível definir parâmetros PPCP."
#~ msgid "Can encode UUID into the advertisement packet."
#~ msgstr "Pode codificar o UUID no pacote de anúncios."
#~ msgid "Invalid Service type"
#~ msgstr "Tipo de serviço inválido"
#~ msgid "Cannot apply GAP parameters."
#~ msgstr "Não é possível aplicar parâmetros GAP."
#~ msgid "Baud rate too high for this SPI peripheral"
#~ msgstr "Taxa de transmissão muito alta para esse periférico SPI"
#~ msgid "Can not apply device name in the stack."
#~ msgstr "Não é possível aplicar o nome do dispositivo na pilha."
#~ msgid "Can not apply advertisement data. status: 0x%02x"
#~ msgstr "Não é possível aplicar dados de anúncio. status: 0x%02x"
#~ msgid "Invalid UUID parameter"
#~ msgstr "Parâmetro UUID inválido"

View File

@ -81,9 +81,10 @@ BASE_CFLAGS = \
-DCIRCUITPY_SAFE_RESTART_WORD=0xDEADBEEF \
--param max-inline-insns-single=500
# Use these flags to debug build times and header includes.
# -ftime-report
# -H
# Use these flags to debug build times and header includes.
# -ftime-report
# -H
# NDEBUG disables assert() statements. This reduces code size pretty dramatically, per tannewt.
ifeq ($(CHIP_FAMILY), samd21)

View File

@ -1,8 +1,8 @@
# Old Nordic soft devices that don't allow redistribution
#########################################################
bluetooth/s132_nrf52_2.0.1/
drivers/bluetooth/s132_nrf52_2.0.1/
!bluetooth/*/*.hex
!drivers/bluetooth/*/*.hex
# Build files
#####################

View File

@ -79,12 +79,14 @@ CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_NRF5X -DCFG_TUD_CDC_RX_BUFSIZE=1024 -DCFG_TUD_C
#Debugging/Optimization
ifeq ($(DEBUG), 1)
#ASMFLAGS += -g -gtabs+
CFLAGS += -O1 -ggdb
LDFLAGS += -O1
#ASMFLAGS += -g -gtabs+
CFLAGS += -O1 -ggdb
LDFLAGS += -O1
# You may want to enable these flags to make setting breakpoints easier.
CFLAGS += -fno-inline -fno-ipa-sra
else
CFLAGS += -Os -DNDEBUG
LDFLAGS += -Os
CFLAGS += -Os -DNDEBUG
LDFLAGS += -Os
endif
LIBM_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-file-name=libm.a)
@ -171,9 +173,11 @@ ifneq ($(SD), )
SRC_COMMON_HAL += \
bleio/__init__.c \
bleio/Adapter.c \
bleio/Broadcaster.c \
bleio/Characteristic.c \
bleio/CharacteristicBuffer.c \
bleio/Descriptor.c \
bleio/Device.c \
bleio/Peripheral.c \
bleio/Scanner.c \
bleio/Service.c \
bleio/UUID.c
@ -196,8 +200,7 @@ SRC_BINDINGS_ENUMS += \
bleio/Address.c \
bleio/AddressType.c \
bleio/AdvertisementData.c \
bleio/ScanEntry.c \
bleio/UUIDType.c
bleio/ScanEntry.c
endif
SRC_SHARED_MODULE = \

View File

@ -22,9 +22,6 @@ This is a port of CircuitPython to the Nordic Semiconductor nRF52 series of chip
## Tested Hardware
* nRF52832
* [PCA10040](http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52%2Fdita%2Fnrf52%2Fdevelopment%2Fnrf52_dev_kit.html)
* [Adafruit Feather nRF52](https://www.adafruit.com/product/3406)
* nRF52840
* [PCA10056](http://www.nordicsemi.com/eng/Products/nRF52840-Preview-DK)
@ -36,10 +33,9 @@ the following links:
> **NOTE**: These board specific readmes may be more up to date than the
generic board-neutral documentation further down.
* Adafruit Feather nRF52: boards/feather_nrf52832/README.md: 512KB Flash, 64KB SRAM
* Adafruit Feather nRF52840: boards/feather_nrf52840_express/README.md: 1MB Flash, 256KB SRAM
* Nordic PCA10056 (uses nRF52840): boards/pca10056/README.md
* MakerDiary NRF52840 MDK: boards/makerdiary_nrf52840_mdk/README.md
* Adafruit Feather nRF52840: `boards/feather_nrf52840_express/README.md`: 1MB Flash, 256KB SRAM
* Nordic PCA10056 (uses nRF52840): `boards/pca10056/README.md`
* MakerDiary NRF52840 MDK: `boards/makerdiary_nrf52840_mdk/README.md`
For all other board targets, see the generic notes below.
@ -77,9 +73,7 @@ Note: further tuning of features to include in bluetooth or even setting up the
Target Board (BOARD) | Bluetooth Stack (SD) | Bluetooth Support | Flash Util
-------------------------|-------------------------|------------------------|-------------------------------
pca10040 | s132 | Peripheral and Scanner | [Segger](#segger-targets)
pca10056 | s140 | Peripheral and Scanner | [Segger](#segger-targets)
feather_nrf52832 | s132 | Peripheral and Scanner | [UART DFU](#dfu-targets)
feather_nrf52840_express | s140 | Peripheral and Scanner | UF2 bootloader
makerdiary_nrf52840_mdk | s140 | Peripheral and Scanner | pyocd or ARM mbed DAPLink
@ -109,10 +103,10 @@ run follow command to install [adafruit-nrfutil](https://github.com/adafruit/Ada
* dfu-gen: Generates a Firmware zip to be used by the DFU flash application.
* dfu-flash: Triggers the DFU flash application to upload the firmware from the generated Firmware zip file.
Example on how to generate and flash feather_nrf52832 target:
Example on how to generate and flash feather_nrf52840 target:
make BOARD=feather_nrf52832 SD=s132
make BOARD=feather_nrf52832 SD=s132 dfu-gen dfu-flash
make BOARD=feather_nrf52840 SD=s140
make BOARD=feather_nrf52840 SD=s140 dfu-gen dfu-flash
## Bluetooth LE REPL

View File

@ -45,30 +45,44 @@ typedef struct event_handler {
ble_drv_evt_handler_t func;
} event_handler_t;
static event_handler_t *m_event_handlers;
static event_handler_t *m_event_handlers = NULL;
void ble_drv_reset() {
// Linked list items will be gc'd.
m_event_handlers = NULL;
}
void ble_drv_add_event_handler(ble_drv_evt_handler_t func, void *param) {
event_handler_t *handler = m_new_ll(event_handler_t, 1);
handler->next = NULL;
handler->param = param;
handler->func = func;
if (m_event_handlers == NULL) {
m_event_handlers = handler;
return;
}
event_handler_t *it = m_event_handlers;
while (it->next != NULL) {
while (it != NULL) {
// If event handler and its corresponding param are already on the list, don't add again.
if ((it->func == func) && (it->param == param)) {
m_free(handler);
return;
}
it = it->next;
}
it->next = handler;
// Add a new handler to the front of the list
event_handler_t *handler = m_new_ll(event_handler_t, 1);
handler->next = m_event_handlers;
handler->param = param;
handler->func = func;
m_event_handlers = handler;
}
void ble_drv_remove_event_handler(ble_drv_evt_handler_t func, void *param) {
event_handler_t *it = m_event_handlers;
event_handler_t **prev = &m_event_handlers;
while (it != NULL) {
if ((it->func == func) && (it->param == param)) {
// Splice out the matching handler.
*prev = it->next;
return;
}
prev = &(it->next);
it = it->next;
}
}
void SD_EVT_IRQHandler(void) {

View File

@ -43,11 +43,15 @@
#define BLE_CONN_CFG_TAG_CUSTOM 1
#define MSEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000) / (RESOLUTION))
// 0.625 msecs (625 usecs)
#define ADV_INTERVAL_UNIT_FLOAT_SECS (0.000625)
#define UNIT_0_625_MS (625)
#define UNIT_10_MS (10000)
typedef void (*ble_drv_evt_handler_t)(ble_evt_t*, void*);
void ble_drv_reset();
void ble_drv_add_event_handler(ble_drv_evt_handler_t func, void *param);
void ble_drv_remove_event_handler(ble_drv_evt_handler_t func, void *param);
#endif // MICROPY_INCLUDED_NRF_BLUETOOTH_BLE_DRV_H

View File

@ -1,12 +1,4 @@
ifeq ($(SD), s132)
CFLAGS += -DBLUETOOTH_SD=132
ifeq ($(SOFTDEV_VERSION), 2.0.1)
CFLAGS += -DBLE_API_VERSION=2
else ifeq ($(SOFTDEV_VERSION), 5.0.0)
CFLAGS += -DBLE_API_VERSION=4
endif
else ifeq ($(SD), s140)
ifeq ($(SD), s140)
CFLAGS += -DBLUETOOTH_SD=140
CFLAGS += -DBLE_API_VERSION=4
else

View File

@ -1,32 +0,0 @@
#!/bin/bash
function download_s132_nrf52_2_0_1
{
echo ""
echo "####################################"
echo "### Downloading s132_nrf52_2.0.1 ###"
echo "####################################"
echo ""
mkdir -p "${1}/s132_nrf52_2.0.1"
cd "${1}/s132_nrf52_2.0.1"
wget https://www.nordicsemi.com/api/sitecore/Products/MedialibraryZipDownload2 --post-data="ids=863031714A574444AADFE444EBE5BA9B|&fileName=DeviceDownload" -O temp.zip
unzip -u temp.zip
unzip -u s132nrf52201.zip
rm temp.zip s132nrf52201.zip
cd -
}
SCRIPT_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ $# -eq 0 ]; then
echo "No Bluetooth LE stack defined, downloading all."
download_s132_nrf52_2_0_1 "${SCRIPT_DIR}"
else
case $1 in
"s132_nrf52_2_0_1" )
download_s132_nrf52_2_0_1 "${SCRIPT_DIR}" ;;
esac
fi
exit 0

View File

@ -1,620 +0,0 @@
/*
* Copyright (c) 2012 - 2017, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@addtogroup BLE_COMMON BLE SoftDevice Common
@{
@defgroup ble_api Events, type definitions and API calls
@{
@brief Module independent events, type definitions and API calls for the BLE SoftDevice.
*/
#ifndef BLE_H__
#define BLE_H__
#include "ble_ranges.h"
#include "ble_types.h"
#include "ble_gap.h"
#include "ble_l2cap.h"
#include "ble_gatt.h"
#include "ble_gattc.h"
#include "ble_gatts.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup BLE_COMMON_ENUMERATIONS Enumerations
* @{ */
/**
* @brief Common API SVC numbers.
*/
enum BLE_COMMON_SVCS
{
SD_BLE_ENABLE = BLE_SVC_BASE, /**< Enable and initialize the BLE stack */
SD_BLE_EVT_GET, /**< Get an event from the pending events queue. */
SD_BLE_UUID_VS_ADD, /**< Add a Vendor Specific UUID. */
SD_BLE_UUID_DECODE, /**< Decode UUID bytes. */
SD_BLE_UUID_ENCODE, /**< Encode UUID bytes. */
SD_BLE_VERSION_GET, /**< Get the local version information (company ID, Link Layer Version, Link Layer Subversion). */
SD_BLE_USER_MEM_REPLY, /**< User Memory Reply. */
SD_BLE_OPT_SET, /**< Set a BLE option. */
SD_BLE_OPT_GET, /**< Get a BLE option. */
SD_BLE_CFG_SET, /**< Add a configuration to the BLE stack. */
};
/**
* @brief BLE Module Independent Event IDs.
*/
enum BLE_COMMON_EVTS
{
BLE_EVT_USER_MEM_REQUEST = BLE_EVT_BASE, /**< User Memory request. @ref ble_evt_user_mem_request_t */
BLE_EVT_USER_MEM_RELEASE, /**< User Memory release. @ref ble_evt_user_mem_release_t */
};
/**@brief BLE Connection Configuration IDs.
*
* IDs that uniquely identify a connection configuration.
*/
enum BLE_CONN_CFGS
{
BLE_CONN_CFG_GAP = BLE_CONN_CFG_BASE, /**< BLE GAP specific connection configuration. */
BLE_CONN_CFG_GATTC, /**< BLE GATTC specific connection configuration. */
BLE_CONN_CFG_GATTS, /**< BLE GATTS specific connection configuration. */
BLE_CONN_CFG_GATT, /**< BLE GATT specific connection configuration. */
BLE_CONN_CFG_L2CAP, /**< BLE L2CAP specific connection configuration. */
};
/**@brief BLE Common Configuration IDs.
*
* IDs that uniquely identify a common configuration.
*/
enum BLE_COMMON_CFGS
{
BLE_COMMON_CFG_VS_UUID = BLE_CFG_BASE, /**< Vendor specific UUID configuration */
};
/**@brief Common Option IDs.
* IDs that uniquely identify a common option.
*/
enum BLE_COMMON_OPTS
{
BLE_COMMON_OPT_PA_LNA = BLE_OPT_BASE, /**< PA and LNA options */
BLE_COMMON_OPT_CONN_EVT_EXT, /**< Extended connection events option */
};
/** @} */
/** @addtogroup BLE_COMMON_DEFINES Defines
* @{ */
/** @brief Required pointer alignment for BLE Events.
*/
#define BLE_EVT_PTR_ALIGNMENT 4
/** @brief Leaves the maximum of the two arguments.
*/
#define BLE_MAX(a, b) ((a) < (b) ? (b) : (a))
/** @brief Maximum possible length for BLE Events.
* @note The highest value used for @ref ble_gatt_conn_cfg_t::att_mtu in any connection configuration shall be used as a parameter.
* If that value has not been configured for any connections then @ref BLE_GATT_ATT_MTU_DEFAULT must be used instead.
*/
#define BLE_EVT_LEN_MAX(ATT_MTU) (BLE_MAX( \
sizeof(ble_evt_t), \
BLE_MAX( \
offsetof(ble_evt_t, evt.gattc_evt.params.rel_disc_rsp.includes) + ((ATT_MTU) - 2) / 6 * sizeof(ble_gattc_include_t), \
offsetof(ble_evt_t, evt.gattc_evt.params.attr_info_disc_rsp.info.attr_info16) + ((ATT_MTU) - 2) / 4 * sizeof(ble_gattc_attr_info16_t) \
) \
))
/** @defgroup BLE_USER_MEM_TYPES User Memory Types
* @{ */
#define BLE_USER_MEM_TYPE_INVALID 0x00 /**< Invalid User Memory Types. */
#define BLE_USER_MEM_TYPE_GATTS_QUEUED_WRITES 0x01 /**< User Memory for GATTS queued writes. */
/** @} */
/** @defgroup BLE_UUID_VS_COUNTS Vendor Specific UUID counts
* @{
*/
#define BLE_UUID_VS_COUNT_DEFAULT 10 /**< Default VS UUID count. */
#define BLE_UUID_VS_COUNT_MAX 254 /**< Maximum VS UUID count. */
/** @} */
/** @defgroup BLE_COMMON_CFG_DEFAULTS Configuration defaults.
* @{
*/
#define BLE_CONN_CFG_TAG_DEFAULT 0 /**< Default configuration tag, SoftDevice default connection configuration. */
/** @} */
/** @} */
/** @addtogroup BLE_COMMON_STRUCTURES Structures
* @{ */
/**@brief User Memory Block. */
typedef struct
{
uint8_t *p_mem; /**< Pointer to the start of the user memory block. */
uint16_t len; /**< Length in bytes of the user memory block. */
} ble_user_mem_block_t;
/**@brief Event structure for @ref BLE_EVT_USER_MEM_REQUEST. */
typedef struct
{
uint8_t type; /**< User memory type, see @ref BLE_USER_MEM_TYPES. */
} ble_evt_user_mem_request_t;
/**@brief Event structure for @ref BLE_EVT_USER_MEM_RELEASE. */
typedef struct
{
uint8_t type; /**< User memory type, see @ref BLE_USER_MEM_TYPES. */
ble_user_mem_block_t mem_block; /**< User memory block */
} ble_evt_user_mem_release_t;
/**@brief Event structure for events not associated with a specific function module. */
typedef struct
{
uint16_t conn_handle; /**< Connection Handle on which this event occurred. */
union
{
ble_evt_user_mem_request_t user_mem_request; /**< User Memory Request Event Parameters. */
ble_evt_user_mem_release_t user_mem_release; /**< User Memory Release Event Parameters. */
} params; /**< Event parameter union. */
} ble_common_evt_t;
/**@brief BLE Event header. */
typedef struct
{
uint16_t evt_id; /**< Value from a BLE_<module>_EVT series. */
uint16_t evt_len; /**< Length in octets including this header. */
} ble_evt_hdr_t;
/**@brief Common BLE Event type, wrapping the module specific event reports. */
typedef struct
{
ble_evt_hdr_t header; /**< Event header. */
union
{
ble_common_evt_t common_evt; /**< Common Event, evt_id in BLE_EVT_* series. */
ble_gap_evt_t gap_evt; /**< GAP originated event, evt_id in BLE_GAP_EVT_* series. */
ble_gattc_evt_t gattc_evt; /**< GATT client originated event, evt_id in BLE_GATTC_EVT* series. */
ble_gatts_evt_t gatts_evt; /**< GATT server originated event, evt_id in BLE_GATTS_EVT* series. */
ble_l2cap_evt_t l2cap_evt; /**< L2CAP originated event, evt_id in BLE_L2CAP_EVT* series. */
} evt; /**< Event union. */
} ble_evt_t;
/**
* @brief Version Information.
*/
typedef struct
{
uint8_t version_number; /**< Link Layer Version number. See https://www.bluetooth.org/en-us/specification/assigned-numbers/link-layer for assigned values. */
uint16_t company_id; /**< Company ID, Nordic Semiconductor's company ID is 89 (0x0059) (https://www.bluetooth.org/apps/content/Default.aspx?doc_id=49708). */
uint16_t subversion_number; /**< Link Layer Sub Version number, corresponds to the SoftDevice Config ID or Firmware ID (FWID). */
} ble_version_t;
/**
* @brief Configuration parameters for the PA and LNA.
*/
typedef struct
{
uint8_t enable :1; /**< Enable toggling for this amplifier */
uint8_t active_high :1; /**< Set the pin to be active high */
uint8_t gpio_pin :6; /**< The GPIO pin to toggle for this amplifier */
} ble_pa_lna_cfg_t;
/**
* @brief PA & LNA GPIO toggle configuration
*
* This option configures the SoftDevice to toggle pins when the radio is active for use with a power amplifier and/or
* a low noise amplifier.
*
* Toggling the pins is achieved by using two PPI channels and a GPIOTE channel. The hardware channel IDs are provided
* by the application and should be regarded as reserved as long as any PA/LNA toggling is enabled.
*
* @note @ref sd_ble_opt_get is not supported for this option.
* @note Setting this option while the radio is in use (i.e. any of the roles are active) may have undefined consequences
* and must be avoided by the application.
*/
typedef struct
{
ble_pa_lna_cfg_t pa_cfg; /**< Power Amplifier configuration */
ble_pa_lna_cfg_t lna_cfg; /**< Low Noise Amplifier configuration */
uint8_t ppi_ch_id_set; /**< PPI channel used for radio pin setting */
uint8_t ppi_ch_id_clr; /**< PPI channel used for radio pin clearing */
uint8_t gpiote_ch_id; /**< GPIOTE channel used for radio pin toggling */
} ble_common_opt_pa_lna_t;
/**
* @brief Configuration of extended BLE connection events.
*
* When enabled the SoftDevice will dynamically extend the connection event when possible.
*
* The connection event length is controlled by the connection configuration as set by @ref ble_gap_conn_cfg_t::event_length.
* The connection event can be extended if there is time to send another packet pair before the start of the next connection interval,
* and if there are no conflicts with other BLE roles requesting radio time.
*
* @note @ref sd_ble_opt_get is not supported for this option.
*/
typedef struct
{
uint8_t enable : 1; /**< Enable extended BLE connection events, disabled by default. */
} ble_common_opt_conn_evt_ext_t;
/**@brief Option structure for common options. */
typedef union
{
ble_common_opt_pa_lna_t pa_lna; /**< Parameters for controlling PA and LNA pin toggling. */
ble_common_opt_conn_evt_ext_t conn_evt_ext; /**< Parameters for enabling extended connection events. */
} ble_common_opt_t;
/**@brief Common BLE Option type, wrapping the module specific options. */
typedef union
{
ble_common_opt_t common_opt; /**< COMMON options, opt_id in @ref BLE_COMMON_OPTS series. */
ble_gap_opt_t gap_opt; /**< GAP option, opt_id in @ref BLE_GAP_OPTS series. */
} ble_opt_t;
/**@brief BLE connection configuration type, wrapping the module specific configurations, set with
* @ref sd_ble_cfg_set.
*
* @note Connection configurations don't have to be set.
* In the case that no configurations has been set, or fewer connection configurations has been set than enabled connections,
* the default connection configuration will be automatically added for the remaining connections.
* When creating connections with the default configuration, @ref BLE_CONN_CFG_TAG_DEFAULT should be used in
* place of @ref ble_conn_cfg_t::conn_cfg_tag. See @ref sd_ble_gap_adv_start() and @ref sd_ble_gap_connect()"
*
* @mscs
* @mmsc{@ref BLE_CONN_CFG}
* @endmscs
*/
typedef struct
{
uint8_t conn_cfg_tag; /**< The application chosen tag it can use with the @ref sd_ble_gap_adv_start() and @ref sd_ble_gap_connect()
calls to select this configuration when creating a connection.
Must be different for all connection configurations added and not @ref BLE_CONN_CFG_TAG_DEFAULT. */
union {
ble_gap_conn_cfg_t gap_conn_cfg; /**< GAP connection configuration, cfg_id is @ref BLE_CONN_CFG_GAP. */
ble_gattc_conn_cfg_t gattc_conn_cfg; /**< GATTC connection configuration, cfg_id is @ref BLE_CONN_CFG_GATTC. */
ble_gatts_conn_cfg_t gatts_conn_cfg; /**< GATTS connection configuration, cfg_id is @ref BLE_CONN_CFG_GATTS. */
ble_gatt_conn_cfg_t gatt_conn_cfg; /**< GATT connection configuration, cfg_id is @ref BLE_CONN_CFG_GATT. */
ble_l2cap_conn_cfg_t l2cap_conn_cfg; /**< L2CAP connection configuration, cfg_id is @ref BLE_CONN_CFG_L2CAP. */
} params; /**< Connection configuration union. */
} ble_conn_cfg_t;
/**
* @brief Configuration of Vendor Specific UUIDs, set with @ref sd_ble_cfg_set.
*
* @retval ::NRF_ERROR_INVALID_PARAM Too many UUIDs configured.
*/
typedef struct
{
uint8_t vs_uuid_count; /**< Number of 128-bit Vendor Specific UUID bases to allocate memory for.
Default value is @ref BLE_UUID_VS_COUNT_DEFAULT. Maximum value is
@ref BLE_UUID_VS_COUNT_MAX. */
} ble_common_cfg_vs_uuid_t;
/**@brief Common BLE Configuration type, wrapping the common configurations. */
typedef union
{
ble_common_cfg_vs_uuid_t vs_uuid_cfg; /**< Vendor specific UUID configuration, cfg_id is @ref BLE_COMMON_CFG_VS_UUID. */
} ble_common_cfg_t;
/**@brief BLE Configuration type, wrapping the module specific configurations. */
typedef union
{
ble_conn_cfg_t conn_cfg; /**< Connection specific configurations, cfg_id in @ref BLE_CONN_CFGS series. */
ble_common_cfg_t common_cfg; /**< Global common configurations, cfg_id in @ref BLE_COMMON_CFGS series. */
ble_gap_cfg_t gap_cfg; /**< Global GAP configurations, cfg_id in @ref BLE_GAP_CFGS series. */
ble_gatts_cfg_t gatts_cfg; /**< Global GATTS configuration, cfg_id in @ref BLE_GATTS_CFGS series. */
} ble_cfg_t;
/** @} */
/** @addtogroup BLE_COMMON_FUNCTIONS Functions
* @{ */
/**@brief Enable the BLE stack
*
* @param[in, out] p_app_ram_base Pointer to a variable containing the start address of the
* application RAM region (APP_RAM_BASE). On return, this will
* contain the minimum start address of the application RAM region
* required by the SoftDevice for this configuration.
*
* @note The memory requirement for a specific configuration will not increase between SoftDevices
* with the same major version number.
*
* @note The value of *p_app_ram_base when the app has done no custom configuration of the
* SoftDevice, i.e. the app has not called @ref sd_ble_cfg_set before @ref sd_ble_enable, can
* be found in the release notes.
*
* @note At runtime the IC's RAM is split into 2 regions: The SoftDevice RAM region is located
* between 0x20000000 and APP_RAM_BASE-1 and the application's RAM region is located between
* APP_RAM_BASE and the start of the call stack.
*
* @details This call initializes the BLE stack, no BLE related function other than @ref
* sd_ble_cfg_set can be called before this one.
*
* @mscs
* @mmsc{@ref BLE_COMMON_ENABLE}
* @endmscs
*
* @retval ::NRF_SUCCESS The BLE stack has been initialized successfully.
* @retval ::NRF_ERROR_INVALID_STATE The BLE stack had already been initialized and cannot be reinitialized.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied.
* @retval ::NRF_ERROR_NO_MEM The amount of memory assigned to the SoftDevice by *p_app_ram_base is not
* large enough to fit this configuration's memory requirement. Check *p_app_ram_base
* and set the start address of the application RAM region accordingly.
*/
SVCALL(SD_BLE_ENABLE, uint32_t, sd_ble_enable(uint32_t * p_app_ram_base));
/**@brief Add configurations for the BLE stack
*
* @param[in] cfg_id Config ID, see @ref BLE_CONN_CFGS, @ref BLE_COMMON_CFGS, @ref
* BLE_GAP_CFGS or @ref BLE_GATTS_CFGS.
* @param[in] p_cfg Pointer to a ble_cfg_t structure containing the configuration value.
* @param[in] app_ram_base The start address of the application RAM region (APP_RAM_BASE).
* See @ref sd_ble_enable for details about APP_RAM_BASE.
*
* @note The memory requirement for a specific configuration will not increase between SoftDevices
* with the same major version number.
*
* @note If a configuration is set more than once, the last one set is the one that takes effect on
* @ref sd_ble_enable.
*
* @note Any part of the BLE stack that is NOT configured with @ref sd_ble_cfg_set will have default
* configuration.
*
* @note @ref sd_ble_cfg_set may be called at any time when the SoftDevice is enabled (see @ref
* sd_softdevice_enable) while the BLE part of the SoftDevice is not enabled (see @ref
* sd_ble_enable).
*
* @note Error codes for the configurations are described in the configuration structs.
*
* @mscs
* @mmsc{@ref BLE_COMMON_ENABLE}
* @endmscs
*
* @retval ::NRF_SUCCESS The configuration has been added successfully.
* @retval ::NRF_ERROR_INVALID_STATE The BLE stack had already been initialized.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied.
* @retval ::NRF_ERROR_INVALID_PARAM Invalid cfg_id supplied.
* @retval ::NRF_ERROR_NO_MEM The amount of memory assigned to the SoftDevice by app_ram_base is not
* large enough to fit this configuration's memory requirement.
*/
SVCALL(SD_BLE_CFG_SET, uint32_t, sd_ble_cfg_set(uint32_t cfg_id, ble_cfg_t const * p_cfg, uint32_t app_ram_base));
/**@brief Get an event from the pending events queue.
*
* @param[out] p_dest Pointer to buffer to be filled in with an event, or NULL to retrieve the event length.
* This buffer <b>must be aligned to the extend defined by @ref BLE_EVT_PTR_ALIGNMENT</b>.
* The buffer should be interpreted as a @ref ble_evt_t struct.
* @param[in, out] p_len Pointer the length of the buffer, on return it is filled with the event length.
*
* @details This call allows the application to pull a BLE event from the BLE stack. The application is signaled that
* an event is available from the BLE stack by the triggering of the SD_EVT_IRQn interrupt.
* The application is free to choose whether to call this function from thread mode (main context) or directly from the
* Interrupt Service Routine that maps to SD_EVT_IRQn. In any case however, and because the BLE stack runs at a higher
* priority than the application, this function should be called in a loop (until @ref NRF_ERROR_NOT_FOUND is returned)
* every time SD_EVT_IRQn is raised to ensure that all available events are pulled from the BLE stack. Failure to do so
* could potentially leave events in the internal queue without the application being aware of this fact.
*
* Sizing the p_dest buffer is equally important, since the application needs to provide all the memory necessary for the event to
* be copied into application memory. If the buffer provided is not large enough to fit the entire contents of the event,
* @ref NRF_ERROR_DATA_SIZE will be returned and the application can then call again with a larger buffer size.
* The maximum possible event length is defined by @ref BLE_EVT_LEN_MAX. The application may also "peek" the event length
* by providing p_dest as a NULL pointer and inspecting the value of *p_len upon return:
*
* \code
* uint16_t len;
* errcode = sd_ble_evt_get(NULL, &len);
* \endcode
*
* @mscs
* @mmsc{@ref BLE_COMMON_IRQ_EVT_MSC}
* @mmsc{@ref BLE_COMMON_THREAD_EVT_MSC}
* @endmscs
*
* @retval ::NRF_SUCCESS Event pulled and stored into the supplied buffer.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied.
* @retval ::NRF_ERROR_NOT_FOUND No events ready to be pulled.
* @retval ::NRF_ERROR_DATA_SIZE Event ready but could not fit into the supplied buffer.
*/
SVCALL(SD_BLE_EVT_GET, uint32_t, sd_ble_evt_get(uint8_t *p_dest, uint16_t *p_len));
/**@brief Add a Vendor Specific base UUID.
*
* @details This call enables the application to add a vendor specific base UUID to the BLE stack's table, for later
* use with all other modules and APIs. This then allows the application to use the shorter, 24-bit @ref ble_uuid_t
* format when dealing with both 16-bit and 128-bit UUIDs without having to check for lengths and having split code
* paths. This is accomplished by extending the grouping mechanism that the Bluetooth SIG standard base UUID uses
* for all other 128-bit UUIDs. The type field in the @ref ble_uuid_t structure is an index (relative to
* @ref BLE_UUID_TYPE_VENDOR_BEGIN) to the table populated by multiple calls to this function, and the UUID field
* in the same structure contains the 2 bytes at indexes 12 and 13. The number of possible 128-bit UUIDs available to
* the application is therefore the number of Vendor Specific UUIDs added with the help of this function times 65536,
* although restricted to modifying bytes 12 and 13 for each of the entries in the supplied array.
*
* @note Bytes 12 and 13 of the provided UUID will not be used internally, since those are always replaced by
* the 16-bit uuid field in @ref ble_uuid_t.
*
* @note If a UUID is already present in the BLE stack's internal table, the corresponding index will be returned in
* p_uuid_type along with an NRF_SUCCESS error code.
*
* @param[in] p_vs_uuid Pointer to a 16-octet (128-bit) little endian Vendor Specific UUID disregarding
* bytes 12 and 13.
* @param[out] p_uuid_type Pointer to a uint8_t where the type field in @ref ble_uuid_t corresponding to this UUID will be stored.
*
* @retval ::NRF_SUCCESS Successfully added the Vendor Specific UUID.
* @retval ::NRF_ERROR_INVALID_ADDR If p_vs_uuid or p_uuid_type is NULL or invalid.
* @retval ::NRF_ERROR_NO_MEM If there are no more free slots for VS UUIDs.
*/
SVCALL(SD_BLE_UUID_VS_ADD, uint32_t, sd_ble_uuid_vs_add(ble_uuid128_t const *p_vs_uuid, uint8_t *p_uuid_type));
/** @brief Decode little endian raw UUID bytes (16-bit or 128-bit) into a 24 bit @ref ble_uuid_t structure.
*
* @details The raw UUID bytes excluding bytes 12 and 13 (i.e. bytes 0-11 and 14-15) of p_uuid_le are compared
* to the corresponding ones in each entry of the table of vendor specific UUIDs populated with @ref sd_ble_uuid_vs_add
* to look for a match. If there is such a match, bytes 12 and 13 are returned as p_uuid->uuid and the index
* relative to @ref BLE_UUID_TYPE_VENDOR_BEGIN as p_uuid->type.
*
* @note If the UUID length supplied is 2, then the type set by this call will always be @ref BLE_UUID_TYPE_BLE.
*
* @param[in] uuid_le_len Length in bytes of the buffer pointed to by p_uuid_le (must be 2 or 16 bytes).
* @param[in] p_uuid_le Pointer pointing to little endian raw UUID bytes.
* @param[out] p_uuid Pointer to a @ref ble_uuid_t structure to be filled in.
*
* @retval ::NRF_SUCCESS Successfully decoded into the @ref ble_uuid_t structure.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::NRF_ERROR_INVALID_LENGTH Invalid UUID length.
* @retval ::NRF_ERROR_NOT_FOUND For a 128-bit UUID, no match in the populated table of UUIDs.
*/
SVCALL(SD_BLE_UUID_DECODE, uint32_t, sd_ble_uuid_decode(uint8_t uuid_le_len, uint8_t const *p_uuid_le, ble_uuid_t *p_uuid));
/** @brief Encode a @ref ble_uuid_t structure into little endian raw UUID bytes (16-bit or 128-bit).
*
* @note The pointer to the destination buffer p_uuid_le may be NULL, in which case only the validity and size of p_uuid is computed.
*
* @param[in] p_uuid Pointer to a @ref ble_uuid_t structure that will be encoded into bytes.
* @param[out] p_uuid_le_len Pointer to a uint8_t that will be filled with the encoded length (2 or 16 bytes).
* @param[out] p_uuid_le Pointer to a buffer where the little endian raw UUID bytes (2 or 16) will be stored.
*
* @retval ::NRF_SUCCESS Successfully encoded into the buffer.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::NRF_ERROR_INVALID_PARAM Invalid UUID type.
*/
SVCALL(SD_BLE_UUID_ENCODE, uint32_t, sd_ble_uuid_encode(ble_uuid_t const *p_uuid, uint8_t *p_uuid_le_len, uint8_t *p_uuid_le));
/**@brief Get Version Information.
*
* @details This call allows the application to get the BLE stack version information.
*
* @param[out] p_version Pointer to a ble_version_t structure to be filled in.
*
* @retval ::NRF_SUCCESS Version information stored successfully.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::NRF_ERROR_BUSY The BLE stack is busy (typically doing a locally-initiated disconnection procedure).
*/
SVCALL(SD_BLE_VERSION_GET, uint32_t, sd_ble_version_get(ble_version_t *p_version));
/**@brief Provide a user memory block.
*
* @note This call can only be used as a response to a @ref BLE_EVT_USER_MEM_REQUEST event issued to the application.
*
* @param[in] conn_handle Connection handle.
* @param[in] p_block Pointer to a user memory block structure or NULL if memory is managed by the application.
*
* @mscs
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_PEER_CANCEL_MSC}
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_AUTH_MSC}
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_NOAUTH_MSC}
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_BUF_AUTH_MSC}
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_BUF_NOAUTH_MSC}
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_QUEUE_FULL_MSC}
* @endmscs
*
* @retval ::NRF_SUCCESS Successfully queued a response to the peer.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
* @retval ::NRF_ERROR_INVALID_LENGTH Invalid user memory block length supplied.
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection state or no user memory request pending.
*/
SVCALL(SD_BLE_USER_MEM_REPLY, uint32_t, sd_ble_user_mem_reply(uint16_t conn_handle, ble_user_mem_block_t const *p_block));
/**@brief Set a BLE option.
*
* @details This call allows the application to set the value of an option.
*
* @mscs
* @mmsc{@ref BLE_GAP_PERIPH_BONDING_STATIC_PK_MSC}
* @endmscs
*
* @param[in] opt_id Option ID, see @ref BLE_COMMON_OPTS and @ref BLE_GAP_OPTS.
* @param[in] p_opt Pointer to a ble_opt_t structure containing the option value.
*
* @retval ::NRF_SUCCESS Option set successfully.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints.
* @retval ::NRF_ERROR_INVALID_STATE Unable to set the parameter at this time.
* @retval ::NRF_ERROR_BUSY The BLE stack is busy or the previous procedure has not completed.
*/
SVCALL(SD_BLE_OPT_SET, uint32_t, sd_ble_opt_set(uint32_t opt_id, ble_opt_t const *p_opt));
/**@brief Get a BLE option.
*
* @details This call allows the application to retrieve the value of an option.
*
* @param[in] opt_id Option ID, see @ref BLE_COMMON_OPTS and @ref BLE_GAP_OPTS.
* @param[out] p_opt Pointer to a ble_opt_t structure to be filled in.
*
* @retval ::NRF_SUCCESS Option retrieved successfully.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints.
* @retval ::NRF_ERROR_INVALID_STATE Unable to retrieve the parameter at this time.
* @retval ::NRF_ERROR_BUSY The BLE stack is busy or the previous procedure has not completed.
* @retval ::NRF_ERROR_NOT_SUPPORTED This option is not supported.
*
*/
SVCALL(SD_BLE_OPT_GET, uint32_t, sd_ble_opt_get(uint32_t opt_id, ble_opt_t *p_opt));
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* BLE_H__ */
/**
@}
@}
*/

View File

@ -1,91 +0,0 @@
/*
* Copyright (c) 2012 - 2017, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@addtogroup BLE_COMMON
@{
@addtogroup nrf_error
@{
@ingroup BLE_COMMON
@}
@defgroup ble_err General error codes
@{
@brief General error code definitions for the BLE API.
@ingroup BLE_COMMON
*/
#ifndef NRF_BLE_ERR_H__
#define NRF_BLE_ERR_H__
#include "nrf_error.h"
#ifdef __cplusplus
extern "C" {
#endif
/* @defgroup BLE_ERRORS Error Codes
* @{ */
#define BLE_ERROR_NOT_ENABLED (NRF_ERROR_STK_BASE_NUM+0x001) /**< @ref sd_ble_enable has not been called. */
#define BLE_ERROR_INVALID_CONN_HANDLE (NRF_ERROR_STK_BASE_NUM+0x002) /**< Invalid connection handle. */
#define BLE_ERROR_INVALID_ATTR_HANDLE (NRF_ERROR_STK_BASE_NUM+0x003) /**< Invalid attribute handle. */
#define BLE_ERROR_INVALID_ROLE (NRF_ERROR_STK_BASE_NUM+0x004) /**< Invalid role. */
/** @} */
/** @defgroup BLE_ERROR_SUBRANGES Module specific error code subranges
* @brief Assignment of subranges for module specific error codes.
* @note For specific error codes, see ble_<module>.h or ble_error_<module>.h.
* @{ */
#define NRF_L2CAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x100) /**< L2CAP specific errors. */
#define NRF_GAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x200) /**< GAP specific errors. */
#define NRF_GATTC_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x300) /**< GATT client specific errors. */
#define NRF_GATTS_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x400) /**< GATT server specific errors. */
/** @} */
#ifdef __cplusplus
}
#endif
#endif
/**
@}
@}
*/

View File

@ -1,223 +0,0 @@
/*
* Copyright (c) 2013 - 2017, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@addtogroup BLE_GATT Generic Attribute Profile (GATT) Common
@{
@brief Common definitions and prototypes for the GATT interfaces.
*/
#ifndef BLE_GATT_H__
#define BLE_GATT_H__
#include "ble_types.h"
#include "ble_ranges.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup BLE_GATT_DEFINES Defines
* @{ */
/** @brief Default ATT MTU, in bytes. */
#define BLE_GATT_ATT_MTU_DEFAULT 23
/**@brief Invalid Attribute Handle. */
#define BLE_GATT_HANDLE_INVALID 0x0000
/**@brief First Attribute Handle. */
#define BLE_GATT_HANDLE_START 0x0001
/**@brief Last Attribute Handle. */
#define BLE_GATT_HANDLE_END 0xFFFF
/** @defgroup BLE_GATT_TIMEOUT_SOURCES GATT Timeout sources
* @{ */
#define BLE_GATT_TIMEOUT_SRC_PROTOCOL 0x00 /**< ATT Protocol timeout. */
/** @} */
/** @defgroup BLE_GATT_WRITE_OPS GATT Write operations
* @{ */
#define BLE_GATT_OP_INVALID 0x00 /**< Invalid Operation. */
#define BLE_GATT_OP_WRITE_REQ 0x01 /**< Write Request. */
#define BLE_GATT_OP_WRITE_CMD 0x02 /**< Write Command. */
#define BLE_GATT_OP_SIGN_WRITE_CMD 0x03 /**< Signed Write Command. */
#define BLE_GATT_OP_PREP_WRITE_REQ 0x04 /**< Prepare Write Request. */
#define BLE_GATT_OP_EXEC_WRITE_REQ 0x05 /**< Execute Write Request. */
/** @} */
/** @defgroup BLE_GATT_EXEC_WRITE_FLAGS GATT Execute Write flags
* @{ */
#define BLE_GATT_EXEC_WRITE_FLAG_PREPARED_CANCEL 0x00 /**< Cancel prepared write. */
#define BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE 0x01 /**< Execute prepared write. */
/** @} */
/** @defgroup BLE_GATT_HVX_TYPES GATT Handle Value operations
* @{ */
#define BLE_GATT_HVX_INVALID 0x00 /**< Invalid Operation. */
#define BLE_GATT_HVX_NOTIFICATION 0x01 /**< Handle Value Notification. */
#define BLE_GATT_HVX_INDICATION 0x02 /**< Handle Value Indication. */
/** @} */
/** @defgroup BLE_GATT_STATUS_CODES GATT Status Codes
* @{ */
#define BLE_GATT_STATUS_SUCCESS 0x0000 /**< Success. */
#define BLE_GATT_STATUS_UNKNOWN 0x0001 /**< Unknown or not applicable status. */
#define BLE_GATT_STATUS_ATTERR_INVALID 0x0100 /**< ATT Error: Invalid Error Code. */
#define BLE_GATT_STATUS_ATTERR_INVALID_HANDLE 0x0101 /**< ATT Error: Invalid Attribute Handle. */
#define BLE_GATT_STATUS_ATTERR_READ_NOT_PERMITTED 0x0102 /**< ATT Error: Read not permitted. */
#define BLE_GATT_STATUS_ATTERR_WRITE_NOT_PERMITTED 0x0103 /**< ATT Error: Write not permitted. */
#define BLE_GATT_STATUS_ATTERR_INVALID_PDU 0x0104 /**< ATT Error: Used in ATT as Invalid PDU. */
#define BLE_GATT_STATUS_ATTERR_INSUF_AUTHENTICATION 0x0105 /**< ATT Error: Authenticated link required. */
#define BLE_GATT_STATUS_ATTERR_REQUEST_NOT_SUPPORTED 0x0106 /**< ATT Error: Used in ATT as Request Not Supported. */
#define BLE_GATT_STATUS_ATTERR_INVALID_OFFSET 0x0107 /**< ATT Error: Offset specified was past the end of the attribute. */
#define BLE_GATT_STATUS_ATTERR_INSUF_AUTHORIZATION 0x0108 /**< ATT Error: Used in ATT as Insufficient Authorization. */
#define BLE_GATT_STATUS_ATTERR_PREPARE_QUEUE_FULL 0x0109 /**< ATT Error: Used in ATT as Prepare Queue Full. */
#define BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND 0x010A /**< ATT Error: Used in ATT as Attribute not found. */
#define BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_LONG 0x010B /**< ATT Error: Attribute cannot be read or written using read/write blob requests. */
#define BLE_GATT_STATUS_ATTERR_INSUF_ENC_KEY_SIZE 0x010C /**< ATT Error: Encryption key size used is insufficient. */
#define BLE_GATT_STATUS_ATTERR_INVALID_ATT_VAL_LENGTH 0x010D /**< ATT Error: Invalid value size. */
#define BLE_GATT_STATUS_ATTERR_UNLIKELY_ERROR 0x010E /**< ATT Error: Very unlikely error. */
#define BLE_GATT_STATUS_ATTERR_INSUF_ENCRYPTION 0x010F /**< ATT Error: Encrypted link required. */
#define BLE_GATT_STATUS_ATTERR_UNSUPPORTED_GROUP_TYPE 0x0110 /**< ATT Error: Attribute type is not a supported grouping attribute. */
#define BLE_GATT_STATUS_ATTERR_INSUF_RESOURCES 0x0111 /**< ATT Error: Encrypted link required. */
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_BEGIN 0x0112 /**< ATT Error: Reserved for Future Use range #1 begin. */
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_END 0x017F /**< ATT Error: Reserved for Future Use range #1 end. */
#define BLE_GATT_STATUS_ATTERR_APP_BEGIN 0x0180 /**< ATT Error: Application range begin. */
#define BLE_GATT_STATUS_ATTERR_APP_END 0x019F /**< ATT Error: Application range end. */
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE2_BEGIN 0x01A0 /**< ATT Error: Reserved for Future Use range #2 begin. */
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE2_END 0x01DF /**< ATT Error: Reserved for Future Use range #2 end. */
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE3_BEGIN 0x01E0 /**< ATT Error: Reserved for Future Use range #3 begin. */
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE3_END 0x01FC /**< ATT Error: Reserved for Future Use range #3 end. */
#define BLE_GATT_STATUS_ATTERR_CPS_CCCD_CONFIG_ERROR 0x01FD /**< ATT Common Profile and Service Error: Client Characteristic Configuration Descriptor improperly configured. */
#define BLE_GATT_STATUS_ATTERR_CPS_PROC_ALR_IN_PROG 0x01FE /**< ATT Common Profile and Service Error: Procedure Already in Progress. */
#define BLE_GATT_STATUS_ATTERR_CPS_OUT_OF_RANGE 0x01FF /**< ATT Common Profile and Service Error: Out Of Range. */
/** @} */
/** @defgroup BLE_GATT_CPF_FORMATS Characteristic Presentation Formats
* @note Found at http://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorViewer.aspx?u=org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml
* @{ */
#define BLE_GATT_CPF_FORMAT_RFU 0x00 /**< Reserved For Future Use. */
#define BLE_GATT_CPF_FORMAT_BOOLEAN 0x01 /**< Boolean. */
#define BLE_GATT_CPF_FORMAT_2BIT 0x02 /**< Unsigned 2-bit integer. */
#define BLE_GATT_CPF_FORMAT_NIBBLE 0x03 /**< Unsigned 4-bit integer. */
#define BLE_GATT_CPF_FORMAT_UINT8 0x04 /**< Unsigned 8-bit integer. */
#define BLE_GATT_CPF_FORMAT_UINT12 0x05 /**< Unsigned 12-bit integer. */
#define BLE_GATT_CPF_FORMAT_UINT16 0x06 /**< Unsigned 16-bit integer. */
#define BLE_GATT_CPF_FORMAT_UINT24 0x07 /**< Unsigned 24-bit integer. */
#define BLE_GATT_CPF_FORMAT_UINT32 0x08 /**< Unsigned 32-bit integer. */
#define BLE_GATT_CPF_FORMAT_UINT48 0x09 /**< Unsigned 48-bit integer. */
#define BLE_GATT_CPF_FORMAT_UINT64 0x0A /**< Unsigned 64-bit integer. */
#define BLE_GATT_CPF_FORMAT_UINT128 0x0B /**< Unsigned 128-bit integer. */
#define BLE_GATT_CPF_FORMAT_SINT8 0x0C /**< Signed 2-bit integer. */
#define BLE_GATT_CPF_FORMAT_SINT12 0x0D /**< Signed 12-bit integer. */
#define BLE_GATT_CPF_FORMAT_SINT16 0x0E /**< Signed 16-bit integer. */
#define BLE_GATT_CPF_FORMAT_SINT24 0x0F /**< Signed 24-bit integer. */
#define BLE_GATT_CPF_FORMAT_SINT32 0x10 /**< Signed 32-bit integer. */
#define BLE_GATT_CPF_FORMAT_SINT48 0x11 /**< Signed 48-bit integer. */
#define BLE_GATT_CPF_FORMAT_SINT64 0x12 /**< Signed 64-bit integer. */
#define BLE_GATT_CPF_FORMAT_SINT128 0x13 /**< Signed 128-bit integer. */
#define BLE_GATT_CPF_FORMAT_FLOAT32 0x14 /**< IEEE-754 32-bit floating point. */
#define BLE_GATT_CPF_FORMAT_FLOAT64 0x15 /**< IEEE-754 64-bit floating point. */
#define BLE_GATT_CPF_FORMAT_SFLOAT 0x16 /**< IEEE-11073 16-bit SFLOAT. */
#define BLE_GATT_CPF_FORMAT_FLOAT 0x17 /**< IEEE-11073 32-bit FLOAT. */
#define BLE_GATT_CPF_FORMAT_DUINT16 0x18 /**< IEEE-20601 format. */
#define BLE_GATT_CPF_FORMAT_UTF8S 0x19 /**< UTF-8 string. */
#define BLE_GATT_CPF_FORMAT_UTF16S 0x1A /**< UTF-16 string. */
#define BLE_GATT_CPF_FORMAT_STRUCT 0x1B /**< Opaque Structure. */
/** @} */
/** @defgroup BLE_GATT_CPF_NAMESPACES GATT Bluetooth Namespaces
* @{
*/
#define BLE_GATT_CPF_NAMESPACE_BTSIG 0x01 /**< Bluetooth SIG defined Namespace. */
#define BLE_GATT_CPF_NAMESPACE_DESCRIPTION_UNKNOWN 0x0000 /**< Namespace Description Unknown. */
/** @} */
/** @} */
/** @addtogroup BLE_GATT_STRUCTURES Structures
* @{ */
/**
* @brief BLE GATT connection configuration parameters, set with @ref sd_ble_cfg_set.
*
* @retval NRF_ERROR_INVALID_PARAM att_mtu is smaller than @ref BLE_GATT_ATT_MTU_DEFAULT.
*/
typedef struct
{
uint16_t att_mtu; /**< Maximum size of ATT packet the SoftDevice can send or receive.
The default and minimum value is @ref BLE_GATT_ATT_MTU_DEFAULT.
@mscs
@mmsc{@ref BLE_GATTC_MTU_EXCHANGE}
@mmsc{@ref BLE_GATTS_MTU_EXCHANGE}
@endmscs
*/
} ble_gatt_conn_cfg_t;
/**@brief GATT Characteristic Properties. */
typedef struct
{
/* Standard properties */
uint8_t broadcast :1; /**< Broadcasting of the value permitted. */
uint8_t read :1; /**< Reading the value permitted. */
uint8_t write_wo_resp :1; /**< Writing the value with Write Command permitted. */
uint8_t write :1; /**< Writing the value with Write Request permitted. */
uint8_t notify :1; /**< Notification of the value permitted. */
uint8_t indicate :1; /**< Indications of the value permitted. */
uint8_t auth_signed_wr :1; /**< Writing the value with Signed Write Command permitted. */
} ble_gatt_char_props_t;
/**@brief GATT Characteristic Extended Properties. */
typedef struct
{
/* Extended properties */
uint8_t reliable_wr :1; /**< Writing the value with Queued Write operations permitted. */
uint8_t wr_aux :1; /**< Writing the Characteristic User Description descriptor permitted. */
} ble_gatt_char_ext_props_t;
/** @} */
#ifdef __cplusplus
}
#endif
#endif // BLE_GATT_H__
/** @} */

View File

@ -1,702 +0,0 @@
/*
* Copyright (c) 2011 - 2017, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@addtogroup BLE_GATTC Generic Attribute Profile (GATT) Client
@{
@brief Definitions and prototypes for the GATT Client interface.
*/
#ifndef BLE_GATTC_H__
#define BLE_GATTC_H__
#include "ble_gatt.h"
#include "ble_types.h"
#include "ble_ranges.h"
#include "nrf_svc.h"
#include "nrf_error.h"
#include "nrf.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup BLE_GATTC_ENUMERATIONS Enumerations
* @{ */
/**@brief GATTC API SVC numbers. */
enum BLE_GATTC_SVCS
{
SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER = BLE_GATTC_SVC_BASE, /**< Primary Service Discovery. */
SD_BLE_GATTC_RELATIONSHIPS_DISCOVER, /**< Relationship Discovery. */
SD_BLE_GATTC_CHARACTERISTICS_DISCOVER, /**< Characteristic Discovery. */
SD_BLE_GATTC_DESCRIPTORS_DISCOVER, /**< Characteristic Descriptor Discovery. */
SD_BLE_GATTC_ATTR_INFO_DISCOVER, /**< Attribute Information Discovery. */
SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ, /**< Read Characteristic Value by UUID. */
SD_BLE_GATTC_READ, /**< Generic read. */
SD_BLE_GATTC_CHAR_VALUES_READ, /**< Read multiple Characteristic Values. */
SD_BLE_GATTC_WRITE, /**< Generic write. */
SD_BLE_GATTC_HV_CONFIRM, /**< Handle Value Confirmation. */
SD_BLE_GATTC_EXCHANGE_MTU_REQUEST, /**< Exchange MTU Request. */
};
/**
* @brief GATT Client Event IDs.
*/
enum BLE_GATTC_EVTS
{
BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP = BLE_GATTC_EVT_BASE, /**< Primary Service Discovery Response event. \n See @ref ble_gattc_evt_prim_srvc_disc_rsp_t. */
BLE_GATTC_EVT_REL_DISC_RSP, /**< Relationship Discovery Response event. \n See @ref ble_gattc_evt_rel_disc_rsp_t. */
BLE_GATTC_EVT_CHAR_DISC_RSP, /**< Characteristic Discovery Response event. \n See @ref ble_gattc_evt_char_disc_rsp_t. */
BLE_GATTC_EVT_DESC_DISC_RSP, /**< Descriptor Discovery Response event. \n See @ref ble_gattc_evt_desc_disc_rsp_t. */
BLE_GATTC_EVT_ATTR_INFO_DISC_RSP, /**< Attribute Information Response event. \n See @ref ble_gattc_evt_attr_info_disc_rsp_t. */
BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP, /**< Read By UUID Response event. \n See @ref ble_gattc_evt_char_val_by_uuid_read_rsp_t. */
BLE_GATTC_EVT_READ_RSP, /**< Read Response event. \n See @ref ble_gattc_evt_read_rsp_t. */
BLE_GATTC_EVT_CHAR_VALS_READ_RSP, /**< Read multiple Response event. \n See @ref ble_gattc_evt_char_vals_read_rsp_t. */
BLE_GATTC_EVT_WRITE_RSP, /**< Write Response event. \n See @ref ble_gattc_evt_write_rsp_t. */
BLE_GATTC_EVT_HVX, /**< Handle Value Notification or Indication event. \n Confirm indication with @ref sd_ble_gattc_hv_confirm. \n See @ref ble_gattc_evt_hvx_t. */
BLE_GATTC_EVT_EXCHANGE_MTU_RSP, /**< Exchange MTU Response event. \n See @ref ble_gattc_evt_exchange_mtu_rsp_t. */
BLE_GATTC_EVT_TIMEOUT, /**< Timeout event. \n See @ref ble_gattc_evt_timeout_t. */
BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE /**< Write without Response transmission complete. \n See @ref ble_gattc_evt_write_cmd_tx_complete_t. */
};
/** @} */
/** @addtogroup BLE_GATTC_DEFINES Defines
* @{ */
/** @defgroup BLE_ERRORS_GATTC SVC return values specific to GATTC
* @{ */
#define BLE_ERROR_GATTC_PROC_NOT_PERMITTED (NRF_GATTC_ERR_BASE + 0x000) /**< Procedure not Permitted. */
/** @} */
/** @defgroup BLE_GATTC_ATTR_INFO_FORMAT Attribute Information Formats
* @{ */
#define BLE_GATTC_ATTR_INFO_FORMAT_16BIT 1 /**< 16-bit Attribute Information Format. */
#define BLE_GATTC_ATTR_INFO_FORMAT_128BIT 2 /**< 128-bit Attribute Information Format. */
/** @} */
/** @defgroup BLE_GATTC_DEFAULTS GATT Client defaults
* @{ */
#define BLE_GATTC_WRITE_CMD_TX_QUEUE_SIZE_DEFAULT 1 /**< Default number of Write without Response that can be queued for transmission. */
/** @} */
/** @} */
/** @addtogroup BLE_GATTC_STRUCTURES Structures
* @{ */
/**
* @brief BLE GATTC connection configuration parameters, set with @ref sd_ble_cfg_set.
*/
typedef struct
{
uint8_t write_cmd_tx_queue_size; /**< The guaranteed minimum number of Write without Response that can be queued for transmission.
The default value is @ref BLE_GATTC_WRITE_CMD_TX_QUEUE_SIZE_DEFAULT */
} ble_gattc_conn_cfg_t;
/**@brief Operation Handle Range. */
typedef struct
{
uint16_t start_handle; /**< Start Handle. */
uint16_t end_handle; /**< End Handle. */
} ble_gattc_handle_range_t;
/**@brief GATT service. */
typedef struct
{
ble_uuid_t uuid; /**< Service UUID. */
ble_gattc_handle_range_t handle_range; /**< Service Handle Range. */
} ble_gattc_service_t;
/**@brief GATT include. */
typedef struct
{
uint16_t handle; /**< Include Handle. */
ble_gattc_service_t included_srvc; /**< Handle of the included service. */
} ble_gattc_include_t;
/**@brief GATT characteristic. */
typedef struct
{
ble_uuid_t uuid; /**< Characteristic UUID. */
ble_gatt_char_props_t char_props; /**< Characteristic Properties. */
uint8_t char_ext_props : 1; /**< Extended properties present. */
uint16_t handle_decl; /**< Handle of the Characteristic Declaration. */
uint16_t handle_value; /**< Handle of the Characteristic Value. */
} ble_gattc_char_t;
/**@brief GATT descriptor. */
typedef struct
{
uint16_t handle; /**< Descriptor Handle. */
ble_uuid_t uuid; /**< Descriptor UUID. */
} ble_gattc_desc_t;
/**@brief Write Parameters. */
typedef struct
{
uint8_t write_op; /**< Write Operation to be performed, see @ref BLE_GATT_WRITE_OPS. */
uint8_t flags; /**< Flags, see @ref BLE_GATT_EXEC_WRITE_FLAGS. */
uint16_t handle; /**< Handle to the attribute to be written. */
uint16_t offset; /**< Offset in bytes. @note For WRITE_CMD and WRITE_REQ, offset must be 0. */
uint16_t len; /**< Length of data in bytes. */
uint8_t const *p_value; /**< Pointer to the value data. */
} ble_gattc_write_params_t;
/**@brief Attribute Information for 16-bit Attribute UUID. */
typedef struct
{
uint16_t handle; /**< Attribute handle. */
ble_uuid_t uuid; /**< 16-bit Attribute UUID. */
} ble_gattc_attr_info16_t;
/**@brief Attribute Information for 128-bit Attribute UUID. */
typedef struct
{
uint16_t handle; /**< Attribute handle. */
ble_uuid128_t uuid; /**< 128-bit Attribute UUID. */
} ble_gattc_attr_info128_t;
/**@brief Event structure for @ref BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP. */
typedef struct
{
uint16_t count; /**< Service count. */
ble_gattc_service_t services[1]; /**< Service data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
} ble_gattc_evt_prim_srvc_disc_rsp_t;
/**@brief Event structure for @ref BLE_GATTC_EVT_REL_DISC_RSP. */
typedef struct
{
uint16_t count; /**< Include count. */
ble_gattc_include_t includes[1]; /**< Include data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
} ble_gattc_evt_rel_disc_rsp_t;
/**@brief Event structure for @ref BLE_GATTC_EVT_CHAR_DISC_RSP. */
typedef struct
{
uint16_t count; /**< Characteristic count. */
ble_gattc_char_t chars[1]; /**< Characteristic data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
} ble_gattc_evt_char_disc_rsp_t;
/**@brief Event structure for @ref BLE_GATTC_EVT_DESC_DISC_RSP. */
typedef struct
{
uint16_t count; /**< Descriptor count. */
ble_gattc_desc_t descs[1]; /**< Descriptor data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
} ble_gattc_evt_desc_disc_rsp_t;
/**@brief Event structure for @ref BLE_GATTC_EVT_ATTR_INFO_DISC_RSP. */
typedef struct
{
uint16_t count; /**< Attribute count. */
uint8_t format; /**< Attribute information format, see @ref BLE_GATTC_ATTR_INFO_FORMAT. */
union {
ble_gattc_attr_info16_t attr_info16[1]; /**< Attribute information for 16-bit Attribute UUID.
@note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
ble_gattc_attr_info128_t attr_info128[1]; /**< Attribute information for 128-bit Attribute UUID.
@note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
} info; /**< Attribute information union. */
} ble_gattc_evt_attr_info_disc_rsp_t;
/**@brief GATT read by UUID handle value pair. */
typedef struct
{
uint16_t handle; /**< Attribute Handle. */
uint8_t *p_value; /**< Pointer to the Attribute Value, length is available in @ref ble_gattc_evt_char_val_by_uuid_read_rsp_t::value_len. */
} ble_gattc_handle_value_t;
/**@brief Event structure for @ref BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP. */
typedef struct
{
uint16_t count; /**< Handle-Value Pair Count. */
uint16_t value_len; /**< Length of the value in Handle-Value(s) list. */
uint8_t handle_value[1]; /**< Handle-Value(s) list. To iterate through the list use @ref sd_ble_gattc_evt_char_val_by_uuid_read_rsp_iter.
@note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
} ble_gattc_evt_char_val_by_uuid_read_rsp_t;
/**@brief Event structure for @ref BLE_GATTC_EVT_READ_RSP. */
typedef struct
{
uint16_t handle; /**< Attribute Handle. */
uint16_t offset; /**< Offset of the attribute data. */
uint16_t len; /**< Attribute data length. */
uint8_t data[1]; /**< Attribute data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
} ble_gattc_evt_read_rsp_t;
/**@brief Event structure for @ref BLE_GATTC_EVT_CHAR_VALS_READ_RSP. */
typedef struct
{
uint16_t len; /**< Concatenated Attribute values length. */
uint8_t values[1]; /**< Attribute values. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
} ble_gattc_evt_char_vals_read_rsp_t;
/**@brief Event structure for @ref BLE_GATTC_EVT_WRITE_RSP. */
typedef struct
{
uint16_t handle; /**< Attribute Handle. */
uint8_t write_op; /**< Type of write operation, see @ref BLE_GATT_WRITE_OPS. */
uint16_t offset; /**< Data offset. */
uint16_t len; /**< Data length. */
uint8_t data[1]; /**< Data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
} ble_gattc_evt_write_rsp_t;
/**@brief Event structure for @ref BLE_GATTC_EVT_HVX. */
typedef struct
{
uint16_t handle; /**< Handle to which the HVx operation applies. */
uint8_t type; /**< Indication or Notification, see @ref BLE_GATT_HVX_TYPES. */
uint16_t len; /**< Attribute data length. */
uint8_t data[1]; /**< Attribute data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
} ble_gattc_evt_hvx_t;
/**@brief Event structure for @ref BLE_GATTC_EVT_EXCHANGE_MTU_RSP. */
typedef struct
{
uint16_t server_rx_mtu; /**< Server RX MTU size. */
} ble_gattc_evt_exchange_mtu_rsp_t;
/**@brief Event structure for @ref BLE_GATTC_EVT_TIMEOUT. */
typedef struct
{
uint8_t src; /**< Timeout source, see @ref BLE_GATT_TIMEOUT_SOURCES. */
} ble_gattc_evt_timeout_t;
/**@brief Event structure for @ref BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE. */
typedef struct
{
uint8_t count; /**< Number of write without response transmissions completed. */
} ble_gattc_evt_write_cmd_tx_complete_t;
/**@brief GATTC event structure. */
typedef struct
{
uint16_t conn_handle; /**< Connection Handle on which event occurred. */
uint16_t gatt_status; /**< GATT status code for the operation, see @ref BLE_GATT_STATUS_CODES. */
uint16_t error_handle; /**< In case of error: The handle causing the error. In all other cases @ref BLE_GATT_HANDLE_INVALID. */
union
{
ble_gattc_evt_prim_srvc_disc_rsp_t prim_srvc_disc_rsp; /**< Primary Service Discovery Response Event Parameters. */
ble_gattc_evt_rel_disc_rsp_t rel_disc_rsp; /**< Relationship Discovery Response Event Parameters. */
ble_gattc_evt_char_disc_rsp_t char_disc_rsp; /**< Characteristic Discovery Response Event Parameters. */
ble_gattc_evt_desc_disc_rsp_t desc_disc_rsp; /**< Descriptor Discovery Response Event Parameters. */
ble_gattc_evt_char_val_by_uuid_read_rsp_t char_val_by_uuid_read_rsp; /**< Characteristic Value Read by UUID Response Event Parameters. */
ble_gattc_evt_read_rsp_t read_rsp; /**< Read Response Event Parameters. */
ble_gattc_evt_char_vals_read_rsp_t char_vals_read_rsp; /**< Characteristic Values Read Response Event Parameters. */
ble_gattc_evt_write_rsp_t write_rsp; /**< Write Response Event Parameters. */
ble_gattc_evt_hvx_t hvx; /**< Handle Value Notification/Indication Event Parameters. */
ble_gattc_evt_exchange_mtu_rsp_t exchange_mtu_rsp; /**< Exchange MTU Response Event Parameters. */
ble_gattc_evt_timeout_t timeout; /**< Timeout Event Parameters. */
ble_gattc_evt_attr_info_disc_rsp_t attr_info_disc_rsp; /**< Attribute Information Discovery Event Parameters. */
ble_gattc_evt_write_cmd_tx_complete_t write_cmd_tx_complete; /**< Write without Response transmission complete Event Parameters. */
} params; /**< Event Parameters. @note Only valid if @ref gatt_status == @ref BLE_GATT_STATUS_SUCCESS. */
} ble_gattc_evt_t;
/** @} */
/** @addtogroup BLE_GATTC_FUNCTIONS Functions
* @{ */
/**@brief Initiate or continue a GATT Primary Service Discovery procedure.
*
* @details This function initiates or resumes a Primary Service discovery procedure, starting from the supplied handle.
* If the last service has not been reached, this function must be called again with an updated start handle value to continue the search.
*
* @note If any of the discovered services have 128-bit UUIDs which are not present in the table provided to ble_vs_uuids_assign, a UUID structure with
* type @ref BLE_UUID_TYPE_UNKNOWN will be received in the corresponding event.
*
* @events
* @event{@ref BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP}
* @endevents
*
* @mscs
* @mmsc{@ref BLE_GATTC_PRIM_SRVC_DISC_MSC}
* @endmscs
*
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
* @param[in] start_handle Handle to start searching from.
* @param[in] p_srvc_uuid Pointer to the service UUID to be found. If it is NULL, all primary services will be returned.
*
* @retval ::NRF_SUCCESS Successfully started or resumed the Primary Service Discovery procedure.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
*/
SVCALL(SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER, uint32_t, sd_ble_gattc_primary_services_discover(uint16_t conn_handle, uint16_t start_handle, ble_uuid_t const *p_srvc_uuid));
/**@brief Initiate or continue a GATT Relationship Discovery procedure.
*
* @details This function initiates or resumes the Find Included Services sub-procedure. If the last included service has not been reached,
* this must be called again with an updated handle range to continue the search.
*
* @events
* @event{@ref BLE_GATTC_EVT_REL_DISC_RSP}
* @endevents
*
* @mscs
* @mmsc{@ref BLE_GATTC_REL_DISC_MSC}
* @endmscs
*
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
* @param[in] p_handle_range A pointer to the range of handles of the Service to perform this procedure on.
*
* @retval ::NRF_SUCCESS Successfully started or resumed the Relationship Discovery procedure.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
*/
SVCALL(SD_BLE_GATTC_RELATIONSHIPS_DISCOVER, uint32_t, sd_ble_gattc_relationships_discover(uint16_t conn_handle, ble_gattc_handle_range_t const *p_handle_range));
/**@brief Initiate or continue a GATT Characteristic Discovery procedure.
*
* @details This function initiates or resumes a Characteristic discovery procedure. If the last Characteristic has not been reached,
* this must be called again with an updated handle range to continue the discovery.
*
* @note If any of the discovered characteristics have 128-bit UUIDs which are not present in the table provided to ble_vs_uuids_assign, a UUID structure with
* type @ref BLE_UUID_TYPE_UNKNOWN will be received in the corresponding event.
*
* @events
* @event{@ref BLE_GATTC_EVT_CHAR_DISC_RSP}
* @endevents
*
* @mscs
* @mmsc{@ref BLE_GATTC_CHAR_DISC_MSC}
* @endmscs
*
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
* @param[in] p_handle_range A pointer to the range of handles of the Service to perform this procedure on.
*
* @retval ::NRF_SUCCESS Successfully started or resumed the Characteristic Discovery procedure.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
*/
SVCALL(SD_BLE_GATTC_CHARACTERISTICS_DISCOVER, uint32_t, sd_ble_gattc_characteristics_discover(uint16_t conn_handle, ble_gattc_handle_range_t const *p_handle_range));
/**@brief Initiate or continue a GATT Characteristic Descriptor Discovery procedure.
*
* @details This function initiates or resumes a Characteristic Descriptor discovery procedure. If the last Descriptor has not been reached,
* this must be called again with an updated handle range to continue the discovery.
*
* @events
* @event{@ref BLE_GATTC_EVT_DESC_DISC_RSP}
* @endevents
*
* @mscs
* @mmsc{@ref BLE_GATTC_DESC_DISC_MSC}
* @endmscs
*
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
* @param[in] p_handle_range A pointer to the range of handles of the Characteristic to perform this procedure on.
*
* @retval ::NRF_SUCCESS Successfully started or resumed the Descriptor Discovery procedure.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
*/
SVCALL(SD_BLE_GATTC_DESCRIPTORS_DISCOVER, uint32_t, sd_ble_gattc_descriptors_discover(uint16_t conn_handle, ble_gattc_handle_range_t const *p_handle_range));
/**@brief Initiate or continue a GATT Read using Characteristic UUID procedure.
*
* @details This function initiates or resumes a Read using Characteristic UUID procedure. If the last Characteristic has not been reached,
* this must be called again with an updated handle range to continue the discovery.
*
* @events
* @event{@ref BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP}
* @endevents
*
* @mscs
* @mmsc{@ref BLE_GATTC_READ_UUID_MSC}
* @endmscs
*
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
* @param[in] p_uuid Pointer to a Characteristic value UUID to read.
* @param[in] p_handle_range A pointer to the range of handles to perform this procedure on.
*
* @retval ::NRF_SUCCESS Successfully started or resumed the Read using Characteristic UUID procedure.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
*/
SVCALL(SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ, uint32_t, sd_ble_gattc_char_value_by_uuid_read(uint16_t conn_handle, ble_uuid_t const *p_uuid, ble_gattc_handle_range_t const *p_handle_range));
/**@brief Initiate or continue a GATT Read (Long) Characteristic or Descriptor procedure.
*
* @details This function initiates or resumes a GATT Read (Long) Characteristic or Descriptor procedure. If the Characteristic or Descriptor
* to be read is longer than ATT_MTU - 1, this function must be called multiple times with appropriate offset to read the
* complete value.
*
* @events
* @event{@ref BLE_GATTC_EVT_READ_RSP}
* @endevents
*
* @mscs
* @mmsc{@ref BLE_GATTC_VALUE_READ_MSC}
* @endmscs
*
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
* @param[in] handle The handle of the attribute to be read.
* @param[in] offset Offset into the attribute value to be read.
*
* @retval ::NRF_SUCCESS Successfully started or resumed the Read (Long) procedure.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
*/
SVCALL(SD_BLE_GATTC_READ, uint32_t, sd_ble_gattc_read(uint16_t conn_handle, uint16_t handle, uint16_t offset));
/**@brief Initiate a GATT Read Multiple Characteristic Values procedure.
*
* @details This function initiates a GATT Read Multiple Characteristic Values procedure.
*
* @events
* @event{@ref BLE_GATTC_EVT_CHAR_VALS_READ_RSP}
* @endevents
*
* @mscs
* @mmsc{@ref BLE_GATTC_READ_MULT_MSC}
* @endmscs
*
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
* @param[in] p_handles A pointer to the handle(s) of the attribute(s) to be read.
* @param[in] handle_count The number of handles in p_handles.
*
* @retval ::NRF_SUCCESS Successfully started the Read Multiple Characteristic Values procedure.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
*/
SVCALL(SD_BLE_GATTC_CHAR_VALUES_READ, uint32_t, sd_ble_gattc_char_values_read(uint16_t conn_handle, uint16_t const *p_handles, uint16_t handle_count));
/**@brief Perform a Write (Characteristic Value or Descriptor, with or without response, signed or not, long or reliable) procedure.
*
* @details This function can perform all write procedures described in GATT.
*
* @note Only one write with response procedure can be ongoing per connection at a time.
* If the application tries to write with response while another write with response procedure is ongoing,
* the function call will return @ref NRF_ERROR_BUSY.
* A @ref BLE_GATTC_EVT_WRITE_RSP event will be issued as soon as the write response arrives from the peer.
*
* @note The number of Write without Response that can be queued is configured by @ref ble_gattc_conn_cfg_t::write_cmd_tx_queue_size
* When the queue is full, the function call will return @ref NRF_ERROR_RESOURCES.
* A @ref BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE event will be issued as soon as the transmission of the write without response is complete.
*
* @note The application can keep track of the available queue element count for writes without responses by following the procedure below:
* - Store initial queue element count in a variable.
* - Decrement the variable, which stores the currently available queue element count, by one when a call to this function returns @ref NRF_SUCCESS.
* - Increment the variable, which stores the current available queue element count, by the count variable in @ref BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE event.
*
* @events
* @event{@ref BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE, Write without response transmission complete.}
* @event{@ref BLE_GATTC_EVT_WRITE_RSP, Write response received from the peer.}
* @endevents
*
* @mscs
* @mmsc{@ref BLE_GATTC_VALUE_WRITE_WITHOUT_RESP_MSC}
* @mmsc{@ref BLE_GATTC_VALUE_WRITE_MSC}
* @mmsc{@ref BLE_GATTC_VALUE_LONG_WRITE_MSC}
* @mmsc{@ref BLE_GATTC_VALUE_RELIABLE_WRITE_MSC}
* @endmscs
*
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
* @param[in] p_write_params A pointer to a write parameters structure.
*
* @retval ::NRF_SUCCESS Successfully started the Write procedure.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
* @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied.
* @retval ::NRF_ERROR_BUSY For write with response, procedure already in progress. Wait for a @ref BLE_GATTC_EVT_WRITE_RSP event and retry.
* @retval ::NRF_ERROR_RESOURCES Too many writes without responses queued.
* Wait for a @ref BLE_GATTC_EVT_WRITE_CMD_TX_COMPLETE event and retry.
*/
SVCALL(SD_BLE_GATTC_WRITE, uint32_t, sd_ble_gattc_write(uint16_t conn_handle, ble_gattc_write_params_t const *p_write_params));
/**@brief Send a Handle Value Confirmation to the GATT Server.
*
* @mscs
* @mmsc{@ref BLE_GATTC_HVI_MSC}
* @endmscs
*
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
* @param[in] handle The handle of the attribute in the indication.
*
* @retval ::NRF_SUCCESS Successfully queued the Handle Value Confirmation for transmission.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or no Indication pending to be confirmed.
* @retval ::BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle.
*/
SVCALL(SD_BLE_GATTC_HV_CONFIRM, uint32_t, sd_ble_gattc_hv_confirm(uint16_t conn_handle, uint16_t handle));
/**@brief Discovers information about a range of attributes on a GATT server.
*
* @events
* @event{@ref BLE_GATTC_EVT_ATTR_INFO_DISC_RSP, Generated when information about a range of attributes has been received.}
* @endevents
*
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
* @param[in] p_handle_range The range of handles to request information about.
*
* @retval ::NRF_SUCCESS Successfully started an attribute information discovery procedure.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle.
* @retval ::NRF_ERROR_INVALID_STATE Invalid connection state
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
*/
SVCALL(SD_BLE_GATTC_ATTR_INFO_DISCOVER, uint32_t, sd_ble_gattc_attr_info_discover(uint16_t conn_handle, ble_gattc_handle_range_t const * p_handle_range));
/**@brief Start an ATT_MTU exchange by sending an Exchange MTU Request to the server.
*
* @details The SoftDevice sets ATT_MTU to the minimum of:
* - The Client RX MTU value, and
* - The Server RX MTU value from @ref BLE_GATTC_EVT_EXCHANGE_MTU_RSP.
*
* However, the SoftDevice never sets ATT_MTU lower than @ref BLE_GATT_ATT_MTU_DEFAULT.
*
* @events
* @event{@ref BLE_GATTC_EVT_EXCHANGE_MTU_RSP}
* @endevents
*
* @mscs
* @mmsc{@ref BLE_GATTC_MTU_EXCHANGE}
* @endmscs
*
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
* @param[in] client_rx_mtu Client RX MTU size.
* - The minimum value is @ref BLE_GATT_ATT_MTU_DEFAULT.
* - The maximum value is @ref ble_gatt_conn_cfg_t::att_mtu in the connection configuration
used for this connection.
* - The value must be equal to Server RX MTU size given in @ref sd_ble_gatts_exchange_mtu_reply
* if an ATT_MTU exchange has already been performed in the other direction.
*
* @retval ::NRF_SUCCESS Successfully sent request to the server.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle.
* @retval ::NRF_ERROR_INVALID_STATE Invalid connection state or an ATT_MTU exchange was already requested once.
* @retval ::NRF_ERROR_INVALID_PARAM Invalid Client RX MTU size supplied.
* @retval ::NRF_ERROR_BUSY Client procedure already in progress.
*/
SVCALL(SD_BLE_GATTC_EXCHANGE_MTU_REQUEST, uint32_t, sd_ble_gattc_exchange_mtu_request(uint16_t conn_handle, uint16_t client_rx_mtu));
/**@brief Iterate through Handle-Value(s) list in @ref BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP event.
*
* @param[in] p_gattc_evt Pointer to event buffer containing @ref BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP event.
* @note If the buffer contains different event, behavior is undefined.
* @param[in,out] p_iter Iterator, points to @ref ble_gattc_handle_value_t structure that will be filled in with
* the next Handle-Value pair in each iteration. If the function returns other than
* @ref NRF_SUCCESS, it will not be changed.
* - To start iteration, initialize the structure to zero.
* - To continue, pass the value from previous iteration.
*
* \code
* ble_gattc_handle_value_t iter;
* memset(&iter, 0, sizeof(ble_gattc_handle_value_t));
* while (sd_ble_gattc_evt_char_val_by_uuid_read_rsp_iter(&ble_evt.evt.gattc_evt, &iter) == NRF_SUCCESS)
* {
* app_handle = iter.handle;
* memcpy(app_value, iter.p_value, ble_evt.evt.gattc_evt.params.char_val_by_uuid_read_rsp.value_len);
* }
* \endcode
*
* @retval ::NRF_SUCCESS Successfully retrieved the next Handle-Value pair.
* @retval ::NRF_ERROR_NOT_FOUND No more Handle-Value pairs available in the list.
*/
__STATIC_INLINE uint32_t sd_ble_gattc_evt_char_val_by_uuid_read_rsp_iter(ble_gattc_evt_t *p_gattc_evt, ble_gattc_handle_value_t *p_iter);
/** @} */
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
__STATIC_INLINE uint32_t sd_ble_gattc_evt_char_val_by_uuid_read_rsp_iter(ble_gattc_evt_t *p_gattc_evt, ble_gattc_handle_value_t *p_iter)
{
uint32_t value_len = p_gattc_evt->params.char_val_by_uuid_read_rsp.value_len;
uint8_t *p_first = p_gattc_evt->params.char_val_by_uuid_read_rsp.handle_value;
uint8_t *p_next = p_iter->p_value ? p_iter->p_value + value_len : p_first;
if ((p_next - p_first) / (sizeof(uint16_t) + value_len) < p_gattc_evt->params.char_val_by_uuid_read_rsp.count)
{
p_iter->handle = (uint16_t)p_next[1] << 8 | p_next[0];
p_iter->p_value = p_next + sizeof(uint16_t);
return NRF_SUCCESS;
}
else
{
return NRF_ERROR_NOT_FOUND;
}
}
#endif /* SUPPRESS_INLINE_IMPLEMENTATION */
#ifdef __cplusplus
}
#endif
#endif /* BLE_GATTC_H__ */
/**
@}
*/

View File

@ -1,835 +0,0 @@
/*
* Copyright (c) 2011 - 2017, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@addtogroup BLE_GATTS Generic Attribute Profile (GATT) Server
@{
@brief Definitions and prototypes for the GATTS interface.
*/
#ifndef BLE_GATTS_H__
#define BLE_GATTS_H__
#include "ble_types.h"
#include "ble_ranges.h"
#include "ble_l2cap.h"
#include "ble_gap.h"
#include "ble_gatt.h"
#include "nrf_svc.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup BLE_GATTS_ENUMERATIONS Enumerations
* @{ */
/**
* @brief GATTS API SVC numbers.
*/
enum BLE_GATTS_SVCS
{
SD_BLE_GATTS_SERVICE_ADD = BLE_GATTS_SVC_BASE, /**< Add a service. */
SD_BLE_GATTS_INCLUDE_ADD, /**< Add an included service. */
SD_BLE_GATTS_CHARACTERISTIC_ADD, /**< Add a characteristic. */
SD_BLE_GATTS_DESCRIPTOR_ADD, /**< Add a generic attribute. */
SD_BLE_GATTS_VALUE_SET, /**< Set an attribute value. */
SD_BLE_GATTS_VALUE_GET, /**< Get an attribute value. */
SD_BLE_GATTS_HVX, /**< Handle Value Notification or Indication. */
SD_BLE_GATTS_SERVICE_CHANGED, /**< Perform a Service Changed Indication to one or more peers. */
SD_BLE_GATTS_RW_AUTHORIZE_REPLY, /**< Reply to an authorization request for a read or write operation on one or more attributes. */
SD_BLE_GATTS_SYS_ATTR_SET, /**< Set the persistent system attributes for a connection. */
SD_BLE_GATTS_SYS_ATTR_GET, /**< Retrieve the persistent system attributes. */
SD_BLE_GATTS_INITIAL_USER_HANDLE_GET, /**< Retrieve the first valid user handle. */
SD_BLE_GATTS_ATTR_GET, /**< Retrieve the UUID and/or metadata of an attribute. */
SD_BLE_GATTS_EXCHANGE_MTU_REPLY /**< Reply to Exchange MTU Request. */
};
/**
* @brief GATT Server Event IDs.
*/
enum BLE_GATTS_EVTS
{
BLE_GATTS_EVT_WRITE = BLE_GATTS_EVT_BASE, /**< Write operation performed. \n See @ref ble_gatts_evt_write_t. */
BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST, /**< Read/Write Authorization request. \n Reply with @ref sd_ble_gatts_rw_authorize_reply. \n See @ref ble_gatts_evt_rw_authorize_request_t. */
BLE_GATTS_EVT_SYS_ATTR_MISSING, /**< A persistent system attribute access is pending. \n Respond with @ref sd_ble_gatts_sys_attr_set. \n See @ref ble_gatts_evt_sys_attr_missing_t. */
BLE_GATTS_EVT_HVC, /**< Handle Value Confirmation. \n See @ref ble_gatts_evt_hvc_t. */
BLE_GATTS_EVT_SC_CONFIRM, /**< Service Changed Confirmation. \n No additional event structure applies. */
BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST, /**< Exchange MTU Request. \n Reply with @ref sd_ble_gatts_exchange_mtu_reply. \n See @ref ble_gatts_evt_exchange_mtu_request_t. */
BLE_GATTS_EVT_TIMEOUT, /**< Peer failed to respond to an ATT request in time. \n See @ref ble_gatts_evt_timeout_t. */
BLE_GATTS_EVT_HVN_TX_COMPLETE /**< Handle Value Notification transmission complete. \n See @ref ble_gatts_evt_hvn_tx_complete_t. */
};
/**@brief GATTS Configuration IDs.
*
* IDs that uniquely identify a GATTS configuration.
*/
enum BLE_GATTS_CFGS
{
BLE_GATTS_CFG_SERVICE_CHANGED = BLE_GATTS_CFG_BASE, /**< Service changed configuration. */
BLE_GATTS_CFG_ATTR_TAB_SIZE, /**< Attribute table size configuration. */
};
/** @} */
/** @addtogroup BLE_GATTS_DEFINES Defines
* @{ */
/** @defgroup BLE_ERRORS_GATTS SVC return values specific to GATTS
* @{ */
#define BLE_ERROR_GATTS_INVALID_ATTR_TYPE (NRF_GATTS_ERR_BASE + 0x000) /**< Invalid attribute type. */
#define BLE_ERROR_GATTS_SYS_ATTR_MISSING (NRF_GATTS_ERR_BASE + 0x001) /**< System Attributes missing. */
/** @} */
/** @defgroup BLE_GATTS_ATTR_LENS_MAX Maximum attribute lengths
* @{ */
#define BLE_GATTS_FIX_ATTR_LEN_MAX (510) /**< Maximum length for fixed length Attribute Values. */
#define BLE_GATTS_VAR_ATTR_LEN_MAX (512) /**< Maximum length for variable length Attribute Values. */
/** @} */
/** @defgroup BLE_GATTS_SRVC_TYPES GATT Server Service Types
* @{ */
#define BLE_GATTS_SRVC_TYPE_INVALID 0x00 /**< Invalid Service Type. */
#define BLE_GATTS_SRVC_TYPE_PRIMARY 0x01 /**< Primary Service. */
#define BLE_GATTS_SRVC_TYPE_SECONDARY 0x02 /**< Secondary Type. */
/** @} */
/** @defgroup BLE_GATTS_ATTR_TYPES GATT Server Attribute Types
* @{ */
#define BLE_GATTS_ATTR_TYPE_INVALID 0x00 /**< Invalid Attribute Type. */
#define BLE_GATTS_ATTR_TYPE_PRIM_SRVC_DECL 0x01 /**< Primary Service Declaration. */
#define BLE_GATTS_ATTR_TYPE_SEC_SRVC_DECL 0x02 /**< Secondary Service Declaration. */
#define BLE_GATTS_ATTR_TYPE_INC_DECL 0x03 /**< Include Declaration. */
#define BLE_GATTS_ATTR_TYPE_CHAR_DECL 0x04 /**< Characteristic Declaration. */
#define BLE_GATTS_ATTR_TYPE_CHAR_VAL 0x05 /**< Characteristic Value. */
#define BLE_GATTS_ATTR_TYPE_DESC 0x06 /**< Descriptor. */
#define BLE_GATTS_ATTR_TYPE_OTHER 0x07 /**< Other, non-GATT specific type. */
/** @} */
/** @defgroup BLE_GATTS_OPS GATT Server Operations
* @{ */
#define BLE_GATTS_OP_INVALID 0x00 /**< Invalid Operation. */
#define BLE_GATTS_OP_WRITE_REQ 0x01 /**< Write Request. */
#define BLE_GATTS_OP_WRITE_CMD 0x02 /**< Write Command. */
#define BLE_GATTS_OP_SIGN_WRITE_CMD 0x03 /**< Signed Write Command. */
#define BLE_GATTS_OP_PREP_WRITE_REQ 0x04 /**< Prepare Write Request. */
#define BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL 0x05 /**< Execute Write Request: Cancel all prepared writes. */
#define BLE_GATTS_OP_EXEC_WRITE_REQ_NOW 0x06 /**< Execute Write Request: Immediately execute all prepared writes. */
/** @} */
/** @defgroup BLE_GATTS_VLOCS GATT Value Locations
* @{ */
#define BLE_GATTS_VLOC_INVALID 0x00 /**< Invalid Location. */
#define BLE_GATTS_VLOC_STACK 0x01 /**< Attribute Value is located in stack memory, no user memory is required. */
#define BLE_GATTS_VLOC_USER 0x02 /**< Attribute Value is located in user memory. This requires the user to maintain a valid buffer through the lifetime of the attribute, since the stack
will read and write directly to the memory using the pointer provided in the APIs. There are no alignment requirements for the buffer. */
/** @} */
/** @defgroup BLE_GATTS_AUTHORIZE_TYPES GATT Server Authorization Types
* @{ */
#define BLE_GATTS_AUTHORIZE_TYPE_INVALID 0x00 /**< Invalid Type. */
#define BLE_GATTS_AUTHORIZE_TYPE_READ 0x01 /**< Authorize a Read Operation. */
#define BLE_GATTS_AUTHORIZE_TYPE_WRITE 0x02 /**< Authorize a Write Request Operation. */
/** @} */
/** @defgroup BLE_GATTS_SYS_ATTR_FLAGS System Attribute Flags
* @{ */
#define BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS (1 << 0) /**< Restrict system attributes to system services only. */
#define BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS (1 << 1) /**< Restrict system attributes to user services only. */
/** @} */
/** @defgroup BLE_GATTS_SERVICE_CHANGED Service Changed Inclusion Values
* @{
*/
#define BLE_GATTS_SERVICE_CHANGED_DEFAULT (1) /**< Default is to include the Service Changed characteristic in the Attribute Table. */
/** @} */
/** @defgroup BLE_GATTS_ATTR_TAB_SIZE Attribute Table size
* @{
*/
#define BLE_GATTS_ATTR_TAB_SIZE_MIN (248) /**< Minimum Attribute Table size */
#define BLE_GATTS_ATTR_TAB_SIZE_DEFAULT (1408) /**< Default Attribute Table size. */
/** @} */
/** @defgroup BLE_GATTS_DEFAULTS GATT Server defaults
* @{
*/
#define BLE_GATTS_HVN_TX_QUEUE_SIZE_DEFAULT 1 /**< Default number of Handle Value Notifications that can be queued for transmission. */
/** @} */
/** @} */
/** @addtogroup BLE_GATTS_STRUCTURES Structures
* @{ */
/**
* @brief BLE GATTS connection configuration parameters, set with @ref sd_ble_cfg_set.
*/
typedef struct
{
uint8_t hvn_tx_queue_size; /**< Minimum guaranteed number of Handle Value Notifications that can be queued for transmission.
The default value is @ref BLE_GATTS_HVN_TX_QUEUE_SIZE_DEFAULT */
} ble_gatts_conn_cfg_t;
/**@brief Attribute metadata. */
typedef struct
{
ble_gap_conn_sec_mode_t read_perm; /**< Read permissions. */
ble_gap_conn_sec_mode_t write_perm; /**< Write permissions. */
uint8_t vlen :1; /**< Variable length attribute. */
uint8_t vloc :2; /**< Value location, see @ref BLE_GATTS_VLOCS.*/
uint8_t rd_auth :1; /**< Read authorization and value will be requested from the application on every read operation. */
uint8_t wr_auth :1; /**< Write authorization will be requested from the application on every Write Request operation (but not Write Command). */
} ble_gatts_attr_md_t;
/**@brief GATT Attribute. */
typedef struct
{
ble_uuid_t const *p_uuid; /**< Pointer to the attribute UUID. */
ble_gatts_attr_md_t const *p_attr_md; /**< Pointer to the attribute metadata structure. */
uint16_t init_len; /**< Initial attribute value length in bytes. */
uint16_t init_offs; /**< Initial attribute value offset in bytes. If different from zero, the first init_offs bytes of the attribute value will be left uninitialized. */
uint16_t max_len; /**< Maximum attribute value length in bytes, see @ref BLE_GATTS_ATTR_LENS_MAX for maximum values. */
uint8_t *p_value; /**< Pointer to the attribute data. Please note that if the @ref BLE_GATTS_VLOC_USER value location is selected in the attribute metadata, this will have to point to a buffer
that remains valid through the lifetime of the attribute. This excludes usage of automatic variables that may go out of scope or any other temporary location.
The stack may access that memory directly without the application's knowledge. For writable characteristics, this value must not be a location in flash memory.*/
} ble_gatts_attr_t;
/**@brief GATT Attribute Value. */
typedef struct
{
uint16_t len; /**< Length in bytes to be written or read. Length in bytes written or read after successful return.*/
uint16_t offset; /**< Attribute value offset. */
uint8_t *p_value; /**< Pointer to where value is stored or will be stored.
If value is stored in user memory, only the attribute length is updated when p_value == NULL.
Set to NULL when reading to obtain the complete length of the attribute value */
} ble_gatts_value_t;
/**@brief GATT Characteristic Presentation Format. */
typedef struct
{
uint8_t format; /**< Format of the value, see @ref BLE_GATT_CPF_FORMATS. */
int8_t exponent; /**< Exponent for integer data types. */
uint16_t unit; /**< Unit from Bluetooth Assigned Numbers. */
uint8_t name_space; /**< Namespace from Bluetooth Assigned Numbers, see @ref BLE_GATT_CPF_NAMESPACES. */
uint16_t desc; /**< Namespace description from Bluetooth Assigned Numbers, see @ref BLE_GATT_CPF_NAMESPACES. */
} ble_gatts_char_pf_t;
/**@brief GATT Characteristic metadata. */
typedef struct
{
ble_gatt_char_props_t char_props; /**< Characteristic Properties. */
ble_gatt_char_ext_props_t char_ext_props; /**< Characteristic Extended Properties. */
uint8_t const *p_char_user_desc; /**< Pointer to a UTF-8 encoded string (non-NULL terminated), NULL if the descriptor is not required. */
uint16_t char_user_desc_max_size; /**< The maximum size in bytes of the user description descriptor. */
uint16_t char_user_desc_size; /**< The size of the user description, must be smaller or equal to char_user_desc_max_size. */
ble_gatts_char_pf_t const *p_char_pf; /**< Pointer to a presentation format structure or NULL if the CPF descriptor is not required. */
ble_gatts_attr_md_t const *p_user_desc_md; /**< Attribute metadata for the User Description descriptor, or NULL for default values. */
ble_gatts_attr_md_t const *p_cccd_md; /**< Attribute metadata for the Client Characteristic Configuration Descriptor, or NULL for default values. */
ble_gatts_attr_md_t const *p_sccd_md; /**< Attribute metadata for the Server Characteristic Configuration Descriptor, or NULL for default values. */
} ble_gatts_char_md_t;
/**@brief GATT Characteristic Definition Handles. */
typedef struct
{
uint16_t value_handle; /**< Handle to the characteristic value. */
uint16_t user_desc_handle; /**< Handle to the User Description descriptor, or @ref BLE_GATT_HANDLE_INVALID if not present. */
uint16_t cccd_handle; /**< Handle to the Client Characteristic Configuration Descriptor, or @ref BLE_GATT_HANDLE_INVALID if not present. */
uint16_t sccd_handle; /**< Handle to the Server Characteristic Configuration Descriptor, or @ref BLE_GATT_HANDLE_INVALID if not present. */
} ble_gatts_char_handles_t;
/**@brief GATT HVx parameters. */
typedef struct
{
uint16_t handle; /**< Characteristic Value Handle. */
uint8_t type; /**< Indication or Notification, see @ref BLE_GATT_HVX_TYPES. */
uint16_t offset; /**< Offset within the attribute value. */
uint16_t *p_len; /**< Length in bytes to be written, length in bytes written after successful return. */
uint8_t const *p_data; /**< Actual data content, use NULL to use the current attribute value. */
} ble_gatts_hvx_params_t;
/**@brief GATT Authorization parameters. */
typedef struct
{
uint16_t gatt_status; /**< GATT status code for the operation, see @ref BLE_GATT_STATUS_CODES. */
uint8_t update : 1; /**< If set, data supplied in p_data will be used to update the attribute value.
Please note that for @ref BLE_GATTS_AUTHORIZE_TYPE_WRITE operations this bit must always be set,
as the data to be written needs to be stored and later provided by the application. */
uint16_t offset; /**< Offset of the attribute value being updated. */
uint16_t len; /**< Length in bytes of the value in p_data pointer, see @ref BLE_GATTS_ATTR_LENS_MAX. */
uint8_t const *p_data; /**< Pointer to new value used to update the attribute value. */
} ble_gatts_authorize_params_t;
/**@brief GATT Read or Write Authorize Reply parameters. */
typedef struct
{
uint8_t type; /**< Type of authorize operation, see @ref BLE_GATTS_AUTHORIZE_TYPES. */
union {
ble_gatts_authorize_params_t read; /**< Read authorization parameters. */
ble_gatts_authorize_params_t write; /**< Write authorization parameters. */
} params; /**< Reply Parameters. */
} ble_gatts_rw_authorize_reply_params_t;
/**@brief Service Changed Inclusion configuration parameters, set with @ref sd_ble_cfg_set. */
typedef struct
{
uint8_t service_changed : 1; /**< If 1, include the Service Changed characteristic in the Attribute Table. Default is @ref BLE_GATTS_SERVICE_CHANGED_DEFAULT. */
} ble_gatts_cfg_service_changed_t;
/**@brief Attribute table size configuration parameters, set with @ref sd_ble_cfg_set.
*
* @retval ::NRF_ERROR_INVALID_LENGTH One or more of the following is true:
* - The specified Attribute Table size is too small.
* The minimum acceptable size is defined by @ref BLE_GATTS_ATTR_TAB_SIZE_MIN.
* - The specified Attribute Table size is not a multiple of 4.
*/
typedef struct
{
uint32_t attr_tab_size; /**< Attribute table size. Default is @ref BLE_GATTS_ATTR_TAB_SIZE_DEFAULT, minimum is @ref BLE_GATTS_ATTR_TAB_SIZE_MIN. */
} ble_gatts_cfg_attr_tab_size_t;
/**@brief Config structure for GATTS configurations. */
typedef union
{
ble_gatts_cfg_service_changed_t service_changed; /**< Include service changed characteristic, cfg_id is @ref BLE_GATTS_CFG_SERVICE_CHANGED. */
ble_gatts_cfg_attr_tab_size_t attr_tab_size; /**< Attribute table size, cfg_id is @ref BLE_GATTS_CFG_ATTR_TAB_SIZE. */
} ble_gatts_cfg_t;
/**@brief Event structure for @ref BLE_GATTS_EVT_WRITE. */
typedef struct
{
uint16_t handle; /**< Attribute Handle. */
ble_uuid_t uuid; /**< Attribute UUID. */
uint8_t op; /**< Type of write operation, see @ref BLE_GATTS_OPS. */
uint8_t auth_required; /**< Writing operation deferred due to authorization requirement. Application may use @ref sd_ble_gatts_value_set to finalize the writing operation. */
uint16_t offset; /**< Offset for the write operation. */
uint16_t len; /**< Length of the received data. */
uint8_t data[1]; /**< Received data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation.
See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */
} ble_gatts_evt_write_t;
/**@brief Event substructure for authorized read requests, see @ref ble_gatts_evt_rw_authorize_request_t. */
typedef struct
{
uint16_t handle; /**< Attribute Handle. */
ble_uuid_t uuid; /**< Attribute UUID. */
uint16_t offset; /**< Offset for the read operation. */
} ble_gatts_evt_read_t;
/**@brief Event structure for @ref BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST. */
typedef struct
{
uint8_t type; /**< Type of authorize operation, see @ref BLE_GATTS_AUTHORIZE_TYPES. */
union {
ble_gatts_evt_read_t read; /**< Attribute Read Parameters. */
ble_gatts_evt_write_t write; /**< Attribute Write Parameters. */
} request; /**< Request Parameters. */
} ble_gatts_evt_rw_authorize_request_t;
/**@brief Event structure for @ref BLE_GATTS_EVT_SYS_ATTR_MISSING. */
typedef struct
{
uint8_t hint; /**< Hint (currently unused). */
} ble_gatts_evt_sys_attr_missing_t;
/**@brief Event structure for @ref BLE_GATTS_EVT_HVC. */
typedef struct
{
uint16_t handle; /**< Attribute Handle. */
} ble_gatts_evt_hvc_t;
/**@brief Event structure for @ref BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST. */
typedef struct
{
uint16_t client_rx_mtu; /**< Client RX MTU size. */
} ble_gatts_evt_exchange_mtu_request_t;
/**@brief Event structure for @ref BLE_GATTS_EVT_TIMEOUT. */
typedef struct
{
uint8_t src; /**< Timeout source, see @ref BLE_GATT_TIMEOUT_SOURCES. */
} ble_gatts_evt_timeout_t;
/**@brief Event structure for @ref BLE_GATTS_EVT_HVN_TX_COMPLETE. */
typedef struct
{
uint8_t count; /**< Number of notification transmissions completed. */
} ble_gatts_evt_hvn_tx_complete_t;
/**@brief GATTS event structure. */
typedef struct
{
uint16_t conn_handle; /**< Connection Handle on which the event occurred. */
union
{
ble_gatts_evt_write_t write; /**< Write Event Parameters. */
ble_gatts_evt_rw_authorize_request_t authorize_request; /**< Read or Write Authorize Request Parameters. */
ble_gatts_evt_sys_attr_missing_t sys_attr_missing; /**< System attributes missing. */
ble_gatts_evt_hvc_t hvc; /**< Handle Value Confirmation Event Parameters. */
ble_gatts_evt_exchange_mtu_request_t exchange_mtu_request; /**< Exchange MTU Request Event Parameters. */
ble_gatts_evt_timeout_t timeout; /**< Timeout Event. */
ble_gatts_evt_hvn_tx_complete_t hvn_tx_complete; /**< Handle Value Notification transmission complete Event Parameters. */
} params; /**< Event Parameters. */
} ble_gatts_evt_t;
/** @} */
/** @addtogroup BLE_GATTS_FUNCTIONS Functions
* @{ */
/**@brief Add a service declaration to the Attribute Table.
*
* @note Secondary Services are only relevant in the context of the entity that references them, it is therefore forbidden to
* add a secondary service declaration that is not referenced by another service later in the Attribute Table.
*
* @mscs
* @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC}
* @endmscs
*
* @param[in] type Toggles between primary and secondary services, see @ref BLE_GATTS_SRVC_TYPES.
* @param[in] p_uuid Pointer to service UUID.
* @param[out] p_handle Pointer to a 16-bit word where the assigned handle will be stored.
*
* @retval ::NRF_SUCCESS Successfully added a service declaration.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, Vendor Specific UUIDs need to be present in the table.
* @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack.
* @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
*/
SVCALL(SD_BLE_GATTS_SERVICE_ADD, uint32_t, sd_ble_gatts_service_add(uint8_t type, ble_uuid_t const *p_uuid, uint16_t *p_handle));
/**@brief Add an include declaration to the Attribute Table.
*
* @note It is currently only possible to add an include declaration to the last added service (i.e. only sequential population is supported at this time).
*
* @note The included service must already be present in the Attribute Table prior to this call.
*
* @mscs
* @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC}
* @endmscs
*
* @param[in] service_handle Handle of the service where the included service is to be placed, if @ref BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially.
* @param[in] inc_srvc_handle Handle of the included service.
* @param[out] p_include_handle Pointer to a 16-bit word where the assigned handle will be stored.
*
* @retval ::NRF_SUCCESS Successfully added an include declaration.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, handle values need to match previously added services.
* @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation.
* @retval ::NRF_ERROR_NOT_SUPPORTED Feature is not supported, service_handle must be that of the last added service.
* @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, self inclusions are not allowed.
* @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
* @retval ::NRF_ERROR_NOT_FOUND Attribute not found.
*/
SVCALL(SD_BLE_GATTS_INCLUDE_ADD, uint32_t, sd_ble_gatts_include_add(uint16_t service_handle, uint16_t inc_srvc_handle, uint16_t *p_include_handle));
/**@brief Add a characteristic declaration, a characteristic value declaration and optional characteristic descriptor declarations to the Attribute Table.
*
* @note It is currently only possible to add a characteristic to the last added service (i.e. only sequential population is supported at this time).
*
* @note Several restrictions apply to the parameters, such as matching permissions between the user description descriptor and the writable auxiliaries bits,
* readable (no security) and writable (selectable) CCCDs and SCCDs and valid presentation format values.
*
* @note If no metadata is provided for the optional descriptors, their permissions will be derived from the characteristic permissions.
*
* @mscs
* @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC}
* @endmscs
*
* @param[in] service_handle Handle of the service where the characteristic is to be placed, if @ref BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially.
* @param[in] p_char_md Characteristic metadata.
* @param[in] p_attr_char_value Pointer to the attribute structure corresponding to the characteristic value.
* @param[out] p_handles Pointer to the structure where the assigned handles will be stored.
*
* @retval ::NRF_SUCCESS Successfully added a characteristic.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, service handle, Vendor Specific UUIDs, lengths, and permissions need to adhere to the constraints.
* @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation, a service context is required.
* @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack.
* @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
* @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX.
*/
SVCALL(SD_BLE_GATTS_CHARACTERISTIC_ADD, uint32_t, sd_ble_gatts_characteristic_add(uint16_t service_handle, ble_gatts_char_md_t const *p_char_md, ble_gatts_attr_t const *p_attr_char_value, ble_gatts_char_handles_t *p_handles));
/**@brief Add a descriptor to the Attribute Table.
*
* @note It is currently only possible to add a descriptor to the last added characteristic (i.e. only sequential population is supported at this time).
*
* @mscs
* @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC}
* @endmscs
*
* @param[in] char_handle Handle of the characteristic where the descriptor is to be placed, if @ref BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially.
* @param[in] p_attr Pointer to the attribute structure.
* @param[out] p_handle Pointer to a 16-bit word where the assigned handle will be stored.
*
* @retval ::NRF_SUCCESS Successfully added a descriptor.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, characteristic handle, Vendor Specific UUIDs, lengths, and permissions need to adhere to the constraints.
* @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation, a characteristic context is required.
* @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack.
* @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
* @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX.
*/
SVCALL(SD_BLE_GATTS_DESCRIPTOR_ADD, uint32_t, sd_ble_gatts_descriptor_add(uint16_t char_handle, ble_gatts_attr_t const *p_attr, uint16_t *p_handle));
/**@brief Set the value of a given attribute.
*
* @note Values other than system attributes can be set at any time, regardless of whether any active connections exist.
*
* @mscs
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_QUEUE_FULL_MSC}
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_NOAUTH_MSC}
* @endmscs
*
* @param[in] conn_handle Connection handle. Ignored if the value does not belong to a system attribute.
* @param[in] handle Attribute handle.
* @param[in,out] p_value Attribute value information.
*
* @retval ::NRF_SUCCESS Successfully set the value of the attribute.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
* @retval ::NRF_ERROR_NOT_FOUND Attribute not found.
* @retval ::NRF_ERROR_FORBIDDEN Forbidden handle supplied, certain attributes are not modifiable by the application.
* @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied on a system attribute.
*/
SVCALL(SD_BLE_GATTS_VALUE_SET, uint32_t, sd_ble_gatts_value_set(uint16_t conn_handle, uint16_t handle, ble_gatts_value_t *p_value));
/**@brief Get the value of a given attribute.
*
* @note If the attribute value is longer than the size of the supplied buffer,
* p_len will return the total attribute value length (excluding offset),
* and not the number of bytes actually returned in p_data.
* The application may use this information to allocate a suitable buffer size.
*
* @note When retrieving system attribute values with this function, the connection handle
* may refer to an already disconnected connection. Refer to the documentation of
* @ref sd_ble_gatts_sys_attr_get for further information.
*
* @param[in] conn_handle Connection handle. Ignored if the value does not belong to a system attribute.
* @param[in] handle Attribute handle.
* @param[in,out] p_value Attribute value information.
*
* @retval ::NRF_SUCCESS Successfully retrieved the value of the attribute.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::NRF_ERROR_NOT_FOUND Attribute not found.
* @retval ::NRF_ERROR_INVALID_PARAM Invalid attribute offset supplied.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied on a system attribute.
* @retval ::BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value.
*/
SVCALL(SD_BLE_GATTS_VALUE_GET, uint32_t, sd_ble_gatts_value_get(uint16_t conn_handle, uint16_t handle, ble_gatts_value_t *p_value));
/**@brief Notify or Indicate an attribute value.
*
* @details This function checks for the relevant Client Characteristic Configuration descriptor value to verify that the relevant operation
* (notification or indication) has been enabled by the client. It is also able to update the attribute value before issuing the PDU, so that
* the application can atomically perform a value update and a server initiated transaction with a single API call.
*
* @note The local attribute value may be updated even if an outgoing packet is not sent to the peer due to an error during execution.
* The Attribute Table has been updated if one of the following error codes is returned: @ref NRF_ERROR_INVALID_STATE, @ref NRF_ERROR_BUSY,
* @ref NRF_ERROR_FORBIDDEN, @ref BLE_ERROR_GATTS_SYS_ATTR_MISSING and @ref NRF_ERROR_RESOURCES.
* The caller can check whether the value has been updated by looking at the contents of *(p_hvx_params->p_len).
*
* @note Only one indication procedure can be ongoing per connection at a time.
* If the application tries to indicate an attribute value while another indication procedure is ongoing,
* the function call will return @ref NRF_ERROR_BUSY.
* A @ref BLE_GATTS_EVT_HVC event will be issued as soon as the confirmation arrives from the peer.
*
* @note The number of Handle Value Notifications that can be queued is configured by @ref ble_gatts_conn_cfg_t::hvn_tx_queue_size
* When the queue is full, the function call will return @ref NRF_ERROR_RESOURCES.
* A @ref BLE_GATTS_EVT_HVN_TX_COMPLETE event will be issued as soon as the transmission of the notification is complete.
*
* @note The application can keep track of the available queue element count for notifications by following the procedure below:
* - Store initial queue element count in a variable.
* - Decrement the variable, which stores the currently available queue element count, by one when a call to this function returns @ref NRF_SUCCESS.
* - Increment the variable, which stores the current available queue element count, by the count variable in @ref BLE_GATTS_EVT_HVN_TX_COMPLETE event.
*
* @events
* @event{@ref BLE_GATTS_EVT_HVN_TX_COMPLETE, Notification transmission complete.}
* @event{@ref BLE_GATTS_EVT_HVC, Confirmation received from the peer.}
* @endevents
*
* @mscs
* @mmsc{@ref BLE_GATTS_HVX_SYS_ATTRS_MISSING_MSC}
* @mmsc{@ref BLE_GATTS_HVN_MSC}
* @mmsc{@ref BLE_GATTS_HVI_MSC}
* @mmsc{@ref BLE_GATTS_HVX_DISABLED_MSC}
* @endmscs
*
* @param[in] conn_handle Connection handle.
* @param[in] p_hvx_params Pointer to an HVx parameters structure. If the p_data member contains a non-NULL pointer the attribute value will be updated with
* the contents pointed by it before sending the notification or indication.
*
* @retval ::NRF_SUCCESS Successfully queued a notification or indication for transmission, and optionally updated the attribute value.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
* @retval ::NRF_ERROR_INVALID_STATE One or more of the following is true:
* - Invalid Connection State
* - Notifications and/or indications not enabled in the CCCD
* - An ATT_MTU exchange is ongoing
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
* @retval ::BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle(s) supplied. Only attributes added directly by the application are available to notify and indicate.
* @retval ::BLE_ERROR_GATTS_INVALID_ATTR_TYPE Invalid attribute type(s) supplied, only characteristic values may be notified and indicated.
* @retval ::NRF_ERROR_NOT_FOUND Attribute not found.
* @retval ::NRF_ERROR_FORBIDDEN The connection's current security level is lower than the one required by the write permissions of the CCCD associated with this characteristic.
* @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied.
* @retval ::NRF_ERROR_BUSY For @ref BLE_GATT_HVX_INDICATION Procedure already in progress. Wait for a @ref BLE_GATTS_EVT_HVC event and retry.
* @retval ::BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value.
* @retval ::NRF_ERROR_RESOURCES Too many notifications queued.
* Wait for a @ref BLE_GATTS_EVT_HVN_TX_COMPLETE event and retry.
*/
SVCALL(SD_BLE_GATTS_HVX, uint32_t, sd_ble_gatts_hvx(uint16_t conn_handle, ble_gatts_hvx_params_t const *p_hvx_params));
/**@brief Indicate the Service Changed attribute value.
*
* @details This call will send a Handle Value Indication to one or more peers connected to inform them that the Attribute
* Table layout has changed. As soon as the peer has confirmed the indication, a @ref BLE_GATTS_EVT_SC_CONFIRM event will
* be issued.
*
* @note Some of the restrictions and limitations that apply to @ref sd_ble_gatts_hvx also apply here.
*
* @events
* @event{@ref BLE_GATTS_EVT_SC_CONFIRM, Confirmation of attribute table change received from peer.}
* @endevents
*
* @mscs
* @mmsc{@ref BLE_GATTS_SC_MSC}
* @endmscs
*
* @param[in] conn_handle Connection handle.
* @param[in] start_handle Start of affected attribute handle range.
* @param[in] end_handle End of affected attribute handle range.
*
* @retval ::NRF_SUCCESS Successfully queued the Service Changed indication for transmission.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
* @retval ::NRF_ERROR_NOT_SUPPORTED Service Changed not enabled at initialization. See @ref
* sd_ble_cfg_set and @ref ble_gatts_cfg_service_changed_t.
* @retval ::NRF_ERROR_INVALID_STATE One or more of the following is true:
* - Invalid Connection State
* - Notifications and/or indications not enabled in the CCCD
* - An ATT_MTU exchange is ongoing
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
* @retval ::BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle(s) supplied, handles must be in the range populated by the application.
* @retval ::NRF_ERROR_BUSY Procedure already in progress.
* @retval ::BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value.
*/
SVCALL(SD_BLE_GATTS_SERVICE_CHANGED, uint32_t, sd_ble_gatts_service_changed(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle));
/**@brief Respond to a Read/Write authorization request.
*
* @note This call should only be used as a response to a @ref BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event issued to the application.
*
* @mscs
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_AUTH_MSC}
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_BUF_AUTH_MSC}
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_NOAUTH_MSC}
* @mmsc{@ref BLE_GATTS_READ_REQ_AUTH_MSC}
* @mmsc{@ref BLE_GATTS_WRITE_REQ_AUTH_MSC}
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_QUEUE_FULL_MSC}
* @mmsc{@ref BLE_GATTS_QUEUED_WRITE_PEER_CANCEL_MSC}
* @endmscs
*
* @param[in] conn_handle Connection handle.
* @param[in] p_rw_authorize_reply_params Pointer to a structure with the attribute provided by the application.
*
* @note @ref ble_gatts_authorize_params_t::p_data is ignored when this function is used to respond
* to a @ref BLE_GATTS_AUTHORIZE_TYPE_READ event if @ref ble_gatts_authorize_params_t::update
* is set to 0.
*
* @retval ::NRF_SUCCESS Successfully queued a response to the peer, and in the case of a write operation, Attribute Table updated.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
* @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or no authorization request pending.
* @retval ::NRF_ERROR_INVALID_PARAM Authorization op invalid,
* handle supplied does not match requested handle,
* or invalid data to be written provided by the application.
*/
SVCALL(SD_BLE_GATTS_RW_AUTHORIZE_REPLY, uint32_t, sd_ble_gatts_rw_authorize_reply(uint16_t conn_handle, ble_gatts_rw_authorize_reply_params_t const *p_rw_authorize_reply_params));
/**@brief Update persistent system attribute information.
*
* @details Supply information about persistent system attributes to the stack,
* previously obtained using @ref sd_ble_gatts_sys_attr_get.
* This call is only allowed for active connections, and is usually
* made immediately after a connection is established with an known bonded device,
* often as a response to a @ref BLE_GATTS_EVT_SYS_ATTR_MISSING.
*
* p_sysattrs may point directly to the application's stored copy of the system attributes
* obtained using @ref sd_ble_gatts_sys_attr_get.
* If the pointer is NULL, the system attribute info is initialized, assuming that
* the application does not have any previously saved system attribute data for this device.
*
* @note The state of persistent system attributes is reset upon connection establishment and then remembered for its duration.
*
* @note If this call returns with an error code different from @ref NRF_SUCCESS, the storage of persistent system attributes may have been completed only partially.
* This means that the state of the attribute table is undefined, and the application should either provide a new set of attributes using this same call or
* reset the SoftDevice to return to a known state.
*
* @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS is used with this function, only the system attributes included in system services will be modified.
* @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS is used with this function, only the system attributes included in user services will be modified.
*
* @mscs
* @mmsc{@ref BLE_GATTS_HVX_SYS_ATTRS_MISSING_MSC}
* @mmsc{@ref BLE_GATTS_SYS_ATTRS_UNK_PEER_MSC}
* @mmsc{@ref BLE_GATTS_SYS_ATTRS_BONDED_PEER_MSC}
* @endmscs
*
* @param[in] conn_handle Connection handle.
* @param[in] p_sys_attr_data Pointer to a saved copy of system attributes supplied to the stack, or NULL.
* @param[in] len Size of data pointed by p_sys_attr_data, in octets.
* @param[in] flags Optional additional flags, see @ref BLE_GATTS_SYS_ATTR_FLAGS
*
* @retval ::NRF_SUCCESS Successfully set the system attribute information.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
* @retval ::NRF_ERROR_INVALID_PARAM Invalid flags supplied.
* @retval ::NRF_ERROR_INVALID_DATA Invalid data supplied, the data should be exactly the same as retrieved with @ref sd_ble_gatts_sys_attr_get.
* @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
*/
SVCALL(SD_BLE_GATTS_SYS_ATTR_SET, uint32_t, sd_ble_gatts_sys_attr_set(uint16_t conn_handle, uint8_t const *p_sys_attr_data, uint16_t len, uint32_t flags));
/**@brief Retrieve persistent system attribute information from the stack.
*
* @details This call is used to retrieve information about values to be stored persistently by the application
* during the lifetime of a connection or after it has been terminated. When a new connection is established with the same bonded device,
* the system attribute information retrieved with this function should be restored using using @ref sd_ble_gatts_sys_attr_set.
* If retrieved after disconnection, the data should be read before a new connection established. The connection handle for
* the previous, now disconnected, connection will remain valid until a new one is created to allow this API call to refer to it.
* Connection handles belonging to active connections can be used as well, but care should be taken since the system attributes
* may be written to at any time by the peer during a connection's lifetime.
*
* @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS is used with this function, only the system attributes included in system services will be returned.
* @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS is used with this function, only the system attributes included in user services will be returned.
*
* @mscs
* @mmsc{@ref BLE_GATTS_SYS_ATTRS_BONDED_PEER_MSC}
* @endmscs
*
* @param[in] conn_handle Connection handle of the recently terminated connection.
* @param[out] p_sys_attr_data Pointer to a buffer where updated information about system attributes will be filled in. The format of the data is described
* in @ref BLE_GATTS_SYS_ATTRS_FORMAT. NULL can be provided to obtain the length of the data.
* @param[in,out] p_len Size of application buffer if p_sys_attr_data is not NULL. Unconditionally updated to actual length of system attribute data.
* @param[in] flags Optional additional flags, see @ref BLE_GATTS_SYS_ATTR_FLAGS
*
* @retval ::NRF_SUCCESS Successfully retrieved the system attribute information.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::NRF_ERROR_INVALID_PARAM Invalid flags supplied.
* @retval ::NRF_ERROR_DATA_SIZE The system attribute information did not fit into the provided buffer.
* @retval ::NRF_ERROR_NOT_FOUND No system attributes found.
*/
SVCALL(SD_BLE_GATTS_SYS_ATTR_GET, uint32_t, sd_ble_gatts_sys_attr_get(uint16_t conn_handle, uint8_t *p_sys_attr_data, uint16_t *p_len, uint32_t flags));
/**@brief Retrieve the first valid user attribute handle.
*
* @param[out] p_handle Pointer to an integer where the handle will be stored.
*
* @retval ::NRF_SUCCESS Successfully retrieved the handle.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
*/
SVCALL(SD_BLE_GATTS_INITIAL_USER_HANDLE_GET, uint32_t, sd_ble_gatts_initial_user_handle_get(uint16_t *p_handle));
/**@brief Retrieve the attribute UUID and/or metadata.
*
* @param[in] handle Attribute handle
* @param[out] p_uuid UUID of the attribute. Use NULL to omit this field.
* @param[out] p_md Metadata of the attribute. Use NULL to omit this field.
*
* @retval ::NRF_SUCCESS Successfully retrieved the attribute metadata,
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameters supplied. Returned when both @c p_uuid and @c p_md are NULL.
* @retval ::NRF_ERROR_NOT_FOUND Attribute was not found.
*/
SVCALL(SD_BLE_GATTS_ATTR_GET, uint32_t, sd_ble_gatts_attr_get(uint16_t handle, ble_uuid_t * p_uuid, ble_gatts_attr_md_t * p_md));
/**@brief Reply to an ATT_MTU exchange request by sending an Exchange MTU Response to the client.
*
* @details This function is only used to reply to a @ref BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST event.
*
* @details The SoftDevice sets ATT_MTU to the minimum of:
* - The Client RX MTU value from @ref BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST, and
* - The Server RX MTU value.
*
* However, the SoftDevice never sets ATT_MTU lower than @ref BLE_GATT_ATT_MTU_DEFAULT.
*
* @mscs
* @mmsc{@ref BLE_GATTS_MTU_EXCHANGE}
* @endmscs
*
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
* @param[in] server_rx_mtu Server RX MTU size.
* - The minimum value is @ref BLE_GATT_ATT_MTU_DEFAULT.
* - The maximum value is @ref ble_gatt_conn_cfg_t::att_mtu in the connection configuration
used for this connection.
* - The value must be equal to Client RX MTU size given in @ref sd_ble_gattc_exchange_mtu_request
* if an ATT_MTU exchange has already been performed in the other direction.
*
* @retval ::NRF_SUCCESS Successfully sent response to the client.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
* @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or no ATT_MTU exchange request pending.
* @retval ::NRF_ERROR_INVALID_PARAM Invalid Server RX MTU size supplied.
*/
SVCALL(SD_BLE_GATTS_EXCHANGE_MTU_REPLY, uint32_t, sd_ble_gatts_exchange_mtu_reply(uint16_t conn_handle, uint16_t server_rx_mtu));
/** @} */
#ifdef __cplusplus
}
#endif
#endif // BLE_GATTS_H__
/**
@}
*/

View File

@ -1,135 +0,0 @@
/*
* Copyright (c) 2012 - 2017, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@addtogroup BLE_COMMON
@{
*/
#ifndef BLE_HCI_H__
#define BLE_HCI_H__
#ifdef __cplusplus
extern "C" {
#endif
/** @defgroup BLE_HCI_STATUS_CODES Bluetooth status codes
* @{ */
#define BLE_HCI_STATUS_CODE_SUCCESS 0x00 /**< Success. */
#define BLE_HCI_STATUS_CODE_UNKNOWN_BTLE_COMMAND 0x01 /**< Unknown BLE Command. */
#define BLE_HCI_STATUS_CODE_UNKNOWN_CONNECTION_IDENTIFIER 0x02 /**< Unknown Connection Identifier. */
/*0x03 Hardware Failure
0x04 Page Timeout
*/
#define BLE_HCI_AUTHENTICATION_FAILURE 0x05 /**< Authentication Failure. */
#define BLE_HCI_STATUS_CODE_PIN_OR_KEY_MISSING 0x06 /**< Pin or Key missing. */
#define BLE_HCI_MEMORY_CAPACITY_EXCEEDED 0x07 /**< Memory Capacity Exceeded. */
#define BLE_HCI_CONNECTION_TIMEOUT 0x08 /**< Connection Timeout. */
/*0x09 Connection Limit Exceeded
0x0A Synchronous Connection Limit To A Device Exceeded
0x0B ACL Connection Already Exists*/
#define BLE_HCI_STATUS_CODE_COMMAND_DISALLOWED 0x0C /**< Command Disallowed. */
/*0x0D Connection Rejected due to Limited Resources
0x0E Connection Rejected Due To Security Reasons
0x0F Connection Rejected due to Unacceptable BD_ADDR
0x10 Connection Accept Timeout Exceeded
0x11 Unsupported Feature or Parameter Value*/
#define BLE_HCI_STATUS_CODE_INVALID_BTLE_COMMAND_PARAMETERS 0x12 /**< Invalid BLE Command Parameters. */
#define BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION 0x13 /**< Remote User Terminated Connection. */
#define BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES 0x14 /**< Remote Device Terminated Connection due to low resources.*/
#define BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF 0x15 /**< Remote Device Terminated Connection due to power off. */
#define BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION 0x16 /**< Local Host Terminated Connection. */
/*
0x17 Repeated Attempts
0x18 Pairing Not Allowed
0x19 Unknown LMP PDU
*/
#define BLE_HCI_UNSUPPORTED_REMOTE_FEATURE 0x1A /**< Unsupported Remote Feature. */
/*
0x1B SCO Offset Rejected
0x1C SCO Interval Rejected
0x1D SCO Air Mode Rejected*/
#define BLE_HCI_STATUS_CODE_INVALID_LMP_PARAMETERS 0x1E /**< Invalid LMP Parameters. */
#define BLE_HCI_STATUS_CODE_UNSPECIFIED_ERROR 0x1F /**< Unspecified Error. */
/*0x20 Unsupported LMP Parameter Value
0x21 Role Change Not Allowed
*/
#define BLE_HCI_STATUS_CODE_LMP_RESPONSE_TIMEOUT 0x22 /**< LMP Response Timeout. */
#define BLE_HCI_STATUS_CODE_LMP_ERROR_TRANSACTION_COLLISION 0x23 /**< LMP Error Transaction Collision/LL Procedure Collision. */
#define BLE_HCI_STATUS_CODE_LMP_PDU_NOT_ALLOWED 0x24 /**< LMP PDU Not Allowed. */
/*0x25 Encryption Mode Not Acceptable
0x26 Link Key Can Not be Changed
0x27 Requested QoS Not Supported
*/
#define BLE_HCI_INSTANT_PASSED 0x28 /**< Instant Passed. */
#define BLE_HCI_PAIRING_WITH_UNIT_KEY_UNSUPPORTED 0x29 /**< Pairing with Unit Key Unsupported. */
#define BLE_HCI_DIFFERENT_TRANSACTION_COLLISION 0x2A /**< Different Transaction Collision. */
/*
0x2B Reserved
0x2C QoS Unacceptable Parameter
0x2D QoS Rejected
0x2E Channel Classification Not Supported
0x2F Insufficient Security
*/
#define BLE_HCI_PARAMETER_OUT_OF_MANDATORY_RANGE 0x30 /**< Parameter Out Of Mandatory Range. */
/*
0x31 Reserved
0x32 Role Switch Pending
0x33 Reserved
0x34 Reserved Slot Violation
0x35 Role Switch Failed
0x36 Extended Inquiry Response Too Large
0x37 Secure Simple Pairing Not Supported By Host.
0x38 Host Busy - Pairing
0x39 Connection Rejected due to No Suitable Channel Found*/
#define BLE_HCI_CONTROLLER_BUSY 0x3A /**< Controller Busy. */
#define BLE_HCI_CONN_INTERVAL_UNACCEPTABLE 0x3B /**< Connection Interval Unacceptable. */
#define BLE_HCI_DIRECTED_ADVERTISER_TIMEOUT 0x3C /**< Directed Advertisement Timeout. */
#define BLE_HCI_CONN_TERMINATED_DUE_TO_MIC_FAILURE 0x3D /**< Connection Terminated due to MIC Failure. */
#define BLE_HCI_CONN_FAILED_TO_BE_ESTABLISHED 0x3E /**< Connection Failed to be Established. */
/** @} */
#ifdef __cplusplus
}
#endif
#endif // BLE_HCI_H__
/** @} */

View File

@ -1,504 +0,0 @@
/*
* Copyright (c) 2011 - 2017, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@addtogroup BLE_L2CAP Logical Link Control and Adaptation Protocol (L2CAP)
@{
@brief Definitions and prototypes for the L2CAP interface.
*/
#ifndef BLE_L2CAP_H__
#define BLE_L2CAP_H__
#include "ble_types.h"
#include "ble_ranges.h"
#include "ble_err.h"
#include "nrf_svc.h"
#ifdef __cplusplus
extern "C" {
#endif
/**@addtogroup BLE_L2CAP_TERMINOLOGY Terminology
* @{
* @details
*
* L2CAP SDU
* - A data unit that the application can send/receive to/from a peer.
*
* L2CAP PDU
* - A data unit that is exchanged between local and remote L2CAP entities.
* It consists of L2CAP protocol control information and payload fields.
* The payload field can contain an L2CAP SDU or a part of an L2CAP SDU.
*
* L2CAP MTU
* - The maximum length of an L2CAP SDU.
*
* L2CAP MPS
* - The maximum length of an L2CAP PDU payload field.
*
* Credits
* - A value indicating the number of L2CAP PDUs that the receiver of the credit can send to the peer.
* @} */
/**@addtogroup BLE_L2CAP_ENUMERATIONS Enumerations
* @{ */
/**@brief L2CAP API SVC numbers. */
enum BLE_L2CAP_SVCS
{
SD_BLE_L2CAP_CH_SETUP = BLE_L2CAP_SVC_BASE, /**< Set up an L2CAP channel. */
SD_BLE_L2CAP_CH_RELEASE, /**< Release an L2CAP channel. */
SD_BLE_L2CAP_CH_RX, /**< Receive an SDU on an L2CAP channel. */
SD_BLE_L2CAP_CH_TX, /**< Transmit an SDU on an L2CAP channel. */
SD_BLE_L2CAP_CH_FLOW_CONTROL, /**< Advanced SDU reception flow control. */
};
/**@brief L2CAP Event IDs. */
enum BLE_L2CAP_EVTS
{
BLE_L2CAP_EVT_CH_SETUP_REQUEST = BLE_L2CAP_EVT_BASE, /**< L2CAP Channel Setup Request event.
\n See @ref ble_l2cap_evt_ch_setup_request_t. */
BLE_L2CAP_EVT_CH_SETUP_REFUSED, /**< L2CAP Channel Setup Refused event.
\n See @ref ble_l2cap_evt_ch_setup_refused_t. */
BLE_L2CAP_EVT_CH_SETUP, /**< L2CAP Channel Setup Completed event.
\n See @ref ble_l2cap_evt_ch_setup_t. */
BLE_L2CAP_EVT_CH_RELEASED, /**< L2CAP Channel Released event.
\n No additional event structure applies. */
BLE_L2CAP_EVT_CH_SDU_BUF_RELEASED, /**< L2CAP Channel SDU data buffer released event.
\n See @ref ble_l2cap_evt_ch_sdu_buf_released_t. */
BLE_L2CAP_EVT_CH_CREDIT, /**< L2CAP Channel Credit received.
\n See @ref ble_l2cap_evt_ch_credit_t. */
BLE_L2CAP_EVT_CH_RX, /**< L2CAP Channel SDU received.
\n See @ref ble_l2cap_evt_ch_rx_t. */
BLE_L2CAP_EVT_CH_TX, /**< L2CAP Channel SDU transmitted.
\n See @ref ble_l2cap_evt_ch_tx_t. */
};
/** @} */
/**@addtogroup BLE_L2CAP_DEFINES Defines
* @{ */
/**@brief Maximum number of L2CAP channels per connection. */
#define BLE_L2CAP_CH_COUNT_MAX (64)
/**@brief Minimum L2CAP MTU, in bytes. */
#define BLE_L2CAP_MTU_MIN (23)
/**@brief Minimum L2CAP MPS, in bytes. */
#define BLE_L2CAP_MPS_MIN (23)
/**@brief Invalid CID. */
#define BLE_L2CAP_CID_INVALID (0x0000)
/**@brief Default number of credits for @ref sd_ble_l2cap_ch_flow_control. */
#define BLE_L2CAP_CREDITS_DEFAULT (1)
/**@defgroup BLE_L2CAP_CH_SETUP_REFUSED_SRCS L2CAP channel setup refused sources
* @{ */
#define BLE_L2CAP_CH_SETUP_REFUSED_SRC_LOCAL (0x01) /**< Local. */
#define BLE_L2CAP_CH_SETUP_REFUSED_SRC_REMOTE (0x02) /**< Remote. */
/** @} */
/** @defgroup BLE_L2CAP_CH_STATUS_CODES L2CAP channel status codes
* @{ */
#define BLE_L2CAP_CH_STATUS_CODE_SUCCESS (0x0000) /**< Success. */
#define BLE_L2CAP_CH_STATUS_CODE_LE_PSM_NOT_SUPPORTED (0x0002) /**< LE_PSM not supported. */
#define BLE_L2CAP_CH_STATUS_CODE_NO_RESOURCES (0x0004) /**< No resources available. */
#define BLE_L2CAP_CH_STATUS_CODE_INSUFF_AUTHENTICATION (0x0005) /**< Insufficient authentication. */
#define BLE_L2CAP_CH_STATUS_CODE_INSUFF_AUTHORIZATION (0x0006) /**< Insufficient authorization. */
#define BLE_L2CAP_CH_STATUS_CODE_INSUFF_ENC_KEY_SIZE (0x0007) /**< Insufficient encryption key size. */
#define BLE_L2CAP_CH_STATUS_CODE_INSUFF_ENC (0x0008) /**< Insufficient encryption. */
#define BLE_L2CAP_CH_STATUS_CODE_INVALID_SCID (0x0009) /**< Invalid Source CID. */
#define BLE_L2CAP_CH_STATUS_CODE_SCID_ALLOCATED (0x000A) /**< Source CID already allocated. */
#define BLE_L2CAP_CH_STATUS_CODE_UNACCEPTABLE_PARAMS (0x000B) /**< Unacceptable parameters. */
#define BLE_L2CAP_CH_STATUS_CODE_NOT_UNDERSTOOD (0x8000) /**< Command Reject received instead of LE Credit Based Connection Response. */
#define BLE_L2CAP_CH_STATUS_CODE_TIMEOUT (0xC000) /**< Operation timed out. */
/** @} */
/** @} */
/**@addtogroup BLE_L2CAP_STRUCTURES Structures
* @{ */
/**
* @brief BLE L2CAP connection configuration parameters, set with @ref sd_ble_cfg_set.
*
* @note These parameters are set per connection, so all L2CAP channels created on this connection
* will have the same parameters.
*
* @retval ::NRF_ERROR_INVALID_PARAM One or more of the following is true:
* - rx_mps is smaller than @ref BLE_L2CAP_MPS_MIN.
* - tx_mps is smaller than @ref BLE_L2CAP_MPS_MIN.
* - ch_count is greater than @ref BLE_L2CAP_CH_COUNT_MAX.
* @retval ::NRF_ERROR_NO_MEM rx_mps or tx_mps is set too high.
*/
typedef struct
{
uint16_t rx_mps; /**< The maximum L2CAP PDU payload size, in bytes, that L2CAP shall
be able to receive on L2CAP channels on connections with this
configuration. The minimum value is @ref BLE_L2CAP_MPS_MIN. */
uint16_t tx_mps; /**< The maximum L2CAP PDU payload size, in bytes, that L2CAP shall
be able to transmit on L2CAP channels on connections with this
configuration. The minimum value is @ref BLE_L2CAP_MPS_MIN. */
uint8_t rx_queue_size; /**< Number of SDU data buffers that can be queued for reception per
L2CAP channel. The minimum value is one. */
uint8_t tx_queue_size; /**< Number of SDU data buffers that can be queued for transmission
per L2CAP channel. The minimum value is one. */
uint8_t ch_count; /**< Number of L2CAP channels the application can create per connection
with this configuration. The default value is zero, the maximum
value is @ref BLE_L2CAP_CH_COUNT_MAX.
@note if this parameter is set to zero, all other parameters in
@ref ble_l2cap_conn_cfg_t are ignored. */
} ble_l2cap_conn_cfg_t;
/**@brief L2CAP channel RX parameters. */
typedef struct
{
uint16_t rx_mtu; /**< The maximum L2CAP SDU size, in bytes, that L2CAP shall be able to
receive on this L2CAP channel.
- Must be equal to or greater than @ref BLE_L2CAP_MTU_MIN. */
uint16_t rx_mps; /**< The maximum L2CAP PDU payload size, in bytes, that L2CAP shall be
able to receive on this L2CAP channel.
- Must be equal to or greater than @ref BLE_L2CAP_MPS_MIN.
- Must be equal to or less than @ref ble_l2cap_conn_cfg_t::rx_mps. */
ble_data_t sdu_buf; /**< SDU data buffer for reception.
- If @ref ble_data_t::p_data is non-NULL, initial credits are
issued to the peer.
- If @ref ble_data_t::p_data is NULL, no initial credits are
issued to the peer. */
} ble_l2cap_ch_rx_params_t;
/**@brief L2CAP channel setup parameters. */
typedef struct
{
ble_l2cap_ch_rx_params_t rx_params; /**< L2CAP channel RX parameters. */
uint16_t le_psm; /**< LE Protocol/Service Multiplexer. Used when requesting
setup of an L2CAP channel, ignored otherwise. */
uint16_t status; /**< Status code, see @ref BLE_L2CAP_CH_STATUS_CODES.
Used when replying to a setup request of an L2CAP
channel, ignored otherwise. */
} ble_l2cap_ch_setup_params_t;
/**@brief L2CAP channel TX parameters. */
typedef struct
{
uint16_t tx_mtu; /**< The maximum L2CAP SDU size, in bytes, that L2CAP is able to
transmit on this L2CAP channel. */
uint16_t peer_mps; /**< The maximum L2CAP PDU payload size, in bytes, that the peer is
able to receive on this L2CAP channel. */
uint16_t tx_mps; /**< The maximum L2CAP PDU payload size, in bytes, that L2CAP is able
to transmit on this L2CAP channel. This is effective tx_mps,
selected by the SoftDevice as
MIN( @ref ble_l2cap_ch_tx_params_t::peer_mps, @ref ble_l2cap_conn_cfg_t::tx_mps ) */
uint16_t credits; /**< Initial credits given by the peer. */
} ble_l2cap_ch_tx_params_t;
/**@brief L2CAP Channel Setup Request event. */
typedef struct
{
ble_l2cap_ch_tx_params_t tx_params; /**< L2CAP channel TX parameters. */
uint16_t le_psm; /**< LE Protocol/Service Multiplexer. */
} ble_l2cap_evt_ch_setup_request_t;
/**@brief L2CAP Channel Setup Refused event. */
typedef struct
{
uint8_t source; /**< Source, see @ref BLE_L2CAP_CH_SETUP_REFUSED_SRCS */
uint16_t status; /**< Status code, see @ref BLE_L2CAP_CH_STATUS_CODES */
} ble_l2cap_evt_ch_setup_refused_t;
/**@brief L2CAP Channel Setup Completed event. */
typedef struct
{
ble_l2cap_ch_tx_params_t tx_params; /**< L2CAP channel TX parameters. */
} ble_l2cap_evt_ch_setup_t;
/**@brief L2CAP Channel SDU Data Duffer Released event. */
typedef struct
{
ble_data_t sdu_buf; /**< Returned reception or transmission SDU data buffer. The SoftDevice
returns SDU data buffers supplied by the application, which have
not yet been returned previously via a @ref BLE_L2CAP_EVT_CH_RX or
@ref BLE_L2CAP_EVT_CH_TX event. */
} ble_l2cap_evt_ch_sdu_buf_released_t;
/**@brief L2CAP Channel Credit received event. */
typedef struct
{
uint16_t credits; /**< Additional credits given by the peer. */
} ble_l2cap_evt_ch_credit_t;
/**@brief L2CAP Channel received SDU event. */
typedef struct
{
uint16_t sdu_len; /**< Total SDU length, in bytes. */
ble_data_t sdu_buf; /**< SDU data buffer.
@note If there is not enough space in the buffer
(sdu_buf.len < sdu_len) then the rest of the SDU will be
silently discarded by the SoftDevice. */
} ble_l2cap_evt_ch_rx_t;
/**@brief L2CAP Channel transmitted SDU event. */
typedef struct
{
ble_data_t sdu_buf; /**< SDU data buffer. */
} ble_l2cap_evt_ch_tx_t;
/**@brief L2CAP event structure. */
typedef struct
{
uint16_t conn_handle; /**< Connection Handle on which the event occured. */
uint16_t local_cid; /**< Local Channel ID of the L2CAP channel, or
@ref BLE_L2CAP_CID_INVALID if not present. */
union
{
ble_l2cap_evt_ch_setup_request_t ch_setup_request; /**< L2CAP Channel Setup Request Event Parameters. */
ble_l2cap_evt_ch_setup_refused_t ch_setup_refused; /**< L2CAP Channel Setup Refused Event Parameters. */
ble_l2cap_evt_ch_setup_t ch_setup; /**< L2CAP Channel Setup Completed Event Parameters. */
ble_l2cap_evt_ch_sdu_buf_released_t ch_sdu_buf_released;/**< L2CAP Channel SDU Data Buffer Released Event Parameters. */
ble_l2cap_evt_ch_credit_t credit; /**< L2CAP Channel Credit Received Event Parameters. */
ble_l2cap_evt_ch_rx_t rx; /**< L2CAP Channel SDU Received Event Parameters. */
ble_l2cap_evt_ch_tx_t tx; /**< L2CAP Channel SDU Transmitted Event Parameters. */
} params; /**< Event Parameters. */
} ble_l2cap_evt_t;
/** @} */
/**@addtogroup BLE_L2CAP_FUNCTIONS Functions
* @{ */
/**@brief Set up an L2CAP channel.
*
* @details This function is used to:
* - Request setup of an L2CAP channel: sends an LE Credit Based Connection Request packet to a peer.
* - Reply to a setup request of an L2CAP channel (if called in response to a
* @ref BLE_L2CAP_EVT_CH_SETUP_REQUEST event): sends an LE Credit Based Connection
* Response packet to a peer.
*
* @note A call to this function will require the application to keep the SDU data buffer alive
* until the SDU data buffer is returned in @ref BLE_L2CAP_EVT_CH_RX or
* @ref BLE_L2CAP_EVT_CH_SDU_BUF_RELEASED event.
*
* @events
* @event{@ref BLE_L2CAP_EVT_CH_SETUP, Setup successful.}
* @event{@ref BLE_L2CAP_EVT_CH_SETUP_REFUSED, Setup failed.}
* @endevents
*
* @mscs
* @mmsc{@ref BLE_L2CAP_CH_SETUP_MSC}
* @endmscs
*
* @param[in] conn_handle Connection Handle.
* @param[in,out] p_local_cid Pointer to a uint16_t containing Local Channel ID of the L2CAP channel:
* - As input: @ref BLE_L2CAP_CID_INVALID when requesting setup of an L2CAP
* channel or local_cid provided in the @ref BLE_L2CAP_EVT_CH_SETUP_REQUEST
* event when replying to a setup request of an L2CAP channel.
* - As output: local_cid for this channel.
* @param[in] p_params L2CAP channel parameters.
*
* @retval ::NRF_SUCCESS Successfully queued request or response for transmission.
* @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
* @retval ::NRF_ERROR_INVALID_LENGTH Supplied higher rx_mps than has been configured on this link.
* @retval ::NRF_ERROR_INVALID_STATE Invalid State to perform operation (L2CAP channel already set up).
* @retval ::NRF_ERROR_NOT_FOUND CID not found.
* @retval ::NRF_ERROR_RESOURCES The limit has been reached for available L2CAP channels,
* see @ref ble_l2cap_conn_cfg_t::ch_count.
*/
SVCALL(SD_BLE_L2CAP_CH_SETUP, uint32_t, sd_ble_l2cap_ch_setup(uint16_t conn_handle, uint16_t *p_local_cid, ble_l2cap_ch_setup_params_t const *p_params));
/**@brief Release an L2CAP channel.
*
* @details This sends a Disconnection Request packet to a peer.
*
* @events
* @event{@ref BLE_L2CAP_EVT_CH_RELEASED, Release complete.}
* @endevents
*
* @mscs
* @mmsc{@ref BLE_L2CAP_CH_RELEASE_MSC}
* @endmscs
*
* @param[in] conn_handle Connection Handle.
* @param[in] local_cid Local Channel ID of the L2CAP channel.
*
* @retval ::NRF_SUCCESS Successfully queued request for transmission.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
* @retval ::NRF_ERROR_INVALID_STATE Invalid State to perform operation (Setup or release is
* in progress for the L2CAP channel).
* @retval ::NRF_ERROR_NOT_FOUND CID not found.
*/
SVCALL(SD_BLE_L2CAP_CH_RELEASE, uint32_t, sd_ble_l2cap_ch_release(uint16_t conn_handle, uint16_t local_cid));
/**@brief Receive an SDU on an L2CAP channel.
*
* @details This may issue additional credits to the peer using an LE Flow Control Credit packet.
*
* @note A call to this function will require the application to keep the memory pointed by
* @ref ble_data_t::p_data alive until the SDU data buffer is returned in @ref BLE_L2CAP_EVT_CH_RX
* or @ref BLE_L2CAP_EVT_CH_SDU_BUF_RELEASED event.
*
* @note The SoftDevice can queue up to @ref ble_l2cap_conn_cfg_t::rx_queue_size SDU data buffers
* for reception per L2CAP channel.
*
* @events
* @event{@ref BLE_L2CAP_EVT_CH_RX, The SDU is received.}
* @endevents
*
* @mscs
* @mmsc{@ref BLE_L2CAP_CH_RX_MSC}
* @endmscs
*
* @param[in] conn_handle Connection Handle.
* @param[in] local_cid Local Channel ID of the L2CAP channel.
* @param[in] p_sdu_buf Pointer to the SDU data buffer.
*
* @retval ::NRF_SUCCESS Buffer accepted.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
* @retval ::NRF_ERROR_INVALID_STATE Invalid State to perform operation (Setup or release is
* in progress for an L2CAP channel).
* @retval ::NRF_ERROR_NOT_FOUND CID not found.
* @retval ::NRF_ERROR_RESOURCES Too many SDU data buffers supplied. Wait for a
* @ref BLE_L2CAP_EVT_CH_RX event and retry.
*/
SVCALL(SD_BLE_L2CAP_CH_RX, uint32_t, sd_ble_l2cap_ch_rx(uint16_t conn_handle, uint16_t local_cid, ble_data_t const *p_sdu_buf));
/**@brief Transmit an SDU on an L2CAP channel.
*
* @note A call to this function will require the application to keep the memory pointed by
* @ref ble_data_t::p_data alive until the SDU data buffer is returned in @ref BLE_L2CAP_EVT_CH_TX
* or @ref BLE_L2CAP_EVT_CH_SDU_BUF_RELEASED event.
*
* @note The SoftDevice can queue up to @ref ble_l2cap_conn_cfg_t::tx_queue_size SDUs for
* transmission per L2CAP channel.
*
* @note The application can keep track of the available credits for transmission by following
* the procedure below:
* - Store initial credits given by the peer in a variable.
* (Initial credits are provided in a @ref BLE_L2CAP_EVT_CH_SETUP event.)
* - Decrement the variable, which stores the currently available credits, by
* ceiling((@ref ble_data_t::len + 2) / tx_mps) when a call to this function returns
* @ref NRF_SUCCESS. (tx_mps is provided in a @ref BLE_L2CAP_EVT_CH_SETUP event.)
* - Increment the variable, which stores the currently available credits, by additional
* credits given by the peer in a @ref BLE_L2CAP_EVT_CH_CREDIT event.
*
* @events
* @event{@ref BLE_L2CAP_EVT_CH_TX, The SDU is transmitted.}
* @endevents
*
* @mscs
* @mmsc{@ref BLE_L2CAP_CH_TX_MSC}
* @endmscs
*
* @param[in] conn_handle Connection Handle.
* @param[in] local_cid Local Channel ID of the L2CAP channel.
* @param[in] p_sdu_buf Pointer to the SDU data buffer.
*
* @retval ::NRF_SUCCESS Successfully queued L2CAP SDU for transmission.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
* @retval ::NRF_ERROR_INVALID_STATE Invalid State to perform operation (Setup or release is
* in progress for the L2CAP channel).
* @retval ::NRF_ERROR_NOT_FOUND CID not found.
* @retval ::NRF_ERROR_DATA_SIZE Invalid SDU length supplied, must not be more than
* @ref ble_l2cap_ch_tx_params_t::tx_mtu provided in
* @ref BLE_L2CAP_EVT_CH_SETUP event.
* @retval ::NRF_ERROR_RESOURCES Too many SDUs queued for transmission. Wait for a
* @ref BLE_L2CAP_EVT_CH_TX event and retry.
*/
SVCALL(SD_BLE_L2CAP_CH_TX, uint32_t, sd_ble_l2cap_ch_tx(uint16_t conn_handle, uint16_t local_cid, ble_data_t const *p_sdu_buf));
/**@brief Advanced SDU reception flow control.
*
* @details Adjust the way the SoftDevice issues credits to the peer.
* This may issue additional credits to the peer using an LE Flow Control Credit packet.
*
* @mscs
* @mmsc{@ref BLE_L2CAP_CH_FLOW_CONTROL_MSC}
* @endmscs
*
* @param[in] conn_handle Connection Handle.
* @param[in] local_cid Local Channel ID of the L2CAP channel or @ref BLE_L2CAP_CID_INVALID to set
* the value that will be used for newly created channels.
* @param[in] credits Number of credits that the SoftDevice will make sure the peer has every
* time it starts using a new reception buffer.
* - @ref BLE_L2CAP_CREDITS_DEFAULT is the default value the SoftDevice will
* use if this function is not called.
* - If set to zero, the SoftDevice will stop issuing credits for new reception
* buffers the application provides or has provided. SDU reception that is
* currently ongoing will be allowed to complete.
* @param[out] p_credits NULL or pointer to a uint16_t. If a valid pointer is provided, it will be
* written by the SoftDevice with the number of credits that is or will be
* available to the peer. If the value written by the SoftDevice is 0 when
* credits parameter was set to 0, the peer will not be able to send more
* data until more credits are provided by calling this function again with
* credits > 0. This parameter is ignored when local_cid is set to @ref
* BLE_L2CAP_CID_INVALID.
*
* @note Application should take care when setting number of credits higher than default value. In
* this case the application must make sure that the SoftDevice always has reception buffers
* available (see @ref sd_ble_l2cap_ch_rx) for that channel. If the SoftDevice does not have
* such buffers available, packets may be NACKed on the Link Layer and all Bluetooth traffic
* on the connection handle may be stalled until the SoftDevice again has an available
* reception buffer. This applies even if the application has used this call to set the
* credits back to default, or zero.
*
* @retval ::NRF_SUCCESS Flow control parameters accepted.
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
* @retval ::NRF_ERROR_INVALID_STATE Invalid State to perform operation (Setup or release is
* in progress for an L2CAP channel).
* @retval ::NRF_ERROR_NOT_FOUND CID not found.
*/
SVCALL(SD_BLE_L2CAP_CH_FLOW_CONTROL, uint32_t, sd_ble_l2cap_ch_flow_control(uint16_t conn_handle, uint16_t local_cid, uint16_t credits, uint16_t *p_credits));
/** @} */
#ifdef __cplusplus
}
#endif
#endif // BLE_L2CAP_H__
/**
@}
*/

View File

@ -1,156 +0,0 @@
/*
* Copyright (c) 2012 - 2017, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@addtogroup BLE_COMMON
@{
@defgroup ble_ranges Module specific SVC, event and option number subranges
@{
@brief Definition of SVC, event and option number subranges for each API module.
@note
SVCs, event and option numbers are split into subranges for each API module.
Each module receives its entire allocated range of SVC calls, whether implemented or not,
but return BLE_ERROR_NOT_SUPPORTED for unimplemented or undefined calls in its range.
Note that the symbols BLE_<module>_SVC_LAST is the end of the allocated SVC range,
rather than the last SVC function call actually defined and implemented.
Specific SVC, event and option values are defined in each module's ble_<module>.h file,
which defines names of each individual SVC code based on the range start value.
*/
#ifndef BLE_RANGES_H__
#define BLE_RANGES_H__
#ifdef __cplusplus
extern "C" {
#endif
#define BLE_SVC_BASE 0x60 /**< Common BLE SVC base. */
#define BLE_SVC_LAST 0x6B /**< Common BLE SVC last. */
#define BLE_GAP_SVC_BASE 0x6C /**< GAP BLE SVC base. */
#define BLE_GAP_SVC_LAST 0x93 /**< GAP BLE SVC last. */
#define BLE_GATTC_SVC_BASE 0x94 /**< GATTC BLE SVC base. */
#define BLE_GATTC_SVC_LAST 0x9F /**< GATTC BLE SVC last. */
#define BLE_GATTS_SVC_BASE 0xA0 /**< GATTS BLE SVC base. */
#define BLE_GATTS_SVC_LAST 0xAF /**< GATTS BLE SVC last. */
#define BLE_L2CAP_SVC_BASE 0xB0 /**< L2CAP BLE SVC base. */
#define BLE_L2CAP_SVC_LAST 0xBF /**< L2CAP BLE SVC last. */
#define BLE_EVT_INVALID 0x00 /**< Invalid BLE Event. */
#define BLE_EVT_BASE 0x01 /**< Common BLE Event base. */
#define BLE_EVT_LAST 0x0F /**< Common BLE Event last. */
#define BLE_GAP_EVT_BASE 0x10 /**< GAP BLE Event base. */
#define BLE_GAP_EVT_LAST 0x2F /**< GAP BLE Event last. */
#define BLE_GATTC_EVT_BASE 0x30 /**< GATTC BLE Event base. */
#define BLE_GATTC_EVT_LAST 0x4F /**< GATTC BLE Event last. */
#define BLE_GATTS_EVT_BASE 0x50 /**< GATTS BLE Event base. */
#define BLE_GATTS_EVT_LAST 0x6F /**< GATTS BLE Event last. */
#define BLE_L2CAP_EVT_BASE 0x70 /**< L2CAP BLE Event base. */
#define BLE_L2CAP_EVT_LAST 0x8F /**< L2CAP BLE Event last. */
#define BLE_OPT_INVALID 0x00 /**< Invalid BLE Option. */
#define BLE_OPT_BASE 0x01 /**< Common BLE Option base. */
#define BLE_OPT_LAST 0x1F /**< Common BLE Option last. */
#define BLE_GAP_OPT_BASE 0x20 /**< GAP BLE Option base. */
#define BLE_GAP_OPT_LAST 0x3F /**< GAP BLE Option last. */
#define BLE_GATT_OPT_BASE 0x40 /**< GATT BLE Option base. */
#define BLE_GATT_OPT_LAST 0x5F /**< GATT BLE Option last. */
#define BLE_GATTC_OPT_BASE 0x60 /**< GATTC BLE Option base. */
#define BLE_GATTC_OPT_LAST 0x7F /**< GATTC BLE Option last. */
#define BLE_GATTS_OPT_BASE 0x80 /**< GATTS BLE Option base. */
#define BLE_GATTS_OPT_LAST 0x9F /**< GATTS BLE Option last. */
#define BLE_L2CAP_OPT_BASE 0xA0 /**< L2CAP BLE Option base. */
#define BLE_L2CAP_OPT_LAST 0xBF /**< L2CAP BLE Option last. */
#define BLE_CFG_INVALID 0x00 /**< Invalid BLE configuration. */
#define BLE_CFG_BASE 0x01 /**< Common BLE configuration base. */
#define BLE_CFG_LAST 0x1F /**< Common BLE configuration last. */
#define BLE_CONN_CFG_BASE 0x20 /**< BLE connection configuration base. */
#define BLE_CONN_CFG_LAST 0x3F /**< BLE connection configuration last. */
#define BLE_GAP_CFG_BASE 0x40 /**< GAP BLE configuration base. */
#define BLE_GAP_CFG_LAST 0x5F /**< GAP BLE configuration last. */
#define BLE_GATT_CFG_BASE 0x60 /**< GATT BLE configuration base. */
#define BLE_GATT_CFG_LAST 0x7F /**< GATT BLE configuration last. */
#define BLE_GATTC_CFG_BASE 0x80 /**< GATTC BLE configuration base. */
#define BLE_GATTC_CFG_LAST 0x9F /**< GATTC BLE configuration last. */
#define BLE_GATTS_CFG_BASE 0xA0 /**< GATTS BLE configuration base. */
#define BLE_GATTS_CFG_LAST 0xBF /**< GATTS BLE configuration last. */
#define BLE_L2CAP_CFG_BASE 0xC0 /**< L2CAP BLE configuration base. */
#define BLE_L2CAP_CFG_LAST 0xDF /**< L2CAP BLE configuration last. */
#ifdef __cplusplus
}
#endif
#endif /* BLE_RANGES_H__ */
/**
@}
@}
*/

View File

@ -1,215 +0,0 @@
/*
* Copyright (c) 2012 - 2017, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@addtogroup BLE_COMMON
@{
@defgroup ble_types Common types and macro definitions
@{
@brief Common types and macro definitions for the BLE SoftDevice.
*/
#ifndef BLE_TYPES_H__
#define BLE_TYPES_H__
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup BLE_TYPES_DEFINES Defines
* @{ */
/** @defgroup BLE_CONN_HANDLES BLE Connection Handles
* @{ */
#define BLE_CONN_HANDLE_INVALID 0xFFFF /**< Invalid Connection Handle. */
#define BLE_CONN_HANDLE_ALL 0xFFFE /**< Applies to all Connection Handles. */
/** @} */
/** @defgroup BLE_UUID_VALUES Assigned Values for BLE UUIDs
* @{ */
/* Generic UUIDs, applicable to all services */
#define BLE_UUID_UNKNOWN 0x0000 /**< Reserved UUID. */
#define BLE_UUID_SERVICE_PRIMARY 0x2800 /**< Primary Service. */
#define BLE_UUID_SERVICE_SECONDARY 0x2801 /**< Secondary Service. */
#define BLE_UUID_SERVICE_INCLUDE 0x2802 /**< Include. */
#define BLE_UUID_CHARACTERISTIC 0x2803 /**< Characteristic. */
#define BLE_UUID_DESCRIPTOR_CHAR_EXT_PROP 0x2900 /**< Characteristic Extended Properties Descriptor. */
#define BLE_UUID_DESCRIPTOR_CHAR_USER_DESC 0x2901 /**< Characteristic User Description Descriptor. */
#define BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG 0x2902 /**< Client Characteristic Configuration Descriptor. */
#define BLE_UUID_DESCRIPTOR_SERVER_CHAR_CONFIG 0x2903 /**< Server Characteristic Configuration Descriptor. */
#define BLE_UUID_DESCRIPTOR_CHAR_PRESENTATION_FORMAT 0x2904 /**< Characteristic Presentation Format Descriptor. */
#define BLE_UUID_DESCRIPTOR_CHAR_AGGREGATE_FORMAT 0x2905 /**< Characteristic Aggregate Format Descriptor. */
/* GATT specific UUIDs */
#define BLE_UUID_GATT 0x1801 /**< Generic Attribute Profile. */
#define BLE_UUID_GATT_CHARACTERISTIC_SERVICE_CHANGED 0x2A05 /**< Service Changed Characteristic. */
/* GAP specific UUIDs */
#define BLE_UUID_GAP 0x1800 /**< Generic Access Profile. */
#define BLE_UUID_GAP_CHARACTERISTIC_DEVICE_NAME 0x2A00 /**< Device Name Characteristic. */
#define BLE_UUID_GAP_CHARACTERISTIC_APPEARANCE 0x2A01 /**< Appearance Characteristic. */
#define BLE_UUID_GAP_CHARACTERISTIC_RECONN_ADDR 0x2A03 /**< Reconnection Address Characteristic. */
#define BLE_UUID_GAP_CHARACTERISTIC_PPCP 0x2A04 /**< Peripheral Preferred Connection Parameters Characteristic. */
#define BLE_UUID_GAP_CHARACTERISTIC_CAR 0x2AA6 /**< Central Address Resolution Characteristic. */
#define BLE_UUID_GAP_CHARACTERISTIC_RPA_ONLY 0x2AC9 /**< Resolvable Private Address Only Characteristic. */
/** @} */
/** @defgroup BLE_UUID_TYPES Types of UUID
* @{ */
#define BLE_UUID_TYPE_UNKNOWN 0x00 /**< Invalid UUID type. */
#define BLE_UUID_TYPE_BLE 0x01 /**< Bluetooth SIG UUID (16-bit). */
#define BLE_UUID_TYPE_VENDOR_BEGIN 0x02 /**< Vendor UUID types start at this index (128-bit). */
/** @} */
/** @defgroup BLE_APPEARANCES Bluetooth Appearance values
* @note Retrieved from http://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml
* @{ */
#define BLE_APPEARANCE_UNKNOWN 0 /**< Unknown. */
#define BLE_APPEARANCE_GENERIC_PHONE 64 /**< Generic Phone. */
#define BLE_APPEARANCE_GENERIC_COMPUTER 128 /**< Generic Computer. */
#define BLE_APPEARANCE_GENERIC_WATCH 192 /**< Generic Watch. */
#define BLE_APPEARANCE_WATCH_SPORTS_WATCH 193 /**< Watch: Sports Watch. */
#define BLE_APPEARANCE_GENERIC_CLOCK 256 /**< Generic Clock. */
#define BLE_APPEARANCE_GENERIC_DISPLAY 320 /**< Generic Display. */
#define BLE_APPEARANCE_GENERIC_REMOTE_CONTROL 384 /**< Generic Remote Control. */
#define BLE_APPEARANCE_GENERIC_EYE_GLASSES 448 /**< Generic Eye-glasses. */
#define BLE_APPEARANCE_GENERIC_TAG 512 /**< Generic Tag. */
#define BLE_APPEARANCE_GENERIC_KEYRING 576 /**< Generic Keyring. */
#define BLE_APPEARANCE_GENERIC_MEDIA_PLAYER 640 /**< Generic Media Player. */
#define BLE_APPEARANCE_GENERIC_BARCODE_SCANNER 704 /**< Generic Barcode Scanner. */
#define BLE_APPEARANCE_GENERIC_THERMOMETER 768 /**< Generic Thermometer. */
#define BLE_APPEARANCE_THERMOMETER_EAR 769 /**< Thermometer: Ear. */
#define BLE_APPEARANCE_GENERIC_HEART_RATE_SENSOR 832 /**< Generic Heart rate Sensor. */
#define BLE_APPEARANCE_HEART_RATE_SENSOR_HEART_RATE_BELT 833 /**< Heart Rate Sensor: Heart Rate Belt. */
#define BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE 896 /**< Generic Blood Pressure. */
#define BLE_APPEARANCE_BLOOD_PRESSURE_ARM 897 /**< Blood Pressure: Arm. */
#define BLE_APPEARANCE_BLOOD_PRESSURE_WRIST 898 /**< Blood Pressure: Wrist. */
#define BLE_APPEARANCE_GENERIC_HID 960 /**< Human Interface Device (HID). */
#define BLE_APPEARANCE_HID_KEYBOARD 961 /**< Keyboard (HID Subtype). */
#define BLE_APPEARANCE_HID_MOUSE 962 /**< Mouse (HID Subtype). */
#define BLE_APPEARANCE_HID_JOYSTICK 963 /**< Joystick (HID Subtype). */
#define BLE_APPEARANCE_HID_GAMEPAD 964 /**< Gamepad (HID Subtype). */
#define BLE_APPEARANCE_HID_DIGITIZERSUBTYPE 965 /**< Digitizer Tablet (HID Subtype). */
#define BLE_APPEARANCE_HID_CARD_READER 966 /**< Card Reader (HID Subtype). */
#define BLE_APPEARANCE_HID_DIGITAL_PEN 967 /**< Digital Pen (HID Subtype). */
#define BLE_APPEARANCE_HID_BARCODE 968 /**< Barcode Scanner (HID Subtype). */
#define BLE_APPEARANCE_GENERIC_GLUCOSE_METER 1024 /**< Generic Glucose Meter. */
#define BLE_APPEARANCE_GENERIC_RUNNING_WALKING_SENSOR 1088 /**< Generic Running Walking Sensor. */
#define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_IN_SHOE 1089 /**< Running Walking Sensor: In-Shoe. */
#define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_ON_SHOE 1090 /**< Running Walking Sensor: On-Shoe. */
#define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_ON_HIP 1091 /**< Running Walking Sensor: On-Hip. */
#define BLE_APPEARANCE_GENERIC_CYCLING 1152 /**< Generic Cycling. */
#define BLE_APPEARANCE_CYCLING_CYCLING_COMPUTER 1153 /**< Cycling: Cycling Computer. */
#define BLE_APPEARANCE_CYCLING_SPEED_SENSOR 1154 /**< Cycling: Speed Sensor. */
#define BLE_APPEARANCE_CYCLING_CADENCE_SENSOR 1155 /**< Cycling: Cadence Sensor. */
#define BLE_APPEARANCE_CYCLING_POWER_SENSOR 1156 /**< Cycling: Power Sensor. */
#define BLE_APPEARANCE_CYCLING_SPEED_CADENCE_SENSOR 1157 /**< Cycling: Speed and Cadence Sensor. */
#define BLE_APPEARANCE_GENERIC_PULSE_OXIMETER 3136 /**< Generic Pulse Oximeter. */
#define BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP 3137 /**< Fingertip (Pulse Oximeter subtype). */
#define BLE_APPEARANCE_PULSE_OXIMETER_WRIST_WORN 3138 /**< Wrist Worn(Pulse Oximeter subtype). */
#define BLE_APPEARANCE_GENERIC_WEIGHT_SCALE 3200 /**< Generic Weight Scale. */
#define BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS_ACT 5184 /**< Generic Outdoor Sports Activity. */
#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_DISP 5185 /**< Location Display Device (Outdoor Sports Activity subtype). */
#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_AND_NAV_DISP 5186 /**< Location and Navigation Display Device (Outdoor Sports Activity subtype). */
#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_POD 5187 /**< Location Pod (Outdoor Sports Activity subtype). */
#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_AND_NAV_POD 5188 /**< Location and Navigation Pod (Outdoor Sports Activity subtype). */
/** @} */
/** @brief Set .type and .uuid fields of ble_uuid_struct to specified UUID value. */
#define BLE_UUID_BLE_ASSIGN(instance, value) do {\
instance.type = BLE_UUID_TYPE_BLE; \
instance.uuid = value;} while(0)
/** @brief Copy type and uuid members from src to dst ble_uuid_t pointer. Both pointers must be valid/non-null. */
#define BLE_UUID_COPY_PTR(dst, src) do {\
(dst)->type = (src)->type; \
(dst)->uuid = (src)->uuid;} while(0)
/** @brief Copy type and uuid members from src to dst ble_uuid_t struct. */
#define BLE_UUID_COPY_INST(dst, src) do {\
(dst).type = (src).type; \
(dst).uuid = (src).uuid;} while(0)
/** @brief Compare for equality both type and uuid members of two (valid, non-null) ble_uuid_t pointers. */
#define BLE_UUID_EQ(p_uuid1, p_uuid2) \
(((p_uuid1)->type == (p_uuid2)->type) && ((p_uuid1)->uuid == (p_uuid2)->uuid))
/** @brief Compare for difference both type and uuid members of two (valid, non-null) ble_uuid_t pointers. */
#define BLE_UUID_NEQ(p_uuid1, p_uuid2) \
(((p_uuid1)->type != (p_uuid2)->type) || ((p_uuid1)->uuid != (p_uuid2)->uuid))
/** @} */
/** @addtogroup BLE_TYPES_STRUCTURES Structures
* @{ */
/** @brief 128 bit UUID values. */
typedef struct
{
uint8_t uuid128[16]; /**< Little-Endian UUID bytes. */
} ble_uuid128_t;
/** @brief Bluetooth Low Energy UUID type, encapsulates both 16-bit and 128-bit UUIDs. */
typedef struct
{
uint16_t uuid; /**< 16-bit UUID value or octets 12-13 of 128-bit UUID. */
uint8_t type; /**< UUID type, see @ref BLE_UUID_TYPES. If type is @ref BLE_UUID_TYPE_UNKNOWN, the value of uuid is undefined. */
} ble_uuid_t;
/**@brief Data structure. */
typedef struct
{
uint8_t *p_data; /**< Pointer to the data buffer provided to/from the application. */
uint16_t len; /**< Length of the data buffer, in bytes. */
} ble_data_t;
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* BLE_TYPES_H__ */
/**
@}
@}
*/

View File

@ -1,228 +0,0 @@
/*
* Copyright (c) 2014 - 2017, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@defgroup nrf_mbr_api Master Boot Record API
@{
@brief APIs for updating SoftDevice and BootLoader
*/
#ifndef NRF_MBR_H__
#define NRF_MBR_H__
#include "nrf_svc.h"
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup NRF_MBR_DEFINES Defines
* @{ */
/**@brief MBR SVC Base number. */
#define MBR_SVC_BASE (0x18)
/**@brief Page size in words. */
#define MBR_PAGE_SIZE_IN_WORDS (1024)
/** @brief The size that must be reserved for the MBR when a SoftDevice is written to flash.
This is the offset where the first byte of the SoftDevice hex file is written.*/
#define MBR_SIZE (0x1000)
/** @} */
/** @addtogroup NRF_MBR_ENUMS Enumerations
* @{ */
/**@brief nRF Master Boot Record API SVC numbers. */
enum NRF_MBR_SVCS
{
SD_MBR_COMMAND = MBR_SVC_BASE, /**< ::sd_mbr_command */
};
/**@brief Possible values for ::sd_mbr_command_t.command */
enum NRF_MBR_COMMANDS
{
SD_MBR_COMMAND_COPY_BL, /**< Copy a new BootLoader. @see sd_mbr_command_copy_bl_t*/
SD_MBR_COMMAND_COPY_SD, /**< Copy a new SoftDevice. @see ::sd_mbr_command_copy_sd_t*/
SD_MBR_COMMAND_INIT_SD, /**< Initialize forwarding interrupts to SD, and run reset function in SD*/
SD_MBR_COMMAND_COMPARE, /**< This command works like memcmp. @see ::sd_mbr_command_compare_t*/
SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET, /**< Change the address the MBR starts after a reset @see ::sd_mbr_command_vector_table_base_set_t*/
SD_MBR_COMMAND_RESERVED,
SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET, /**< Start forwarding all interrupts to this address @see ::sd_mbr_command_irq_forward_address_set_t*/
};
/** @} */
/** @addtogroup NRF_MBR_TYPES Types
* @{ */
/**@brief This command copies part of a new SoftDevice
* The destination area is erased before copying.
* If dst is in the middle of a flash page, that whole flash page will be erased.
* If (dst+len) is in the middle of a flash page, that whole flash page will be erased.
*
* The user of this function is responsible for setting the BPROT registers.
*
* @retval ::NRF_SUCCESS indicates that the contents of the memory blocks where copied correctly.
* @retval ::NRF_ERROR_INTERNAL indicates that the contents of the memory blocks where not verified correctly after copying.
*/
typedef struct
{
uint32_t *src; /**< Pointer to the source of data to be copied.*/
uint32_t *dst; /**< Pointer to the destination where the content is to be copied.*/
uint32_t len; /**< Number of 32 bit words to copy. Must be a multiple of @ref MBR_PAGE_SIZE_IN_WORDS words.*/
} sd_mbr_command_copy_sd_t;
/**@brief This command works like memcmp, but takes the length in words.
*
* @retval ::NRF_SUCCESS indicates that the contents of both memory blocks are equal.
* @retval ::NRF_ERROR_NULL indicates that the contents of the memory blocks are not equal.
*/
typedef struct
{
uint32_t *ptr1; /**< Pointer to block of memory. */
uint32_t *ptr2; /**< Pointer to block of memory. */
uint32_t len; /**< Number of 32 bit words to compare.*/
} sd_mbr_command_compare_t;
/**@brief This command copies a new BootLoader.
* With this command, destination of BootLoader is always the address written in NRF_UICR->BOOTADDR.
*
* Destination is erased by this function.
* If (destination+bl_len) is in the middle of a flash page, that whole flash page will be erased.
*
* This function will use PROTENSET to protect the flash that is not intended to be written.
*
* On success, this function will not return. It will start the new BootLoader from reset-vector as normal.
*
* @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen.
* @retval ::NRF_ERROR_FORBIDDEN if NRF_UICR->BOOTADDR is not set.
* @retval ::NRF_ERROR_INVALID_LENGTH if parameters attempts to read or write outside flash area.
* @retval ::NRF_ERROR_NO_MEM if no parameter page is provided (see SoftDevice Specification for more info)
*/
typedef struct
{
uint32_t *bl_src; /**< Pointer to the source of the Bootloader to be be copied.*/
uint32_t bl_len; /**< Number of 32 bit words to copy for BootLoader. */
} sd_mbr_command_copy_bl_t;
/**@brief Change the address the MBR starts after a reset
*
* Once this function has been called, this address is where the MBR will start to forward interrupts to after a reset.
*
* To restore default forwarding this function should be called with @param address set to 0.
* The MBR will then start forwarding to interrupts to the address in NFR_UICR->BOOTADDR or to the SoftDevice if the BOOTADDR is not set.
*
* On success, this function will not return. It will reset the device.
*
* @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen.
* @retval ::NRF_ERROR_INVALID_ADDR if parameter address is outside of the flash size.
* @retval ::NRF_ERROR_NO_MEM if no parameter page is provided (see SoftDevice Specification for more info)
*/
typedef struct
{
uint32_t address; /**< The base address of the interrupt vector table for forwarded interrupts.*/
} sd_mbr_command_vector_table_base_set_t;
/**@brief Sets the base address of the interrupt vector table for interrupts forwarded from the MBR
* Unlike sd_mbr_command_vector_table_base_set_t, this function does not reset, and it does not
* change where the MBR starts after reset.
*
* @retval ::NRF_SUCCESS
*/
typedef struct
{
uint32_t address; /**< The base address of the interrupt vector table for forwarded interrupts.*/
} sd_mbr_command_irq_forward_address_set_t;
typedef struct
{
uint32_t command; /**< type of command to be issued see @ref NRF_MBR_COMMANDS. */
union
{
sd_mbr_command_copy_sd_t copy_sd; /**< Parameters for copy SoftDevice.*/
sd_mbr_command_compare_t compare; /**< Parameters for verify.*/
sd_mbr_command_copy_bl_t copy_bl; /**< Parameters for copy BootLoader. Requires parameter page. */
sd_mbr_command_vector_table_base_set_t base_set; /**< Parameters for vector table base set. Requires parameter page.*/
sd_mbr_command_irq_forward_address_set_t irq_forward_address_set; /**< Parameters for irq forward address set*/
} params;
} sd_mbr_command_t;
/** @} */
/** @addtogroup NRF_MBR_FUNCTIONS Functions
* @{ */
/**@brief Issue Master Boot Record commands
*
* Commands used when updating a SoftDevice and bootloader.
*
* The SD_MBR_COMMAND_COPY_BL and SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET requires parameters to be
* retained by the MBR when resetting the IC. This is done in a separate flash page
* provided by the application. The UICR register UICR.NRFFW[1] must be set
* to an address corresponding to a page in the application flash space. This page will be cleared
* by the MBR and used to store the command before reset. When the UICR.NRFFW[1] field is set
* the page it refers to must not be used by the application. If the UICR.NRFFW[1] is set to
* 0xFFFFFFFF (the default) MBR commands which use flash will be unavailable and return
* NRF_ERROR_NO_MEM.
*
* @param[in] param Pointer to a struct describing the command.
*
* @note For return values, see ::sd_mbr_command_copy_sd_t ::sd_mbr_command_copy_bl_t ::sd_mbr_command_compare_t ::sd_mbr_command_vector_table_base_set_t ::sd_mbr_command_irq_forward_address_set_t
*
* @retval NRF_ERROR_NO_MEM if UICR.NRFFW[1] is not set (i.e. is 0xFFFFFFFF).
* @retval NRF_ERROR_INVALID_PARAM if an invalid command is given.
*/
SVCALL(SD_MBR_COMMAND, uint32_t, sd_mbr_command(sd_mbr_command_t* param));
/** @} */
#ifdef __cplusplus
}
#endif
#endif // NRF_MBR_H__
/**
@}
*/

View File

@ -1,90 +0,0 @@
/*
* Copyright (c) 2014 - 2017, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@defgroup nrf_error SoftDevice Global Error Codes
@{
@brief Global Error definitions
*/
/* Header guard */
#ifndef NRF_ERROR_H__
#define NRF_ERROR_H__
#ifdef __cplusplus
extern "C" {
#endif
/** @defgroup NRF_ERRORS_BASE Error Codes Base number definitions
* @{ */
#define NRF_ERROR_BASE_NUM (0x0) ///< Global error base
#define NRF_ERROR_SDM_BASE_NUM (0x1000) ///< SDM error base
#define NRF_ERROR_SOC_BASE_NUM (0x2000) ///< SoC error base
#define NRF_ERROR_STK_BASE_NUM (0x3000) ///< STK error base
/** @} */
#define NRF_SUCCESS (NRF_ERROR_BASE_NUM + 0) ///< Successful command
#define NRF_ERROR_SVC_HANDLER_MISSING (NRF_ERROR_BASE_NUM + 1) ///< SVC handler is missing
#define NRF_ERROR_SOFTDEVICE_NOT_ENABLED (NRF_ERROR_BASE_NUM + 2) ///< SoftDevice has not been enabled
#define NRF_ERROR_INTERNAL (NRF_ERROR_BASE_NUM + 3) ///< Internal Error
#define NRF_ERROR_NO_MEM (NRF_ERROR_BASE_NUM + 4) ///< No Memory for operation
#define NRF_ERROR_NOT_FOUND (NRF_ERROR_BASE_NUM + 5) ///< Not found
#define NRF_ERROR_NOT_SUPPORTED (NRF_ERROR_BASE_NUM + 6) ///< Not supported
#define NRF_ERROR_INVALID_PARAM (NRF_ERROR_BASE_NUM + 7) ///< Invalid Parameter
#define NRF_ERROR_INVALID_STATE (NRF_ERROR_BASE_NUM + 8) ///< Invalid state, operation disallowed in this state
#define NRF_ERROR_INVALID_LENGTH (NRF_ERROR_BASE_NUM + 9) ///< Invalid Length
#define NRF_ERROR_INVALID_FLAGS (NRF_ERROR_BASE_NUM + 10) ///< Invalid Flags
#define NRF_ERROR_INVALID_DATA (NRF_ERROR_BASE_NUM + 11) ///< Invalid Data
#define NRF_ERROR_DATA_SIZE (NRF_ERROR_BASE_NUM + 12) ///< Invalid Data size
#define NRF_ERROR_TIMEOUT (NRF_ERROR_BASE_NUM + 13) ///< Operation timed out
#define NRF_ERROR_NULL (NRF_ERROR_BASE_NUM + 14) ///< Null Pointer
#define NRF_ERROR_FORBIDDEN (NRF_ERROR_BASE_NUM + 15) ///< Forbidden Operation
#define NRF_ERROR_INVALID_ADDR (NRF_ERROR_BASE_NUM + 16) ///< Bad Memory Address
#define NRF_ERROR_BUSY (NRF_ERROR_BASE_NUM + 17) ///< Busy
#define NRF_ERROR_CONN_COUNT (NRF_ERROR_BASE_NUM + 18) ///< Maximum connection count exceeded.
#define NRF_ERROR_RESOURCES (NRF_ERROR_BASE_NUM + 19) ///< Not enough resources for operation
#ifdef __cplusplus
}
#endif
#endif // NRF_ERROR_H__
/**
@}
*/

View File

@ -1,70 +0,0 @@
/*
* Copyright (c) 2012 - 2017, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@addtogroup nrf_sdm_api
@{
@defgroup nrf_sdm_error SoftDevice Manager Error Codes
@{
@brief Error definitions for the SDM API
*/
/* Header guard */
#ifndef NRF_ERROR_SDM_H__
#define NRF_ERROR_SDM_H__
#include "nrf_error.h"
#ifdef __cplusplus
extern "C" {
#endif
#define NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN (NRF_ERROR_SDM_BASE_NUM + 0) ///< Unknown LFCLK source.
#define NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION (NRF_ERROR_SDM_BASE_NUM + 1) ///< Incorrect interrupt configuration (can be caused by using illegal priority levels, or having enabled SoftDevice interrupts).
#define NRF_ERROR_SDM_INCORRECT_CLENR0 (NRF_ERROR_SDM_BASE_NUM + 2) ///< Incorrect CLENR0 (can be caused by erroneous SoftDevice flashing).
#ifdef __cplusplus
}
#endif
#endif // NRF_ERROR_SDM_H__
/**
@}
@}
*/

View File

@ -1,85 +0,0 @@
/*
* Copyright (c) 2012 - 2017, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@addtogroup nrf_soc_api
@{
@defgroup nrf_soc_error SoC Library Error Codes
@{
@brief Error definitions for the SoC library
*/
/* Header guard */
#ifndef NRF_ERROR_SOC_H__
#define NRF_ERROR_SOC_H__
#include "nrf_error.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Mutex Errors */
#define NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN (NRF_ERROR_SOC_BASE_NUM + 0) ///< Mutex already taken
/* NVIC errors */
#define NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE (NRF_ERROR_SOC_BASE_NUM + 1) ///< NVIC interrupt not available
#define NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED (NRF_ERROR_SOC_BASE_NUM + 2) ///< NVIC interrupt priority not allowed
#define NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 3) ///< NVIC should not return
/* Power errors */
#define NRF_ERROR_SOC_POWER_MODE_UNKNOWN (NRF_ERROR_SOC_BASE_NUM + 4) ///< Power mode unknown
#define NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN (NRF_ERROR_SOC_BASE_NUM + 5) ///< Power POF threshold unknown
#define NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 6) ///< Power off should not return
/* Rand errors */
#define NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES (NRF_ERROR_SOC_BASE_NUM + 7) ///< RAND not enough values
/* PPI errors */
#define NRF_ERROR_SOC_PPI_INVALID_CHANNEL (NRF_ERROR_SOC_BASE_NUM + 8) ///< Invalid PPI Channel
#define NRF_ERROR_SOC_PPI_INVALID_GROUP (NRF_ERROR_SOC_BASE_NUM + 9) ///< Invalid PPI Group
#ifdef __cplusplus
}
#endif
#endif // NRF_ERROR_SOC_H__
/**
@}
@}
*/

View File

@ -1,485 +0,0 @@
/*
* Copyright (c) 2016 - 2017, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @defgroup nrf_nvic_api SoftDevice NVIC API
* @{
*
* @note In order to use this module, the following code has to be added to a .c file:
* \code
* nrf_nvic_state_t nrf_nvic_state = {0};
* \endcode
*
* @note Definitions and declarations starting with __ (double underscore) in this header file are
* not intended for direct use by the application.
*
* @brief APIs for the accessing NVIC when using a SoftDevice.
*
*/
#ifndef NRF_NVIC_H__
#define NRF_NVIC_H__
#include <stdint.h>
#include "nrf.h"
#include "nrf_error_soc.h"
#ifdef __cplusplus
extern "C" {
#endif
/**@addtogroup NRF_NVIC_DEFINES Defines
* @{ */
/**@defgroup NRF_NVIC_ISER_DEFINES SoftDevice NVIC internal definitions
* @{ */
#define __NRF_NVIC_NVMC_IRQn (30) /**< The peripheral ID of the NVMC. IRQ numbers are used to identify peripherals, but the NVMC doesn't have an IRQ number in the MDK. */
#define __NRF_NVIC_ISER_COUNT (2) /**< The number of ISER/ICER registers in the NVIC that are used. */
/**@brief Interrupts used by the SoftDevice, with IRQn in the range 0-31. */
#define __NRF_NVIC_SD_IRQS_0 ((uint32_t)( \
(1U << POWER_CLOCK_IRQn) \
| (1U << RADIO_IRQn) \
| (1U << RTC0_IRQn) \
| (1U << TIMER0_IRQn) \
| (1U << RNG_IRQn) \
| (1U << ECB_IRQn) \
| (1U << CCM_AAR_IRQn) \
| (1U << TEMP_IRQn) \
| (1U << __NRF_NVIC_NVMC_IRQn) \
| (1U << (uint32_t)SWI5_EGU5_IRQn) \
))
/**@brief Interrupts used by the SoftDevice, with IRQn in the range 32-63. */
#define __NRF_NVIC_SD_IRQS_1 ((uint32_t)0)
/**@brief Interrupts available for to application, with IRQn in the range 0-31. */
#define __NRF_NVIC_APP_IRQS_0 (~__NRF_NVIC_SD_IRQS_0)
/**@brief Interrupts available for to application, with IRQn in the range 32-63. */
#define __NRF_NVIC_APP_IRQS_1 (~__NRF_NVIC_SD_IRQS_1)
/**@} */
/**@} */
/**@addtogroup NRF_NVIC_VARIABLES Variables
* @{ */
/**@brief Type representing the state struct for the SoftDevice NVIC module. */
typedef struct
{
uint32_t volatile __irq_masks[__NRF_NVIC_ISER_COUNT]; /**< IRQs enabled by the application in the NVIC. */
uint32_t volatile __cr_flag; /**< Non-zero if already in a critical region */
} nrf_nvic_state_t;
/**@brief Variable keeping the state for the SoftDevice NVIC module. This must be declared in an
* application source file. */
extern nrf_nvic_state_t nrf_nvic_state;
/**@} */
/**@addtogroup NRF_NVIC_INTERNAL_FUNCTIONS SoftDevice NVIC internal functions
* @{ */
/**@brief Disables IRQ interrupts globally, including the SoftDevice's interrupts.
*
* @retval The value of PRIMASK prior to disabling the interrupts.
*/
__STATIC_INLINE int __sd_nvic_irq_disable(void);
/**@brief Enables IRQ interrupts globally, including the SoftDevice's interrupts.
*/
__STATIC_INLINE void __sd_nvic_irq_enable(void);
/**@brief Checks if IRQn is available to application
* @param[in] IRQn IRQ to check
*
* @retval 1 (true) if the IRQ to check is available to the application
*/
__STATIC_INLINE uint32_t __sd_nvic_app_accessible_irq(IRQn_Type IRQn);
/**@brief Checks if priority is available to application
* @param[in] priority priority to check
*
* @retval 1 (true) if the priority to check is available to the application
*/
__STATIC_INLINE uint32_t __sd_nvic_is_app_accessible_priority(uint32_t priority);
/**@} */
/**@addtogroup NRF_NVIC_FUNCTIONS SoftDevice NVIC public functions
* @{ */
/**@brief Enable External Interrupt.
* @note Corresponds to NVIC_EnableIRQ in CMSIS.
*
* @pre IRQn is valid and not reserved by the stack.
*
* @param[in] IRQn See the NVIC_EnableIRQ documentation in CMSIS.
*
* @retval ::NRF_SUCCESS The interrupt was enabled.
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE The interrupt is not available for the application.
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED The interrupt has a priority not available for the application.
*/
__STATIC_INLINE uint32_t sd_nvic_EnableIRQ(IRQn_Type IRQn);
/**@brief Disable External Interrupt.
* @note Corresponds to NVIC_DisableIRQ in CMSIS.
*
* @pre IRQn is valid and not reserved by the stack.
*
* @param[in] IRQn See the NVIC_DisableIRQ documentation in CMSIS.
*
* @retval ::NRF_SUCCESS The interrupt was disabled.
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE The interrupt is not available for the application.
*/
__STATIC_INLINE uint32_t sd_nvic_DisableIRQ(IRQn_Type IRQn);
/**@brief Get Pending Interrupt.
* @note Corresponds to NVIC_GetPendingIRQ in CMSIS.
*
* @pre IRQn is valid and not reserved by the stack.
*
* @param[in] IRQn See the NVIC_GetPendingIRQ documentation in CMSIS.
* @param[out] p_pending_irq Return value from NVIC_GetPendingIRQ.
*
* @retval ::NRF_SUCCESS The interrupt is available for the application.
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application.
*/
__STATIC_INLINE uint32_t sd_nvic_GetPendingIRQ(IRQn_Type IRQn, uint32_t * p_pending_irq);
/**@brief Set Pending Interrupt.
* @note Corresponds to NVIC_SetPendingIRQ in CMSIS.
*
* @pre IRQn is valid and not reserved by the stack.
*
* @param[in] IRQn See the NVIC_SetPendingIRQ documentation in CMSIS.
*
* @retval ::NRF_SUCCESS The interrupt is set pending.
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application.
*/
__STATIC_INLINE uint32_t sd_nvic_SetPendingIRQ(IRQn_Type IRQn);
/**@brief Clear Pending Interrupt.
* @note Corresponds to NVIC_ClearPendingIRQ in CMSIS.
*
* @pre IRQn is valid and not reserved by the stack.
*
* @param[in] IRQn See the NVIC_ClearPendingIRQ documentation in CMSIS.
*
* @retval ::NRF_SUCCESS The interrupt pending flag is cleared.
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application.
*/
__STATIC_INLINE uint32_t sd_nvic_ClearPendingIRQ(IRQn_Type IRQn);
/**@brief Set Interrupt Priority.
* @note Corresponds to NVIC_SetPriority in CMSIS.
*
* @pre IRQn is valid and not reserved by the stack.
* @pre Priority is valid and not reserved by the stack.
*
* @param[in] IRQn See the NVIC_SetPriority documentation in CMSIS.
* @param[in] priority A valid IRQ priority for use by the application.
*
* @retval ::NRF_SUCCESS The interrupt and priority level is available for the application.
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application.
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED The interrupt priority is not available for the application.
*/
__STATIC_INLINE uint32_t sd_nvic_SetPriority(IRQn_Type IRQn, uint32_t priority);
/**@brief Get Interrupt Priority.
* @note Corresponds to NVIC_GetPriority in CMSIS.
*
* @pre IRQn is valid and not reserved by the stack.
*
* @param[in] IRQn See the NVIC_GetPriority documentation in CMSIS.
* @param[out] p_priority Return value from NVIC_GetPriority.
*
* @retval ::NRF_SUCCESS The interrupt priority is returned in p_priority.
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE - IRQn is not available for the application.
*/
__STATIC_INLINE uint32_t sd_nvic_GetPriority(IRQn_Type IRQn, uint32_t * p_priority);
/**@brief System Reset.
* @note Corresponds to NVIC_SystemReset in CMSIS.
*
* @retval ::NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN
*/
__STATIC_INLINE uint32_t sd_nvic_SystemReset(void);
/**@brief Enter critical region.
*
* @post Application interrupts will be disabled.
* @note sd_nvic_critical_region_enter() and ::sd_nvic_critical_region_exit() must be called in matching pairs inside each
* execution context
* @sa sd_nvic_critical_region_exit
*
* @param[out] p_is_nested_critical_region If 1, the application is now in a nested critical region.
*
* @retval ::NRF_SUCCESS
*/
__STATIC_INLINE uint32_t sd_nvic_critical_region_enter(uint8_t * p_is_nested_critical_region);
/**@brief Exit critical region.
*
* @pre Application has entered a critical region using ::sd_nvic_critical_region_enter.
* @post If not in a nested critical region, the application interrupts will restored to the state before ::sd_nvic_critical_region_enter was called.
*
* @param[in] is_nested_critical_region If this is set to 1, the critical region won't be exited. @sa sd_nvic_critical_region_enter.
*
* @retval ::NRF_SUCCESS
*/
__STATIC_INLINE uint32_t sd_nvic_critical_region_exit(uint8_t is_nested_critical_region);
/**@} */
#ifndef SUPPRESS_INLINE_IMPLEMENTATION
__STATIC_INLINE int __sd_nvic_irq_disable(void)
{
int pm = __get_PRIMASK();
__disable_irq();
return pm;
}
__STATIC_INLINE void __sd_nvic_irq_enable(void)
{
__enable_irq();
}
__STATIC_INLINE uint32_t __sd_nvic_app_accessible_irq(IRQn_Type IRQn)
{
if (IRQn < 32)
{
return ((1UL<<IRQn) & __NRF_NVIC_APP_IRQS_0) != 0;
}
else if (IRQn < 64)
{
return ((1UL<<(IRQn-32)) & __NRF_NVIC_APP_IRQS_1) != 0;
}
else
{
return 1;
}
}
__STATIC_INLINE uint32_t __sd_nvic_is_app_accessible_priority(uint32_t priority)
{
if(priority >= (1 << __NVIC_PRIO_BITS))
{
return 0;
}
if( priority == 0
|| priority == 1
|| priority == 4
)
{
return 0;
}
return 1;
}
__STATIC_INLINE uint32_t sd_nvic_EnableIRQ(IRQn_Type IRQn)
{
if (!__sd_nvic_app_accessible_irq(IRQn))
{
return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE;
}
if (!__sd_nvic_is_app_accessible_priority(NVIC_GetPriority(IRQn)))
{
return NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED;
}
if (nrf_nvic_state.__cr_flag)
{
nrf_nvic_state.__irq_masks[(uint32_t)((int32_t)IRQn) >> 5] |= (uint32_t)(1 << ((uint32_t)((int32_t)IRQn) & (uint32_t)0x1F));
}
else
{
NVIC_EnableIRQ(IRQn);
}
return NRF_SUCCESS;
}
__STATIC_INLINE uint32_t sd_nvic_DisableIRQ(IRQn_Type IRQn)
{
if (!__sd_nvic_app_accessible_irq(IRQn))
{
return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE;
}
if (nrf_nvic_state.__cr_flag)
{
nrf_nvic_state.__irq_masks[(uint32_t)((int32_t)IRQn) >> 5] &= ~(1UL << ((uint32_t)(IRQn) & 0x1F));
}
else
{
NVIC_DisableIRQ(IRQn);
}
return NRF_SUCCESS;
}
__STATIC_INLINE uint32_t sd_nvic_GetPendingIRQ(IRQn_Type IRQn, uint32_t * p_pending_irq)
{
if (__sd_nvic_app_accessible_irq(IRQn))
{
*p_pending_irq = NVIC_GetPendingIRQ(IRQn);
return NRF_SUCCESS;
}
else
{
return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE;
}
}
__STATIC_INLINE uint32_t sd_nvic_SetPendingIRQ(IRQn_Type IRQn)
{
if (__sd_nvic_app_accessible_irq(IRQn))
{
NVIC_SetPendingIRQ(IRQn);
return NRF_SUCCESS;
}
else
{
return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE;
}
}
__STATIC_INLINE uint32_t sd_nvic_ClearPendingIRQ(IRQn_Type IRQn)
{
if (__sd_nvic_app_accessible_irq(IRQn))
{
NVIC_ClearPendingIRQ(IRQn);
return NRF_SUCCESS;
}
else
{
return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE;
}
}
__STATIC_INLINE uint32_t sd_nvic_SetPriority(IRQn_Type IRQn, uint32_t priority)
{
if (!__sd_nvic_app_accessible_irq(IRQn))
{
return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE;
}
if (!__sd_nvic_is_app_accessible_priority(priority))
{
return NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED;
}
NVIC_SetPriority(IRQn, (uint32_t)priority);
return NRF_SUCCESS;
}
__STATIC_INLINE uint32_t sd_nvic_GetPriority(IRQn_Type IRQn, uint32_t * p_priority)
{
if (__sd_nvic_app_accessible_irq(IRQn))
{
*p_priority = (NVIC_GetPriority(IRQn) & 0xFF);
return NRF_SUCCESS;
}
else
{
return NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE;
}
}
__STATIC_INLINE uint32_t sd_nvic_SystemReset(void)
{
NVIC_SystemReset();
return NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN;
}
__STATIC_INLINE uint32_t sd_nvic_critical_region_enter(uint8_t * p_is_nested_critical_region)
{
int was_masked = __sd_nvic_irq_disable();
if (!nrf_nvic_state.__cr_flag)
{
nrf_nvic_state.__cr_flag = 1;
nrf_nvic_state.__irq_masks[0] = ( NVIC->ICER[0] & __NRF_NVIC_APP_IRQS_0 );
NVIC->ICER[0] = __NRF_NVIC_APP_IRQS_0;
nrf_nvic_state.__irq_masks[1] = ( NVIC->ICER[1] & __NRF_NVIC_APP_IRQS_1 );
NVIC->ICER[1] = __NRF_NVIC_APP_IRQS_1;
*p_is_nested_critical_region = 0;
}
else
{
*p_is_nested_critical_region = 1;
}
if (!was_masked)
{
__sd_nvic_irq_enable();
}
return NRF_SUCCESS;
}
__STATIC_INLINE uint32_t sd_nvic_critical_region_exit(uint8_t is_nested_critical_region)
{
if (nrf_nvic_state.__cr_flag && (is_nested_critical_region == 0))
{
int was_masked = __sd_nvic_irq_disable();
NVIC->ISER[0] = nrf_nvic_state.__irq_masks[0];
NVIC->ISER[1] = nrf_nvic_state.__irq_masks[1];
nrf_nvic_state.__cr_flag = 0;
if (!was_masked)
{
__sd_nvic_irq_enable();
}
}
return NRF_SUCCESS;
}
#endif /* SUPPRESS_INLINE_IMPLEMENTATION */
#ifdef __cplusplus
}
#endif
#endif // NRF_NVIC_H__
/**@} */

View File

@ -1,355 +0,0 @@
/*
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@defgroup nrf_sdm_api SoftDevice Manager API
@{
@brief APIs for SoftDevice management.
*/
#ifndef NRF_SDM_H__
#define NRF_SDM_H__
#include "nrf_svc.h"
#include "nrf.h"
#include "nrf_soc.h"
#include "nrf_error_sdm.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup NRF_SDM_DEFINES Defines
* @{ */
#ifdef NRFSOC_DOXYGEN
/// Declared in nrf_mbr.h
#define MBR_SIZE 0
#warning test
#endif
/** @brief The major version for the SoftDevice binary distributed with this header file. */
#define SD_MAJOR_VERSION (5)
/** @brief The minor version for the SoftDevice binary distributed with this header file. */
#define SD_MINOR_VERSION (0)
/** @brief The bugfix version for the SoftDevice binary distributed with this header file. */
#define SD_BUGFIX_VERSION (0)
/** @brief The full version number for the SoftDevice binary this header file was distributed
* with, as a decimal number in the form Mmmmbbb, where:
* - M is major version (one or more digits)
* - mmm is minor version (three digits)
* - bbb is bugfix version (three digits). */
#define SD_VERSION (SD_MAJOR_VERSION * 1000000 + SD_MINOR_VERSION * 1000 + SD_BUGFIX_VERSION)
/** @brief SoftDevice Manager SVC Base number. */
#define SDM_SVC_BASE 0x10
/** @brief SoftDevice unique string size in bytes. */
#define SD_UNIQUE_STR_SIZE 20
/** @brief Invalid info field. Returned when an info field does not exist. */
#define SDM_INFO_FIELD_INVALID (0)
/** @brief Defines the SoftDevice Information Structure location (address) as an offset from
the start of the SoftDevice (without MBR)*/
#define SOFTDEVICE_INFO_STRUCT_OFFSET (0x2000)
/** @brief Defines the absolute SoftDevice Information Structure location (address) when the
* SoftDevice is installed just above the MBR (the usual case). */
#define SOFTDEVICE_INFO_STRUCT_ADDRESS (SOFTDEVICE_INFO_STRUCT_OFFSET + MBR_SIZE)
/** @brief Defines the offset for the SoftDevice Information Structure size value relative to the
* SoftDevice base address. The size value is of type uint8_t. */
#define SD_INFO_STRUCT_SIZE_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET)
/** @brief Defines the offset for the SoftDevice size value relative to the SoftDevice base address.
* The size value is of type uint32_t. */
#define SD_SIZE_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x08)
/** @brief Defines the offset for FWID value relative to the SoftDevice base address. The FWID value
* is of type uint16_t. */
#define SD_FWID_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x0C)
/** @brief Defines the offset for the SoftDevice ID relative to the SoftDevice base address. The ID
* is of type uint32_t. */
#define SD_ID_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x10)
/** @brief Defines the offset for the SoftDevice version relative to the SoftDevice base address in
* the same format as @ref SD_VERSION, stored as an uint32_t. */
#define SD_VERSION_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x14)
/** @brief Defines the offset for the SoftDevice unique string relative to the SoftDevice base address.
* The SD_UNIQUE_STR is stored as an array of uint8_t. The size of array is @ref SD_UNIQUE_STR_SIZE.
*/
#define SD_UNIQUE_STR_OFFSET (SOFTDEVICE_INFO_STRUCT_OFFSET + 0x18)
/** @brief Defines a macro for retrieving the actual SoftDevice Information Structure size value
* from a given base address. Use @ref MBR_SIZE as the argument when the SoftDevice is
* installed just above the MBR (the usual case). */
#define SD_INFO_STRUCT_SIZE_GET(baseaddr) (*((uint8_t *) ((baseaddr) + SD_INFO_STRUCT_SIZE_OFFSET)))
/** @brief Defines a macro for retrieving the actual SoftDevice size value from a given base
* address. Use @ref MBR_SIZE as the argument when the SoftDevice is installed just above
* the MBR (the usual case). */
#define SD_SIZE_GET(baseaddr) (*((uint32_t *) ((baseaddr) + SD_SIZE_OFFSET)))
/** @brief Defines a macro for retrieving the actual FWID value from a given base address. Use @ref
* MBR_SIZE as the argument when the SoftDevice is installed just above the MBR (the usual
* case). */
#define SD_FWID_GET(baseaddr) (*((uint16_t *) ((baseaddr) + SD_FWID_OFFSET)))
/** @brief Defines a macro for retrieving the actual SoftDevice ID from a given base address. Use
* @ref MBR_SIZE as the argument when the SoftDevice is installed just above the MBR (the
* usual case). */
#define SD_ID_GET(baseaddr) ((SD_INFO_STRUCT_SIZE_GET(baseaddr) > (SD_ID_OFFSET - SOFTDEVICE_INFO_STRUCT_OFFSET)) \
? (*((uint32_t *) ((baseaddr) + SD_ID_OFFSET))) : SDM_INFO_FIELD_INVALID)
/** @brief Defines a macro for retrieving the actual SoftDevice version from a given base address.
* Use @ref MBR_SIZE as the argument when the SoftDevice is installed just above the MBR
* (the usual case). */
#define SD_VERSION_GET(baseaddr) ((SD_INFO_STRUCT_SIZE_GET(baseaddr) > (SD_VERSION_OFFSET - SOFTDEVICE_INFO_STRUCT_OFFSET)) \
? (*((uint32_t *) ((baseaddr) + SD_VERSION_OFFSET))) : SDM_INFO_FIELD_INVALID)
/** @brief Defines a macro for retrieving the address of SoftDevice unique str based on a given base address.
* Use @ref MBR_SIZE as the argument when the SoftDevice is installed just above the MBR
* (the usual case). */
#define SD_UNIQUE_STR_ADDR_GET(baseaddr) ((SD_INFO_STRUCT_SIZE_GET(baseaddr) > (SD_UNIQUE_STR_OFFSET - SOFTDEVICE_INFO_STRUCT_OFFSET)) \
? (((uint8_t *) ((baseaddr) + SD_UNIQUE_STR_OFFSET))) : SDM_INFO_FIELD_INVALID)
/**@defgroup NRF_FAULT_ID_RANGES Fault ID ranges
* @{ */
#define NRF_FAULT_ID_SD_RANGE_START 0x00000000 /**< SoftDevice ID range start. */
#define NRF_FAULT_ID_APP_RANGE_START 0x00001000 /**< Application ID range start. */
/**@} */
/**@defgroup NRF_FAULT_IDS Fault ID types
* @{ */
#define NRF_FAULT_ID_SD_ASSERT (NRF_FAULT_ID_SD_RANGE_START + 1) /**< SoftDevice assertion. The info parameter is reserved for future used. */
#define NRF_FAULT_ID_APP_MEMACC (NRF_FAULT_ID_APP_RANGE_START + 1) /**< Application invalid memory access. The info parameter will contain 0x00000000,
in case of SoftDevice RAM access violation. In case of SoftDevice peripheral
register violation the info parameter will contain the sub-region number of
PREGION[0], on whose address range the disallowed write access caused the
memory access fault. */
/**@} */
/** @} */
/** @addtogroup NRF_SDM_ENUMS Enumerations
* @{ */
/**@brief nRF SoftDevice Manager API SVC numbers. */
enum NRF_SD_SVCS
{
SD_SOFTDEVICE_ENABLE = SDM_SVC_BASE, /**< ::sd_softdevice_enable */
SD_SOFTDEVICE_DISABLE, /**< ::sd_softdevice_disable */
SD_SOFTDEVICE_IS_ENABLED, /**< ::sd_softdevice_is_enabled */
SD_SOFTDEVICE_VECTOR_TABLE_BASE_SET, /**< ::sd_softdevice_vector_table_base_set */
SVC_SDM_LAST /**< Placeholder for last SDM SVC */
};
/** @} */
/** @addtogroup NRF_SDM_DEFINES Defines
* @{ */
/**@defgroup NRF_CLOCK_LF_ACCURACY Clock accuracy
* @{ */
#define NRF_CLOCK_LF_ACCURACY_250_PPM (0) /**< Default: 250 ppm */
#define NRF_CLOCK_LF_ACCURACY_500_PPM (1) /**< 500 ppm */
#define NRF_CLOCK_LF_ACCURACY_150_PPM (2) /**< 150 ppm */
#define NRF_CLOCK_LF_ACCURACY_100_PPM (3) /**< 100 ppm */
#define NRF_CLOCK_LF_ACCURACY_75_PPM (4) /**< 75 ppm */
#define NRF_CLOCK_LF_ACCURACY_50_PPM (5) /**< 50 ppm */
#define NRF_CLOCK_LF_ACCURACY_30_PPM (6) /**< 30 ppm */
#define NRF_CLOCK_LF_ACCURACY_20_PPM (7) /**< 20 ppm */
#define NRF_CLOCK_LF_ACCURACY_10_PPM (8) /**< 10 ppm */
#define NRF_CLOCK_LF_ACCURACY_5_PPM (9) /**< 5 ppm */
#define NRF_CLOCK_LF_ACCURACY_2_PPM (10) /**< 2 ppm */
#define NRF_CLOCK_LF_ACCURACY_1_PPM (11) /**< 1 ppm */
/** @} */
/**@defgroup NRF_CLOCK_LF_SRC Possible LFCLK oscillator sources
* @{ */
#define NRF_CLOCK_LF_SRC_RC (0) /**< LFCLK RC oscillator. */
#define NRF_CLOCK_LF_SRC_XTAL (1) /**< LFCLK crystal oscillator. */
#define NRF_CLOCK_LF_SRC_SYNTH (2) /**< LFCLK Synthesized from HFCLK. */
/** @} */
/** @} */
/** @addtogroup NRF_SDM_TYPES Types
* @{ */
/**@brief Type representing LFCLK oscillator source. */
typedef struct
{
uint8_t source; /**< LF oscillator clock source, see @ref NRF_CLOCK_LF_SRC. */
uint8_t rc_ctiv; /**< Only for NRF_CLOCK_LF_SRC_RC: Calibration timer interval in 1/4 second
units (nRF51: 1-64, nRF52: 1-32).
@note To avoid excessive clock drift, 0.5 degrees Celsius is the
maximum temperature change allowed in one calibration timer
interval. The interval should be selected to ensure this.
@note Must be 0 if source is not NRF_CLOCK_LF_SRC_RC. */
uint8_t rc_temp_ctiv; /**< Only for NRF_CLOCK_LF_SRC_RC: How often (in number of calibration
intervals) the RC oscillator shall be calibrated if the temperature
hasn't changed.
0: Always calibrate even if the temperature hasn't changed.
1: Only calibrate if the temperature has changed (nRF51 only).
2-33: Check the temperature and only calibrate if it has changed,
however calibration will take place every rc_temp_ctiv
intervals in any case.
@note Must be 0 if source is not NRF_CLOCK_LF_SRC_RC.
@note For nRF52, the application must ensure calibration at least once
every 8 seconds to ensure +/-500 ppm clock stability. The
recommended configuration for NRF_CLOCK_LF_SRC_RC on nRF52 is
rc_ctiv=16 and rc_temp_ctiv=2. This will ensure calibration at
least once every 8 seconds and for temperature changes of 0.5
degrees Celsius every 4 seconds. See the Product Specification
for the nRF52 device being used for more information.*/
uint8_t accuracy; /**< External clock accuracy used in the LL to compute timing
windows, see @ref NRF_CLOCK_LF_ACCURACY.*/
} nrf_clock_lf_cfg_t;
/**@brief Fault Handler type.
*
* When certain unrecoverable errors occur within the application or SoftDevice the fault handler will be called back.
* The protocol stack will be in an undefined state when this happens and the only way to recover will be to
* perform a reset, using e.g. CMSIS NVIC_SystemReset().
* If the application returns from the fault handler the SoftDevice will call NVIC_SystemReset().
*
* @note This callback is executed in HardFault context, thus SVC functions cannot be called from the fault callback.
*
* @param[in] id Fault identifier. See @ref NRF_FAULT_IDS.
* @param[in] pc The program counter of the instruction that triggered the fault.
* @param[in] info Optional additional information regarding the fault. Refer to each Fault identifier for details.
*
* @note When id is set to NRF_FAULT_ID_APP_MEMACC, pc will contain the address of the instruction being executed at the time when
* the fault is detected by the CPU. The CPU program counter may have advanced up to 2 instructions (no branching) after the one that triggered the fault.
*/
typedef void (*nrf_fault_handler_t)(uint32_t id, uint32_t pc, uint32_t info);
/** @} */
/** @addtogroup NRF_SDM_FUNCTIONS Functions
* @{ */
/**@brief Enables the SoftDevice and by extension the protocol stack.
*
* @note Some care must be taken if a low frequency clock source is already running when calling this function:
* If the LF clock has a different source then the one currently running, it will be stopped. Then, the new
* clock source will be started.
*
* @note This function has no effect when returning with an error.
*
* @post If return code is ::NRF_SUCCESS
* - SoC library and protocol stack APIs are made available.
* - A portion of RAM will be unavailable (see relevant SDS documentation).
* - Some peripherals will be unavailable or available only through the SoC API (see relevant SDS documentation).
* - Interrupts will not arrive from protected peripherals or interrupts.
* - nrf_nvic_ functions must be used instead of CMSIS NVIC_ functions for reliable usage of the SoftDevice.
* - Interrupt latency may be affected by the SoftDevice (see relevant SDS documentation).
* - Chosen low frequency clock source will be running.
*
* @param p_clock_lf_cfg Low frequency clock source and accuracy.
If NULL the clock will be configured as an RC source with rc_ctiv = 16 and .rc_temp_ctiv = 2
In the case of XTAL source, the PPM accuracy of the chosen clock source must be greater than or equal to the actual characteristics of your XTAL clock.
* @param fault_handler Callback to be invoked in case of fault, cannot be NULL.
*
* @retval ::NRF_SUCCESS
* @retval ::NRF_ERROR_INVALID_ADDR Invalid or NULL pointer supplied.
* @retval ::NRF_ERROR_INVALID_STATE SoftDevice is already enabled, and the clock source and fault handler cannot be updated.
* @retval ::NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION SoftDevice interrupt is already enabled, or an enabled interrupt has an illegal priority level.
* @retval ::NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN Unknown low frequency clock source selected.
*/
SVCALL(SD_SOFTDEVICE_ENABLE, uint32_t, sd_softdevice_enable(nrf_clock_lf_cfg_t const * p_clock_lf_cfg, nrf_fault_handler_t fault_handler));
/**@brief Disables the SoftDevice and by extension the protocol stack.
*
* Idempotent function to disable the SoftDevice.
*
* @post SoC library and protocol stack APIs are made unavailable.
* @post All interrupts that was protected by the SoftDevice will be disabled and initialized to priority 0 (highest).
* @post All peripherals used by the SoftDevice will be reset to default values.
* @post All of RAM become available.
* @post All interrupts are forwarded to the application.
* @post LFCLK source chosen in ::sd_softdevice_enable will be left running.
*
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_SOFTDEVICE_DISABLE, uint32_t, sd_softdevice_disable(void));
/**@brief Check if the SoftDevice is enabled.
*
* @param[out] p_softdevice_enabled If the SoftDevice is enabled: 1 else 0.
*
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_SOFTDEVICE_IS_ENABLED, uint32_t, sd_softdevice_is_enabled(uint8_t * p_softdevice_enabled));
/**@brief Sets the base address of the interrupt vector table for interrupts forwarded from the SoftDevice
*
* This function is only intended to be called when a bootloader is enabled.
*
* @param[in] address The base address of the interrupt vector table for forwarded interrupts.
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_SOFTDEVICE_VECTOR_TABLE_BASE_SET, uint32_t, sd_softdevice_vector_table_base_set(uint32_t address));
/** @} */
#ifdef __cplusplus
}
#endif
#endif // NRF_SDM_H__
/**
@}
*/

View File

@ -1,931 +0,0 @@
/*
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @defgroup nrf_soc_api SoC Library API
* @{
*
* @brief APIs for the SoC library.
*
*/
#ifndef NRF_SOC_H__
#define NRF_SOC_H__
#include <stdint.h>
#include <stdbool.h>
#include "nrf_svc.h"
#include "nrf.h"
#include "nrf_error_soc.h"
#ifdef __cplusplus
extern "C" {
#endif
/**@addtogroup NRF_SOC_DEFINES Defines
* @{ */
/**@brief The number of the lowest SVC number reserved for the SoC library. */
#define SOC_SVC_BASE (0x20) /**< Base value for SVCs that are available when the SoftDevice is disabled. */
#define SOC_SVC_BASE_NOT_AVAILABLE (0x2B) /**< Base value for SVCs that are not available when the SoftDevice is disabled. */
/**@brief Guaranteed time for application to process radio inactive notification. */
#define NRF_RADIO_NOTIFICATION_INACTIVE_GUARANTEED_TIME_US (62)
/**@brief The minimum allowed timeslot extension time. */
#define NRF_RADIO_MINIMUM_TIMESLOT_LENGTH_EXTENSION_TIME_US (200)
/**@brief The maximum processing time to handle a timeslot extension. */
#define NRF_RADIO_MAX_EXTENSION_PROCESSING_TIME_US (17)
/**@brief The latest time before the end of a timeslot the timeslot can be extended. */
#define NRF_RADIO_MIN_EXTENSION_MARGIN_US (79)
#define SOC_ECB_KEY_LENGTH (16) /**< ECB key length. */
#define SOC_ECB_CLEARTEXT_LENGTH (16) /**< ECB cleartext length. */
#define SOC_ECB_CIPHERTEXT_LENGTH (SOC_ECB_CLEARTEXT_LENGTH) /**< ECB ciphertext length. */
#define SD_EVT_IRQn (SWI2_EGU2_IRQn) /**< SoftDevice Event IRQ number. Used for both protocol events and SoC events. */
#define SD_EVT_IRQHandler (SWI2_EGU2_IRQHandler) /**< SoftDevice Event IRQ handler. Used for both protocol events and SoC events.
The default interrupt priority for this handler is set to 4 */
#define RADIO_NOTIFICATION_IRQn (SWI1_EGU1_IRQn) /**< The radio notification IRQ number. */
#define RADIO_NOTIFICATION_IRQHandler (SWI1_EGU1_IRQHandler) /**< The radio notification IRQ handler.
The default interrupt priority for this handler is set to 4 */
#define NRF_RADIO_LENGTH_MIN_US (100) /**< The shortest allowed radio timeslot, in microseconds. */
#define NRF_RADIO_LENGTH_MAX_US (100000) /**< The longest allowed radio timeslot, in microseconds. */
#define NRF_RADIO_DISTANCE_MAX_US (128000000UL - 1UL) /**< The longest timeslot distance, in microseconds, allowed for the distance parameter (see @ref nrf_radio_request_normal_t) in the request. */
#define NRF_RADIO_EARLIEST_TIMEOUT_MAX_US (128000000UL - 1UL) /**< The longest timeout, in microseconds, allowed when requesting the earliest possible timeslot. */
#define NRF_RADIO_START_JITTER_US (2) /**< The maximum jitter in @ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_START relative to the requested start time. */
/**@} */
/**@addtogroup NRF_SOC_ENUMS Enumerations
* @{ */
/**@brief The SVC numbers used by the SVC functions in the SoC library. */
enum NRF_SOC_SVCS
{
SD_PPI_CHANNEL_ENABLE_GET = SOC_SVC_BASE,
SD_PPI_CHANNEL_ENABLE_SET,
SD_PPI_CHANNEL_ENABLE_CLR,
SD_PPI_CHANNEL_ASSIGN,
SD_PPI_GROUP_TASK_ENABLE,
SD_PPI_GROUP_TASK_DISABLE,
SD_PPI_GROUP_ASSIGN,
SD_PPI_GROUP_GET,
SD_FLASH_PAGE_ERASE,
SD_FLASH_WRITE,
SD_FLASH_PROTECT,
SD_MUTEX_NEW = SOC_SVC_BASE_NOT_AVAILABLE,
SD_MUTEX_ACQUIRE,
SD_MUTEX_RELEASE,
SD_RAND_APPLICATION_POOL_CAPACITY_GET,
SD_RAND_APPLICATION_BYTES_AVAILABLE_GET,
SD_RAND_APPLICATION_VECTOR_GET,
SD_POWER_MODE_SET,
SD_POWER_SYSTEM_OFF,
SD_POWER_RESET_REASON_GET,
SD_POWER_RESET_REASON_CLR,
SD_POWER_POF_ENABLE,
SD_POWER_POF_THRESHOLD_SET,
SD_POWER_RAM_POWER_SET,
SD_POWER_RAM_POWER_CLR,
SD_POWER_RAM_POWER_GET,
SD_POWER_GPREGRET_SET,
SD_POWER_GPREGRET_CLR,
SD_POWER_GPREGRET_GET,
SD_POWER_DCDC_MODE_SET,
SD_APP_EVT_WAIT,
SD_CLOCK_HFCLK_REQUEST,
SD_CLOCK_HFCLK_RELEASE,
SD_CLOCK_HFCLK_IS_RUNNING,
SD_RADIO_NOTIFICATION_CFG_SET,
SD_ECB_BLOCK_ENCRYPT,
SD_ECB_BLOCKS_ENCRYPT,
SD_RADIO_SESSION_OPEN,
SD_RADIO_SESSION_CLOSE,
SD_RADIO_REQUEST,
SD_EVT_GET,
SD_TEMP_GET,
SVC_SOC_LAST
};
/**@brief Possible values of a ::nrf_mutex_t. */
enum NRF_MUTEX_VALUES
{
NRF_MUTEX_FREE,
NRF_MUTEX_TAKEN
};
/**@brief Power modes. */
enum NRF_POWER_MODES
{
NRF_POWER_MODE_CONSTLAT, /**< Constant latency mode. See power management in the reference manual. */
NRF_POWER_MODE_LOWPWR /**< Low power mode. See power management in the reference manual. */
};
/**@brief Power failure thresholds */
enum NRF_POWER_THRESHOLDS
{
NRF_POWER_THRESHOLD_V17 = 4UL, /**< 1.7 Volts power failure threshold. */
NRF_POWER_THRESHOLD_V18, /**< 1.8 Volts power failure threshold. */
NRF_POWER_THRESHOLD_V19, /**< 1.9 Volts power failure threshold. */
NRF_POWER_THRESHOLD_V20, /**< 2.0 Volts power failure threshold. */
NRF_POWER_THRESHOLD_V21, /**< 2.1 Volts power failure threshold. */
NRF_POWER_THRESHOLD_V22, /**< 2.2 Volts power failure threshold. */
NRF_POWER_THRESHOLD_V23, /**< 2.3 Volts power failure threshold. */
NRF_POWER_THRESHOLD_V24, /**< 2.4 Volts power failure threshold. */
NRF_POWER_THRESHOLD_V25, /**< 2.5 Volts power failure threshold. */
NRF_POWER_THRESHOLD_V26, /**< 2.6 Volts power failure threshold. */
NRF_POWER_THRESHOLD_V27, /**< 2.7 Volts power failure threshold. */
NRF_POWER_THRESHOLD_V28 /**< 2.8 Volts power failure threshold. */
};
/**@brief DC/DC converter modes. */
enum NRF_POWER_DCDC_MODES
{
NRF_POWER_DCDC_DISABLE, /**< The DCDC is disabled. */
NRF_POWER_DCDC_ENABLE /**< The DCDC is enabled. */
};
/**@brief Radio notification distances. */
enum NRF_RADIO_NOTIFICATION_DISTANCES
{
NRF_RADIO_NOTIFICATION_DISTANCE_NONE = 0, /**< The event does not have a notification. */
NRF_RADIO_NOTIFICATION_DISTANCE_800US, /**< The distance from the active notification to start of radio activity. */
NRF_RADIO_NOTIFICATION_DISTANCE_1740US, /**< The distance from the active notification to start of radio activity. */
NRF_RADIO_NOTIFICATION_DISTANCE_2680US, /**< The distance from the active notification to start of radio activity. */
NRF_RADIO_NOTIFICATION_DISTANCE_3620US, /**< The distance from the active notification to start of radio activity. */
NRF_RADIO_NOTIFICATION_DISTANCE_4560US, /**< The distance from the active notification to start of radio activity. */
NRF_RADIO_NOTIFICATION_DISTANCE_5500US /**< The distance from the active notification to start of radio activity. */
};
/**@brief Radio notification types. */
enum NRF_RADIO_NOTIFICATION_TYPES
{
NRF_RADIO_NOTIFICATION_TYPE_NONE = 0, /**< The event does not have a radio notification signal. */
NRF_RADIO_NOTIFICATION_TYPE_INT_ON_ACTIVE, /**< Using interrupt for notification when the radio will be enabled. */
NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE, /**< Using interrupt for notification when the radio has been disabled. */
NRF_RADIO_NOTIFICATION_TYPE_INT_ON_BOTH, /**< Using interrupt for notification both when the radio will be enabled and disabled. */
};
/**@brief The Radio signal callback types. */
enum NRF_RADIO_CALLBACK_SIGNAL_TYPE
{
NRF_RADIO_CALLBACK_SIGNAL_TYPE_START, /**< This signal indicates the start of the radio timeslot. */
NRF_RADIO_CALLBACK_SIGNAL_TYPE_TIMER0, /**< This signal indicates the NRF_TIMER0 interrupt. */
NRF_RADIO_CALLBACK_SIGNAL_TYPE_RADIO, /**< This signal indicates the NRF_RADIO interrupt. */
NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_FAILED, /**< This signal indicates extend action failed. */
NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_SUCCEEDED /**< This signal indicates extend action succeeded. */
};
/**@brief The actions requested by the signal callback.
*
* This code gives the SOC instructions about what action to take when the signal callback has
* returned.
*/
enum NRF_RADIO_SIGNAL_CALLBACK_ACTION
{
NRF_RADIO_SIGNAL_CALLBACK_ACTION_NONE, /**< Return without action. */
NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND, /**< Request an extension of the current
timeslot. Maximum execution time for this action:
@ref NRF_RADIO_MAX_EXTENSION_PROCESSING_TIME_US.
This action must be started at least @ref
NRF_RADIO_MIN_EXTENSION_MARGIN_US before
the end of the timeslot. */
NRF_RADIO_SIGNAL_CALLBACK_ACTION_END, /**< End the current radio timeslot. */
NRF_RADIO_SIGNAL_CALLBACK_ACTION_REQUEST_AND_END /**< Request a new radio timeslot and end the current timeslot. */
};
/**@brief Radio timeslot high frequency clock source configuration. */
enum NRF_RADIO_HFCLK_CFG
{
NRF_RADIO_HFCLK_CFG_XTAL_GUARANTEED, /**< The SoftDevice will guarantee that the high frequency clock source is the
external crystal for the whole duration of the timeslot. This should be the
preferred option for events that use the radio or require high timing accuracy.
@note The SoftDevice will automatically turn on and off the external crystal,
at the beginning and end of the timeslot, respectively. The crystal may also
intentionally be left running after the timeslot, in cases where it is needed
by the SoftDevice shortly after the end of the timeslot. */
NRF_RADIO_HFCLK_CFG_NO_GUARANTEE /**< This configuration allows for earlier and tighter scheduling of timeslots.
The RC oscillator may be the clock source in part or for the whole duration of the timeslot.
The RC oscillator's accuracy must therefore be taken into consideration.
@note If the application will use the radio peripheral in timeslots with this configuration,
it must make sure that the crystal is running and stable before starting the radio. */
};
/**@brief Radio timeslot priorities. */
enum NRF_RADIO_PRIORITY
{
NRF_RADIO_PRIORITY_HIGH, /**< High (equal priority as the normal connection priority of the SoftDevice stack(s)). */
NRF_RADIO_PRIORITY_NORMAL, /**< Normal (equal priority as the priority of secondary activities of the SoftDevice stack(s)). */
};
/**@brief Radio timeslot request type. */
enum NRF_RADIO_REQUEST_TYPE
{
NRF_RADIO_REQ_TYPE_EARLIEST, /**< Request radio timeslot as early as possible. This should always be used for the first request in a session. */
NRF_RADIO_REQ_TYPE_NORMAL /**< Normal radio timeslot request. */
};
/**@brief SoC Events. */
enum NRF_SOC_EVTS
{
NRF_EVT_HFCLKSTARTED, /**< Event indicating that the HFCLK has started. */
NRF_EVT_POWER_FAILURE_WARNING, /**< Event indicating that a power failure warning has occurred. */
NRF_EVT_FLASH_OPERATION_SUCCESS, /**< Event indicating that the ongoing flash operation has completed successfully. */
NRF_EVT_FLASH_OPERATION_ERROR, /**< Event indicating that the ongoing flash operation has timed out with an error. */
NRF_EVT_RADIO_BLOCKED, /**< Event indicating that a radio timeslot was blocked. */
NRF_EVT_RADIO_CANCELED, /**< Event indicating that a radio timeslot was canceled by SoftDevice. */
NRF_EVT_RADIO_SIGNAL_CALLBACK_INVALID_RETURN, /**< Event indicating that a radio timeslot signal callback handler return was invalid. */
NRF_EVT_RADIO_SESSION_IDLE, /**< Event indicating that a radio timeslot session is idle. */
NRF_EVT_RADIO_SESSION_CLOSED, /**< Event indicating that a radio timeslot session is closed. */
NRF_EVT_NUMBER_OF_EVTS
};
/**@} */
/**@addtogroup NRF_SOC_STRUCTURES Structures
* @{ */
/**@brief Represents a mutex for use with the nrf_mutex functions.
* @note Accessing the value directly is not safe, use the mutex functions!
*/
typedef volatile uint8_t nrf_mutex_t;
/**@brief Parameters for a request for a timeslot as early as possible. */
typedef struct
{
uint8_t hfclk; /**< High frequency clock source, see @ref NRF_RADIO_HFCLK_CFG. */
uint8_t priority; /**< The radio timeslot priority, see @ref NRF_RADIO_PRIORITY. */
uint32_t length_us; /**< The radio timeslot length (in the range 100 to 100,000] microseconds). */
uint32_t timeout_us; /**< Longest acceptable delay until the start of the requested timeslot (up to @ref NRF_RADIO_EARLIEST_TIMEOUT_MAX_US microseconds). */
} nrf_radio_request_earliest_t;
/**@brief Parameters for a normal radio timeslot request. */
typedef struct
{
uint8_t hfclk; /**< High frequency clock source, see @ref NRF_RADIO_HFCLK_CFG. */
uint8_t priority; /**< The radio timeslot priority, see @ref NRF_RADIO_PRIORITY. */
uint32_t distance_us; /**< Distance from the start of the previous radio timeslot (up to @ref NRF_RADIO_DISTANCE_MAX_US microseconds). */
uint32_t length_us; /**< The radio timeslot length (in the range [100..100,000] microseconds). */
} nrf_radio_request_normal_t;
/**@brief Radio timeslot request parameters. */
typedef struct
{
uint8_t request_type; /**< Type of request, see @ref NRF_RADIO_REQUEST_TYPE. */
union
{
nrf_radio_request_earliest_t earliest; /**< Parameters for requesting a radio timeslot as early as possible. */
nrf_radio_request_normal_t normal; /**< Parameters for requesting a normal radio timeslot. */
} params; /**< Parameter union. */
} nrf_radio_request_t;
/**@brief Return parameters of the radio timeslot signal callback. */
typedef struct
{
uint8_t callback_action; /**< The action requested by the application when returning from the signal callback, see @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION. */
union
{
struct
{
nrf_radio_request_t * p_next; /**< The request parameters for the next radio timeslot. */
} request; /**< Additional parameters for return_code @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION_REQUEST_AND_END. */
struct
{
uint32_t length_us; /**< Requested extension of the radio timeslot duration (microseconds) (for minimum time see @ref NRF_RADIO_MINIMUM_TIMESLOT_LENGTH_EXTENSION_TIME_US). */
} extend; /**< Additional parameters for return_code @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND. */
} params; /**< Parameter union. */
} nrf_radio_signal_callback_return_param_t;
/**@brief The radio timeslot signal callback type.
*
* @note In case of invalid return parameters, the radio timeslot will automatically end
* immediately after returning from the signal callback and the
* @ref NRF_EVT_RADIO_SIGNAL_CALLBACK_INVALID_RETURN event will be sent.
* @note The returned struct pointer must remain valid after the signal callback
* function returns. For instance, this means that it must not point to a stack variable.
*
* @param[in] signal_type Type of signal, see @ref NRF_RADIO_CALLBACK_SIGNAL_TYPE.
*
* @return Pointer to structure containing action requested by the application.
*/
typedef nrf_radio_signal_callback_return_param_t * (*nrf_radio_signal_callback_t) (uint8_t signal_type);
/**@brief AES ECB parameter typedefs */
typedef uint8_t soc_ecb_key_t[SOC_ECB_KEY_LENGTH]; /**< Encryption key type. */
typedef uint8_t soc_ecb_cleartext_t[SOC_ECB_CLEARTEXT_LENGTH]; /**< Cleartext data type. */
typedef uint8_t soc_ecb_ciphertext_t[SOC_ECB_CIPHERTEXT_LENGTH]; /**< Ciphertext data type. */
/**@brief AES ECB data structure */
typedef struct
{
soc_ecb_key_t key; /**< Encryption key. */
soc_ecb_cleartext_t cleartext; /**< Cleartext data. */
soc_ecb_ciphertext_t ciphertext; /**< Ciphertext data. */
} nrf_ecb_hal_data_t;
/**@brief AES ECB block. Used to provide multiple blocks in a single call
to @ref sd_ecb_blocks_encrypt.*/
typedef struct
{
soc_ecb_key_t const * p_key; /**< Pointer to the Encryption key. */
soc_ecb_cleartext_t const * p_cleartext; /**< Pointer to the Cleartext data. */
soc_ecb_ciphertext_t * p_ciphertext; /**< Pointer to the Ciphertext data. */
} nrf_ecb_hal_data_block_t;
/**@} */
/**@addtogroup NRF_SOC_FUNCTIONS Functions
* @{ */
/**@brief Initialize a mutex.
*
* @param[in] p_mutex Pointer to the mutex to initialize.
*
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_MUTEX_NEW, uint32_t, sd_mutex_new(nrf_mutex_t * p_mutex));
/**@brief Attempt to acquire a mutex.
*
* @param[in] p_mutex Pointer to the mutex to acquire.
*
* @retval ::NRF_SUCCESS The mutex was successfully acquired.
* @retval ::NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN The mutex could not be acquired.
*/
SVCALL(SD_MUTEX_ACQUIRE, uint32_t, sd_mutex_acquire(nrf_mutex_t * p_mutex));
/**@brief Release a mutex.
*
* @param[in] p_mutex Pointer to the mutex to release.
*
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_MUTEX_RELEASE, uint32_t, sd_mutex_release(nrf_mutex_t * p_mutex));
/**@brief Query the capacity of the application random pool.
*
* @param[out] p_pool_capacity The capacity of the pool.
*
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_RAND_APPLICATION_POOL_CAPACITY_GET, uint32_t, sd_rand_application_pool_capacity_get(uint8_t * p_pool_capacity));
/**@brief Get number of random bytes available to the application.
*
* @param[out] p_bytes_available The number of bytes currently available in the pool.
*
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_RAND_APPLICATION_BYTES_AVAILABLE_GET, uint32_t, sd_rand_application_bytes_available_get(uint8_t * p_bytes_available));
/**@brief Get random bytes from the application pool.
*
* @param[out] p_buff Pointer to unit8_t buffer for storing the bytes.
* @param[in] length Number of bytes to take from pool and place in p_buff.
*
* @retval ::NRF_SUCCESS The requested bytes were written to p_buff.
* @retval ::NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES No bytes were written to the buffer, because there were not enough bytes available.
*/
SVCALL(SD_RAND_APPLICATION_VECTOR_GET, uint32_t, sd_rand_application_vector_get(uint8_t * p_buff, uint8_t length));
/**@brief Gets the reset reason register.
*
* @param[out] p_reset_reason Contents of the NRF_POWER->RESETREAS register.
*
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_POWER_RESET_REASON_GET, uint32_t, sd_power_reset_reason_get(uint32_t * p_reset_reason));
/**@brief Clears the bits of the reset reason register.
*
* @param[in] reset_reason_clr_msk Contains the bits to clear from the reset reason register.
*
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_POWER_RESET_REASON_CLR, uint32_t, sd_power_reset_reason_clr(uint32_t reset_reason_clr_msk));
/**@brief Sets the power mode when in CPU sleep.
*
* @param[in] power_mode The power mode to use when in CPU sleep, see @ref NRF_POWER_MODES. @sa sd_app_evt_wait
*
* @retval ::NRF_SUCCESS The power mode was set.
* @retval ::NRF_ERROR_SOC_POWER_MODE_UNKNOWN The power mode was unknown.
*/
SVCALL(SD_POWER_MODE_SET, uint32_t, sd_power_mode_set(uint8_t power_mode));
/**@brief Puts the chip in System OFF mode.
*
* @retval ::NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN
*/
SVCALL(SD_POWER_SYSTEM_OFF, uint32_t, sd_power_system_off(void));
/**@brief Enables or disables the power-fail comparator.
*
* Enabling this will give a SoftDevice event (NRF_EVT_POWER_FAILURE_WARNING) when the power failure warning occurs.
* The event can be retrieved with sd_evt_get();
*
* @param[in] pof_enable True if the power-fail comparator should be enabled, false if it should be disabled.
*
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_POWER_POF_ENABLE, uint32_t, sd_power_pof_enable(uint8_t pof_enable));
/**@brief Sets the power-fail threshold value.
*
* @param[in] threshold The power-fail threshold value to use, see @ref NRF_POWER_THRESHOLDS.
*
* @retval ::NRF_SUCCESS The power failure threshold was set.
* @retval ::NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN The power failure threshold is unknown.
*/
SVCALL(SD_POWER_POF_THRESHOLD_SET, uint32_t, sd_power_pof_threshold_set(uint8_t threshold));
/**@brief Writes the NRF_POWER->RAM[index].POWERSET register.
*
* @param[in] index Contains the index in the NRF_POWER->RAM[index].POWERSET register to write to.
* @param[in] ram_powerset Contains the word to write to the NRF_POWER->RAM[index].POWERSET register.
*
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_POWER_RAM_POWER_SET, uint32_t, sd_power_ram_power_set(uint8_t index, uint32_t ram_powerset));
/**@brief Writes the NRF_POWER->RAM[index].POWERCLR register.
*
* @param[in] index Contains the index in the NRF_POWER->RAM[index].POWERCLR register to write to.
* @param[in] ram_powerclr Contains the word to write to the NRF_POWER->RAM[index].POWERCLR register.
*
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_POWER_RAM_POWER_CLR, uint32_t, sd_power_ram_power_clr(uint8_t index, uint32_t ram_powerclr));
/**@brief Get contents of NRF_POWER->RAM[index].POWER register, indicates power status of RAM[index] blocks.
*
* @param[in] index Contains the index in the NRF_POWER->RAM[index].POWER register to read from.
* @param[out] p_ram_power Content of NRF_POWER->RAM[index].POWER register.
*
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_POWER_RAM_POWER_GET, uint32_t, sd_power_ram_power_get(uint8_t index, uint32_t * p_ram_power));
/**@brief Set bits in the general purpose retention registers (NRF_POWER->GPREGRET*).
*
* @param[in] gpregret_id 0 for GPREGRET, 1 for GPREGRET2.
* @param[in] gpregret_msk Bits to be set in the GPREGRET register.
*
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_POWER_GPREGRET_SET, uint32_t, sd_power_gpregret_set(uint32_t gpregret_id, uint32_t gpregret_msk));
/**@brief Clear bits in the general purpose retention registers (NRF_POWER->GPREGRET*).
*
* @param[in] gpregret_id 0 for GPREGRET, 1 for GPREGRET2.
* @param[in] gpregret_msk Bits to be clear in the GPREGRET register.
*
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_POWER_GPREGRET_CLR, uint32_t, sd_power_gpregret_clr(uint32_t gpregret_id, uint32_t gpregret_msk));
/**@brief Get contents of the general purpose retention registers (NRF_POWER->GPREGRET*).
*
* @param[in] gpregret_id 0 for GPREGRET, 1 for GPREGRET2.
* @param[out] p_gpregret Contents of the GPREGRET register.
*
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_POWER_GPREGRET_GET, uint32_t, sd_power_gpregret_get(uint32_t gpregret_id, uint32_t *p_gpregret));
/**@brief Sets the DCDC mode.
*
* Enable or disable the DCDC peripheral.
*
* @param[in] dcdc_mode The mode of the DCDC, see @ref NRF_POWER_DCDC_MODES.
*
* @retval ::NRF_SUCCESS
* @retval ::NRF_ERROR_INVALID_PARAM The DCDC mode is invalid.
*/
SVCALL(SD_POWER_DCDC_MODE_SET, uint32_t, sd_power_dcdc_mode_set(uint8_t dcdc_mode));
/**@brief Request the high frequency crystal oscillator.
*
* Will start the high frequency crystal oscillator, the startup time of the crystal varies
* and the ::sd_clock_hfclk_is_running function can be polled to check if it has started.
*
* @see sd_clock_hfclk_is_running
* @see sd_clock_hfclk_release
*
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_CLOCK_HFCLK_REQUEST, uint32_t, sd_clock_hfclk_request(void));
/**@brief Releases the high frequency crystal oscillator.
*
* Will stop the high frequency crystal oscillator, this happens immediately.
*
* @see sd_clock_hfclk_is_running
* @see sd_clock_hfclk_request
*
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_CLOCK_HFCLK_RELEASE, uint32_t, sd_clock_hfclk_release(void));
/**@brief Checks if the high frequency crystal oscillator is running.
*
* @see sd_clock_hfclk_request
* @see sd_clock_hfclk_release
*
* @param[out] p_is_running 1 if the external crystal oscillator is running, 0 if not.
*
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_CLOCK_HFCLK_IS_RUNNING, uint32_t, sd_clock_hfclk_is_running(uint32_t * p_is_running));
/**@brief Waits for an application event.
*
* An application event is either an application interrupt or a pended interrupt when the interrupt
* is disabled.
*
* When the application waits for an application event by calling this function, an interrupt that
* is enabled will be taken immediately on pending since this function will wait in thread mode,
* then the execution will return in the application's main thread.
*
* In order to wake up from disabled interrupts, the SEVONPEND flag has to be set in the Cortex-M
* MCU's System Control Register (SCR), CMSIS_SCB. In that case, when a disabled interrupt gets
* pended, this function will return to the application's main thread.
*
* @note The application must ensure that the pended flag is cleared using ::sd_nvic_ClearPendingIRQ
* in order to sleep using this function. This is only necessary for disabled interrupts, as
* the interrupt handler will clear the pending flag automatically for enabled interrupts.
*
* @note If an application interrupt has happened since the last time sd_app_evt_wait was
* called this function will return immediately and not go to sleep. This is to avoid race
* conditions that can occur when a flag is updated in the interrupt handler and processed
* in the main loop.
*
* @post An application interrupt has happened or a interrupt pending flag is set.
*
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_APP_EVT_WAIT, uint32_t, sd_app_evt_wait(void));
/**@brief Get PPI channel enable register contents.
*
* @param[out] p_channel_enable The contents of the PPI CHEN register.
*
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_PPI_CHANNEL_ENABLE_GET, uint32_t, sd_ppi_channel_enable_get(uint32_t * p_channel_enable));
/**@brief Set PPI channel enable register.
*
* @param[in] channel_enable_set_msk Mask containing the bits to set in the PPI CHEN register.
*
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_PPI_CHANNEL_ENABLE_SET, uint32_t, sd_ppi_channel_enable_set(uint32_t channel_enable_set_msk));
/**@brief Clear PPI channel enable register.
*
* @param[in] channel_enable_clr_msk Mask containing the bits to clear in the PPI CHEN register.
*
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_PPI_CHANNEL_ENABLE_CLR, uint32_t, sd_ppi_channel_enable_clr(uint32_t channel_enable_clr_msk));
/**@brief Assign endpoints to a PPI channel.
*
* @param[in] channel_num Number of the PPI channel to assign.
* @param[in] evt_endpoint Event endpoint of the PPI channel.
* @param[in] task_endpoint Task endpoint of the PPI channel.
*
* @retval ::NRF_ERROR_SOC_PPI_INVALID_CHANNEL The channel number is invalid.
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_PPI_CHANNEL_ASSIGN, uint32_t, sd_ppi_channel_assign(uint8_t channel_num, const volatile void * evt_endpoint, const volatile void * task_endpoint));
/**@brief Task to enable a channel group.
*
* @param[in] group_num Number of the channel group.
*
* @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_PPI_GROUP_TASK_ENABLE, uint32_t, sd_ppi_group_task_enable(uint8_t group_num));
/**@brief Task to disable a channel group.
*
* @param[in] group_num Number of the PPI group.
*
* @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid.
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_PPI_GROUP_TASK_DISABLE, uint32_t, sd_ppi_group_task_disable(uint8_t group_num));
/**@brief Assign PPI channels to a channel group.
*
* @param[in] group_num Number of the channel group.
* @param[in] channel_msk Mask of the channels to assign to the group.
*
* @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid.
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_PPI_GROUP_ASSIGN, uint32_t, sd_ppi_group_assign(uint8_t group_num, uint32_t channel_msk));
/**@brief Gets the PPI channels of a channel group.
*
* @param[in] group_num Number of the channel group.
* @param[out] p_channel_msk Mask of the channels assigned to the group.
*
* @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid.
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_PPI_GROUP_GET, uint32_t, sd_ppi_group_get(uint8_t group_num, uint32_t * p_channel_msk));
/**@brief Configures the Radio Notification signal.
*
* @note
* - The notification signal latency depends on the interrupt priority settings of SWI used
* for notification signal.
* - To ensure that the radio notification signal behaves in a consistent way, the radio
* notifications must be configured when there is no protocol stack or other SoftDevice
* activity in progress. It is recommended that the radio notification signal is
* configured directly after the SoftDevice has been enabled.
* - In the period between the ACTIVE signal and the start of the Radio Event, the SoftDevice
* will interrupt the application to do Radio Event preparation.
* - Using the Radio Notification feature may limit the bandwidth, as the SoftDevice may have
* to shorten the connection events to have time for the Radio Notification signals.
*
* @param[in] type Type of notification signal, see @ref NRF_RADIO_NOTIFICATION_TYPES.
* @ref NRF_RADIO_NOTIFICATION_TYPE_NONE shall be used to turn off radio
* notification. Using @ref NRF_RADIO_NOTIFICATION_DISTANCE_NONE is
* recommended (but not required) to be used with
* @ref NRF_RADIO_NOTIFICATION_TYPE_NONE.
*
* @param[in] distance Distance between the notification signal and start of radio activity, see @ref NRF_RADIO_NOTIFICATION_DISTANCES.
* This parameter is ignored when @ref NRF_RADIO_NOTIFICATION_TYPE_NONE or
* @ref NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE is used.
*
* @retval ::NRF_ERROR_INVALID_PARAM The group number is invalid.
* @retval ::NRF_ERROR_INVALID_STATE A protocol stack or other SoftDevice is running. Stop all
* running activities and retry.
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_RADIO_NOTIFICATION_CFG_SET, uint32_t, sd_radio_notification_cfg_set(uint8_t type, uint8_t distance));
/**@brief Encrypts a block according to the specified parameters.
*
* 128-bit AES encryption.
*
* @note:
* - The application may set the SEVONPEND bit in the SCR to 1 to make the SoftDevice sleep while
* the ECB is running. The SEVONPEND bit should only be cleared (set to 0) from application
* main or low interrupt level.
*
* @param[in, out] p_ecb_data Pointer to the ECB parameters' struct (two input
* parameters and one output parameter).
*
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_ECB_BLOCK_ENCRYPT, uint32_t, sd_ecb_block_encrypt(nrf_ecb_hal_data_t * p_ecb_data));
/**@brief Encrypts multiple data blocks provided as an array of data block structures.
*
* @details: Performs 128-bit AES encryption on multiple data blocks
*
* @note:
* - The application may set the SEVONPEND bit in the SCR to 1 to make the SoftDevice sleep while
* the ECB is running. The SEVONPEND bit should only be cleared (set to 0) from application
* main or low interrupt level.
*
* @param[in] block_count Count of blocks in the p_data_blocks array.
* @param[in,out] p_data_blocks Pointer to the first entry in a contiguous array of
* @ref nrf_ecb_hal_data_block_t structures.
*
* @retval ::NRF_SUCCESS
*/
SVCALL(SD_ECB_BLOCKS_ENCRYPT, uint32_t, sd_ecb_blocks_encrypt(uint8_t block_count, nrf_ecb_hal_data_block_t * p_data_blocks));
/**@brief Gets any pending events generated by the SoC API.
*
* The application should keep calling this function to get events, until ::NRF_ERROR_NOT_FOUND is returned.
*
* @param[out] p_evt_id Set to one of the values in @ref NRF_SOC_EVTS, if any events are pending.
*
* @retval ::NRF_SUCCESS An event was pending. The event id is written in the p_evt_id parameter.
* @retval ::NRF_ERROR_NOT_FOUND No pending events.
*/
SVCALL(SD_EVT_GET, uint32_t, sd_evt_get(uint32_t * p_evt_id));
/**@brief Get the temperature measured on the chip
*
* This function will block until the temperature measurement is done.
* It takes around 50 us from call to return.
*
* @param[out] p_temp Result of temperature measurement. Die temperature in 0.25 degrees Celsius.
*
* @retval ::NRF_SUCCESS A temperature measurement was done, and the temperature was written to temp
*/
SVCALL(SD_TEMP_GET, uint32_t, sd_temp_get(int32_t * p_temp));
/**@brief Flash Write
*
* Commands to write a buffer to flash
*
* If the SoftDevice is enabled:
* This call initiates the flash access command, and its completion will be communicated to the
* application with exactly one of the following events:
* - @ref NRF_EVT_FLASH_OPERATION_SUCCESS - The command was successfully completed.
* - @ref NRF_EVT_FLASH_OPERATION_ERROR - The command could not be started.
*
* If the SoftDevice is not enabled no event will be generated, and this call will return @ref NRF_SUCCESS when the
* write has been completed
*
* @note
* - This call takes control over the radio and the CPU during flash erase and write to make sure that
* they will not interfere with the flash access. This means that all interrupts will be blocked
* for a predictable time (depending on the NVMC specification in the device's Product Specification
* and the command parameters).
* - The data in the p_src buffer should not be modified before the @ref NRF_EVT_FLASH_OPERATION_SUCCESS
* or the @ref NRF_EVT_FLASH_OPERATION_ERROR have been received if the SoftDevice is enabled.
*
*
* @param[in] p_dst Pointer to start of flash location to be written.
* @param[in] p_src Pointer to buffer with data to be written.
* @param[in] size Number of 32-bit words to write. Maximum size is the number of words in one
* flash page. See the device's Product Specification for details.
*
* @retval ::NRF_ERROR_INVALID_ADDR Tried to write to a non existing flash address, or p_dst or p_src was unaligned.
* @retval ::NRF_ERROR_BUSY The previous command has not yet completed.
* @retval ::NRF_ERROR_INVALID_LENGTH Size was 0, or higher than the maximum allowed size.
* @retval ::NRF_ERROR_FORBIDDEN Tried to write to or read from protected location.
* @retval ::NRF_SUCCESS The command was accepted.
*/
SVCALL(SD_FLASH_WRITE, uint32_t, sd_flash_write(uint32_t * p_dst, uint32_t const * p_src, uint32_t size));
/**@brief Flash Erase page
*
* Commands to erase a flash page
* If the SoftDevice is enabled:
* This call initiates the flash access command, and its completion will be communicated to the
* application with exactly one of the following events:
* - @ref NRF_EVT_FLASH_OPERATION_SUCCESS - The command was successfully completed.
* - @ref NRF_EVT_FLASH_OPERATION_ERROR - The command could not be started.
*
* If the SoftDevice is not enabled no event will be generated, and this call will return @ref NRF_SUCCESS when the
* erase has been completed
*
* @note
* - This call takes control over the radio and the CPU during flash erase and write to make sure that
* they will not interfere with the flash access. This means that all interrupts will be blocked
* for a predictable time (depending on the NVMC specification in the device's Product Specification
* and the command parameters).
*
*
* @param[in] page_number Page number of the page to erase
*
* @retval ::NRF_ERROR_INTERNAL If a new session could not be opened due to an internal error.
* @retval ::NRF_ERROR_INVALID_ADDR Tried to erase to a non existing flash page.
* @retval ::NRF_ERROR_BUSY The previous command has not yet completed.
* @retval ::NRF_ERROR_FORBIDDEN Tried to erase a protected page.
* @retval ::NRF_SUCCESS The command was accepted.
*/
SVCALL(SD_FLASH_PAGE_ERASE, uint32_t, sd_flash_page_erase(uint32_t page_number));
/**@brief Flash Protection set
*
* Commands to set the flash protection configuration registers.
This sets the CONFIGx registers of the BPROT peripheral.
*
* @note To read the values read them directly. They are only write-protected.
*
* @param[in] block_cfg0 Value to be written to the configuration register.
* @param[in] block_cfg1 Value to be written to the configuration register.
* @param[in] block_cfg2 Value to be written to the configuration register.
* @param[in] block_cfg3 Value to be written to the configuration register.
*
* @retval ::NRF_ERROR_FORBIDDEN Tried to protect the SoftDevice.
* @retval ::NRF_SUCCESS Values successfully written to configuration registers.
*/
SVCALL(SD_FLASH_PROTECT, uint32_t, sd_flash_protect(uint32_t block_cfg0, uint32_t block_cfg1, uint32_t block_cfg2, uint32_t block_cfg3));
/**@brief Opens a session for radio timeslot requests.
*
* @note Only one session can be open at a time.
* @note p_radio_signal_callback(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_START) will be called when the radio timeslot
* starts. From this point the NRF_RADIO and NRF_TIMER0 peripherals can be freely accessed
* by the application.
* @note p_radio_signal_callback(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_TIMER0) is called whenever the NRF_TIMER0
* interrupt occurs.
* @note p_radio_signal_callback(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_RADIO) is called whenever the NRF_RADIO
* interrupt occurs.
* @note p_radio_signal_callback() will be called at ARM interrupt priority level 0. This
* implies that none of the sd_* API calls can be used from p_radio_signal_callback().
*
* @param[in] p_radio_signal_callback The signal callback.
*
* @retval ::NRF_ERROR_INVALID_ADDR p_radio_signal_callback is an invalid function pointer.
* @retval ::NRF_ERROR_BUSY If session cannot be opened.
* @retval ::NRF_ERROR_INTERNAL If a new session could not be opened due to an internal error.
* @retval ::NRF_SUCCESS Otherwise.
*/
SVCALL(SD_RADIO_SESSION_OPEN, uint32_t, sd_radio_session_open(nrf_radio_signal_callback_t p_radio_signal_callback));
/**@brief Closes a session for radio timeslot requests.
*
* @note Any current radio timeslot will be finished before the session is closed.
* @note If a radio timeslot is scheduled when the session is closed, it will be canceled.
* @note The application cannot consider the session closed until the @ref NRF_EVT_RADIO_SESSION_CLOSED
* event is received.
*
* @retval ::NRF_ERROR_FORBIDDEN If session not opened.
* @retval ::NRF_ERROR_BUSY If session is currently being closed.
* @retval ::NRF_SUCCESS Otherwise.
*/
SVCALL(SD_RADIO_SESSION_CLOSE, uint32_t, sd_radio_session_close(void));
/**@brief Requests a radio timeslot.
*
* @note The request type is determined by p_request->request_type, and can be one of @ref NRF_RADIO_REQ_TYPE_EARLIEST
* and @ref NRF_RADIO_REQ_TYPE_NORMAL. The first request in a session must always be of type @ref NRF_RADIO_REQ_TYPE_EARLIEST.
* @note For a normal request (@ref NRF_RADIO_REQ_TYPE_NORMAL), the start time of a radio timeslot is specified by
* p_request->distance_us and is given relative to the start of the previous timeslot.
* @note A too small p_request->distance_us will lead to a @ref NRF_EVT_RADIO_BLOCKED event.
* @note Timeslots scheduled too close will lead to a @ref NRF_EVT_RADIO_BLOCKED event.
* @note See the SoftDevice Specification for more on radio timeslot scheduling, distances and lengths.
* @note If an opportunity for the first radio timeslot is not found before 100 ms after the call to this
* function, it is not scheduled, and instead a @ref NRF_EVT_RADIO_BLOCKED event is sent.
* The application may then try to schedule the first radio timeslot again.
* @note Successful requests will result in nrf_radio_signal_callback_t(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_START).
* Unsuccessful requests will result in a @ref NRF_EVT_RADIO_BLOCKED event, see @ref NRF_SOC_EVTS.
* @note The jitter in the start time of the radio timeslots is +/- @ref NRF_RADIO_START_JITTER_US us.
* @note The nrf_radio_signal_callback_t(@ref NRF_RADIO_CALLBACK_SIGNAL_TYPE_START) call has a latency relative to the
* specified radio timeslot start, but this does not affect the actual start time of the timeslot.
* @note NRF_TIMER0 is reset at the start of the radio timeslot, and is clocked at 1MHz from the high frequency
* (16 MHz) clock source. If p_request->hfclk_force_xtal is true, the high frequency clock is
* guaranteed to be clocked from the external crystal.
* @note The SoftDevice will neither access the NRF_RADIO peripheral nor the NRF_TIMER0 peripheral
* during the radio timeslot.
*
* @param[in] p_request Pointer to the request parameters.
*
* @retval ::NRF_ERROR_FORBIDDEN If session not opened or the session is not IDLE.
* @retval ::NRF_ERROR_INVALID_ADDR If the p_request pointer is invalid.
* @retval ::NRF_ERROR_INVALID_PARAM If the parameters of p_request are not valid.
* @retval ::NRF_SUCCESS Otherwise.
*/
SVCALL(SD_RADIO_REQUEST, uint32_t, sd_radio_request(nrf_radio_request_t const * p_request));
/**@} */
#ifdef __cplusplus
}
#endif
#endif // NRF_SOC_H__
/**@} */

View File

@ -1,90 +0,0 @@
/*
* Copyright (c) 2012 - 2017, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* 4. This software, with or without modification, must only be used with a
* Nordic Semiconductor ASA integrated circuit.
*
* 5. Any software provided in binary form under this license must not be reverse
* engineered, decompiled, modified and/or disassembled.
*
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef NRF_SVC__
#define NRF_SVC__
#include "stdint.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef SVCALL_AS_NORMAL_FUNCTION
#define SVCALL(number, return_type, signature) return_type signature
#else
#ifndef SVCALL
#if defined (__CC_ARM)
#define SVCALL(number, return_type, signature) return_type __svc(number) signature
#elif defined (__GNUC__)
#ifdef __cplusplus
#define GCC_CAST_CPP (uint16_t)
#else
#define GCC_CAST_CPP
#endif
#define SVCALL(number, return_type, signature) \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \
__attribute__((naked)) \
__attribute__((unused)) \
static return_type signature \
{ \
__asm( \
"svc %0\n" \
"bx r14" : : "I" (GCC_CAST_CPP number) : "r0" \
); \
} \
_Pragma("GCC diagnostic pop")
#elif defined (__ICCARM__)
#define PRAGMA(x) _Pragma(#x)
#define SVCALL(number, return_type, signature) \
PRAGMA(swi_number = (number)) \
__swi return_type signature;
#else
#define SVCALL(number, return_type, signature) return_type signature
#endif
#endif // SVCALL
#endif // SVCALL_AS_NORMAL_FUNCTION
#ifdef __cplusplus
}
#endif
#endif // NRF_SVC__

View File

@ -1,35 +0,0 @@
Copyright (c) 2007 - 2017, Nordic Semiconductor ASA
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form, except as embedded into a Nordic
Semiconductor ASA integrated circuit in a product or a software update for
such product, must reproduce the above copyright notice, this list of
conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
3. Neither the name of Nordic Semiconductor ASA nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
4. This software, with or without modification, must only be used with a
Nordic Semiconductor ASA integrated circuit.
5. Any software provided in binary form under this license must not be reverse
engineered, decompiled, modified and/or disassembled.
THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,192 +0,0 @@
# Setup
## Installing CircuitPython submodules
Before you can build, you will need to run the following commands once, which
will install the submodules that are part of the CircuitPython ecosystem, and
build the `mpy-cross` tool:
```
$ cd circuitpython
$ git submodule update --init
$ make -C mpy-cross
```
You then need to download the SD and Nordic SDK files via:
> This script relies on `wget`, which must be available from the command line.
```
$ cd ports/nrf
$ ./bluetooth/download_ble_stack.sh
```
## Installing `adafruit-nrfutil`
The Adafruit Bluefruit nRF52 Feather ships with a serial and OTA BLE bootloader
that can be used to flash firmware images over a simple serial connection,
using the on-board USB serial converter.
run following command to install [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil) from PyPi
$ pip3 install --user adafruit-nrfutil
# Building and flashing firmware images
## Building CircuitPython binaries
#### REPL over UART (default settings)
To build a CircuitPython binary with default settings for the
`feather_nrf52832` target enter:
> **NOTE:** `BOARD=feather_nrf52832` is the default option and isn't stricly required.
```
$ make BOARD=feather_nrf52832 V=1
```
#### REPL over BLE UART (AKA 'NUS')
To build a CircuitPython binary that uses the Nordic UART Service (AKA 'NUS' or
'BLEUART'), modify `/ports/nrf/bluetooth_conf.h` to have the following macro
set to `1` in the `#elif (BLUETOOTH_SD == 132)` section:
```
#define MICROPY_PY_BLE_NUS (1)
```
... then build as normal, via:
```
$ make BOARD=feather52832 V=1
```
You can then connect over BLE UART using an application like Bluefruit LE
Connect, available for Android, iOS and OS X, or any other application that
supports the NUS service and allows you to send the corrent EOL sequence.
## Flashing binaries with `adafruit-nrfutil`
### 1. **Update bootloader** to single-bank version
The Adafruit nRF52 Feather ships, by default, with a **dual-bank** bootloader
that cuts the available flash memory in half in exchange for safer
OTA updates.
Due to the size of CircuitPython, we must migrate this bootloader to a
**single-bank** version, doubling the amount of flash memory available to us.
> These commands only need to be run once and will update the SoftDevice and
bootloader from the dual-bank version that ships on Arduino-based Adafruit
Feather52 boards to a single-bank CircuitPython compatible version:
Firstly clone the [Adafruit_nRF52_Bootloader](https://github.com/adafruit/Adafruit_nRF52_Bootloader.git) and enter its directory
$ git clone https://github.com/adafruit/Adafruit_nRF52_Bootloader.git
$ cd Adafruit_nRF52_Bootloader
#### S132 v2.0.1 single-bank (recommended):
To flash bootloader with s132 v2.0.1
```
$ make BOARD=feather_nrf52832 VERSION=2.0.1 SERIAL=/dev/tty.SLAB_USBtoUART dfu-flash
```
#### S132 v5.0.0 (BLE5, experimental):
To flash bootloader with s132 v5.0.0
```
$ make BOARD=feather52832 VERSION=5.0.0 SERIAL=/dev/tty.SLAB_USBtoUART dfu-flash
```
### 2. Generate and flash a CircuitPython DFU .zip package over serial
The following command will package and flash the CircuitPython binary using the
appropriate bootloader mentionned above.
This command assumes you have already built a valid circuitpython
image, as described earlier in this readme.
> The name of the serial port target will vary, depending on your OS.
```
$ make BOARD=feather_nrf52832 SERIAL=/dev/tty.SLAB_USBtoUART dfu-gen dfu-flash
```
By default, CircuitPython will build with **BLE** support enabled using
`SD=s132` and the `SOFTDEV_VERSION=2.0.1`. If you wish to specify a different
SD family or version you can enter the optional fields as shown below:
```
$ make BOARD=feather_nrf52832 SERIAL=/dev/tty.SLAB_USBtoUART SD=s132 SOFTDEV_VERSION=5.0.0 dfu-gen dfu-flash
```
## Working with CircuitPython
### Running local files with `ampy`
[ampy](https://learn.adafruit.com/micropython-basics-load-files-and-run-code/install-ampy)
is a command-line tool that can be used with the nRF52 Feather to transfer
local python files to the nRF52 for execution, rather than having to enter
the REPL manually, enter paste mode, and paste the code yourself.
> **IMPORTANT**: You must have `ampy` version **1.0.3** or higher to use `ampy`
with the nRF52. The bootloader on the nRF52 requires a delay between the
HW reset, and the moment when the command sequance is sent to enter raw
mode. This required `-d/--delay` flag was added in release 1.0.3.
Save the following file as `test.py`:
```
import board
import digitalio
import time
led = digitalio.DigitalInOut(board.LED2)
led.direction = digitalio.Direction.OUTPUT
while True:
led.value = True
time.sleep(0.5)
led.value = False
time.sleep(0.5)
```
Then run the saved file via ampy, updating the serial port as required:
```
$ ampy -p /dev/tty.SLAB_USBtoUART -d 1.5 run test.py
```
This should give you blinky at 1 Hz on LED2 (the blue LED on the nRF52 Feather).
### Uploading files and libraries with `ampy`
To upload Python files or pre-compiled CircuitPython libraries to the `lib` folder,
run the following commands:
> In this example **i2c_device.py** is used, which is part of
[Adafruit_CircuitPython_BusDevice](https://github.com/adafruit/Adafruit_CircuitPython_BusDevice)
```
$ ampy -p /dev/tty.SLAB_USBtoUART -d 1.5 put i2c_device.py lib/i2c_device.py
```
To verify that the file was uploaded correctly, you can check the contents of
the `lib` folder with:
```
$ ampy -p /dev/tty.SLAB_USBtoUART -d 1.5 ls /lib
i2c_device.py
```
### Suggested libraries
The following libraries should be installed as a minimum on most new boards:
- [Adafruit_CircuitPython_BusDevice](https://github.com/adafruit/Adafruit_CircuitPython_BusDevice)
- [Adafruit_CircuitPython_Register](https://github.com/adafruit/Adafruit_CircuitPython_Register/tree/master)

View File

@ -1,44 +0,0 @@
/*
GNU linker script for NRF52 w/ s132 2.0.1 SoftDevice
MEMORY MAP
------------------------------------------------------------------------
START ADDR END ADDR SIZE DESCRIPTION
---------- ---------- ------- -----------------------------------------
0x0007F000..0x0007FFFF ( 4KB) Bootloader Settings
0x0007E000..0x0007EFFF ( 4KB) Master Boot Record Params
0x00074000..0x0007DFFF ( 40KB) Serial + OTA Bootloader
0x00073000..0x00073FFF ( 4KB ) Private Config Data (Bonding, Keys, etc.)
0x00072000..0x00072FFF ( 4KB ) User NVM data
0x00059000..0x00071FFF (100KB) User Filesystem
0x0001C000..0x00058FFF (244KB) Application Code
0x00001000..0x0001BFFF (108KB) SoftDevice
0x00000000..0x00000FFF (4KB) Master Boot Record
*/
/* Specify the memory areas (S132 2.0.1) */
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x080000 /* entire flash, 512 KiB */
FLASH_ISR (rx) : ORIGIN = 0x0001c000, LENGTH = 0x001000 /* sector 0, 4 KiB */
FLASH_TEXT (rx) : ORIGIN = 0x0001d000, LENGTH = 0x03C000 /* APP - ISR, 240 KiB */
FLASH_FATFS (r) : ORIGIN = 0x00059000, LENGTH = 0x019000 /* File system 100KB KB */
RAM (xrw) : ORIGIN = 0x20003000, LENGTH = 0x0D000 /* 52 KiB, give 8KiB headroom for softdevice */
}
/* produce a link error if there is not this amount of RAM for these sections */
_minimum_stack_size = 2K;
_minimum_heap_size = 0 /*16K Circuit Python use static variable for HEAP */;
/* top end of the stack */
/*_stack_end = ORIGIN(RAM) + LENGTH(RAM);*/
_estack = ORIGIN(RAM) + LENGTH(RAM);
/* RAM extents for the garbage collector */
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
_heap_end = 0x20007000; /* tunable */
INCLUDE "boards/common.ld"

View File

@ -1,44 +0,0 @@
/*
GNU linker script for NRF52 w/ s132 5.0.0 SoftDevice
MEMORY MAP
------------------------------------------------------------------------
START ADDR END ADDR SIZE DESCRIPTION
---------- ---------- ------- -----------------------------------------
0x0007F000..0x0007FFFF ( 4KB) Bootloader Settings
0x0007E000..0x0007EFFF ( 4KB) Master Boot Record Params
0x00074000..0x0007DFFF ( 40KB) Serial + OTA Bootloader
0x00073000..0x00073FFF ( 4KB ) Private Config Data (Bonding, Keys, etc.)
0x00072000..0x00072FFF ( 4KB ) User NVM data
0x00059000..0x00071FFF ( 100KB) User Filesystem
0x00023000..0x00058FFF (216KB) Application Code
0x00001000..0x00022FFF (136KB) SoftDevice
0x00000000..0x00000FFF (4KB) Master Boot Record
*/
/* Specify the memory areas (S132 5.0.0) */
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x080000 /* entire flash, 512 KiB */
FLASH_ISR (rx) : ORIGIN = 0x00023000, LENGTH = 0x001000 /* sector 0, 4 KiB */
FLASH_TEXT (rx) : ORIGIN = 0x00024000, LENGTH = 0x036000 /* APP - ISR, 216 KiB */
FLASH_FATFS (r) : ORIGIN = 0x00059000, LENGTH = 0x019000 /* File system 100KB KB */
RAM (xrw) : ORIGIN = 0x200039c0, LENGTH = 0x0c640 /* 49.5 KiB, give 8KiB headroom for softdevice */
}
/* produce a link error if there is not this amount of RAM for these sections */
_minimum_stack_size = 2K;
_minimum_heap_size = 0 /*16K Circuit Python use static variable for HEAP */;
/* top end of the stack */
/*_stack_end = ORIGIN(RAM) + LENGTH(RAM);*/
_estack = ORIGIN(RAM) + LENGTH(RAM);
/* RAM extents for the garbage collector */
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
_heap_end = 0x20007000; /* tunable */
INCLUDE "boards/common.ld"

View File

@ -1,26 +0,0 @@
from ubluepy import Scanner, constants
def display_scan_results(scan_entries):
for e in scan_entries:
print("ADDR: ", e.addr())
print("TYPE: ", e.addr_type())
print("RSSI: ", e.rssi())
# Parse the contents of the advertising packet
scan = e.getScanData()
if scan:
for s in scan:
# Convert byte array to hex format string
hex = ' '.join('0x%02X' % b for b in s[2])
# Display enum value and hex string together
print('\t{}: {}'.format(s[1], hex))
# Line break between record sets
print("")
# Scan 1s for advertising devices in range
s = Scanner()
scan_res = s.scan(1000)
# Display the scan results
display_scan_results(scan_res)

View File

@ -1,12 +0,0 @@
import board
import digitalio
import time
led = digitalio.DigitalInOut(board.LED2)
led.direction = digitalio.Direction.OUTPUT
while True:
led.value = True
time.sleep(0.5)
led.value = False
time.sleep(0.5)

View File

@ -1,20 +0,0 @@
import board
import busio
i2c = busio.I2C(board.SCL, board.SDA)
count = 0
# Wait for I2C lock
while not i2c.try_lock():
pass
# Scan for devices on the I2C bus
print("Scanning I2C bus")
for x in i2c.scan():
print(hex(x))
count += 1
print("%d device(s) found on I2C bus" % count)
# Release the I2C bus
i2c.unlock()

View File

@ -1,25 +0,0 @@
import time
from board import *
from pulseio import *
# Setup BLUE and RED LEDs as PWM output (default frequency is 500 Hz)
ledb = PWMOut(LED2)
ledr = PWMOut(LED1)
# Set the BLUE LED to have a duty cycle of 5000 (out of 65535, so ~7.5%)
ledb.duty_cycle = 5000
# Setup pin A0 as a standard PWM out @ 50% to test on the oscilloscope.
# You should see a 50% duty cycle waveform at ~500Hz on the scope when you
# connect a probe to pin A0
a0 = PWMOut(A0)
a0.duty_cycle = int(65535/2)
# Constantly pulse the RED LED
while True:
for i in range(100):
ledr.duty_cycle = int(i / 100 * 65535)
time.sleep(0.01)
for i in range(100, -1, -1):
ledr.duty_cycle = int(i / 100 * 65535)
time.sleep(0.01)

View File

@ -1,13 +0,0 @@
MCU_SERIES = m4
MCU_VARIANT = nrf52
# Historical: nrf52 means nrf52832
MCU_SUB_VARIANT = nrf52
MCU_CHIP = nrf52832
SD ?= s132
SOFTDEV_VERSION ?= 2.0.1
LD_FILE = boards/feather_nrf52832/custom_nrf52832_dfu_app_$(SOFTDEV_VERSION).ld
BOOT_FILE = boards/feather_nrf52832/bootloader/feather52_bootloader_$(SOFTDEV_VERSION)_s132_single
BOOT_SETTING_ADDR = 0x7F000
NRF_DEFINES += -DNRF52832_XXAA -DNRF52832

View File

@ -1,47 +0,0 @@
#include "shared-bindings/board/__init__.h"
#include "board_busses.h"
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_P0_02) },
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_03) },
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P0_04) },
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_P0_05) },
{ MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_P0_28) },
{ MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_P0_29) },
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_12) },
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P0_13) },
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P0_14) },
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P0_08) },
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P0_06) },
{ MP_ROM_QSTR(MP_QSTR_DFU), MP_ROM_PTR(&pin_P0_20) },
{ MP_ROM_QSTR(MP_QSTR_NFC1), MP_ROM_PTR(&pin_P0_09) },
{ MP_ROM_QSTR(MP_QSTR_NFC2), MP_ROM_PTR(&pin_P0_10) },
{ MP_ROM_QSTR(MP_QSTR_D27), MP_ROM_PTR(&pin_P0_27) },
{ MP_ROM_QSTR(MP_QSTR_D30), MP_ROM_PTR(&pin_P0_30) },
{ MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_P0_30) },
{ MP_ROM_QSTR(MP_QSTR_D31), MP_ROM_PTR(&pin_P0_31) },
{ MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_P0_31) },
{ MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_P0_31) },
{ MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_P0_07) },
{ MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_P0_11) },
{ MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_P0_15) },
{ MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_P0_16) },
{ MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_P0_17) },
{ MP_ROM_QSTR(MP_QSTR_LED_BLUE), MP_ROM_PTR(&pin_P0_19) },
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_26) },
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_25) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

View File

@ -1,28 +0,0 @@
/*
GNU linker script for NRF52832 blank w/ no SoftDevice
*/
/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x080000 /* entire flash, 512 KiB */
FLASH_ISR (rx) : ORIGIN = 0x00000000, LENGTH = 0x001000 /* sector 0, 4 KiB */
FLASH_TEXT (rx) : ORIGIN = 0x00001000, LENGTH = 0x066000 /* 408 KiB */
FLASH_FATFS (r) : ORIGIN = 0x00067000, LENGTH = 0x019000 /* File system 100KB */
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 0x010000 /* 64 KiB */
}
/* produce a link error if there is not this amount of RAM for these sections */
_minimum_stack_size = 2K;
_minimum_heap_size = 0;
/* top end of the stack */
/*_stack_end = ORIGIN(RAM) + LENGTH(RAM);*/
_estack = ORIGIN(RAM) + LENGTH(RAM);
/* RAM extents for the garbage collector */
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
_heap_end = 0x20008000; /* tunable */
INCLUDE "boards/common.ld"

View File

@ -1,28 +0,0 @@
/*
GNU linker script for NRF52 w/ s132 2.0.1 SoftDevice
*/
/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x080000 /* entire flash, 512 KiB */
FLASH_ISR (rx) : ORIGIN = 0x0001c000, LENGTH = 0x001000 /* sector 0, 4 KiB */
FLASH_TEXT (rx) : ORIGIN = 0x0001d000, LENGTH = 0x04A000 /* 296 KiB */
FLASH_FATFS (r) : ORIGIN = 0x00067000, LENGTH = 0x019000 /* File system 100KB */
RAM (xrw) : ORIGIN = 0x200039c0, LENGTH = 0x0c640 /* 49.5 KiB, give 8KiB headroom for softdevice */
}
/* produce a link error if there is not this amount of RAM for these sections */
_minimum_stack_size = 2K;
_minimum_heap_size = 0;
/* top end of the stack */
/*_stack_end = ORIGIN(RAM) + LENGTH(RAM);*/
_estack = ORIGIN(RAM) + LENGTH(RAM);
/* RAM extents for the garbage collector */
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
_heap_end = 0x20007000; /* tunable */
INCLUDE "boards/common.ld"

View File

@ -1,28 +0,0 @@
/*
GNU linker script for NRF52 w/ s132 2.0.1 SoftDevice
*/
/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x080000 /* entire flash, 512 KiB */
FLASH_ISR (rx) : ORIGIN = 0x00023000, LENGTH = 0x001000 /* sector 0, 4 KiB */
FLASH_TEXT (rx) : ORIGIN = 0x00024000, LENGTH = 0x043000 /* 268 KiB */
FLASH_FATFS (r) : ORIGIN = 0x00067000, LENGTH = 0x019000 /* File system 100KB */
RAM (xrw) : ORIGIN = 0x200039c0, LENGTH = 0x0c640 /* 49.5 KiB, give 8KiB headroom for softdevice */
}
/* produce a link error if there is not this amount of RAM for these sections */
_minimum_stack_size = 2K;
_minimum_heap_size = 0;
/* top end of the stack */
/*_stack_end = ORIGIN(RAM) + LENGTH(RAM);*/
_estack = ORIGIN(RAM) + LENGTH(RAM);
/* RAM extents for the garbage collector */
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
_heap_end = 0x20007000; /* tunable */
INCLUDE "boards/common.ld"

View File

@ -1,15 +0,0 @@
MCU_SERIES = m4
MCU_VARIANT = nrf52
# Historical: nrf52 means nrf52832
MCU_SUB_VARIANT = nrf52
MCU_CHIP = nrf52832
SD ?= s132
SOFTDEV_VERSION ?= 5.0.0
ifeq ($(SD),)
LD_FILE = boards/nrf52832_512k_64k.ld
else
LD_FILE = boards/nrf52832_512k_64k_s132_$(SOFTDEV_VERSION).ld
endif
NRF_DEFINES += -DNRF52832_XXAA -DNRF52832

View File

@ -1,44 +0,0 @@
#include "shared-bindings/board/__init__.h"
#include "board_busses.h"
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_P0_00), MP_ROM_PTR(&pin_P0_00) },
{ MP_ROM_QSTR(MP_QSTR_P0_01), MP_ROM_PTR(&pin_P0_01) },
{ MP_ROM_QSTR(MP_QSTR_P0_02), MP_ROM_PTR(&pin_P0_02) },
{ MP_ROM_QSTR(MP_QSTR_P0_03), MP_ROM_PTR(&pin_P0_03) },
{ MP_ROM_QSTR(MP_QSTR_P0_04), MP_ROM_PTR(&pin_P0_04) },
{ MP_ROM_QSTR(MP_QSTR_P0_05), MP_ROM_PTR(&pin_P0_05) },
{ MP_ROM_QSTR(MP_QSTR_P0_06), MP_ROM_PTR(&pin_P0_06) },
{ MP_ROM_QSTR(MP_QSTR_P0_07), MP_ROM_PTR(&pin_P0_07) },
{ MP_ROM_QSTR(MP_QSTR_P0_08), MP_ROM_PTR(&pin_P0_08) },
{ MP_ROM_QSTR(MP_QSTR_P0_09), MP_ROM_PTR(&pin_P0_09) },
{ MP_ROM_QSTR(MP_QSTR_P0_10), MP_ROM_PTR(&pin_P0_10) },
{ MP_ROM_QSTR(MP_QSTR_P0_11), MP_ROM_PTR(&pin_P0_11) },
{ MP_ROM_QSTR(MP_QSTR_P0_12), MP_ROM_PTR(&pin_P0_12) },
{ MP_ROM_QSTR(MP_QSTR_P0_13), MP_ROM_PTR(&pin_P0_13) },
{ MP_ROM_QSTR(MP_QSTR_P0_14), MP_ROM_PTR(&pin_P0_14) },
{ MP_ROM_QSTR(MP_QSTR_P0_15), MP_ROM_PTR(&pin_P0_15) },
{ MP_ROM_QSTR(MP_QSTR_P0_16), MP_ROM_PTR(&pin_P0_16) },
{ MP_ROM_QSTR(MP_QSTR_P0_17), MP_ROM_PTR(&pin_P0_17) },
{ MP_ROM_QSTR(MP_QSTR_LED1), MP_ROM_PTR(&pin_P0_17) },
{ MP_ROM_QSTR(MP_QSTR_P0_18), MP_ROM_PTR(&pin_P0_18) },
{ MP_ROM_QSTR(MP_QSTR_LED2), MP_ROM_PTR(&pin_P0_18) },
{ MP_ROM_QSTR(MP_QSTR_P0_19), MP_ROM_PTR(&pin_P0_19) },
{ MP_ROM_QSTR(MP_QSTR_LED3), MP_ROM_PTR(&pin_P0_19) },
{ MP_ROM_QSTR(MP_QSTR_P0_20), MP_ROM_PTR(&pin_P0_20) },
{ MP_ROM_QSTR(MP_QSTR_LED4), MP_ROM_PTR(&pin_P0_20) },
{ MP_ROM_QSTR(MP_QSTR_P0_21), MP_ROM_PTR(&pin_P0_21) },
{ MP_ROM_QSTR(MP_QSTR_P0_22), MP_ROM_PTR(&pin_P0_22) },
{ MP_ROM_QSTR(MP_QSTR_P0_23), MP_ROM_PTR(&pin_P0_23) },
{ MP_ROM_QSTR(MP_QSTR_P0_24), MP_ROM_PTR(&pin_P0_24) },
{ MP_ROM_QSTR(MP_QSTR_P0_25), MP_ROM_PTR(&pin_P0_25) },
{ MP_ROM_QSTR(MP_QSTR_P0_26), MP_ROM_PTR(&pin_P0_26) },
{ MP_ROM_QSTR(MP_QSTR_P0_27), MP_ROM_PTR(&pin_P0_27) },
{ MP_ROM_QSTR(MP_QSTR_P0_28), MP_ROM_PTR(&pin_P0_28) },
{ MP_ROM_QSTR(MP_QSTR_P0_29), MP_ROM_PTR(&pin_P0_29) },
{ MP_ROM_QSTR(MP_QSTR_P0_30), MP_ROM_PTR(&pin_P0_30) },
{ MP_ROM_QSTR(MP_QSTR_P0_31), MP_ROM_PTR(&pin_P0_31) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

View File

@ -33,28 +33,22 @@
#include "nrfx_power.h"
#include "nrf_nvic.h"
#include "nrf_sdm.h"
#include "py/nlr.h"
#include "py/runtime.h"
#include "shared-bindings/bleio/Adapter.h"
STATIC void softdevice_assert_handler(uint32_t id, uint32_t pc, uint32_t info) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_AssertionError,
translate("Soft device assert, id: 0x%08lX, pc: 0x%08lX"), id, pc));
mp_raise_msg_varg(&mp_type_AssertionError,
translate("Soft device assert, id: 0x%08lX, pc: 0x%08lX"), id, pc);
}
STATIC uint32_t ble_stack_enable(void) {
nrf_clock_lf_cfg_t clock_config = {
.source = NRF_CLOCK_LF_SRC_XTAL,
#if (BLE_API_VERSION == 4)
.accuracy = NRF_CLOCK_LF_ACCURACY_20_PPM
#else
.xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM
#endif
};
#if (BLUETOOTH_SD == 140)
// The SD takes over the POWER IRQ and will fail if the IRQ is already in use
nrfx_power_uninit();
#endif
uint32_t err_code = sd_softdevice_enable(&clock_config, softdevice_assert_handler);
if (err_code != NRF_SUCCESS)
@ -64,17 +58,10 @@ STATIC uint32_t ble_stack_enable(void) {
if (err_code != NRF_SUCCESS)
return err_code;
uint32_t app_ram_start;
#if (BLE_API_VERSION == 2)
ble_enable_params_t ble_enable_params = {
.gatts_enable_params.attr_tab_size = BLE_GATTS_ATTR_TAB_SIZE_DEFAULT,
.gap_enable_params.central_conn_count = 1,
.gap_enable_params.periph_conn_count = 1,
};
// Start with no event handlers, etc.
ble_drv_reset();
app_ram_start = 0x200039c0;
err_code = sd_ble_enable(&ble_enable_params, &app_ram_start);
#else
uint32_t app_ram_start;
app_ram_start = 0x20004000;
ble_cfg_t ble_conf;
@ -100,7 +87,6 @@ STATIC uint32_t ble_stack_enable(void) {
return err_code;
err_code = sd_ble_enable(&app_ram_start);
#endif
return err_code;
}
@ -121,8 +107,7 @@ void common_hal_bleio_adapter_set_enabled(bool enabled) {
}
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to change softdevice state, error: 0x%08lX"), err_code));
mp_raise_OSError_msg(translate("Failed to change softdevice state"));
}
}
@ -131,8 +116,7 @@ bool common_hal_bleio_adapter_get_enabled(void) {
const uint32_t err_code = sd_softdevice_is_enabled(&is_enabled);
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to get softdevice state, error: 0x%08lX"), err_code));
mp_raise_OSError_msg(translate("Failed to get softdevice state"));
}
return is_enabled;
@ -151,8 +135,7 @@ void common_hal_bleio_adapter_get_address(bleio_address_obj_t *address) {
#endif
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to get local address, error: 0x%08lX"), err_code));
mp_raise_OSError_msg(translate("Failed to get local address"));
}
address->type = local_address.addr_type;

View File

@ -0,0 +1,98 @@
/*
* 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.
*/
#include <string.h>
#include "ble.h"
#include "ble_drv.h"
#include "ble_hci.h"
#include "nrf_soc.h"
#include "py/runtime.h"
#include "common-hal/bleio/Broadcaster.h"
#include "shared-bindings/bleio/Adapter.h"
#include "shared-bindings/bleio/Broadcaster.h"
static uint8_t m_adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET;
void common_hal_bleio_broadcaster_construct(bleio_broadcaster_obj_t *self, mp_float_t interval) {
common_hal_bleio_adapter_set_enabled(true); // TODO -- Do this somewhere else maybe bleio __init__
const mp_float_t min = BLE_GAP_ADV_INTERVAL_MIN * ADV_INTERVAL_UNIT_FLOAT_SECS;
const mp_float_t max = BLE_GAP_ADV_INTERVAL_MAX * ADV_INTERVAL_UNIT_FLOAT_SECS;
if (interval < min || interval > max) {
// Would like to print range using the constants above, but vargs would convert to double.
mp_raise_ValueError(translate("interval not in range 0.0020 to 10.24"));
}
self->interval = interval;
}
void common_hal_bleio_broadcaster_start_advertising(bleio_broadcaster_obj_t *self, mp_buffer_info_t *data) {
uint32_t err_code;
if (data->len >= BLE_GAP_ADV_SET_DATA_SIZE_MAX) {
mp_raise_ValueError(translate("Data too large for advertisement packet"));
}
memcpy(self->adv_data, data->buf, data->len);
ble_gap_adv_params_t m_adv_params = {
.interval = (uint32_t) (self->interval / ADV_INTERVAL_UNIT_FLOAT_SECS),
.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED,
.duration = BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED,
.filter_policy = BLE_GAP_ADV_FP_ANY,
.primary_phy = BLE_GAP_PHY_1MBPS,
};
common_hal_bleio_broadcaster_stop_advertising(self);
const ble_gap_adv_data_t ble_gap_adv_data = {
.adv_data.p_data = self->adv_data,
.adv_data.len = data->len,
};
err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &ble_gap_adv_data, &m_adv_params);
if (err_code == NRF_SUCCESS) {
err_code = sd_ble_gap_adv_start(m_adv_handle, BLE_CONN_CFG_TAG_CUSTOM);
}
if (err_code != NRF_SUCCESS) {
mp_raise_OSError_msg_varg(translate("Failed to start advertising, err 0x%04x"), err_code);
}
}
void common_hal_bleio_broadcaster_stop_advertising(bleio_broadcaster_obj_t *self) {
if (m_adv_handle == BLE_GAP_ADV_SET_HANDLE_NOT_SET) {
return;
}
const uint32_t err_code = sd_ble_gap_adv_stop(m_adv_handle);
if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_INVALID_STATE)) {
mp_raise_OSError_msg_varg(translate("Failed to stop advertising, err 0x%04x"), err_code);
}
}

View File

@ -0,0 +1,47 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2018 Artur Pacholec
* 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_COMMON_HAL_BLEIO_BROADCASTER_H
#define MICROPY_INCLUDED_COMMON_HAL_BLEIO_BROADCASTER_H
#include "ble.h"
#include "shared-module/bleio/__init__.h"
#include "shared-module/bleio/Address.h"
typedef struct {
mp_obj_base_t base;
// In seconds.
mp_float_t interval;
// The advertising data buffer is held by us, not by the SD, so we must
// maintain it and not change it. If we need to change its contents during advertising,
// there are tricks to get the SD to notice (see DevZone - TBS).
uint8_t adv_data[BLE_GAP_ADV_SET_DATA_SIZE_MAX];
} bleio_broadcaster_obj_t;
#endif // MICROPY_INCLUDED_COMMON_HAL_BLEIO_BROADCASTER_H

View File

@ -30,16 +30,71 @@
#include "ble_drv.h"
#include "ble_gatts.h"
#include "nrf_soc.h"
#include "py/nlr.h"
#include "py/runtime.h"
#include "common-hal/bleio/__init__.h"
#include "common-hal/bleio/Characteristic.h"
#include "shared-module/bleio/Characteristic.h"
static volatile bleio_characteristic_obj_t *m_read_characteristic;
static volatile uint8_t m_tx_in_progress;
static nrf_mutex_t *m_write_mutex;
// TODO - should these be per object?? *****
STATIC volatile bleio_characteristic_obj_t *m_read_characteristic;
STATIC volatile uint8_t m_tx_in_progress;
STATIC nrf_mutex_t *m_write_mutex;
STATIC uint16_t get_cccd(bleio_characteristic_obj_t *characteristic) {
const uint16_t conn_handle = common_hal_bleio_device_get_conn_handle(characteristic->service->device);
uint16_t cccd;
ble_gatts_value_t value = {
.p_value = (uint8_t*) &cccd,
.len = 2,
};
const uint32_t err_code = sd_ble_gatts_value_get(conn_handle, characteristic->cccd_handle, &value);
if (err_code == BLE_ERROR_GATTS_SYS_ATTR_MISSING) {
// CCCD is not set, so say that neither Notify nor Indicate is enabled.
cccd = 0;
} else if (err_code != NRF_SUCCESS) {
mp_raise_OSError_msg_varg(translate("Failed to read CCCD value, err 0x%04x"), err_code);
}
return cccd;
}
STATIC void gatts_read(bleio_characteristic_obj_t *characteristic) {
// This might be BLE_CONN_HANDLE_INVALID if we're not conected, but that's OK, because
// we can still read and write the local value.
const uint16_t conn_handle = common_hal_bleio_device_get_conn_handle(characteristic->service->device);
mp_buffer_info_t bufinfo;
ble_gatts_value_t gatts_value = {
.p_value = NULL,
.len = 0,
};
// Read once to find out what size buffer we need, then read again to fill buffer.
uint32_t err_code = sd_ble_gatts_value_get(conn_handle, characteristic->handle, &gatts_value);
if (err_code == NRF_SUCCESS) {
characteristic->value_data = mp_obj_new_bytearray_of_zeros(gatts_value.len);
mp_get_buffer_raise(characteristic->value_data, &bufinfo, MP_BUFFER_WRITE);
gatts_value.p_value = bufinfo.buf;
// Read again, with the correct size of buffer.
err_code = sd_ble_gatts_value_get(conn_handle, characteristic->handle, &gatts_value);
}
if (err_code != NRF_SUCCESS) {
mp_raise_OSError_msg_varg(translate("Failed to read gatts value, err 0x%04x"), err_code);
}
}
STATIC void gatts_write(bleio_characteristic_obj_t *characteristic, mp_buffer_info_t *bufinfo) {
bleio_device_obj_t *device = characteristic->service->device;
const uint16_t conn_handle = device->conn_handle;
// This might be BLE_CONN_HANDLE_INVALID if we're not conected, but that's OK, because
// we can still read and write the local value.
const uint16_t conn_handle = common_hal_bleio_device_get_conn_handle(characteristic->service->device);
ble_gatts_value_t gatts_value = {
.p_value = bufinfo->buf,
@ -48,18 +103,17 @@ STATIC void gatts_write(bleio_characteristic_obj_t *characteristic, mp_buffer_in
const uint32_t err_code = sd_ble_gatts_value_set(conn_handle, characteristic->handle, &gatts_value);
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to write gatts value, status: 0x%08lX"), err_code));
mp_raise_OSError_msg_varg(translate("Failed to write gatts value, err 0x%04x"), err_code);
}
}
STATIC void gatts_notify(bleio_characteristic_obj_t *characteristic, mp_buffer_info_t *bufinfo) {
bleio_device_obj_t *device = characteristic->service->device;
STATIC void gatts_notify_indicate(bleio_characteristic_obj_t *characteristic, mp_buffer_info_t *bufinfo, uint16_t hvx_type) {
uint16_t hvx_len = bufinfo->len;
ble_gatts_hvx_params_t hvx_params = {
.handle = characteristic->handle,
.type = BLE_GATT_HVX_NOTIFICATION,
.type = hvx_type,
.offset = 0,
.p_len = &hvx_len,
.p_data = bufinfo->buf,
};
@ -70,27 +124,27 @@ STATIC void gatts_notify(bleio_characteristic_obj_t *characteristic, mp_buffer_i
#endif
}
const uint32_t err_code = sd_ble_gatts_hvx(device->conn_handle, &hvx_params);
const uint16_t conn_handle = common_hal_bleio_device_get_conn_handle(characteristic->service->device);
m_tx_in_progress++;
const uint32_t err_code = sd_ble_gatts_hvx(conn_handle, &hvx_params);
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to notify attribute value, status: 0x%08lX"), err_code));
m_tx_in_progress--;
mp_raise_OSError_msg_varg(translate("Failed to notify or indicate attribute value, err %0x04x"), err_code);
}
m_tx_in_progress += 1;
}
STATIC void gattc_read(bleio_characteristic_obj_t *characteristic) {
bleio_service_obj_t *service = characteristic->service;
bleio_device_obj_t *device = service->device;
const uint16_t conn_handle = common_hal_bleio_device_get_conn_handle(characteristic->service->device);
m_read_characteristic = characteristic;
const uint32_t err_code = sd_ble_gattc_read(device->conn_handle, characteristic->handle, 0);
const uint32_t err_code = sd_ble_gattc_read(conn_handle, characteristic->handle, 0);
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to read attribute value, status: 0x%08lX"), err_code));
mp_raise_OSError_msg_varg(translate("Failed to read attribute value, err %0x04x"), err_code);
}
//
while (m_read_characteristic != NULL) {
#ifdef MICROPY_VM_HOOK_LOOP
MICROPY_VM_HOOK_LOOP
@ -99,7 +153,7 @@ STATIC void gattc_read(bleio_characteristic_obj_t *characteristic) {
}
STATIC void gattc_write(bleio_characteristic_obj_t *characteristic, mp_buffer_info_t *bufinfo) {
bleio_device_obj_t *device = characteristic->service->device;
const uint16_t conn_handle = common_hal_bleio_device_get_conn_handle(characteristic->service->device);
uint32_t err_code;
ble_gattc_write_params_t write_params = {
@ -110,20 +164,18 @@ STATIC void gattc_write(bleio_characteristic_obj_t *characteristic, mp_buffer_in
.len = bufinfo->len,
};
if (characteristic->props.write_wo_resp) {
if (characteristic->props.write_no_response) {
write_params.write_op = BLE_GATT_OP_WRITE_CMD;
err_code = sd_mutex_acquire(m_write_mutex);
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to acquire mutex, status: 0x%08lX"), err_code));
mp_raise_OSError_msg_varg(translate("Failed to acquire mutex, err 0x%04x"), err_code);
}
}
err_code = sd_ble_gattc_write(device->conn_handle, &write_params);
err_code = sd_ble_gattc_write(conn_handle, &write_params);
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to write attribute value, status: 0x%08lX"), err_code));
mp_raise_OSError_msg_varg(translate("Failed to write attribute value, err 0x%04x"), err_code);
}
while (sd_mutex_acquire(m_write_mutex) == NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN) {
@ -134,58 +186,102 @@ STATIC void gattc_write(bleio_characteristic_obj_t *characteristic, mp_buffer_in
err_code = sd_mutex_release(m_write_mutex);
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to release mutex, status: 0x%08lX"), err_code));
mp_raise_OSError_msg_varg(translate("Failed to release mutex, err 0x%04x"), err_code);
}
}
STATIC void on_ble_evt(ble_evt_t *ble_evt, void *param) {
STATIC void characteristic_on_ble_evt(ble_evt_t *ble_evt, void *param) {
switch (ble_evt->header.evt_id) {
#if (BLE_API_VERSION == 4)
case BLE_GATTS_EVT_HVN_TX_COMPLETE:
m_tx_in_progress -= ble_evt->evt.gatts_evt.params.hvn_tx_complete.count;
break;
#else
case BLE_EVT_TX_COMPLETE:
m_tx_in_progress -= ble_evt->evt.common_evt.params.tx_complete.count;
break;
#endif
case BLE_GATTC_EVT_READ_RSP:
{
ble_gattc_evt_read_rsp_t *response = &ble_evt->evt.gattc_evt.params.read_rsp;
m_read_characteristic->value_data = mp_obj_new_bytearray(response->len, response->data);
m_read_characteristic = NULL;
break;
case BLE_GATTS_EVT_HVN_TX_COMPLETE:
{
uint8_t count = ble_evt->evt.gatts_evt.params.hvn_tx_complete.count;
// Don't underflow the count.
if (count >= m_tx_in_progress) {
m_tx_in_progress = 0;
} else {
m_tx_in_progress -= count;
}
break;
}
case BLE_GATTC_EVT_WRITE_RSP:
sd_mutex_release(m_write_mutex);
// m_write_done = true;
break;
case BLE_GATTC_EVT_READ_RSP:
{
ble_gattc_evt_read_rsp_t *response = &ble_evt->evt.gattc_evt.params.read_rsp;
m_read_characteristic->value_data = mp_obj_new_bytearray(response->len, response->data);
// Flag to busy-wait loop that we've read the characteristic.
m_read_characteristic = NULL;
break;
}
case BLE_GATTC_EVT_WRITE_RSP:
// Someone else can write now.
sd_mutex_release(m_write_mutex);
break;
// For debugging.
default:
// mp_printf(&mp_plat_print, "Unhandled characteristic event: 0x%04x\n", ble_evt->header.evt_id);
break;
}
}
void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, bleio_uuid_obj_t *uuid, bleio_characteristic_properties_t props) {
self->service = NULL;
self->uuid = uuid;
self->value_data = NULL;
self->props = props;
self->handle = BLE_GATT_HANDLE_INVALID;
ble_drv_add_event_handler(characteristic_on_ble_evt, self);
}
void common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self) {
switch (common_hal_bleio_device_get_gatt_role(self->service->device)) {
case GATT_ROLE_CLIENT:
gattc_read(self);
break;
case GATT_ROLE_SERVER:
gatts_read(self);
break;
default:
mp_raise_RuntimeError(translate("bad GATT role"));
break;
}
}
void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self) {
ble_drv_add_event_handler(on_ble_evt, NULL);
}
void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, mp_buffer_info_t *bufinfo) {
bool sent = false;
uint16_t cccd = 0;
void common_hal_bleio_characteristic_read_value(bleio_characteristic_obj_t *self) {
gattc_read(self);
}
void common_hal_bleio_characteristic_write_value(bleio_characteristic_obj_t *self, mp_buffer_info_t *bufinfo) {
const bleio_device_obj_t *device = self->service->device;
if (device->is_peripheral) {
// TODO: Add indications
if (self->props.notify) {
gatts_notify(self, bufinfo);
} else {
switch (common_hal_bleio_device_get_gatt_role(self->service->device)) {
case GATT_ROLE_SERVER:
if (self->props.notify || self->props.indicate) {
cccd = get_cccd(self);
}
// It's possible that both notify and indicate are set.
if (self->props.notify && (cccd & BLE_GATT_HVX_NOTIFICATION)) {
gatts_notify_indicate(self, bufinfo, BLE_GATT_HVX_NOTIFICATION);
sent = true;
}
if (self->props.indicate && (cccd & BLE_GATT_HVX_INDICATION)) {
gatts_notify_indicate(self, bufinfo, BLE_GATT_HVX_INDICATION);
sent = true;
}
if (!sent) {
gatts_write(self, bufinfo);
}
} else {
gattc_write(self, bufinfo);
}
break;
case GATT_ROLE_CLIENT:
gattc_write(self, bufinfo);
break;
default:
mp_raise_RuntimeError(translate("bad GATT role"));
break;
}
}

View File

@ -1,5 +1,5 @@
/*
* This file is part of the Micro Python project, http://micropython.org/
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
@ -24,23 +24,23 @@
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_UUIDTYPE_H
#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_UUIDTYPE_H
#ifndef MICROPY_INCLUDED_COMMON_HAL_BLEIO_CHARACTERISTIC_H
#define MICROPY_INCLUDED_COMMON_HAL_BLEIO_CHARACTERISTIC_H
#include "py/obj.h"
typedef enum {
UUID_TYPE_16BIT,
UUID_TYPE_128BIT
} bleio_uuid_type_t;
extern const mp_obj_type_t bleio_uuidtype_type;
#include "shared-module/bleio/Characteristic.h"
#include "shared-module/bleio/Service.h"
#include "common-hal/bleio/UUID.h"
typedef struct {
mp_obj_base_t base;
} bleio_uuidtype_obj_t;
bleio_service_obj_t *service;
bleio_uuid_obj_t *uuid;
mp_obj_t value_data;
uint16_t handle;
bleio_characteristic_properties_t props;
uint16_t user_desc_handle;
uint16_t cccd_handle;
uint16_t sccd_handle;
} bleio_characteristic_obj_t;
extern const bleio_uuidtype_obj_t bleio_uuidtype_16bit_obj;
extern const bleio_uuidtype_obj_t bleio_uuidtype_128bit_obj;
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_UUIDTYPE_H
#endif // MICROPY_INCLUDED_COMMON_HAL_BLEIO_CHARACTERISTIC_H

View File

@ -0,0 +1,75 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* 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 <string.h>
#include <stdio.h>
#include "ble_drv.h"
#include "ble_gatts.h"
#include "nrf_soc.h"
#include "py/runtime.h"
#include "common-hal/bleio/__init__.h"
#include "common-hal/bleio/CharacteristicBuffer.h"
STATIC void characteristic_buffer_on_ble_evt(ble_evt_t *ble_evt, void *param) {
bleio_characteristic_buffer_obj_t *self = (bleio_characteristic_buffer_obj_t *) param;
switch (ble_evt->header.evt_id) {
case BLE_GATTS_EVT_WRITE: {
ble_gatts_evt_write_t *evt_write = &ble_evt->evt.gatts_evt.params.write;
// Event handle must match the handle for my characteristic.
if (evt_write->handle == self->characteristic->handle) {
// Push all the data onto the ring buffer.
for (size_t i = 0; i < evt_write->len; i++) {
ringbuf_put(&self->ringbuf, evt_write->data[i]);
}
break;
}
}
}
}
// Assumes that buffer_size has been validated before call.
void common_hal_bleio_characteristic_buffer_construct(bleio_characteristic_buffer_obj_t *self, bleio_characteristic_obj_t *characteristic, size_t buffer_size) {
self->characteristic = characteristic;
// This is a macro.
ringbuf_alloc(&self->ringbuf, buffer_size);
ble_drv_add_event_handler(characteristic_buffer_on_ble_evt, self);
}
// Returns a uint8_t byte value, or -1 if no data is available.
int common_hal_bleio_characteristic_buffer_read(bleio_characteristic_buffer_obj_t *self) {
return ringbuf_get(&self->ringbuf);
}
void common_hal_bleio_characteristic_buffer_deinit(bleio_characteristic_buffer_obj_t *self) {
ble_drv_remove_event_handler(characteristic_buffer_on_ble_evt, self);
}

View File

@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
* Copyright (c) 2017 Scott Shawcroft 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
@ -24,19 +24,18 @@
* THE SOFTWARE.
*/
#include <string.h>
#include <stdbool.h>
#ifndef MICROPY_INCLUDED_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H
#define MICROPY_INCLUDED_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H
#include "nrf.h"
#include "py/ringbuf.h"
#include "boards/board.h"
#include "shared-bindings/bleio/Characteristic.h"
void board_init(void) {
}
typedef struct {
mp_obj_base_t base;
bleio_characteristic_obj_t *characteristic;
// Ring buffer storing consecutive incoming values.
ringbuf_t ringbuf;
} bleio_characteristic_buffer_obj_t;
bool board_requests_safe_mode(void) {
return false;
}
void reset_board(void) {
}
#endif // MICROPY_INCLUDED_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H

View File

@ -26,20 +26,17 @@
*/
#include "common-hal/bleio/Descriptor.h"
#include "shared-bindings/bleio/UUID.h"
void common_hal_bleio_descriptor_construct(bleio_descriptor_obj_t *self, bleio_uuid_obj_t *uuid) {
// TODO: set handle ???
self->uuid = uuid;
}
void common_hal_bleio_descriptor_print(bleio_descriptor_obj_t *self, const mp_print_t *print) {
mp_printf(print, "Descriptor(uuid: 0x" HEX2_FMT HEX2_FMT ")",
self->uuid->value[1], self->uuid->value[0]);
}
mp_int_t common_hal_bleio_descriptor_get_handle(bleio_descriptor_obj_t *self) {
return self->handle;
}
mp_int_t common_hal_bleio_descriptor_get_uuid(bleio_descriptor_obj_t *self) {
return self->uuid->value[0] | (self->uuid->value[1] << 8);
mp_obj_t common_hal_bleio_descriptor_get_uuid(bleio_descriptor_obj_t *self) {
return MP_OBJ_FROM_PTR(self->uuid);
}

View File

@ -77,8 +77,7 @@ STATIC uint32_t set_advertisement_data(bleio_device_obj_t *device, bool connecta
#define ADD_FIELD(field, len) \
do { \
if (byte_pos + (len) > BLE_GAP_ADV_MAX_SIZE) { \
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, \
translate("Can not fit data into the advertisment packet"))); \
mp_raise_ValueError(translate("Data too large for the advertisement packet")); \
} \
adv_data[byte_pos] = (field); \
byte_pos += (len); \
@ -110,8 +109,7 @@ STATIC uint32_t set_advertisement_data(bleio_device_obj_t *device, bool connecta
ADD_FIELD(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE, BLE_AD_TYPE_FLAGS_DATA_SIZE);
} else {
if (byte_pos + raw_data->len > BLE_GAP_ADV_MAX_SIZE) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Can not fit data into the advertisment packet")));
mp_raise_ValueError(translate("Data too large for the advertisement packet"));
}
memcpy(&adv_data[byte_pos], raw_data->buf, raw_data->len);
@ -130,12 +128,13 @@ STATIC uint32_t set_advertisement_data(bleio_device_obj_t *device, bool connecta
continue;
}
if (service->uuid->type == UUID_TYPE_16BIT) {
switch (common_hal_bleio_uuid_get_size(service->uuid)) {
case 16:
has_16bit_services = true;
}
if (service->uuid->type == UUID_TYPE_128BIT) {
break;
case 128:
has_128bit_services = true;
break;
}
}
@ -152,13 +151,12 @@ STATIC uint32_t set_advertisement_data(bleio_device_obj_t *device, bool connecta
const bleio_service_obj_t *service = MP_OBJ_TO_PTR(service_list->items[i]);
uint8_t encoded_size = 0;
if ((service->uuid->type != UUID_TYPE_16BIT) || service->is_secondary) {
if (common_hal_bleio_uuid_get_size(service->uuid) != 16 || service->is_secondary) {
continue;
}
ble_uuid_t uuid;
uuid.type = BLE_UUID_TYPE_BLE;
uuid.uuid = service->uuid->value[0] | (service->uuid->value[1] << 8);
bleio_uuid_convert_to_nrf_ble_uuid(service->uuid, &uuid);
err_code = sd_ble_uuid_encode(&uuid, &encoded_size, &adv_data[byte_pos]);
if (err_code != NRF_SUCCESS) {
@ -185,13 +183,12 @@ STATIC uint32_t set_advertisement_data(bleio_device_obj_t *device, bool connecta
const bleio_service_obj_t *service = MP_OBJ_TO_PTR(service_list->items[i]);
uint8_t encoded_size = 0;
if ((service->uuid->type != UUID_TYPE_128BIT) || service->is_secondary) {
if (common_hal_bleio_uuid_get_size(service->uuid) != 16 || service->is_secondary) {
continue;
}
ble_uuid_t uuid;
uuid.type = service->uuid->uuid_vs_idx;
uuid.uuid = service->uuid->value[0] | (service->uuid->value[1] << 8);
bleio_uuid_convert_to_nrf_ble_uuid(service->uuid, &uuid);
err_code = sd_ble_uuid_encode(&uuid, &encoded_size, &adv_data[byte_pos]);
if (err_code != NRF_SUCCESS) {
@ -262,14 +259,12 @@ STATIC bool discover_services(bleio_device_obj_t *device, uint16_t start_handle)
uint32_t err_code = sd_ble_gattc_primary_services_discover(device->conn_handle, start_handle, NULL);
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to discover serivices, status: 0x%08lX"), err_code));
mp_raise_OSError_msg(translate("Failed to discover services"));
}
err_code = sd_mutex_acquire(m_discovery_mutex);
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to acquire mutex, status: 0x%08lX"), err_code));
mp_raise_OSError_msg(translate("Failed to acquire mutex"));
}
while (sd_mutex_acquire(m_discovery_mutex) == NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN) {
@ -280,8 +275,7 @@ STATIC bool discover_services(bleio_device_obj_t *device, uint16_t start_handle)
err_code = sd_mutex_release(m_discovery_mutex);
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to release mutex, status: 0x%08lX"), err_code));
mp_raise_OSError_msg(translate("Failed to release mutex"));
}
return m_discovery_successful;
@ -303,8 +297,7 @@ STATIC bool discover_characteristics(bleio_device_obj_t *device, bleio_service_o
err_code = sd_mutex_acquire(m_discovery_mutex);
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to acquire mutex, status: 0x%08lX"), err_code));
mp_raise_OSError_msg(translate("Failed to acquire mutex"));
}
while (sd_mutex_acquire(m_discovery_mutex) == NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN) {
@ -315,8 +308,7 @@ STATIC bool discover_characteristics(bleio_device_obj_t *device, bleio_service_o
err_code = sd_mutex_release(m_discovery_mutex);
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to release mutex, status: 0x%08lX"), err_code));
mp_raise_OSError_msg(translate("Failed to release mutex"));
}
return m_discovery_successful;
@ -324,7 +316,7 @@ STATIC bool discover_characteristics(bleio_device_obj_t *device, bleio_service_o
STATIC void on_primary_srv_discovery_rsp(ble_gattc_evt_prim_srvc_disc_rsp_t *response, bleio_device_obj_t *device) {
for (size_t i = 0; i < response->count; ++i) {
const ble_gattc_service_t *gattc_service = &response->services[i];
ble_gattc_service_t *gattc_service = &response->services[i];
bleio_service_obj_t *service = m_new_obj(bleio_service_obj_t);
service->base.type = &bleio_service_type;
@ -335,10 +327,7 @@ STATIC void on_primary_srv_discovery_rsp(ble_gattc_evt_prim_srvc_disc_rsp_t *res
service->handle = gattc_service->handle_range.start_handle;
bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t);
uuid->base.type = &bleio_uuid_type;
uuid->type = (gattc_service->uuid.type == BLE_UUID_TYPE_BLE) ? UUID_TYPE_16BIT : UUID_TYPE_128BIT;
uuid->value[0] = gattc_service->uuid.uuid & 0xFF;
uuid->value[1] = gattc_service->uuid.uuid >> 8;
bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_service->uuid);
service->uuid = uuid;
mp_obj_list_append(device->service_list, service);
@ -350,23 +339,20 @@ STATIC void on_primary_srv_discovery_rsp(ble_gattc_evt_prim_srvc_disc_rsp_t *res
const uint32_t err_code = sd_mutex_release(m_discovery_mutex);
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to release mutex, status: 0x%08lX"), err_code));
mp_raise_OSError_msg(translate("Failed to release mutex"));
}
}
STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, bleio_device_obj_t *device) {
for (size_t i = 0; i < response->count; ++i) {
const ble_gattc_char_t *gattc_char = &response->chars[i];
ble_gattc_char_t *gattc_char = &response->chars[i];
bleio_characteristic_obj_t *characteristic = m_new_obj(bleio_characteristic_obj_t);
characteristic->base.type = &bleio_characteristic_type;
bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t);
uuid->base.type = &bleio_uuid_type;
uuid->type = (gattc_char->uuid.type == BLE_UUID_TYPE_BLE) ? UUID_TYPE_16BIT : UUID_TYPE_128BIT;
uuid->value[0] = gattc_char->uuid.uuid & 0xFF;
uuid->value[1] = gattc_char->uuid.uuid >> 8;
bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_char->uuid);
characteristic->uuid = uuid;
characteristic->props.broadcast = gattc_char->char_props.broadcast;
@ -374,7 +360,7 @@ STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, bleio
characteristic->props.notify = gattc_char->char_props.notify;
characteristic->props.read = gattc_char->char_props.read;
characteristic->props.write = gattc_char->char_props.write;
characteristic->props.write_wo_resp = gattc_char->char_props.write_wo_resp;
characteristic->props.write_no_response = gattc_char->char_props.write_wo_resp;
characteristic->handle = gattc_char->handle_value;
characteristic->service = m_char_discovery_service;
@ -387,8 +373,7 @@ STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, bleio
const uint32_t err_code = sd_mutex_release(m_discovery_mutex);
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to release mutex, status: 0x%08lX"), err_code));
mp_raise_OSError_msg(translate("Failed to release mutex"));
}
}
@ -399,8 +384,7 @@ STATIC void on_adv_report(ble_gap_evt_adv_report_t *report, bleio_device_obj_t *
#if (BLUETOOTH_SD == 140)
err_code = sd_ble_gap_scan_start(NULL, &m_scan_buffer);
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to continue scanning, status: 0x%0xlX"), err_code));
mp_raise_OSError_msg(translate("Failed to continue scanning"));
}
#endif
return;
@ -432,8 +416,7 @@ STATIC void on_adv_report(ble_gap_evt_adv_report_t *report, bleio_device_obj_t *
#endif
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to connect, status: 0x%08lX"), err_code));
mp_raise_OSError_msg(translate("Failed to connect:"));
}
}
@ -491,14 +474,8 @@ STATIC void on_ble_evt(ble_evt_t *ble_evt, void *device_in) {
}
void common_hal_bleio_device_add_service(bleio_device_obj_t *device, bleio_service_obj_t *service) {
ble_uuid_t uuid = {
.type = BLE_UUID_TYPE_BLE,
.uuid = service->uuid->value[0] | (service->uuid->value[1] << 8)
};
if (service->uuid->type == UUID_TYPE_128BIT) {
uuid.type = service->uuid->uuid_vs_idx;
}
ble_uuid_t uuid;
bleio_uuid_convert_to_nrf_ble_uuid(service->uuid, &uuid);
uint8_t service_type = BLE_GATTS_SRVC_TYPE_PRIMARY;
if (service->is_secondary) {
@ -509,8 +486,7 @@ void common_hal_bleio_device_add_service(bleio_device_obj_t *device, bleio_servi
const uint32_t err_code = sd_ble_gatts_service_add(service_type, &uuid, &service->handle);
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to add service, status: 0x%08lX"), err_code));
mp_raise_OSError_msg(translate("Failed to add service"));
}
const mp_obj_list_t *char_list = MP_OBJ_TO_PTR(service->char_list);
@ -527,8 +503,7 @@ void common_hal_bleio_device_start_advertising(bleio_device_obj_t *device, bool
const uint32_t err_code = set_advertisement_data(device, connectable, raw_data);
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to start advertisment, status: 0x%08lX"), err_code));
mp_raise_OSError_msg(translate("Failed to start advertising"));
}
}
@ -545,8 +520,7 @@ void common_hal_bleio_device_stop_advertising(bleio_device_obj_t *device) {
#endif
if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_INVALID_STATE)) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to stop advertisment, status: 0x%08lX"), err_code));
mp_raise_OSError_msg(translate("Failed to stop advertising"));
}
}
@ -571,8 +545,7 @@ void common_hal_bleio_device_connect(bleio_device_obj_t *device) {
#endif
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to start scanning, status: 0x%0xlX"), err_code));
mp_raise_OSError_msg(translate("Failed to start scanning"));
}
while (device->conn_handle == BLE_CONN_HANDLE_INVALID) {
@ -588,8 +561,7 @@ void common_hal_bleio_device_connect(bleio_device_obj_t *device) {
err_code = sd_mutex_new(m_discovery_mutex);
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to create mutex, status: 0x%0xlX"), err_code));
mp_raise_OSError_msg(translate("Failed to create mutex"));
}
}

View File

@ -0,0 +1,338 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2018 Artur Pacholec
* 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.
*/
#include <string.h>
#include <stdio.h>
#include "ble.h"
#include "ble_drv.h"
#include "ble_hci.h"
#include "nrf_soc.h"
#include "py/objstr.h"
#include "py/runtime.h"
#include "shared-bindings/bleio/Adapter.h"
#include "shared-bindings/bleio/Characteristic.h"
#include "shared-bindings/bleio/Peripheral.h"
#include "shared-bindings/bleio/Service.h"
#include "shared-bindings/bleio/UUID.h"
#define BLE_MIN_CONN_INTERVAL MSEC_TO_UNITS(15, UNIT_0_625_MS)
#define BLE_MAX_CONN_INTERVAL MSEC_TO_UNITS(300, UNIT_0_625_MS)
#define BLE_SLAVE_LATENCY 0
#define BLE_CONN_SUP_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS)
#define BLE_ADV_LENGTH_FIELD_SIZE 1
#define BLE_ADV_AD_TYPE_FIELD_SIZE 1
#define BLE_AD_TYPE_FLAGS_DATA_SIZE 1
static uint8_t m_adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET;
STATIC void check_data_fit(size_t pos, size_t data_len) {
if (pos + data_len >= BLE_GAP_ADV_SET_DATA_SIZE_MAX) {
mp_raise_ValueError(translate("Data too large for advertisement packet"));
}
}
STATIC uint32_t add_services_to_advertisement(bleio_peripheral_obj_t *self, size_t* adv_data_pos_p, size_t uuid_len) {
uint32_t uuids_total_size = 0;
const mp_obj_list_t *service_list = MP_OBJ_TO_PTR(self->service_list);
uint32_t err_code = NRF_SUCCESS;
check_data_fit(*adv_data_pos_p, 1 + 1);
// Remember where length byte is; fill in later when we know the size.
const size_t length_pos = *adv_data_pos_p;
(*adv_data_pos_p)++;
self->adv_data[(*adv_data_pos_p)++] = (uuid_len == 16)
? BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE
: BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE;
for (size_t i = 0; i < service_list->len; ++i) {
const bleio_service_obj_t *service = MP_OBJ_TO_PTR(service_list->items[i]);
uint8_t encoded_size = 0;
// Skip services of the wrong length and secondary services.
if (common_hal_bleio_uuid_get_size(service->uuid) != uuid_len || service->is_secondary) {
continue;
}
ble_uuid_t uuid;
bleio_uuid_convert_to_nrf_ble_uuid(service->uuid, &uuid);
err_code = sd_ble_uuid_encode(&uuid, &encoded_size, &(self->adv_data[*adv_data_pos_p]));
if (err_code != NRF_SUCCESS) {
return err_code;
}
check_data_fit(*adv_data_pos_p, encoded_size);
uuids_total_size += encoded_size;
(*adv_data_pos_p) += encoded_size;
}
self->adv_data[length_pos] = 1 + uuids_total_size; // 1 for the field type.
return err_code;
}
// if raw_data is a zero-length buffer, generate an advertising packet that advertises the
// services passed in when this Peripheral was created.
// If raw_data contains some bytes, use those bytes as the advertising packet.
// TODO: Generate the advertising packet in Python, not here.
STATIC uint32_t set_advertisement_data(bleio_peripheral_obj_t *self, bool connectable, mp_buffer_info_t *raw_data) {
common_hal_bleio_adapter_set_enabled(true);
size_t adv_data_pos = 0;
uint32_t err_code;
GET_STR_DATA_LEN(self->name, name_data, name_len);
if (name_len > 0) {
ble_gap_conn_sec_mode_t sec_mode;
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
// We'll add the name after everything else, shortening it if necessary.
err_code = sd_ble_gap_device_name_set(&sec_mode, name_data, name_len);
if (err_code != NRF_SUCCESS) {
return err_code;
}
}
if (raw_data->len != 0) {
// User-supplied advertising packet.
check_data_fit(adv_data_pos, raw_data->len);
memcpy(&(self->adv_data[adv_data_pos]), raw_data->buf, raw_data->len);
adv_data_pos += raw_data->len;
} else {
// Build up advertising packet.
check_data_fit(adv_data_pos, 1 + 1 + 1);
self->adv_data[adv_data_pos++] = 2;
self->adv_data[adv_data_pos++] = BLE_GAP_AD_TYPE_FLAGS;
self->adv_data[adv_data_pos++] = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
// The 16-bit ids and 128-bit ids are grouped together by length, so find it whether we have
// 16 and/or 128-bit service UUIDs.
const mp_obj_list_t *service_list = MP_OBJ_TO_PTR(self->service_list);
if (service_list->len > 0) {
bool has_128bit_services = false;
bool has_16bit_services = false;
for (size_t i = 0; i < service_list->len; ++i) {
const bleio_service_obj_t *service = MP_OBJ_TO_PTR(service_list->items[i]);
if (service->is_secondary) {
continue;
}
switch (common_hal_bleio_uuid_get_size(service->uuid)) {
case 16:
has_16bit_services = true;
break;
case 128:
has_128bit_services = true;
break;
}
}
// Add 16-bit service UUID's in a group, then 128-bit service UUID's.
if (has_16bit_services) {
err_code = add_services_to_advertisement(self, &adv_data_pos, 16);
if (err_code != NRF_SUCCESS) {
return err_code;
}
}
if (has_128bit_services) {
err_code = add_services_to_advertisement(self, &adv_data_pos, 128);
if (err_code != NRF_SUCCESS) {
return err_code;
}
}
}
// Always include TX power.
check_data_fit(adv_data_pos, 1 + 1 + 1);
self->adv_data[adv_data_pos++] = 1 + 1;
self->adv_data[adv_data_pos++] = BLE_GAP_AD_TYPE_TX_POWER_LEVEL;
self->adv_data[adv_data_pos++] = 0; // TODO - allow power level to be set later.
// We need room for at least a one-character name.
check_data_fit(adv_data_pos, 1 + 1 + 1);
// How big a name can we fit?
size_t bytes_left = BLE_GAP_ADV_SET_DATA_SIZE_MAX - adv_data_pos - 1 - 1;
size_t partial_name_len = MIN(bytes_left, name_len);
self->adv_data[adv_data_pos++] = 1 + partial_name_len;
self->adv_data[adv_data_pos++] = (partial_name_len == name_len)
? BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME
: BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME;
memcpy(&(self->adv_data[adv_data_pos]), name_data, partial_name_len);
adv_data_pos += partial_name_len;
} // end of advertising packet construction
static ble_gap_adv_params_t m_adv_params = {
.interval = MSEC_TO_UNITS(1000, UNIT_0_625_MS),
.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED,
.duration = BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED,
.filter_policy = BLE_GAP_ADV_FP_ANY,
.primary_phy = BLE_GAP_PHY_1MBPS,
};
if (!connectable) {
m_adv_params.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;
}
common_hal_bleio_peripheral_stop_advertising(self);
const ble_gap_adv_data_t ble_gap_adv_data = {
.adv_data.p_data = self->adv_data,
.adv_data.len = adv_data_pos,
};
err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &ble_gap_adv_data, &m_adv_params);
if (err_code != NRF_SUCCESS) {
return err_code;
}
err_code = sd_ble_gap_adv_start(m_adv_handle, BLE_CONN_CFG_TAG_CUSTOM);
return err_code;
}
STATIC void peripheral_on_ble_evt(ble_evt_t *ble_evt, void *self_in) {
bleio_peripheral_obj_t *self = (bleio_peripheral_obj_t*)self_in;
switch (ble_evt->header.evt_id) {
case BLE_GAP_EVT_CONNECTED: {
// Central has connected.
ble_gap_conn_params_t conn_params;
self->conn_handle = ble_evt->evt.gap_evt.conn_handle;
sd_ble_gap_ppcp_get(&conn_params);
sd_ble_gap_conn_param_update(ble_evt->evt.gap_evt.conn_handle, &conn_params);
break;
}
case BLE_GAP_EVT_DISCONNECTED:
// Central has disconnected.
self->conn_handle = BLE_CONN_HANDLE_INVALID;
break;
case BLE_GAP_EVT_PHY_UPDATE_REQUEST: {
ble_gap_phys_t const phys = {
.rx_phys = BLE_GAP_PHY_AUTO,
.tx_phys = BLE_GAP_PHY_AUTO,
};
sd_ble_gap_phy_update(ble_evt->evt.gap_evt.conn_handle, &phys);
break;
}
case BLE_GAP_EVT_ADV_SET_TERMINATED:
// Someday may handle timeouts or limit reached.
break;
case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
sd_ble_gap_sec_params_reply(self->conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL);
break;
case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: {
ble_gap_evt_conn_param_update_request_t *request = &ble_evt->evt.gap_evt.params.conn_param_update_request;
sd_ble_gap_conn_param_update(self->conn_handle, &request->conn_params);
break;
}
case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST: {
sd_ble_gatts_exchange_mtu_reply(self->conn_handle, BLE_GATT_ATT_MTU_DEFAULT);
break;
}
default:
// For debugging.
// mp_printf(&mp_plat_print, "Unhandled peripheral event: 0x%04x\n", ble_evt->header.evt_id);
break;
}
}
void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self) {
common_hal_bleio_adapter_set_enabled(true); // TODO -- Do this somewhere else maybe bleio __init__
self->gatt_role = GATT_ROLE_SERVER;
self->conn_handle = BLE_CONN_HANDLE_INVALID;
// Add all the services.
mp_obj_list_t *service_list = MP_OBJ_TO_PTR(self->service_list);
for (size_t service_idx = 0; service_idx < service_list->len; ++service_idx) {
bleio_service_obj_t *service = MP_OBJ_TO_PTR(service_list->items[service_idx]);
ble_uuid_t uuid;
bleio_uuid_convert_to_nrf_ble_uuid(service->uuid, &uuid);
uint8_t service_type = BLE_GATTS_SRVC_TYPE_PRIMARY;
if (service->is_secondary) {
service_type = BLE_GATTS_SRVC_TYPE_SECONDARY;
}
const uint32_t err_code = sd_ble_gatts_service_add(service_type, &uuid, &service->handle);
if (err_code != NRF_SUCCESS) {
mp_raise_OSError_msg_varg(translate("Failed to add service, err 0x%04x"), err_code);
}
// Once the service has been registered, its characteristics can be added.
common_hal_bleio_service_add_all_characteristics(service);
}
}
bool common_hal_bleio_peripheral_get_connected(bleio_peripheral_obj_t *self) {
return self->conn_handle != BLE_CONN_HANDLE_INVALID;
}
void common_hal_bleio_peripheral_start_advertising(bleio_peripheral_obj_t *self, bool connectable, mp_buffer_info_t *raw_data) {
if (connectable) {
ble_drv_add_event_handler(peripheral_on_ble_evt, self);
}
const uint32_t err_code = set_advertisement_data(self, connectable, raw_data);
if (err_code != NRF_SUCCESS) {
mp_raise_OSError_msg_varg(translate("Failed to start advertising, err 0x%04x"), err_code);
}
}
void common_hal_bleio_peripheral_stop_advertising(bleio_peripheral_obj_t *self) {
if (m_adv_handle == BLE_GAP_ADV_SET_HANDLE_NOT_SET)
return;
const uint32_t err_code = sd_ble_gap_adv_stop(m_adv_handle);
if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_INVALID_STATE)) {
mp_raise_OSError_msg_varg(translate("Failed to stop advertising, err 0x%04x"), err_code);
}
}

View File

@ -0,0 +1,53 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2018 Artur Pacholec
* 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_COMMON_HAL_BLEIO_PERIPHERAL_H
#define MICROPY_INCLUDED_COMMON_HAL_BLEIO_PERIPHERAL_H
#include <stdbool.h>
#include "ble.h"
#include "shared-module/bleio/__init__.h"
#include "shared-module/bleio/Address.h"
typedef struct {
mp_obj_base_t base;
mp_obj_t name;
gatt_role_t gatt_role;
volatile uint16_t conn_handle;
mp_obj_t service_list;
mp_obj_t notif_handler;
mp_obj_t conn_handler;
// The advertising data buffer is held by us, not by the SD, so we must
// maintain it and not change it. If we need to change its contents during advertising,
// there are tricks to get the SD to notice (see DevZone - TBS).
uint8_t adv_data[BLE_GAP_ADV_SET_DATA_SIZE_MAX];
} bleio_peripheral_obj_t;
#endif // MICROPY_INCLUDED_COMMON_HAL_BLEIO_PERIPHERAL_H

View File

@ -30,7 +30,7 @@
#include "ble_drv.h"
#include "ble_gap.h"
#include "py/mphal.h"
#include "py/nlr.h"
#include "py/runtime.h"
#include "shared-bindings/bleio/Adapter.h"
#include "shared-bindings/bleio/ScanEntry.h"
#include "shared-bindings/bleio/Scanner.h"
@ -72,8 +72,7 @@ STATIC void on_ble_evt(ble_evt_t *ble_evt, void *scanner_in) {
#if (BLUETOOTH_SD == 140)
const uint32_t err_code = sd_ble_gap_scan_start(NULL, &m_scan_buffer);
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to continue scanning, status: 0x%0xlX"), err_code));
mp_raise_OSError_msg_varg(translate("Failed to continue scanning, err 0x%04x"), err_code);
}
#endif
}
@ -99,8 +98,7 @@ void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_int_t timeout)
#endif
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to start scanning, status: 0x%0xlX"), err_code));
mp_raise_OSError_msg_varg(translate("Failed to start scanning, err 0x%04x"), err_code);
}
if (timeout > 0) {

View File

@ -26,65 +26,75 @@
#include "ble_drv.h"
#include "ble.h"
#include "py/nlr.h"
#include "py/runtime.h"
#include "common-hal/bleio/__init__.h"
#include "common-hal/bleio/Characteristic.h"
#include "shared-bindings/bleio/Service.h"
#include "shared-bindings/bleio/Adapter.h"
void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self, bleio_characteristic_obj_t *characteristic) {
ble_gatts_char_md_t char_md = {
.char_props.broadcast = characteristic->props.broadcast,
.char_props.read = characteristic->props.read,
.char_props.write_wo_resp = characteristic->props.write_wo_resp,
.char_props.write = characteristic->props.write,
.char_props.notify = characteristic->props.notify,
.char_props.indicate = characteristic->props.indicate,
};
ble_gatts_attr_md_t cccd_md = {
.vloc = BLE_GATTS_VLOC_STACK,
};
if (char_md.char_props.notify || char_md.char_props.indicate) {
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm);
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.write_perm);
char_md.p_cccd_md = &cccd_md;
}
ble_uuid_t uuid = {
.type = BLE_UUID_TYPE_BLE,
.uuid = characteristic->uuid->value[0] | (characteristic->uuid->value[1] << 8),
};
if (characteristic->uuid->type == UUID_TYPE_128BIT)
uuid.type = characteristic->uuid->uuid_vs_idx;
ble_gatts_attr_md_t attr_md = {
.vloc = BLE_GATTS_VLOC_STACK,
.vlen = 1,
};
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm);
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm);
ble_gatts_attr_t attr_char_value = {
.p_uuid = &uuid,
.p_attr_md = &attr_md,
.init_len = sizeof(uint8_t),
.max_len = (BLE_GATT_ATT_MTU_DEFAULT - 3),
};
ble_gatts_char_handles_t handles;
uint32_t err_code;
err_code = sd_ble_gatts_characteristic_add(self->handle, &char_md, &attr_char_value, &handles);
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to add characteristic, status: 0x%08lX"), err_code));
}
characteristic->user_desc_handle = handles.user_desc_handle;
characteristic->cccd_handle = handles.cccd_handle;
characteristic->sccd_handle = handles.sccd_handle;
characteristic->handle = handles.value_handle;
void common_hal_bleio_service_construct(bleio_service_obj_t *self) {
}
// Call this after the Service has been added to the Peripheral.
void common_hal_bleio_service_add_all_characteristics(bleio_service_obj_t *self) {
// Add all the characteristics.
const mp_obj_list_t *char_list = MP_OBJ_TO_PTR(self->char_list);
for (size_t char_idx = 0; char_idx < char_list->len; ++char_idx) {
bleio_characteristic_obj_t *characteristic = char_list->items[char_idx];
ble_gatts_char_md_t char_md = {
.char_props.broadcast = characteristic->props.broadcast,
.char_props.read = characteristic->props.read,
.char_props.write_wo_resp = characteristic->props.write_no_response,
.char_props.write = characteristic->props.write,
.char_props.notify = characteristic->props.notify,
.char_props.indicate = characteristic->props.indicate,
};
ble_gatts_attr_md_t cccd_md = {
.vloc = BLE_GATTS_VLOC_STACK,
};
if (char_md.char_props.notify || char_md.char_props.indicate) {
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm);
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.write_perm);
char_md.p_cccd_md = &cccd_md;
}
ble_uuid_t uuid;
bleio_uuid_convert_to_nrf_ble_uuid(characteristic->uuid, &uuid);
ble_gatts_attr_md_t attr_md = {
.vloc = BLE_GATTS_VLOC_STACK,
.vlen = 1,
};
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm);
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm);
ble_gatts_attr_t attr_char_value = {
.p_uuid = &uuid,
.p_attr_md = &attr_md,
.init_len = sizeof(uint8_t),
.max_len = GATT_MAX_DATA_LENGTH,
};
ble_gatts_char_handles_t handles;
uint32_t err_code;
err_code = sd_ble_gatts_characteristic_add(self->handle, &char_md, &attr_char_value, &handles);
if (err_code != NRF_SUCCESS) {
mp_raise_OSError_msg_varg(translate("Failed to add characteristic, err 0x%04x"), err_code);
}
if (characteristic->handle != BLE_GATT_HANDLE_INVALID) {
mp_raise_ValueError(translate("Characteristic already in use by another Service."));
}
characteristic->user_desc_handle = handles.user_desc_handle;
characteristic->cccd_handle = handles.cccd_handle;
characteristic->sccd_handle = handles.sccd_handle;
characteristic->handle = handles.value_handle;
}
}

View File

@ -25,100 +25,74 @@
* THE SOFTWARE.
*/
#include <string.h>
#include "py/runtime.h"
#include "common-hal/bleio/UUID.h"
#include "shared-bindings/bleio/Adapter.h"
#include "ble.h"
#include "ble_drv.h"
#include "common-hal/bleio/UUID.h"
#include "nrf_error.h"
#include "py/objstr.h"
#include "py/runtime.h"
#include "shared-bindings/bleio/Adapter.h"
#include "shared-bindings/bleio/UUID.h"
#define UUID_STR_16BIT_LEN 6
#define UUID_STR_128BIT_LEN 36
// 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, uint32_t uuid16, uint8_t uuid128[]) {
common_hal_bleio_adapter_set_enabled(true);
static uint8_t xdigit_8b_value(byte nibble1, byte nibble2) {
return unichar_xdigit_value(nibble1) |
(unichar_xdigit_value(nibble2) << 4);
}
void common_hal_bleio_uuid_construct(bleio_uuid_obj_t *self, const mp_obj_t *uuid) {
if (MP_OBJ_IS_INT(*uuid)) {
self->type = UUID_TYPE_16BIT;
self->value[1] = (mp_obj_get_int(*uuid) >> 8) & 0xFF;
self->value[0] = (mp_obj_get_int(*uuid) >> 0) & 0xFF;
return;
}
if (MP_OBJ_IS_STR(*uuid)) {
GET_STR_DATA_LEN(*uuid, str_data, str_len);
if (str_len == UUID_STR_16BIT_LEN) {
self->type = UUID_TYPE_16BIT;
self->value[0] = xdigit_8b_value(str_data[5], str_data[4]);
self->value[1] = xdigit_8b_value(str_data[3], str_data[2]);
} else if (str_len == UUID_STR_128BIT_LEN) {
self->type = UUID_TYPE_128BIT;
ble_uuid128_t vs_uuid;
vs_uuid.uuid128[0] = xdigit_8b_value(str_data[35], str_data[34]);
vs_uuid.uuid128[1] = xdigit_8b_value(str_data[33], str_data[32]);
vs_uuid.uuid128[2] = xdigit_8b_value(str_data[31], str_data[30]);
vs_uuid.uuid128[3] = xdigit_8b_value(str_data[29], str_data[28]);
vs_uuid.uuid128[4] = xdigit_8b_value(str_data[27], str_data[26]);
vs_uuid.uuid128[5] = xdigit_8b_value(str_data[25], str_data[24]);
// 23 '-'
vs_uuid.uuid128[6] = xdigit_8b_value(str_data[22], str_data[21]);
vs_uuid.uuid128[7] = xdigit_8b_value(str_data[20], str_data[19]);
// 18 '-'
vs_uuid.uuid128[8] = xdigit_8b_value(str_data[17], str_data[16]);
vs_uuid.uuid128[9] = xdigit_8b_value(str_data[15], str_data[14]);
// 13 '-'
vs_uuid.uuid128[10] = xdigit_8b_value(str_data[12], str_data[11]);
vs_uuid.uuid128[11] = xdigit_8b_value(str_data[10], str_data[9]);
// 8 '-'
self->value[0] = xdigit_8b_value(str_data[7], str_data[6]);
self->value[1] = xdigit_8b_value(str_data[5], str_data[4]);
vs_uuid.uuid128[14] = xdigit_8b_value(str_data[3], str_data[2]);
vs_uuid.uuid128[15] = xdigit_8b_value(str_data[1], str_data[0]);
common_hal_bleio_adapter_set_enabled(true);
const uint32_t err_code = sd_ble_uuid_vs_add(&vs_uuid, &self->uuid_vs_idx);
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Failed to add Vendor Specific UUID, status: 0x%08lX"), err_code));
}
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
translate("Invalid UUID string length")));
}
return;
}
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
translate("Invalid UUID parameter")));
}
void common_hal_bleio_uuid_print(bleio_uuid_obj_t *self, const mp_print_t *print) {
if (self->type == UUID_TYPE_16BIT) {
mp_printf(print, "UUID(uuid: 0x" HEX2_FMT HEX2_FMT ")",
self->value[1], self->value[0]);
self->nrf_ble_uuid.uuid = uuid16;
if (uuid128 == NULL) {
self->nrf_ble_uuid.type = BLE_UUID_TYPE_BLE;
} else {
mp_printf(print, "UUID(uuid: 0x" HEX2_FMT HEX2_FMT ", VS idx: " HEX2_FMT ")",
self->value[1], self->value[0], self->uuid_vs_idx);
ble_uuid128_t vs_uuid;
memcpy(vs_uuid.uuid128, uuid128, sizeof(vs_uuid.uuid128));
// Register this vendor-specific UUID. Bytes 12 and 13 will be zero.
const uint32_t err_code = sd_ble_uuid_vs_add(&vs_uuid, &self->nrf_ble_uuid.type);
if (err_code != NRF_SUCCESS) {
mp_raise_OSError_msg_varg(translate("Failed to register Vendor-Specific UUID, err 0x%04x"), err_code);
}
}
}
bleio_uuid_type_t common_hal_bleio_uuid_get_type(bleio_uuid_obj_t *self) {
return self->type;
uint32_t common_hal_bleio_uuid_get_size(bleio_uuid_obj_t *self) {
return self->nrf_ble_uuid.type == BLE_UUID_TYPE_BLE ? 16 : 128;
}
uint32_t common_hal_bleio_uuid_get_uuid16(bleio_uuid_obj_t *self) {
return self->nrf_ble_uuid.uuid;
}
// True if uuid128 has been successfully filled in.
bool common_hal_bleio_uuid_get_uuid128(bleio_uuid_obj_t *self, uint8_t uuid128[16]) {
uint8_t length;
const uint32_t err_code = sd_ble_uuid_encode(&self->nrf_ble_uuid, &length, uuid128);
if (err_code != NRF_SUCCESS) {
mp_raise_OSError_msg_varg(translate("Could not decode ble_uuid, err 0x%04x"), err_code);
}
// If not 16 bytes, this is not a 128-bit UUID, so return.
return length == 16;
}
// Returns 0 if this is a 16-bit UUID, otherwise returns a non-zero index
// into the 128-bit uuid registration table.
uint32_t common_hal_bleio_uuid_get_uuid128_reference(bleio_uuid_obj_t *self) {
return self->nrf_ble_uuid.type == BLE_UUID_TYPE_BLE ? 0 : self->nrf_ble_uuid.type;
}
void bleio_uuid_construct_from_nrf_ble_uuid(bleio_uuid_obj_t *self, ble_uuid_t *nrf_ble_uuid) {
if (nrf_ble_uuid->type == BLE_UUID_TYPE_UNKNOWN) {
mp_raise_RuntimeError(translate("Unexpected nrfx uuid type"));
}
self->nrf_ble_uuid.uuid = nrf_ble_uuid->uuid;
self->nrf_ble_uuid.type = nrf_ble_uuid->type;
}
// Fill in a ble_uuid_t from my values.
void bleio_uuid_convert_to_nrf_ble_uuid(bleio_uuid_obj_t *self, ble_uuid_t *nrf_ble_uuid) {
nrf_ble_uuid->uuid = self->nrf_ble_uuid.uuid;
nrf_ble_uuid->type = self->nrf_ble_uuid.type;
}

View File

@ -28,13 +28,21 @@
#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_UUID_H
#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_UUID_H
#include "shared-bindings/bleio/UUIDType.h"
#include "py/obj.h"
#include "ble.h"
typedef struct {
mp_obj_base_t base;
bleio_uuid_type_t type;
uint8_t uuid_vs_idx;
uint8_t value[2];
// 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_t nrf_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_NRF_COMMON_HAL_BLEIO_UUID_H

View File

@ -27,6 +27,15 @@
#include "shared-bindings/bleio/__init__.h"
#include "shared-bindings/bleio/Adapter.h"
#include "shared-bindings/bleio/Peripheral.h"
#include "common-hal/bleio/__init__.h"
// Turn off BLE on a reset or reload.
void bleio_reset() {
if (common_hal_bleio_adapter_get_enabled()) {
common_hal_bleio_adapter_set_enabled(false);
}
}
// The singleton bleio.Adapter object, bound to bleio.adapter
// It currently only has properties and no state
@ -35,3 +44,25 @@ const super_adapter_obj_t common_hal_bleio_adapter_obj = {
.type = &bleio_adapter_type,
},
};
gatt_role_t common_hal_bleio_device_get_gatt_role(mp_obj_t device) {
if (MP_OBJ_IS_TYPE(device, &bleio_peripheral_type)) {
return ((bleio_peripheral_obj_t*) MP_OBJ_TO_PTR(device))->gatt_role;
// Does not exist yet.
// } else if (MP_OBJ_IS_TYPE(device, &bleio_central_type)) {
// return ((bleio_central_obj_t*) MP_OBJ_TO_PTR(device))->gatt_role;
} else {
return GATT_ROLE_NONE;
}
}
uint16_t common_hal_bleio_device_get_conn_handle(mp_obj_t device) {
if (MP_OBJ_IS_TYPE(device, &bleio_peripheral_type)) {
return ((bleio_peripheral_obj_t*) MP_OBJ_TO_PTR(device))->conn_handle;
// Does not exist yet.
// } else if (MP_OBJ_IS_TYPE(device, &bleio_central_type)) {
// return ((bleio_central_obj_t*) MP_OBJ_TO_PTR(device))->conn_handle;
} else {
return 0;
}
}

View File

@ -3,7 +3,6 @@
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Glenn Ruben Bakke
* Copyright (c) 2018 Dan Halbert for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@ -25,15 +24,19 @@
* THE SOFTWARE.
*/
#define MICROPY_HW_BOARD_NAME "PCA10040"
#define MICROPY_HW_MCU_NAME "nRF52832"
#define MICROPY_PY_SYS_PLATFORM "nRF52-DK"
#ifndef MICROPY_INCLUDED_COMMON_HAL_BLEIO_INIT_H
#define MICROPY_INCLUDED_COMMON_HAL_BLEIO_INIT_H
#define MICROPY_HW_LED_STATUS (&pin_P0_17)
#include "shared-bindings/bleio/__init__.h"
#include "shared-bindings/bleio/Adapter.h"
#define MICROPY_HW_UART_RX NRF_GPIO_PIN_MAP(0, 8)
#define MICROPY_HW_UART_TX NRF_GPIO_PIN_MAP(0, 6)
#define MICROPY_HW_UART_HWFC (0)
#include "shared-module/bleio/__init__.h"
#define PORT_HEAP_SIZE (32 * 1024)
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
// We assume variable length data.
// 20 bytes max (23 - 3).
#define GATT_MAX_DATA_LENGTH (BLE_GATT_ATT_MTU_DEFAULT - 3)
gatt_role_t common_hal_bleio_device_get_gatt_role(mp_obj_t device);
uint16_t common_hal_bleio_device_get_conn_handle(mp_obj_t device);
#endif // MICROPY_INCLUDED_COMMON_HAL_BLEIO_INIT_H

View File

@ -23,6 +23,3 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
// Pins aren't actually defined here. They are in the board specific directory
// such as boards/feather_nrf52832/pins.csv

View File

@ -45,10 +45,7 @@ float common_hal_mcu_processor_get_temperature(void) {
if (sd_en) {
uint32_t err_code = sd_temp_get(&temp);
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
translate("Can not get temperature. status: 0x%02x"), (uint16_t)err_code));
return 0;
mp_raise_OSError_msg(translate("Cannot get temperature"));
}
}
#endif

View File

@ -65,7 +65,7 @@
//
// If there is no device available an alternative cycle-counter
// implementation is tried.
// The nRF52832 runs with a fixed clock of 64Mhz. The alternative
// The nRF52840 runs with a fixed clock of 64Mhz. The alternative
// implementation is the same as the one used for the Teensy 3.0/1/2 but
// with the Nordic SDK HAL & registers syntax.
// The number of cycles was hand picked and is guaranteed to be 100%

View File

@ -1,65 +0,0 @@
/*
* 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.
*/
// DO NOT include this file directly. Use shared-bindings/microcontroller/Pin.h instead to ensure
// that all necessary includes are already included.
#include "py/obj.h"
#include "py/mphal.h"
#include "nrf/pins.h"
const mcu_pin_obj_t pin_P0_00 = PIN(P0_00, 0, 0, 0);
const mcu_pin_obj_t pin_P0_01 = PIN(P0_01, 0, 1, 0);
const mcu_pin_obj_t pin_P0_02 = PIN(P0_02, 0, 2, SAADC_CH_PSELP_PSELP_AnalogInput0);
const mcu_pin_obj_t pin_P0_03 = PIN(P0_03, 0, 3, SAADC_CH_PSELP_PSELP_AnalogInput1);
const mcu_pin_obj_t pin_P0_04 = PIN(P0_04, 0, 4, SAADC_CH_PSELP_PSELP_AnalogInput2);
const mcu_pin_obj_t pin_P0_05 = PIN(P0_05, 0, 5, SAADC_CH_PSELP_PSELP_AnalogInput3);
const mcu_pin_obj_t pin_P0_06 = PIN(P0_06, 0, 6, 0);
const mcu_pin_obj_t pin_P0_07 = PIN(P0_07, 0, 7, 0);
const mcu_pin_obj_t pin_P0_08 = PIN(P0_08, 0, 8, 0);
const mcu_pin_obj_t pin_P0_09 = PIN(P0_09, 0, 9, 0);
const mcu_pin_obj_t pin_P0_10 = PIN(P0_10, 0, 10, 0);
const mcu_pin_obj_t pin_P0_11 = PIN(P0_11, 0, 11, 0);
const mcu_pin_obj_t pin_P0_12 = PIN(P0_12, 0, 12, 0);
const mcu_pin_obj_t pin_P0_13 = PIN(P0_13, 0, 13, 0);
const mcu_pin_obj_t pin_P0_14 = PIN(P0_14, 0, 14, 0);
const mcu_pin_obj_t pin_P0_15 = PIN(P0_15, 0, 15, 0);
const mcu_pin_obj_t pin_P0_16 = PIN(P0_16, 0, 16, 0);
const mcu_pin_obj_t pin_P0_17 = PIN(P0_17, 0, 17, 0);
const mcu_pin_obj_t pin_P0_18 = PIN(P0_18, 0, 18, 0);
const mcu_pin_obj_t pin_P0_19 = PIN(P0_19, 0, 19, 0);
const mcu_pin_obj_t pin_P0_20 = PIN(P0_20, 0, 20, 0);
const mcu_pin_obj_t pin_P0_21 = PIN(P0_21, 0, 21, 0);
const mcu_pin_obj_t pin_P0_22 = PIN(P0_22, 0, 22, 0);
const mcu_pin_obj_t pin_P0_23 = PIN(P0_23, 0, 23, 0);
const mcu_pin_obj_t pin_P0_24 = PIN(P0_24, 0, 24, 0);
const mcu_pin_obj_t pin_P0_25 = PIN(P0_25, 0, 25, 0);
const mcu_pin_obj_t pin_P0_26 = PIN(P0_26, 0, 26, 0);
const mcu_pin_obj_t pin_P0_27 = PIN(P0_27, 0, 27, 0);
const mcu_pin_obj_t pin_P0_28 = PIN(P0_28, 0, 28, SAADC_CH_PSELP_PSELP_AnalogInput4);
const mcu_pin_obj_t pin_P0_29 = PIN(P0_29, 0, 29, SAADC_CH_PSELP_PSELP_AnalogInput5);
const mcu_pin_obj_t pin_P0_30 = PIN(P0_30, 0, 30, SAADC_CH_PSELP_PSELP_AnalogInput6);
const mcu_pin_obj_t pin_P0_31 = PIN(P0_31, 0, 31, SAADC_CH_PSELP_PSELP_AnalogInput7);

View File

@ -1,63 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2018 by 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_NRF_PERIPHERALS_NRF52832_PINS_H
#define MICROPY_INCLUDED_NRF_PERIPHERALS_NRF52832_PINS_H
extern const mcu_pin_obj_t pin_P0_00;
extern const mcu_pin_obj_t pin_P0_01;
extern const mcu_pin_obj_t pin_P0_02;
extern const mcu_pin_obj_t pin_P0_03;
extern const mcu_pin_obj_t pin_P0_04;
extern const mcu_pin_obj_t pin_P0_05;
extern const mcu_pin_obj_t pin_P0_06;
extern const mcu_pin_obj_t pin_P0_07;
extern const mcu_pin_obj_t pin_P0_08;
extern const mcu_pin_obj_t pin_P0_09;
extern const mcu_pin_obj_t pin_P0_10;
extern const mcu_pin_obj_t pin_P0_11;
extern const mcu_pin_obj_t pin_P0_12;
extern const mcu_pin_obj_t pin_P0_13;
extern const mcu_pin_obj_t pin_P0_14;
extern const mcu_pin_obj_t pin_P0_15;
extern const mcu_pin_obj_t pin_P0_16;
extern const mcu_pin_obj_t pin_P0_17;
extern const mcu_pin_obj_t pin_P0_18;
extern const mcu_pin_obj_t pin_P0_19;
extern const mcu_pin_obj_t pin_P0_20;
extern const mcu_pin_obj_t pin_P0_21;
extern const mcu_pin_obj_t pin_P0_22;
extern const mcu_pin_obj_t pin_P0_23;
extern const mcu_pin_obj_t pin_P0_24;
extern const mcu_pin_obj_t pin_P0_25;
extern const mcu_pin_obj_t pin_P0_26;
extern const mcu_pin_obj_t pin_P0_27;
extern const mcu_pin_obj_t pin_P0_28;
extern const mcu_pin_obj_t pin_P0_29;
extern const mcu_pin_obj_t pin_P0_30;
extern const mcu_pin_obj_t pin_P0_31;
#endif // MICROPY_INCLUDED_NRF_PERIPHERALS_NRF52832_PINS_H

View File

@ -56,11 +56,7 @@ extern const mp_obj_type_t mcu_pin_type;
// Use illegal pin value to mark unassigned pins.
#define NO_PIN 0xff
// Choose based on chip, but not specifically revision (e.g., not NRF52832_XXAA)
#ifdef NRF52832
#include "nrf52832/pins.h"
#endif
// Choose based on chip, but not specifically revision (e.g., not NRF52840_XXAA)
#ifdef NRF52840
#include "nrf52840/pins.h"
#endif

View File

@ -70,18 +70,55 @@ uint32_t supervisor_flash_get_block_count(void) {
return ((uint32_t) __fatfs_flash_length) / FILESYSTEM_BLOCK_SIZE ;
}
// TODO support flashing with SD enabled
#ifdef BLUETOOTH_SD
STATIC bool wait_for_flash_operation() {
do {
sd_app_evt_wait();
uint32_t evt_id;
uint32_t result = sd_evt_get(&evt_id);
if (result == NRF_SUCCESS) {
switch (evt_id) {
case NRF_EVT_FLASH_OPERATION_SUCCESS:
return true;
case NRF_EVT_FLASH_OPERATION_ERROR:
return false;
default:
// Some other event. Wait for a flash event.
continue;
}
}
return false;
} while (true);
}
#endif
void supervisor_flash_flush(void) {
if (_flash_page_addr == NO_CACHE) return;
// Skip if data is the same
if (memcmp(_flash_cache, (void *)_flash_page_addr, FL_PAGE_SZ) != 0) {
// _is_flashing = true;
#ifdef BLUETOOTH_SD
uint8_t sd_en = 0;
(void) sd_softdevice_is_enabled(&sd_en);
if (sd_en) {
sd_flash_page_erase(_flash_page_addr / FL_PAGE_SZ);
wait_for_flash_operation(); // TODO: handle error return.
sd_flash_write((uint32_t *)_flash_page_addr, (uint32_t *)_flash_cache, FL_PAGE_SZ / sizeof(uint32_t));
wait_for_flash_operation();
} else {
#endif
nrf_nvmc_page_erase(_flash_page_addr);
nrf_nvmc_write_words(_flash_page_addr, (uint32_t *)_flash_cache, FL_PAGE_SZ / sizeof(uint32_t));
#ifdef BLUETOOTH_SD
}
#endif
_flash_page_addr = NO_CACHE;
}
}
mp_uint_t supervisor_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t num_blocks) {
@ -101,10 +138,6 @@ mp_uint_t supervisor_flash_write_blocks(const uint8_t *src, uint32_t lba, uint32
if (page_addr != _flash_page_addr) {
supervisor_flash_flush();
// writing previous cached data, skip current data until flashing is done
// tinyusb stack will invoke write_block() with the same parameters later on
// if ( _is_flashing ) return;
_flash_page_addr = page_addr;
memcpy(_flash_cache, (void *)page_addr, FL_PAGE_SZ);
}

View File

@ -38,6 +38,7 @@
#include "shared-module/gamepad/__init__.h"
#include "common-hal/microcontroller/Pin.h"
#include "common-hal/bleio/__init__.h"
#include "common-hal/busio/I2C.h"
#include "common-hal/busio/SPI.h"
#include "common-hal/pulseio/PWMOut.h"
@ -88,6 +89,8 @@ void reset_port(void) {
pulsein_reset();
timers_reset();
bleio_reset();
reset_all_pins();
}

View File

@ -640,6 +640,7 @@ mp_obj_t mp_obj_new_str_via_qstr(const char* data, size_t len);
mp_obj_t mp_obj_new_str_from_vstr(const mp_obj_type_t *type, vstr_t *vstr);
mp_obj_t mp_obj_new_bytes(const byte* data, size_t len);
mp_obj_t mp_obj_new_bytearray(size_t n, void *items);
mp_obj_t mp_obj_new_bytearray_of_zeros(size_t n);
mp_obj_t mp_obj_new_bytearray_by_ref(size_t n, void *items);
#if MICROPY_PY_BUILTINS_FLOAT
mp_obj_t mp_obj_new_int_from_float(mp_float_t val);

View File

@ -611,6 +611,12 @@ mp_obj_t mp_obj_new_bytearray(size_t n, void *items) {
return MP_OBJ_FROM_PTR(o);
}
mp_obj_t mp_obj_new_bytearray_of_zeros(size_t n) {
mp_obj_array_t *o = array_new(BYTEARRAY_TYPECODE, n);
memset(o->items, 0, n);
return MP_OBJ_FROM_PTR(o);
}
// Create bytearray which references specified memory area
mp_obj_t mp_obj_new_bytearray_by_ref(size_t n, void *items) {
mp_obj_array_t *o = m_new_obj(mp_obj_array_t);

View File

@ -1599,6 +1599,17 @@ NORETURN void mp_raise_OSError(int errno_) {
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(errno_)));
}
NORETURN void mp_raise_OSError_msg(const compressed_string_t *msg) {
mp_raise_msg(&mp_type_OSError, msg);
}
NORETURN void mp_raise_OSError_msg_varg(const compressed_string_t *fmt, ...) {
va_list argptr;
va_start(argptr,fmt);
mp_obj_t exception = mp_obj_new_exception_msg_vlist(&mp_type_OSError, fmt, argptr);
va_end(argptr);
nlr_raise(exception);
}
NORETURN void mp_raise_NotImplementedError(const compressed_string_t *msg) {
mp_raise_msg(&mp_type_NotImplementedError, msg);

View File

@ -158,6 +158,8 @@ NORETURN void mp_raise_RuntimeError(const compressed_string_t *msg);
NORETURN void mp_raise_ImportError(const compressed_string_t *msg);
NORETURN void mp_raise_IndexError(const compressed_string_t *msg);
NORETURN void mp_raise_OSError(int errno_);
NORETURN void mp_raise_OSError_msg(const compressed_string_t *msg);
NORETURN void mp_raise_OSError_msg_varg(const compressed_string_t *fmt, ...);
NORETURN void mp_raise_NotImplementedError(const compressed_string_t *msg);
NORETURN void mp_raise_recursion_depth(void);

View File

@ -33,8 +33,12 @@
#include "shared-bindings/bleio/Address.h"
#include "shared-module/bleio/Address.h"
#define ADDRESS_LONG_LEN 17 // XX:XX:XX:XX:XX:XX
#define ADDRESS_SHORT_LEN 12 // XXXXXXXXXXXX
#define ADDRESS_BYTE_LEN 12
STATIC uint8_t xdigit_8b_value(byte nibble1, byte nibble2) {
return unichar_xdigit_value(nibble1) | (unichar_xdigit_value(nibble2) << 4);
}
//| .. currentmodule:: bleio
//|
@ -49,7 +53,7 @@
//| Create a new Address object encapsulating the address value.
//| The value itself can be one of:
//|
//| - a `str` value in the format of 'XXXXXXXXXXXX' or 'XX:XX:XX:XX:XX'
//| - a `str` value in the format of 'XXXXXXXXXXXX' or 'XX:XX:XX:XX:XX:XX' (12 hex digits)
//| - a `bytes` or `bytearray` containing 6 bytes
//| - another Address object
//|
@ -76,7 +80,7 @@ STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args,
enum { ARG_address };
static const mp_arg_t allowed_args[] = {
{ ARG_address, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_address, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
};
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
@ -85,26 +89,41 @@ STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args,
const mp_obj_t address = args[ARG_address].u_obj;
if (MP_OBJ_IS_STR(address)) {
GET_STR_DATA_LEN(address, str_data, str_len);
const bool is_long = (str_len == ADDRESS_LONG_LEN);
const bool is_short = (str_len == ADDRESS_SHORT_LEN);
GET_STR_DATA_LEN(address, str, str_len);
if (is_long || is_short) {
size_t i = str_len - 1;
for (size_t b = 0; b < BLEIO_ADDRESS_BYTES; ++b) {
self->value[b] = unichar_xdigit_value(str_data[i]) |
unichar_xdigit_value(str_data[i - 1]) << 4;
size_t value_index = 0;
size_t str_index = str_len;
bool error = false;
i -= is_long ? 3 : 2;
// Loop until fewer than two characters left.
while (str_index >= 1 && value_index < sizeof(self->value)) {
if (str[str_index] == ':') {
// Skip colon separators.
str_index--;
continue;
}
} else {
mp_raise_ValueError(translate("Wrong address length"));
if (!unichar_isxdigit(str[str_index]) ||
!unichar_isxdigit(str[str_index-1])) {
error = true;
break;
}
self->value[value_index] = xdigit_8b_value(str[str_index],
str[str_index-1]);
value_index += 1;
str_index -= 2;
}
// Check for correct number of hex digits and no parsing errors.
if (error || value_index != ADDRESS_BYTE_LEN || str_index != -1) {
mp_raise_ValueError_varg(translate("Address is not %d bytes long or is in wrong format"),
ADDRESS_BYTE_LEN);
}
} else if (MP_OBJ_IS_TYPE(address, &mp_type_bytearray) || MP_OBJ_IS_TYPE(address, &mp_type_bytes)) {
mp_buffer_info_t buf_info;
mp_get_buffer_raise(address, &buf_info, MP_BUFFER_READ);
if (buf_info.len != BLEIO_ADDRESS_BYTES) {
mp_raise_ValueError(translate("Wrong number of bytes provided"));
mp_raise_ValueError_varg(translate("Address must be %d bytes long"), BLEIO_ADDRESS_BYTES);
}
for (size_t b = 0; b < BLEIO_ADDRESS_BYTES; ++b) {

View File

@ -0,0 +1,137 @@
/*
* 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.
*/
#include "ble_drv.h"
#include "py/runtime.h"
#include "shared-bindings/bleio/Broadcaster.h"
//| .. currentmodule:: bleio
//|
//| :class:`Broadcaster` -- Broadcast advertising packets.
//| =========================================================
//|
//| Implement a BLE broadcaster which sends data in advertising packets and does not connect.
//| Used for beacons and other one-way data transmission.
//|
//| Usage::
//|
//| import bleio
//| import time
//|
//| # Broadcast once a second.
//| broadcaster = bleio.Broadcaster(interval=1)
//| data = 0
//| # Broadcast a byte of data that's incremented once a minute
//| while True:
//| # data is an entire advertising data packet, starting with flags.
//| broadcaster.start_advertising(data)
//| time.sleep(60)
//| data += 1
//|
//| .. class:: Broadcaster(interval=1)
//|
//| Create a new Broadcaster object.
//| :param float interval: how often to broadcast
//|
STATIC mp_obj_t bleio_broadcaster_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) {
mp_arg_check_num(n_args, n_kw, 0, 1, true);
bleio_broadcaster_obj_t *self = m_new_obj(bleio_broadcaster_obj_t);
self->base.type = &bleio_broadcaster_type;
mp_map_t kw_args;
mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args);
enum { ARG_interval };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_interval, MP_ARG_OBJ, {.u_obj = MP_OBJ_NEW_SMALL_INT(1)} },
};
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, &kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
mp_float_t interval = mp_obj_get_float(args[ARG_interval].u_obj);
// Do port-specific initialization. interval will be validated.
common_hal_bleio_broadcaster_construct(self, interval);
return MP_OBJ_FROM_PTR(self);
}
//| .. method:: start_advertising(data)
//|
//| Start advertising using the given data packet.
//|
//| :param buf data: advertising data packet, starting with advertising data flags (0x01)
//|
STATIC mp_obj_t bleio_broadcaster_start_advertising(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
bleio_broadcaster_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
enum { ARG_data };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_data, MP_ARG_REQUIRED | MP_ARG_OBJ },
};
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(args[ARG_data].u_obj, &bufinfo, MP_BUFFER_READ);
common_hal_bleio_broadcaster_start_advertising(self, &bufinfo);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_broadcaster_start_advertising_obj, 0, bleio_broadcaster_start_advertising);
//| .. method:: stop_advertising()
//|
//| Stop sending advertising packets.
STATIC mp_obj_t bleio_broadcaster_stop_advertising(mp_obj_t self_in) {
bleio_broadcaster_obj_t *self = MP_OBJ_TO_PTR(self_in);
common_hal_bleio_broadcaster_stop_advertising(self);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_broadcaster_stop_advertising_obj, bleio_broadcaster_stop_advertising);
STATIC const mp_rom_map_elem_t bleio_broadcaster_locals_dict_table[] = {
// Methods
{ MP_ROM_QSTR(MP_QSTR_start_advertising), MP_ROM_PTR(&bleio_broadcaster_start_advertising_obj) },
{ MP_ROM_QSTR(MP_QSTR_stop_advertising), MP_ROM_PTR(&bleio_broadcaster_stop_advertising_obj) },
};
STATIC MP_DEFINE_CONST_DICT(bleio_broadcaster_locals_dict, bleio_broadcaster_locals_dict_table);
const mp_obj_type_t bleio_broadcaster_type = {
{ &mp_type_type },
.name = MP_QSTR_Broadcaster,
.make_new = bleio_broadcaster_make_new,
.locals_dict = (mp_obj_dict_t*)&bleio_broadcaster_locals_dict
};

View File

@ -0,0 +1,38 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* 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_SHARED_BINDINGS_BLEIO_BROADCASTER_H
#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_BROADCASTER_H
#include "common-hal/bleio/Broadcaster.h"
extern const mp_obj_type_t bleio_broadcaster_type;
extern void common_hal_bleio_broadcaster_construct(bleio_broadcaster_obj_t *self, mp_float_t interval);
extern void common_hal_bleio_broadcaster_start_advertising(bleio_broadcaster_obj_t *self, mp_buffer_info_t *data);
extern void common_hal_bleio_broadcaster_stop_advertising(bleio_broadcaster_obj_t *self);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_BROADCASTER_H

View File

@ -35,78 +35,41 @@
//| :class:`Characteristic` -- BLE service characteristic
//| =========================================================
//|
//| Stores information about a BLE service characteristic and allows to read
//| and write the characteristic's value.
//| Stores information about a BLE service characteristic and allows reading
//| and writing of the characteristic's value.
//|
//| .. class:: Characteristic(uuid)
//|
//| .. class:: Characteristic(uuid, *, broadcast=False, indicate=False, notify=False, read=False, write=False, write_no_response=False)
//|
//| Create a new Characteristic object identified by the specified UUID.
//|
//| :param bleio.UUID uuid: The uuid of the characteristic
//| :param bool broadcast: Allowed in advertising packets
//| :param bool indicate: Server will indicate to the client when the value is set and wait for a response
//| :param bool notify: Server will notify the client when the value is set
//| :param bool read: Clients may read this characteristic
//| :param bool write: Clients may write this characteristic; a response will be sent back
//| :param bool write_no_response: Clients may write this characteristic; no response will be sent back
//|
//| .. attribute:: broadcast
//|
//| A `bool` specifying if the characteristic allows broadcasting its value.
//|
//| .. attribute:: indicate
//|
//| A `bool` specifying if the characteristic allows indicating its value.
//|
//| .. attribute:: notify
//|
//| A `bool` specifying if the characteristic allows notifying its value.
//|
//| .. attribute:: read
//|
//| A `bool` specifying if the characteristic allows reading its value.
//|
//| .. attribute:: uuid
//|
//| The UUID of this characteristic. (read-only)
//|
//| .. attribute:: value
//|
//| The value of this characteristic. The value can be written to if the `write` property allows it.
//| If the `read` property allows it, the value can be read. If the `notify` property is set, writting
//| to the value will generate a BLE notification.
//|
//| .. attribute:: write
//|
//| A `bool` specifying if the characteristic allows writting to its value.
//|
//| .. attribute:: write_no_resp
//|
//| A `bool` specifying if the characteristic allows writting to its value without response.
//|
STATIC void bleio_characteristic_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_printf(print, "Characteristic(uuid: 0x"HEX2_FMT""HEX2_FMT" handle: 0x" HEX2_FMT ")",
self->uuid->value[1], self->uuid->value[0], self->handle);
}
STATIC mp_obj_t bleio_characteristic_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) {
mp_arg_check_num(n_args, n_kw, 1, 1, true);
bleio_characteristic_obj_t *self = m_new_obj(bleio_characteristic_obj_t);
self->base.type = &bleio_characteristic_type;
self->service = NULL;
self->value_data = NULL;
mp_map_t kw_args;
mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args);
enum { ARG_uuid };
enum {
ARG_uuid, ARG_broadcast, ARG_indicate, ARG_notify, ARG_read, ARG_write, ARG_write_no_response,
};
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_uuid, MP_ARG_REQUIRED| MP_ARG_OBJ, {.u_obj = mp_const_none} },
{ MP_QSTR_uuid, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = mp_const_none} },
{ MP_QSTR_broadcast, MP_ARG_KW_ONLY| MP_ARG_BOOL, {.u_bool = false} },
{ MP_QSTR_indicate, MP_ARG_KW_ONLY| MP_ARG_BOOL, {.u_bool = false} },
{ MP_QSTR_notify, MP_ARG_KW_ONLY| MP_ARG_BOOL, {.u_bool = false} },
{ MP_QSTR_read, MP_ARG_KW_ONLY| MP_ARG_BOOL, {.u_bool = false} },
{ MP_QSTR_write, MP_ARG_KW_ONLY| MP_ARG_BOOL, {.u_bool = false} },
{ MP_QSTR_write_no_response, MP_ARG_KW_ONLY| MP_ARG_BOOL, {.u_bool = false} },
};
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
@ -114,22 +77,30 @@ STATIC mp_obj_t bleio_characteristic_make_new(const mp_obj_type_t *type, size_t
const mp_obj_t uuid = args[ARG_uuid].u_obj;
if (uuid == mp_const_none) {
return MP_OBJ_FROM_PTR(self);
if (!MP_OBJ_IS_TYPE(uuid, &bleio_uuid_type)) {
mp_raise_ValueError(translate("Expected a UUID"));
}
if (MP_OBJ_IS_TYPE(uuid, &bleio_uuid_type)) {
self->uuid = MP_OBJ_TO_PTR(uuid);
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
translate("Invalid UUID parameter")));
}
self->uuid = MP_OBJ_TO_PTR(uuid);
common_hal_bleio_characteristic_construct(self);
bleio_characteristic_properties_t properties;
properties.broadcast = args[ARG_broadcast].u_bool;
properties.indicate = args[ARG_indicate].u_bool;
properties.notify = args[ARG_notify].u_bool;
properties.read = args[ARG_read].u_bool;
properties.write = args[ARG_write].u_bool;
properties.write_no_response = args[ARG_write_no_response].u_bool;
common_hal_bleio_characteristic_construct(self, uuid, properties);
return MP_OBJ_FROM_PTR(self);
}
//| .. attribute:: broadcast
//|
//| A `bool` specifying if the characteristic allows broadcasting its value. (read-only)
//|
STATIC mp_obj_t bleio_characteristic_get_broadcast(mp_obj_t self_in) {
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
@ -137,22 +108,17 @@ STATIC mp_obj_t bleio_characteristic_get_broadcast(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_broadcast_obj, bleio_characteristic_get_broadcast);
STATIC mp_obj_t bleio_characteristic_set_broadcast(mp_obj_t self_in, mp_obj_t broadcast_in) {
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
self->props.broadcast = mp_obj_is_true(broadcast_in);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_characteristic_set_broadcast_obj, bleio_characteristic_set_broadcast);
const mp_obj_property_t bleio_characteristic_broadcast_obj = {
.base.type = &mp_type_property,
.proxy = { (mp_obj_t)&bleio_characteristic_get_broadcast_obj,
(mp_obj_t)&bleio_characteristic_set_broadcast_obj,
(mp_obj_t)&mp_const_none_obj,
(mp_obj_t)&mp_const_none_obj },
};
//| .. attribute:: indicate
//|
//| A `bool` specifying if the characteristic allows indicating its value. (read-only)
//|
STATIC mp_obj_t bleio_characteristic_get_indicate(mp_obj_t self_in) {
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
@ -160,22 +126,18 @@ STATIC mp_obj_t bleio_characteristic_get_indicate(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_indicate_obj, bleio_characteristic_get_indicate);
STATIC mp_obj_t bleio_characteristic_set_indicate(mp_obj_t self_in, mp_obj_t indicate_in) {
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
self->props.indicate = mp_obj_is_true(indicate_in);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_characteristic_set_indicate_obj, bleio_characteristic_set_indicate);
const mp_obj_property_t bleio_characteristic_indicate_obj = {
.base.type = &mp_type_property,
.proxy = { (mp_obj_t)&bleio_characteristic_get_indicate_obj,
(mp_obj_t)&bleio_characteristic_set_indicate_obj,
(mp_obj_t)&mp_const_none_obj,
(mp_obj_t)&mp_const_none_obj },
};
//| .. attribute:: notify
//|
//| A `bool` specifying if the characteristic allows notifying its value. (read-only)
//|
STATIC mp_obj_t bleio_characteristic_get_notify(mp_obj_t self_in) {
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
@ -183,22 +145,17 @@ STATIC mp_obj_t bleio_characteristic_get_notify(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_notify_obj, bleio_characteristic_get_notify);
STATIC mp_obj_t bleio_characteristic_set_notify(mp_obj_t self_in, mp_obj_t notify_in) {
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
self->props.notify = mp_obj_is_true(notify_in);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_characteristic_set_notify_obj, bleio_characteristic_set_notify);
const mp_obj_property_t bleio_characteristic_notify_obj = {
.base.type = &mp_type_property,
.proxy = { (mp_obj_t)&bleio_characteristic_get_notify_obj,
(mp_obj_t)&bleio_characteristic_set_notify_obj,
(mp_obj_t)&mp_const_none_obj,
(mp_obj_t)&mp_const_none_obj },
};
//| .. attribute:: read
//|
//| A `bool` specifying if the characteristic allows reading its value. (read-only)
//|
STATIC mp_obj_t bleio_characteristic_get_read(mp_obj_t self_in) {
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
@ -206,22 +163,17 @@ STATIC mp_obj_t bleio_characteristic_get_read(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_read_obj, bleio_characteristic_get_read);
STATIC mp_obj_t bleio_characteristic_set_read(mp_obj_t self_in, mp_obj_t read_in) {
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
self->props.read = mp_obj_is_true(read_in);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_characteristic_set_read_obj, bleio_characteristic_set_read);
const mp_obj_property_t bleio_characteristic_read_obj = {
.base.type = &mp_type_property,
.proxy = { (mp_obj_t)&bleio_characteristic_get_read_obj,
(mp_obj_t)&bleio_characteristic_set_read_obj,
(mp_obj_t)&mp_const_none_obj,
(mp_obj_t)&mp_const_none_obj },
};
//| .. attribute:: write
//|
//| A `bool` specifying if the characteristic allows writing to its value. (read-only)
//|
STATIC mp_obj_t bleio_characteristic_get_write(mp_obj_t self_in) {
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
@ -229,45 +181,35 @@ STATIC mp_obj_t bleio_characteristic_get_write(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_write_obj, bleio_characteristic_get_write);
STATIC mp_obj_t bleio_characteristic_set_write(mp_obj_t self_in, mp_obj_t write_in) {
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
self->props.write = mp_obj_is_true(write_in);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_characteristic_set_write_obj, bleio_characteristic_set_write);
const mp_obj_property_t bleio_characteristic_write_obj = {
.base.type = &mp_type_property,
.proxy = { (mp_obj_t)&bleio_characteristic_get_write_obj,
(mp_obj_t)&bleio_characteristic_set_write_obj,
(mp_obj_t)&mp_const_none_obj,
(mp_obj_t)&mp_const_none_obj },
};
STATIC mp_obj_t bleio_characteristic_get_write_wo_resp(mp_obj_t self_in) {
//| .. attribute:: write_no_response
//|
//| A `bool` specifying if the characteristic allows writing to its value without response. (read-only)
//|
STATIC mp_obj_t bleio_characteristic_get_write_no_response(mp_obj_t self_in) {
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
return mp_obj_new_bool(self->props.write_wo_resp);
return mp_obj_new_bool(self->props.write_no_response);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_write_wo_resp_obj, bleio_characteristic_get_write_wo_resp);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_write_no_response_obj, bleio_characteristic_get_write_no_response);
STATIC mp_obj_t bleio_characteristic_set_write_wo_resp(mp_obj_t self_in, mp_obj_t write_wo_resp_in) {
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
self->props.write_wo_resp = mp_obj_is_true(write_wo_resp_in);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_characteristic_set_write_wo_resp_obj, bleio_characteristic_set_write_wo_resp);
const mp_obj_property_t bleio_characteristic_write_wo_resp_obj = {
const mp_obj_property_t bleio_characteristic_write_no_response_obj = {
.base.type = &mp_type_property,
.proxy = { (mp_obj_t)&bleio_characteristic_get_write_wo_resp_obj,
(mp_obj_t)&bleio_characteristic_set_write_wo_resp_obj,
.proxy = { (mp_obj_t)&bleio_characteristic_get_write_no_response_obj,
(mp_obj_t)&mp_const_none_obj,
(mp_obj_t)&mp_const_none_obj },
};
//| .. attribute:: uuid
//|
//| The UUID of this characteristic. (read-only)
//|
STATIC mp_obj_t bleio_characteristic_get_uuid(mp_obj_t self_in) {
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
@ -282,10 +224,16 @@ const mp_obj_property_t bleio_characteristic_uuid_obj = {
(mp_obj_t)&mp_const_none_obj },
};
//| .. attribute:: value
//|
//| The value of this characteristic. The value can be written to if the `write` property allows it.
//| If the `read` property allows it, the value can be read. If the `notify` property is set, writing
//| to the value will generate a BLE notification.
//|
STATIC mp_obj_t bleio_characteristic_get_value(mp_obj_t self_in) {
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
common_hal_bleio_characteristic_read_value(self);
common_hal_bleio_characteristic_get_value(self);
return self->value_data;
}
@ -297,7 +245,7 @@ STATIC mp_obj_t bleio_characteristic_set_value(mp_obj_t self_in, mp_obj_t value_
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(value_in, &bufinfo, MP_BUFFER_READ);
common_hal_bleio_characteristic_write_value(self, &bufinfo);
common_hal_bleio_characteristic_set_value(self, &bufinfo);
return mp_const_none;
}
@ -318,7 +266,7 @@ STATIC const mp_rom_map_elem_t bleio_characteristic_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_uuid), MP_ROM_PTR(&bleio_characteristic_uuid_obj) },
{ MP_ROM_QSTR(MP_QSTR_value), MP_ROM_PTR(&bleio_characteristic_value_obj) },
{ MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&bleio_characteristic_write_obj) },
{ MP_ROM_QSTR(MP_QSTR_write_wo_resp), MP_ROM_PTR(&bleio_characteristic_write_wo_resp_obj) },
{ MP_ROM_QSTR(MP_QSTR_write_no_response), MP_ROM_PTR(&bleio_characteristic_write_no_response_obj) },
};
STATIC MP_DEFINE_CONST_DICT(bleio_characteristic_locals_dict, bleio_characteristic_locals_dict_table);
@ -326,7 +274,6 @@ STATIC MP_DEFINE_CONST_DICT(bleio_characteristic_locals_dict, bleio_characterist
const mp_obj_type_t bleio_characteristic_type = {
{ &mp_type_type },
.name = MP_QSTR_Characteristic,
.print = bleio_characteristic_print,
.make_new = bleio_characteristic_make_new,
.locals_dict = (mp_obj_dict_t*)&bleio_characteristic_locals_dict
};

View File

@ -27,12 +27,12 @@
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CHARACTERISTIC_H
#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CHARACTERISTIC_H
#include "shared-module/bleio/Characteristic.h"
#include "common-hal/bleio/Characteristic.h"
extern const mp_obj_type_t bleio_characteristic_type;
extern void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self);
extern void common_hal_bleio_characteristic_read_value(bleio_characteristic_obj_t *self);
extern void common_hal_bleio_characteristic_write_value(bleio_characteristic_obj_t *self, mp_buffer_info_t *bufinfo);
extern void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, bleio_uuid_obj_t *uuid, bleio_characteristic_properties_t props);
extern void common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self);
extern void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, mp_buffer_info_t *bufinfo);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CHARACTERISTIC_H

View File

@ -0,0 +1,120 @@
/*
* 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.
*/
#include "py/objproperty.h"
#include "py/runtime.h"
#include "shared-bindings/bleio/CharacteristicBuffer.h"
#include "shared-bindings/bleio/UUID.h"
//| .. currentmodule:: bleio
//|
//| :class:`CharacteristicBuffer` -- BLE Service incoming values buffer.
//| =====================================================================
//|
//| Accumulates a Characteristic's incoming values in a FIFO buffer.
//|
//| .. class:: CharacteristicBuffer(Characteristic, buffer_size=0)
//|
//| Create a new Characteristic object identified by the specified UUID.
//|
//| :param bleio.Characteristic characteristic: The characteristic to monitor
//| :param int buffer_size: Size of ring buffer that stores incoming data coming from client.
//| Must be >= 1.
//|
STATIC mp_obj_t bleio_characteristic_buffer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) {
mp_arg_check_num(n_args, n_kw, 1, 2, true);
bleio_characteristic_buffer_obj_t *self = m_new_obj(bleio_characteristic_buffer_obj_t);
self->base.type = &bleio_characteristic_buffer_type;
mp_map_t kw_args;
mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args);
enum { ARG_characteristic, ARG_buffer_size, };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_characteristic, MP_ARG_REQUIRED | MP_ARG_OBJ },
{ MP_QSTR_buffer_size, MP_ARG_REQUIRED | MP_ARG_INT },
};
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, &kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
const mp_obj_t characteristic = args[ARG_characteristic].u_obj;
const int buffer_size = args[ARG_buffer_size].u_int;
if (buffer_size < 1) {
mp_raise_ValueError(translate("buffer_size must be >= 1"));
}
if (!MP_OBJ_IS_TYPE(characteristic, &bleio_characteristic_type)) {
mp_raise_ValueError(translate("Expected a Characteristic"));
}
self->characteristic = MP_OBJ_TO_PTR(characteristic);
common_hal_bleio_characteristic_buffer_construct(self, self->characteristic, buffer_size);
return MP_OBJ_FROM_PTR(self);
}
//| .. method:: read()
//|
//| Read a single byte from the buffer. If no character is available, return None.
STATIC mp_obj_t bleio_characteristic_buffer_read(mp_obj_t self_in) {
bleio_characteristic_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in);
int byte = common_hal_bleio_characteristic_buffer_read(self);
if (byte == -1) {
return mp_const_none;
}
return MP_OBJ_NEW_SMALL_INT(byte);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_buffer_read_obj, bleio_characteristic_buffer_read);
//| .. method:: deinit()
//|
//| Disable permanently.
STATIC mp_obj_t bleio_characteristic_buffer_deinit(mp_obj_t self_in) {
bleio_characteristic_buffer_obj_t *self = MP_OBJ_TO_PTR(self_in);
common_hal_bleio_characteristic_buffer_deinit(self);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_buffer_deinit_obj, bleio_characteristic_buffer_deinit);
STATIC const mp_rom_map_elem_t bleio_characteristic_buffer_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&bleio_characteristic_buffer_read_obj) },
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&bleio_characteristic_buffer_deinit_obj) },
};
STATIC MP_DEFINE_CONST_DICT(bleio_characteristic_buffer_locals_dict, bleio_characteristic_buffer_locals_dict_table);
const mp_obj_type_t bleio_characteristic_buffer_type = {
{ &mp_type_type },
.name = MP_QSTR_CharacteristicBuffer,
.make_new = bleio_characteristic_buffer_make_new,
.locals_dict = (mp_obj_dict_t*)&bleio_characteristic_buffer_locals_dict
};

View File

@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
* Copyright (c) 2017 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
@ -24,24 +24,16 @@
* THE SOFTWARE.
*/
#define MICROPY_HW_BOARD_NAME "Bluefruit nRF52 Feather"
#define MICROPY_HW_MCU_NAME "nRF52832"
#define MICROPY_PY_SYS_PLATFORM "nRF52"
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CHARACTERISTICBUFFER_H
#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CHARACTERISTICBUFFER_H
#define MICROPY_HW_LED_STATUS (&pin_P0_17)
#include "common-hal/bleio/CharacteristicBuffer.h"
#define MICROPY_HW_UART_RX NRF_GPIO_PIN_MAP(0, 8)
#define MICROPY_HW_UART_TX NRF_GPIO_PIN_MAP(0, 6)
extern const mp_obj_type_t bleio_characteristic_buffer_type;
#define PORT_HEAP_SIZE (32 * 1024)
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
extern void common_hal_bleio_characteristic_buffer_construct(bleio_characteristic_buffer_obj_t *self, bleio_characteristic_obj_t *characteristic, size_t buffer_size);
// Returns a uint8_t byte value, or -1 if no data is available.
int common_hal_bleio_characteristic_buffer_read(bleio_characteristic_buffer_obj_t *self);
int common_hal_bleio_characteristic_buffer_deinit(bleio_characteristic_buffer_obj_t *self);
#define DEFAULT_I2C_BUS_SCL (&pin_P0_26)
#define DEFAULT_I2C_BUS_SDA (&pin_P0_25)
#define DEFAULT_SPI_BUS_SCK (&pin_P0_12)
#define DEFAULT_SPI_BUS_MOSI (&pin_P0_13)
#define DEFAULT_SPI_BUS_MISO (&pin_P0_14)
#define DEFAULT_UART_BUS_RX (&pin_P0_08)
#define DEFAULT_UART_BUS_TX (&pin_P0_06)
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CHARACTERISTICBUFFER_H

View File

@ -61,7 +61,6 @@ enum {
//| .. class:: Descriptor(uuid)
//|
//| Create a new descriptor object with the UUID uuid.
//| The value can be either of type `bleio.UUID` or any value allowed by the `bleio.UUID` constructor.
//| .. attribute:: handle
//|
@ -82,7 +81,7 @@ STATIC mp_obj_t bleio_descriptor_make_new(const mp_obj_type_t *type, size_t n_ar
enum { ARG_uuid };
static const mp_arg_t allowed_args[] = {
{ ARG_uuid, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_uuid, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
};
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
@ -90,24 +89,16 @@ STATIC mp_obj_t bleio_descriptor_make_new(const mp_obj_type_t *type, size_t n_ar
const mp_obj_t uuid_arg = args[ARG_uuid].u_obj;
bleio_uuid_obj_t *uuid;
if (MP_OBJ_IS_TYPE(uuid_arg, &bleio_uuid_type)) {
uuid = MP_OBJ_TO_PTR(uuid_arg);
} else {
uuid = MP_OBJ_TO_PTR(bleio_uuid_type.make_new(&bleio_uuid_type, 1, 0, &uuid_arg));
if (!MP_OBJ_IS_TYPE(uuid_arg, &bleio_uuid_type)) {
mp_raise_ValueError(translate("Expected a UUID"));
}
bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_arg);
common_hal_bleio_descriptor_construct(self, uuid);
return MP_OBJ_FROM_PTR(self);
}
STATIC void bleio_descriptor_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
bleio_descriptor_obj_t *self = MP_OBJ_TO_PTR(self_in);
common_hal_bleio_descriptor_print(self, print);
}
STATIC mp_obj_t bleio_descriptor_get_handle(mp_obj_t self_in) {
bleio_descriptor_obj_t *self = MP_OBJ_TO_PTR(self_in);
@ -124,9 +115,7 @@ const mp_obj_property_t bleio_descriptor_handle_obj = {
STATIC mp_obj_t bleio_descriptor_get_uuid(mp_obj_t self_in) {
bleio_descriptor_obj_t *self = MP_OBJ_TO_PTR(self_in);
const mp_obj_t uuid = mp_obj_new_int(common_hal_bleio_descriptor_get_uuid(self));
return bleio_uuid_type.make_new(&bleio_uuid_type, 1, 0, &uuid);
return common_hal_bleio_descriptor_get_uuid(self);
}
MP_DEFINE_CONST_FUN_OBJ_1(bleio_descriptor_get_uuid_obj, bleio_descriptor_get_uuid);
@ -165,7 +154,6 @@ STATIC MP_DEFINE_CONST_DICT(bleio_descriptor_locals_dict, bleio_descriptor_local
const mp_obj_type_t bleio_descriptor_type = {
{ &mp_type_type },
.name = MP_QSTR_Descriptor,
.print = bleio_descriptor_print,
.make_new = bleio_descriptor_make_new,
.locals_dict = (mp_obj_dict_t*)&bleio_descriptor_locals_dict
};

View File

@ -33,8 +33,7 @@
extern const mp_obj_type_t bleio_descriptor_type;
extern void common_hal_bleio_descriptor_construct(bleio_descriptor_obj_t *self, bleio_uuid_obj_t *uuid);
extern void common_hal_bleio_descriptor_print(bleio_descriptor_obj_t *self, const mp_print_t *print);
extern mp_int_t common_hal_bleio_descriptor_get_handle(bleio_descriptor_obj_t *self);
extern mp_int_t common_hal_bleio_descriptor_get_uuid(bleio_descriptor_obj_t *self);
extern mp_obj_t common_hal_bleio_descriptor_get_uuid(bleio_descriptor_obj_t *self);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_DESCRIPTOR_H

View File

@ -52,10 +52,10 @@
//| When a device is created without any parameter passed to the constructor,
//| it will be set to the Peripheral role. If a address is passed, the device
//| will be a Central. For a Peripheral you can set the `name`, add services
//| via `add_service` and then start and stop advertising via `start_advertising`
//| and `stop_advertising`. For the Central, you can `bleio.Device.connect` and `bleio.Device.disconnect`
//| via `add_service` and then start and stop advertising via `bleio.Device.start_advertising`
//| and `bleio.Device.stop_advertising`. For the Central, you can `bleio.Device.connect` and `bleio.Device.disconnect`
//| to the device, once a connection is established, the device's services can
//| be accessed using `services`.
//| be accessed using `bleio.Device.services`.
//|
//| Usage::
//|
@ -171,7 +171,7 @@ STATIC mp_obj_t bleio_device_make_new(const mp_obj_type_t *type, size_t n_args,
enum { ARG_address, ARG_scan_entry };
static const mp_arg_t allowed_args[] = {
{ ARG_address, MP_ARG_OBJ, {.u_obj = mp_const_none} },
{ MP_QSTR_address, MP_ARG_OBJ, {.u_obj = mp_const_none} },
{ MP_QSTR_scan_entry, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} },
};

View File

@ -0,0 +1,251 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* 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 <string.h>
#include <stdio.h>
#include "ble_drv.h"
#include "py/objarray.h"
#include "py/objproperty.h"
#include "py/objstr.h"
#include "py/runtime.h"
#include "shared-bindings/bleio/Adapter.h"
#include "shared-bindings/bleio/AddressType.h"
#include "shared-bindings/bleio/Characteristic.h"
#include "shared-bindings/bleio/Peripheral.h"
#include "shared-bindings/bleio/Service.h"
#include "shared-bindings/bleio/UUID.h"
#include "shared-module/bleio/AdvertisementData.h"
#include "shared-module/bleio/ScanEntry.h"
#include "common-hal/bleio/Peripheral.h"
// TODO: Add unique MAC address part to name
static const char default_name[] = "CIRCUITPY";
//| .. currentmodule:: bleio
//|
//| :class:`Peripheral` -- A BLE peripheral device
//| =========================================================
//|
//| Implement a BLE peripheral which runs locally.
//| Set up using the supplied services, and then allow advertising to be started and stopped.
//|
//| Usage::
//|
//| import bleio
//|
//| # Create a Characteristic.
//| chara = bleio.Characteristic(bleio.UUID(0x2919), read=True, notify=True)
//|
//| # Create a Service providing that one Characteristic.
//| serv = bleio.Service(bleio.UUID(0x180f), [chara])
//|
//| # Create a peripheral and start it up.
//| periph = bleio.Peripheral([service])
//| periph.start_advertising()
//|
//| while not periph.connected():
//| # Wait for connection.
//| pass
//|
//| .. class:: Peripheral(services, *, name='CIRCUITPY')
//|
//| Create a new Peripheral object.
//| :param iterable services: the Service objects representing services available from this peripheral.
//| :param str name: The name used when advertising this peripheral
//|
STATIC mp_obj_t bleio_peripheral_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) {
mp_arg_check_num(n_args, n_kw, 0, 1, true);
bleio_peripheral_obj_t *self = m_new_obj(bleio_peripheral_obj_t);
self->base.type = &bleio_peripheral_type;
self->service_list = mp_obj_new_list(0, NULL);
self->notif_handler = mp_const_none;
mp_map_t kw_args;
mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args);
enum { ARG_services, ARG_name };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_services, MP_ARG_OBJ, {.u_obj = mp_const_none} },
{ MP_QSTR_name, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} },
};
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, &kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
// If services is not an iterable, an exception will be thrown.
mp_obj_iter_buf_t iter_buf;
mp_obj_t iterable = mp_getiter(args[ARG_services].u_obj, &iter_buf);
mp_obj_t service;
while ((service = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
if (!MP_OBJ_IS_TYPE(service, &bleio_service_type)) {
mp_raise_ValueError(translate("services includes an object that is not a Service"));
}
bleio_service_obj_t *service_ptr = MP_OBJ_TO_PTR(service);
service_ptr->device = MP_OBJ_FROM_PTR(self);
mp_obj_list_append(self->service_list, service);
}
const mp_obj_t name = args[ARG_name].u_obj;
if (name == mp_const_none) {
self->name = mp_obj_new_str(default_name, strlen(default_name));
} else if (MP_OBJ_IS_STR(name)) {
self->name = name;
} else {
mp_raise_ValueError(translate("name must be a string"));
}
// Do port-specific initialization.
common_hal_bleio_peripheral_construct(self);
return MP_OBJ_FROM_PTR(self);
}
//| .. attribute:: connected
//|
//| True if connected to a BLE Central device.
//|
STATIC mp_obj_t bleio_peripheral_get_connected(mp_obj_t self_in) {
bleio_peripheral_obj_t *self = MP_OBJ_TO_PTR(self_in);
// Return list as a tuple so user won't be able to change it.
return mp_obj_new_bool(common_hal_bleio_peripheral_get_connected(self));
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_peripheral_get_connected_obj, bleio_peripheral_get_connected);
const mp_obj_property_t bleio_peripheral_connected_obj = {
.base.type = &mp_type_property,
.proxy = { (mp_obj_t)&bleio_peripheral_get_connected_obj,
(mp_obj_t)&mp_const_none_obj,
(mp_obj_t)&mp_const_none_obj },
};
//| .. attribute:: services
//|
//| A `tuple` of `bleio.Service` that are offered by this peripheral. (read-only)
//|
STATIC mp_obj_t bleio_peripheral_get_services(mp_obj_t self_in) {
bleio_peripheral_obj_t *self = MP_OBJ_TO_PTR(self_in);
// Return list as a tuple so user won't be able to change it.
mp_obj_list_t *service_list = MP_OBJ_TO_PTR(self->service_list);
return mp_obj_new_tuple(service_list->len, service_list->items);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_peripheral_get_services_obj, bleio_peripheral_get_services);
const mp_obj_property_t bleio_peripheral_services_obj = {
.base.type = &mp_type_property,
.proxy = { (mp_obj_t)&bleio_peripheral_get_services_obj,
(mp_obj_t)&mp_const_none_obj,
(mp_obj_t)&mp_const_none_obj },
};
//| .. attribute:: name
//|
//| The peripheral's name, included when advertising. (read-only)
//|
STATIC mp_obj_t bleio_peripheral_get_name(mp_obj_t self_in) {
bleio_peripheral_obj_t *self = MP_OBJ_TO_PTR(self_in);
return self->name;
}
MP_DEFINE_CONST_FUN_OBJ_1(bleio_peripheral_get_name_obj, bleio_peripheral_get_name);
const mp_obj_property_t bleio_peripheral_name_obj = {
.base.type = &mp_type_property,
.proxy = { (mp_obj_t)&bleio_peripheral_get_name_obj,
(mp_obj_t)&mp_const_none_obj,
(mp_obj_t)&mp_const_none_obj },
};
//| .. method:: start_advertising(*, connectable=True, data=None)
//|
//| Starts advertising the peripheral. The peripheral's name and
//| services are included in the advertisement packets.
//|
//| :param bool connectable: If `True` then other devices are allowed to connect to this peripheral.
//| :param buf data: If `None`, advertise the services passed to this Peripheral when it was created.
//| If not `None`, then send the bytes in ``data`` as the advertising packet.
//|
STATIC mp_obj_t bleio_peripheral_start_advertising(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
bleio_peripheral_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
enum { ARG_connectable, ARG_data };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_connectable, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} },
{ MP_QSTR_data, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
};
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
mp_buffer_info_t bufinfo = { 0 };
if (args[ARG_data].u_obj != mp_const_none) {
mp_get_buffer_raise(args[ARG_data].u_obj, &bufinfo, MP_BUFFER_READ);
}
common_hal_bleio_peripheral_start_advertising(self, args[ARG_connectable].u_bool, &bufinfo);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_peripheral_start_advertising_obj, 0, bleio_peripheral_start_advertising);
//| .. method:: stop_advertising()
//|
//| Stop sending advertising packets.
STATIC mp_obj_t bleio_peripheral_stop_advertising(mp_obj_t self_in) {
bleio_peripheral_obj_t *self = MP_OBJ_TO_PTR(self_in);
common_hal_bleio_peripheral_stop_advertising(self);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_peripheral_stop_advertising_obj, bleio_peripheral_stop_advertising);
STATIC const mp_rom_map_elem_t bleio_peripheral_locals_dict_table[] = {
// Methods
{ MP_ROM_QSTR(MP_QSTR_start_advertising), MP_ROM_PTR(&bleio_peripheral_start_advertising_obj) },
{ MP_ROM_QSTR(MP_QSTR_stop_advertising), MP_ROM_PTR(&bleio_peripheral_stop_advertising_obj) },
// Properties
{ MP_ROM_QSTR(MP_QSTR_connected), MP_ROM_PTR(&bleio_peripheral_connected_obj) },
{ MP_ROM_QSTR(MP_QSTR_name), MP_ROM_PTR(&bleio_peripheral_name_obj) },
{ MP_ROM_QSTR(MP_QSTR_services), MP_ROM_PTR(&bleio_peripheral_services_obj) },
};
STATIC MP_DEFINE_CONST_DICT(bleio_peripheral_locals_dict, bleio_peripheral_locals_dict_table);
const mp_obj_type_t bleio_peripheral_type = {
{ &mp_type_type },
.name = MP_QSTR_Peripheral,
.make_new = bleio_peripheral_make_new,
.locals_dict = (mp_obj_dict_t*)&bleio_peripheral_locals_dict
};

View File

@ -1,8 +1,9 @@
/*
* This file is part of the Micro Python project, http://micropython.org/
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2018 Artur Pacholec
* Copyright (c) 2018 Dan Halbert for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@ -24,7 +25,16 @@
* THE SOFTWARE.
*/
#include "nrfx.h"
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_PERIPHERAL_H
#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_PERIPHERAL_H
void nrf_peripherals_power_init(void) {
}
#include "common-hal/bleio/Peripheral.h"
extern const mp_obj_type_t bleio_peripheral_type;
extern void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self);
extern bool common_hal_bleio_peripheral_get_connected(bleio_peripheral_obj_t *self);
extern void common_hal_bleio_peripheral_start_advertising(bleio_peripheral_obj_t *device, bool connectable, mp_buffer_info_t *raw_data);
extern void common_hal_bleio_peripheral_stop_advertising(bleio_peripheral_obj_t *device);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_PERIPHERAL_H

View File

@ -27,6 +27,7 @@
#include "py/objproperty.h"
#include "py/runtime.h"
#include "shared-bindings/bleio/Characteristic.h"
#include "shared-bindings/bleio/Service.h"
#include "shared-bindings/bleio/UUID.h"
@ -38,52 +39,31 @@
//| Stores information about a BLE service and its characteristics.
//|
//| .. class:: Service(uuid, secondary=False)
//| .. class:: Service(uuid, characteristics, *, secondary=False)
//|
//| Create a new Service object identified by the specified UUID.
//| To mark the service as secondary, pass `True` as :py:data:`secondary`.
//|
//| :param bleio.UUID uuid: The uuid of the service
//| :param iterable characteristics: the Characteristic objects for this service
//| :param bool secondary: If the service is a secondary one
//|
//| .. method:: add_characteristic(characteristic)
//|
//| Appends the :py:data:`characteristic` to the list of this service's characteristics.
//|
//| :param bleio.Characteristic characteristic: the characteristic to append
//|
//| .. attribute:: characteristics
//|
//| A `list` of `bleio.Characteristic` that are offered by this service. (read-only)
//|
//| .. attribute:: uuid
//|
//| The UUID of this service. (read-only)
//|
STATIC void bleio_service_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_printf(print, "Service(uuid: 0x"HEX2_FMT""HEX2_FMT")",
self->uuid->value[1], self->uuid->value[0]);
}
STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) {
mp_arg_check_num(n_args, n_kw, 1, 1, true);
mp_arg_check_num(n_args, n_kw, 2, 3, true);
bleio_service_obj_t *self = m_new_obj(bleio_service_obj_t);
self->base.type = &bleio_service_type;
self->device = NULL;
self->char_list = mp_obj_new_list(0, NULL);
self->base.type = &bleio_service_type;
self->device = mp_const_none;
self->handle = 0xFFFF;
mp_map_t kw_args;
mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args);
enum { ARG_uuid, ARG_secondary };
enum { ARG_uuid, ARG_characteristics, ARG_secondary };
static const mp_arg_t allowed_args[] = {
{ ARG_uuid, MP_ARG_OBJ, {.u_obj = mp_const_none} },
{ MP_QSTR_uuid, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = mp_const_none} },
{ MP_QSTR_characteristics, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = mp_const_none} },
{ MP_QSTR_secondary, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
};
@ -94,41 +74,46 @@ STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args,
const mp_obj_t uuid = args[ARG_uuid].u_obj;
if (uuid == mp_const_none) {
return MP_OBJ_FROM_PTR(self);
if (!MP_OBJ_IS_TYPE(uuid, &bleio_uuid_type)) {
mp_raise_ValueError(translate("Expected a UUID"));
}
if (MP_OBJ_IS_TYPE(uuid, &bleio_uuid_type)) {
self->uuid = MP_OBJ_TO_PTR(uuid);
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
translate("Invalid UUID parameter")));
self->uuid = MP_OBJ_TO_PTR(uuid);
// If characteristics is not an iterable, an exception will be thrown.
mp_obj_iter_buf_t iter_buf;
mp_obj_t iterable = mp_getiter(args[ARG_characteristics].u_obj, &iter_buf);
mp_obj_t characteristic;
while ((characteristic = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
if (!MP_OBJ_IS_TYPE(characteristic, &bleio_characteristic_type)) {
mp_raise_ValueError(translate("characteristics includes an object that is not a Characteristic"));
}
bleio_characteristic_obj_t *characteristic_ptr = MP_OBJ_TO_PTR(characteristic);
if (common_hal_bleio_uuid_get_uuid128_reference(uuid) !=
common_hal_bleio_uuid_get_uuid128_reference(characteristic_ptr->uuid)) {
// The descriptor base UUID doesn't match the characteristic base UUID.
mp_raise_ValueError(translate("Characteristic UUID doesn't match Service UUID"));
}
characteristic_ptr->service = self;
mp_obj_list_append(self->char_list, characteristic);
}
// Do port-specific initialization.
common_hal_bleio_service_construct(self);
return MP_OBJ_FROM_PTR(self);
}
STATIC mp_obj_t bleio_service_add_characteristic(mp_obj_t self_in, mp_obj_t characteristic_in) {
bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in);
bleio_characteristic_obj_t *characteristic = MP_OBJ_TO_PTR(characteristic_in);
if (self->uuid->type == UUID_TYPE_128BIT) {
characteristic->uuid->type = UUID_TYPE_128BIT;
characteristic->uuid->uuid_vs_idx = self->uuid->uuid_vs_idx;
}
characteristic->service = self;
mp_obj_list_append(self->char_list, characteristic);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_service_add_characteristic_obj, bleio_service_add_characteristic);
//| .. attribute:: characteristics
//|
//| A `list` of `bleio.Characteristic` that are offered by this service. (read-only)
//|
STATIC mp_obj_t bleio_service_get_characteristics(mp_obj_t self_in) {
bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in);
return self->char_list;
// Return list as a tuple so user won't be able to change it.
mp_obj_list_t *char_list = MP_OBJ_TO_PTR(self->char_list);
return mp_obj_new_tuple(char_list->len, char_list->items);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_service_get_characteristics_obj, bleio_service_get_characteristics);
@ -139,6 +124,10 @@ const mp_obj_property_t bleio_service_characteristics_obj = {
(mp_obj_t)&mp_const_none_obj },
};
//| .. attribute:: uuid
//|
//| The UUID of this service. (read-only)
//|
STATIC mp_obj_t bleio_service_get_uuid(mp_obj_t self_in) {
bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in);
@ -154,7 +143,6 @@ const mp_obj_property_t bleio_service_uuid_obj = {
};
STATIC const mp_rom_map_elem_t bleio_service_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_add_characteristic), MP_ROM_PTR(&bleio_service_add_characteristic_obj) },
{ MP_ROM_QSTR(MP_QSTR_characteristics), MP_ROM_PTR(&bleio_service_characteristics_obj) },
{ MP_ROM_QSTR(MP_QSTR_uuid), MP_ROM_PTR(&bleio_service_uuid_obj) },
};
@ -164,7 +152,6 @@ STATIC MP_DEFINE_CONST_DICT(bleio_service_locals_dict, bleio_service_locals_dict
const mp_obj_type_t bleio_service_type = {
{ &mp_type_type },
.name = MP_QSTR_Service,
.print = bleio_service_print,
.make_new = bleio_service_make_new,
.locals_dict = (mp_obj_dict_t*)&bleio_service_locals_dict
};

Some files were not shown because too many files have changed in this diff Show More