Merge c28e068f34
into 25f89ee6ab
This commit is contained in:
commit
66feefe6fd
1 changed files with 12 additions and 2 deletions
|
@ -77,12 +77,15 @@ static uint8_t active_profile;
|
|||
|
||||
#define DEVICE_NAME CONFIG_BT_DEVICE_NAME
|
||||
#define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1)
|
||||
#define DEVICE_NAME_ARRAY_MAX_SIZE 17
|
||||
|
||||
static uint8_t device_name[DEVICE_NAME_ARRAY_MAX_SIZE] = DEVICE_NAME;
|
||||
|
||||
BUILD_ASSERT(DEVICE_NAME_LEN <= 16, "ERROR: BLE device name is too long. Max length: 16");
|
||||
|
||||
static const struct bt_data zmk_ble_ad[] = {
|
||||
static struct bt_data zmk_ble_ad[] = {
|
||||
#if IS_HOST_PERIPHERAL
|
||||
BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN),
|
||||
BT_DATA(BT_DATA_NAME_COMPLETE, device_name, DEVICE_NAME_ARRAY_MAX_SIZE - 1),
|
||||
BT_DATA_BYTES(BT_DATA_GAP_APPEARANCE, 0xC1, 0x03),
|
||||
#endif
|
||||
BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
|
||||
|
@ -183,6 +186,13 @@ int update_advertising() {
|
|||
struct bt_conn *conn;
|
||||
enum advertising_type desired_adv = ZMK_ADV_NONE;
|
||||
|
||||
uint8_t max_device_name_length = DEVICE_NAME_ARRAY_MAX_SIZE - ((active_profile > 9) ? 4 : 3);
|
||||
if (max_device_name_length > strlen(DEVICE_NAME)) {
|
||||
max_device_name_length = DEVICE_NAME_LEN;
|
||||
}
|
||||
snprintf(device_name, max_device_name_length + 1, "%s", DEVICE_NAME);
|
||||
sprintf(device_name + max_device_name_length, "~%d", active_profile);
|
||||
|
||||
if (zmk_ble_active_profile_is_open()) {
|
||||
desired_adv = ZMK_ADV_CONN;
|
||||
} else if (!zmk_ble_active_profile_is_connected()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue