Skip to content

extmod/modbluetooth: Add support for changing the GAP device name.#6019

Merged
dpgeorge merged 1 commit intomicropython:masterfrom
dpgeorge:extmod-bluetooth-gap-name
May 11, 2020
Merged

extmod/modbluetooth: Add support for changing the GAP device name.#6019
dpgeorge merged 1 commit intomicropython:masterfrom
dpgeorge:extmod-bluetooth-gap-name

Conversation

@dpgeorge
Copy link
Copy Markdown
Member

@dpgeorge dpgeorge commented May 8, 2020

The GAP device name of a BLE device is currently hard-coded. This PR allows the user to dynamically set/get the GAP device name used by service 0x1800, characteristic 0x2a00. The usage is:

BLE.config(gap_name="myname")
print(BLE.config("gap_name"))

This name appears, for example, when a phone reads characteristic 0x2a00 of a peripheral that it scans/connects to.

The name can be any string of bytes (including an interior null byte on the BTstack implementation), although the BLE spec specifies it should be UTF-8.

Docs and test are included here.

@dpgeorge dpgeorge added the extmod Relates to extmod/ directory in source label May 8, 2020
@walklinewang
Copy link
Copy Markdown

That's a great job!~

@jimmo
Copy link
Copy Markdown
Member

jimmo commented May 11, 2020

Thanks!!

This commit allows the user to set/get the GAP device name used by service
0x1800, characteristic 0x2a00.  The usage is:

    BLE.config(gap_name="myname")
    print(BLE.config("gap_name"))

As part of this change the compile-time setting
MICROPY_PY_BLUETOOTH_DEFAULT_NAME is renamed to
MICROPY_PY_BLUETOOTH_DEFAULT_GAP_NAME to emphasise its link to GAP and this
new "gap_name" config value.  And the default value of this for the NimBLE
bindings is changed from "PYBD" to "MPY NIMBLE" to be more generic.
@dpgeorge dpgeorge force-pushed the extmod-bluetooth-gap-name branch from 390b033 to 3b6c911 Compare May 11, 2020 11:32
@dpgeorge dpgeorge merged commit 3b6c911 into micropython:master May 11, 2020
@dpgeorge dpgeorge deleted the extmod-bluetooth-gap-name branch May 11, 2020 11:53
@jimmo jimmo mentioned this pull request Jun 8, 2020
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extmod Relates to extmod/ directory in source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants