Skip to content

Commit

Permalink
添加蓝牙名称后面地址的显示控制定义
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-kirisame committed Jul 29, 2019
1 parent f4cbec8 commit 95b1a4f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
13 changes: 9 additions & 4 deletions application/main/src/ble/ble_services.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,13 @@ static void whitelist_load(void)
APP_ERROR_CHECK(ret);
}

#ifdef MACADDR_SEPRATOR
static void get_device_name(char* device_name, int offset)
{
const char lookup_table[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };

strcpy(device_name, DEVICE_NAME);
device_name[offset++] = '_';
device_name[offset++] = MACADDR_SEPRATOR;

ble_gap_addr_t ble_addr;
sd_ble_gap_addr_get(&ble_addr);
Expand All @@ -293,6 +294,7 @@ static void get_device_name(char* device_name, int offset)
}
device_name[offset] = 0x00;
}
#endif

/**@brief Function for the GAP initialization.
*
Expand All @@ -306,7 +308,7 @@ static void gap_params_init(void)
ble_gap_conn_sec_mode_t sec_mode;

BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);

#ifdef MACADDR_SEPRATOR
int orig_len = strlen(DEVICE_NAME);
int name_len = orig_len + 8;
char device_name[name_len];
Expand All @@ -315,6 +317,9 @@ static void gap_params_init(void)
err_code = sd_ble_gap_device_name_set(&sec_mode,
(const uint8_t*)device_name,
strlen(device_name));
#else
err_code = sd_ble_gap_device_name_set(&sec_mode, (const uint8_t*)DEVICE_NAME, strlen(DEVICE_NAME));
#endif

APP_ERROR_CHECK(err_code);

Expand Down Expand Up @@ -530,8 +535,8 @@ static void ble_rssi_change(int8_t rssi)
sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_CONN, m_conn_handle, tx_power_table[current_tx]);
}
#else
#define ble_conn_handle_change(A,B)
#define ble_rssi_change(A)
#define ble_conn_handle_change(A, B)
#define ble_rssi_change(A)
#endif

/**@brief Function for handling BLE events.
Expand Down
1 change: 1 addition & 0 deletions keyboard/gt-ble60/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DEVICE_VER 0x0001 /* 硬件版本 */
#define MANUFACTURER "Lotlab" /* 硬件制造商,用于蓝牙显示 */
#define PRODUCT "GT BLE60" /* 硬件名词,用于蓝牙显示 */
#define MACADDR_SEPRATOR ' ' /* 蓝牙名称后地址的分隔符。若不设置则不显示蓝牙名称后面的地址 */

/* USB HID report parameter */
#define KEYBOARD_EPSIZE 8 /* 键盘上传端点大小,请不要修改 */
Expand Down
1 change: 1 addition & 0 deletions keyboard/lot60-ble/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DEVICE_VER 0x0001 /* 硬件版本 */
#define MANUFACTURER "Lotlab" /* 硬件制造商,用于蓝牙显示 */
#define PRODUCT "BLE60-Rev.C" /* 硬件名词,用于蓝牙显示 */
#define MACADDR_SEPRATOR '_' /* 蓝牙名称后地址的分隔符。若不设置则不显示蓝牙名称后面的地址 */

/* USB HID report parameter */
#define KEYBOARD_EPSIZE 8 /* 键盘上传端点大小,请不要修改 */
Expand Down
1 change: 1 addition & 0 deletions keyboard/Ω45/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DEVICE_VER 0x0001 /* 硬件版本 */
#define MANUFACTURER "Lotlab" /* 硬件制造商,用于蓝牙显示 */
#define PRODUCT "GT Ω45" /* 硬件名词,用于蓝牙显示 */
#define MACADDR_SEPRATOR ' ' /* 蓝牙名称后地址的分隔符。若不设置则不显示蓝牙名称后面的地址 */

/* USB HID report parameter */
#define KEYBOARD_EPSIZE 8 /* 键盘上传端点大小,请不要修改 */
Expand Down

0 comments on commit 95b1a4f

Please sign in to comment.