Skip to content

Commit 6abc547

Browse files
committed
Merge branch 'bugfix/espat-2451' into 'master'
bugfix(ESPAT-2451): fixed the issue where blufi was unable to broadcast See merge request application/esp-at!1923
2 parents 3e21441 + 1ff495c commit 6abc547

File tree

3 files changed

+163
-1
lines changed

3 files changed

+163
-1
lines changed

patches/blufi-adv-c61.patch

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
From 2d9eefab416cf738ace73f64473d2209a8c540c1 Mon Sep 17 00:00:00 2001
2+
From: xiewenxiang <[email protected]>
3+
Date: Sat, 11 Oct 2025 09:45:51 +0800
4+
Subject: [PATCH] blufi adv c61
5+
6+
---
7+
.../profile/esp/blufi/nimble_host/esp_blufi.c | 99 ++++++++++++++++++-
8+
1 file changed, 97 insertions(+), 2 deletions(-)
9+
10+
diff --git a/components/bt/common/btc/profile/esp/blufi/nimble_host/esp_blufi.c b/components/bt/common/btc/profile/esp/blufi/nimble_host/esp_blufi.c
11+
index 0f26b9aa940..4609f927709 100644
12+
--- a/components/bt/common/btc/profile/esp/blufi/nimble_host/esp_blufi.c
13+
+++ b/components/bt/common/btc/profile/esp/blufi/nimble_host/esp_blufi.c
14+
@@ -32,11 +32,22 @@
15+
16+
#if (BLUFI_INCLUDED == TRUE)
17+
18+
+#if !CONFIG_BT_NIMBLE_EXT_ADV
19+
static uint8_t own_addr_type;
20+
+#endif
21+
22+
struct gatt_value gatt_values[SERVER_MAX_VALUES];
23+
const static char *TAG = "BLUFI_EXAMPLE";
24+
25+
+#if CONFIG_BT_NIMBLE_EXT_ADV
26+
+static uint8_t ext_adv_pattern_1[] = {
27+
+ 0x02, 0x01, 0x06,
28+
+ 0x03, 0x03, 0xFF, 0xFF,
29+
+ 0x0d, 0X09, 'B', 'L', 'U', 'F','I', '_' ,'D','E','V','I','C','E',
30+
+ 0x02, 0x0A, 0x09
31+
+};
32+
+#endif
33+
+
34+
enum {
35+
GATT_VALUE_TYPE_CHR,
36+
GATT_VALUE_TYPE_DSC,
37+
@@ -366,7 +377,9 @@ esp_blufi_gap_event(struct ble_gap_event *event, void *arg)
38+
case BLE_GAP_EVENT_ADV_COMPLETE:
39+
ESP_LOGI(TAG, "advertise complete; reason=%d",
40+
event->adv_complete.reason);
41+
- ((void(*)(void))arg)();
42+
+ if (arg) {
43+
+ ((void(*)(void))arg)();
44+
+ }
45+
return 0;
46+
47+
case BLE_GAP_EVENT_SUBSCRIBE:
48+
@@ -395,6 +408,79 @@ esp_blufi_gap_event(struct ble_gap_event *event, void *arg)
49+
50+
void esp_blufi_adv_start(void)
51+
{
52+
+#if CONFIG_BT_NIMBLE_EXT_ADV //Extended Adv
53+
+ struct ble_gap_ext_adv_params params;
54+
+ struct os_mbuf *data;
55+
+ uint8_t instance = 0;
56+
+ int rc;
57+
+ const char *name;
58+
+ uint8_t adv_data[31] = {0};
59+
+
60+
+ /* use defaults for non-set params */
61+
+ memset (&params, 0, sizeof(params));
62+
+
63+
+ /* enable connectable advertising */
64+
+ params.connectable = 1;
65+
+ params.scannable = 1;
66+
+ params.legacy_pdu = 1;
67+
+
68+
+ /* advertise using public addr */
69+
+ params.own_addr_type = BLE_OWN_ADDR_PUBLIC;
70+
+
71+
+ params.primary_phy = BLE_HCI_LE_PHY_1M;
72+
+ params.secondary_phy = BLE_HCI_LE_PHY_1M;
73+
+ params.sid = 1;
74+
+
75+
+ params.itvl_min = BLE_GAP_ADV_FAST_INTERVAL1_MIN;
76+
+ params.itvl_max = BLE_GAP_ADV_FAST_INTERVAL1_MIN;
77+
+
78+
+ /* configure instance 0 */
79+
+ rc = ble_gap_ext_adv_configure(instance, &params, NULL,
80+
+ esp_blufi_gap_event, NULL);
81+
+ if (rc != 0) {
82+
+ ESP_LOGE(TAG, "Configuration failed with reason : %d \n" , rc);
83+
+ return;
84+
+ }
85+
+
86+
+ name = ble_svc_gap_device_name();
87+
+ adv_data[0] = 0x02;
88+
+ adv_data[1] = 0x01;
89+
+ adv_data[2] = 0x06;
90+
+ adv_data[3] = 1 + strlen(name);
91+
+ adv_data[4] = 0x09;
92+
+ memcpy(adv_data + 5, name, strlen(name));
93+
+
94+
+ /* get mbuf for scan rsp data */
95+
+ data = os_msys_get_pkthdr(strlen(name) + 5, 0);
96+
+
97+
+ if (data == NULL) {
98+
+ ESP_LOGE(TAG, "Failed to get mbuf \n");
99+
+ return;
100+
+ }
101+
+
102+
+ /* fill mbuf with scan rsp data */
103+
+ rc = os_mbuf_append(data, adv_data, strlen(name) + 5);
104+
+
105+
+ if (rc != 0) {
106+
+ ESP_LOGE(TAG, "Failed to fill scan rsp data with reason: %d \n", rc);
107+
+ return;
108+
+ }
109+
+
110+
+ rc = ble_gap_ext_adv_set_data(instance, data);
111+
+
112+
+ if (rc != 0) {
113+
+ ESP_LOGE(TAG, "Failed to set adv data with reason: %d \n", rc);
114+
+ return;
115+
+ }
116+
+
117+
+ /* start advertising */
118+
+ rc = ble_gap_ext_adv_start(instance, 0, 0);
119+
+
120+
+ if (rc != 0) {
121+
+ ESP_LOGE(TAG, "Failed to start ext adv with reason: %d \n", rc);
122+
+ return;
123+
+ }
124+
+#else // Legacy ADV
125+
int rc;
126+
127+
rc = ble_hs_util_ensure_addr(0);
128+
@@ -466,6 +552,7 @@ void esp_blufi_adv_start(void)
129+
ESP_LOGE(TAG, "error enabling advertisement; rc=%d", rc);
130+
return;
131+
}
132+
+#endif
133+
}
134+
135+
void esp_blufi_adv_start_with_name(const char *name)
136+
@@ -522,7 +609,15 @@ void esp_blufi_disconnect(void)
137+
138+
void esp_blufi_adv_stop(void)
139+
{
140+
- ble_gap_adv_stop();
141+
+#if CONFIG_BT_NIMBLE_EXT_ADV
142+
+ int i;
143+
+
144+
+ for (i = 0; i < BLE_ADV_INSTANCES; i++) {
145+
+ ble_gap_ext_adv_stop(i);
146+
+ }
147+
+#else
148+
+ ble_gap_adv_stop();
149+
+#endif
150+
}
151+
152+
void esp_blufi_send_encap(void *arg)
153+
--
154+
2.39.5 (Apple Git-154)
155+

patches/patch_list.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,10 @@
8383
target = esp32c5
8484
when = after_sdkconfig
8585
dependency = CONFIG_AT_BLUFI_COMMAND_SUPPORT
86+
87+
[blufi-adv-c61.patch]
88+
description = "Add the support for BluFi advertising if uses nimble"
89+
path = esp-idf
90+
target = esp32c61
91+
when = after_sdkconfig
92+
dependency = CONFIG_AT_BLUFI_COMMAND_SUPPORT

tools/patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def ESP_LOGE(x):
1818

1919
at_patch_defaults = {
2020
'path': 'esp-idf',
21-
'target': ['esp32c2', 'esp32c3', 'esp32c5', 'esp32c6', 'esp32', 'esp32s2'],
21+
'target': ['esp32c2', 'esp32c3', 'esp32c5', 'esp32c6', 'esp32c61', 'esp32', 'esp32s2'],
2222
'when': 'before_sdkconfig',
2323
'dependency': None,
2424
}

0 commit comments

Comments
 (0)