Skip to content

Commit

Permalink
extmod/nimble: Do not set GAP device name after sync.
Browse files Browse the repository at this point in the history
Instead, configure the default once at compile-time. This means the GAP
name will no longer be set to default after re-initializing Bluetooth.

Signed-off-by: Daniël van de Giessen <[email protected]>
  • Loading branch information
DvdGiessen authored and dpgeorge committed Dec 22, 2023
1 parent 0b2676d commit d014c82
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
7 changes: 0 additions & 7 deletions extmod/nimble/modbluetooth_nimble.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@
#include "nimble/host/src/ble_hs_hci_priv.h"
#endif

#ifndef MICROPY_PY_BLUETOOTH_DEFAULT_GAP_NAME
#define MICROPY_PY_BLUETOOTH_DEFAULT_GAP_NAME "MPY NIMBLE"
#endif

#define DEBUG_printf(...) // printf("nimble: " __VA_ARGS__)

#define ERRNO_BLUETOOTH_NOT_ACTIVE MP_ENODEV
Expand Down Expand Up @@ -350,9 +346,6 @@ STATIC void sync_cb(void) {
assert(rc == 0);
}

DEBUG_printf("sync_cb: Setting device name\n");
ble_svc_gap_device_name_set(MICROPY_PY_BLUETOOTH_DEFAULT_GAP_NAME);

mp_bluetooth_nimble_ble_state = MP_BLUETOOTH_NIMBLE_BLE_STATE_ACTIVE;
}

Expand Down
6 changes: 5 additions & 1 deletion extmod/nimble/syscfg/syscfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ int nimble_sprintf(char *str, const char *fmt, ...);
#define MYNEWT_VAL_BLE_SVC_GAP_APPEARANCE (0)
#define MYNEWT_VAL_BLE_SVC_GAP_APPEARANCE_WRITE_PERM (-1)
#define MYNEWT_VAL_BLE_SVC_GAP_CENTRAL_ADDRESS_RESOLUTION (-1)
#define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME ("pybd")
#ifdef MICROPY_PY_BLUETOOTH_DEFAULT_GAP_NAME
#define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME (MICROPY_PY_BLUETOOTH_DEFAULT_GAP_NAME)
#else
#define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME ("MPY NIMBLE")
#endif
#define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME_MAX_LENGTH (31)
#define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME_WRITE_PERM (-1)
#define MYNEWT_VAL_BLE_SVC_GAP_PPCP_MAX_CONN_INTERVAL (0)
Expand Down
2 changes: 2 additions & 0 deletions ports/esp32/boards/sdkconfig.ble
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ CONFIG_BT_ENABLED=y
CONFIG_BT_NIMBLE_ENABLED=y
CONFIG_BT_CONTROLLER_ENABLED=y

CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME="MPY ESP32"

CONFIG_BT_NIMBLE_MAX_CONNECTIONS=4

# Put NimBLE on core 1, and for synchronisation
Expand Down

0 comments on commit d014c82

Please sign in to comment.