Skip to content

Commit 611a8ac

Browse files
committed
ble_app: fix gap init error
1 parent d99882c commit 611a8ac

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

main/inc/user/ble_app.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
extern esp_ble_adv_params_t adv_params;
1414

15+
extern void ble_gap_init_adv_data(const char *name);
16+
1517
extern void ble_app_init(void);
1618

1719
#endif /* INC_USER_BLE_APP_H_ */

main/src/user/ble_app.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ esp_ble_adv_params_t adv_params = {
3333
.adv_filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY,
3434
};
3535

36-
static void ble_gap_init_adv_data(const char *name)
36+
void ble_gap_init_adv_data(const char *name)
3737
{
3838
int len = strlen(name);
3939
uint8_t raw_adv_data[len+5];
@@ -97,7 +97,7 @@ static void ble_gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_p
9797

9898
void ble_app_init(void)
9999
{
100-
ble_gap_init_adv_data(CONFIG_BT_NAME);
100+
xEventGroupSetBits(user_event_group, BLE_GATTS_IDLE_BIT);
101101

102102
ESP_ERROR_CHECK(esp_ble_gatts_register_callback(ble_gatts_event_handler));
103103
ESP_ERROR_CHECK(esp_ble_gap_register_callback(ble_gap_event_handler));

main/src/user/ble_gatts.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323

2424
#define BLE_GATTS_TAG "ble_gatts"
2525

26-
#define GATTS_SERVICE_UUID_A 0x00EE
27-
#define GATTS_CHAR_UUID_A 0xEE01
28-
#define GATTS_DESCR_UUID_A 0x2222
26+
#define GATTS_SERVICE_UUID_A 0x00AA
27+
#define GATTS_CHAR_UUID_A 0xAA01
28+
#define GATTS_DESCR_UUID_A 0xDEAD
2929
#define GATTS_NUM_HANDLE_A 4
3030

31-
#define GATTS_SERVICE_UUID_B 0x00FF
32-
#define GATTS_CHAR_UUID_B 0xFF01
33-
#define GATTS_DESCR_UUID_B 0x3333
31+
#define GATTS_SERVICE_UUID_B 0x00BB
32+
#define GATTS_CHAR_UUID_B 0xBB02
33+
#define GATTS_DESCR_UUID_B 0xBEEF
3434
#define GATTS_NUM_HANDLE_B 4
3535

3636
#define PREPARE_BUF_MAX_SIZE 1024
@@ -131,6 +131,8 @@ static void profile_a_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t ga
131131
{
132132
switch (event) {
133133
case ESP_GATTS_REG_EVT:
134+
ble_gap_init_adv_data(CONFIG_BT_NAME);
135+
134136
gl_profile_tab[PROFILE_A_APP_ID].service_id.is_primary = true;
135137
gl_profile_tab[PROFILE_A_APP_ID].service_id.id.inst_id = 0x00;
136138
gl_profile_tab[PROFILE_A_APP_ID].service_id.id.uuid.len = ESP_UUID_LEN_16;

0 commit comments

Comments
 (0)