Skip to content

Commit 20b3582

Browse files
authored
Merge pull request #91 from fpistm/sync_1.5.0
Sync to ArduinoBLE 1.5.0
2 parents 285ca3a + f7f5efe commit 20b3582

12 files changed

Lines changed: 491 additions & 35 deletions

.github/workflows/spell-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
steps:
2121
- name: Checkout repository
22-
uses: actions/checkout@v4
22+
uses: actions/checkout@v6
2323

2424
- name: Spell check
2525
uses: codespell-project/actions-codespell@v2

examples/Peripheral/CallbackLED/CallbackLED.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ void blePeripheralDisconnectHandler(BLEDevice central) {
8181
}
8282

8383
void switchCharacteristicWritten(BLEDevice central, BLECharacteristic characteristic) {
84+
// unused parameters
85+
(void)central;
86+
(void)characteristic;
87+
8488
// central wrote new value to characteristic, update LED
8589
Serial.print("Characteristic event, written: ");
8690

extras/STM32_WPAN/0001-chore-adapt-STM32_WPAN-sources.patch

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
From dca5f9d1a4246cd158d38e1eb140bb40513618fc Mon Sep 17 00:00:00 2001
1+
From 3bce4e86b826f59faf048b8b140b4193a3c99cd5 Mon Sep 17 00:00:00 2001
22
From: Frederic Pillon <frederic.pillon@st.com>
33
Date: Wed, 10 Jan 2024 18:16:01 +0100
4-
Subject: [PATCH 1/6] chore: adapt STM32_WPAN sources
4+
Subject: [PATCH 1/4] chore: adapt STM32_WPAN sources
55

66
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
77
---
@@ -15,7 +15,7 @@ Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1515
7 files changed, 85 insertions(+), 12 deletions(-)
1616

1717
diff --git a/src/utility/STM32_WPAN/app_conf_default.h b/src/utility/STM32_WPAN/app_conf_default.h
18-
index 8356f0d..8db164d 100644
18+
index 49b957b..706ef5f 100644
1919
--- a/src/utility/STM32_WPAN/app_conf_default.h
2020
+++ b/src/utility/STM32_WPAN/app_conf_default.h
2121
@@ -1,9 +1,9 @@
@@ -90,7 +90,7 @@ index 8356f0d..8db164d 100644
9090

9191
/**
9292
* BLE stack Options_extension flags to be configured with:
93-
@@ -299,7 +322,11 @@
93+
@@ -305,7 +328,11 @@
9494
* This parameter is considered by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV flag set
9595
*/
9696

@@ -103,7 +103,7 @@ index 8356f0d..8db164d 100644
103103

104104
/* Maximum advertising data length (in bytes)
105105
* Range: 31 .. 1650 with limitation:
106-
@@ -308,7 +335,11 @@
106+
@@ -314,7 +341,11 @@
107107
* This parameter is considered by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV flag set
108108
*/
109109

@@ -116,15 +116,15 @@ index 8356f0d..8db164d 100644
116116

117117
/* RF TX Path Compensation Value (16-bit signed integer). Units: 0.1 dB.
118118
* Range: -1280 .. 1280
119-
@@ -331,6 +362,7 @@
119+
@@ -337,6 +368,7 @@
120120

121121
#define CFG_BLE_CORE_VERSION (SHCI_C2_BLE_INIT_BLE_CORE_5_4)
122122

123123
+#if 0
124124
/******************************************************************************
125125
* Transport Layer
126126
******************************************************************************/
127-
@@ -667,4 +699,5 @@ typedef enum
127+
@@ -673,4 +705,5 @@ typedef enum
128128

129129
#define CFG_OTP_END_ADRESS OTP_AREA_END_ADDR
130130

@@ -182,7 +182,7 @@ index 6a311b1..ad3c9d4 100644
182182
__weak void HW_IPCC_TRACES_EvtNot( void ){};
183183
+#endif /* STM32WBxx */
184184
diff --git a/src/utility/STM32_WPAN/shci.c b/src/utility/STM32_WPAN/shci.c
185-
index 5c32555..40110f4 100644
185+
index e04a2b4..e641530 100644
186186
--- a/src/utility/STM32_WPAN/shci.c
187187
+++ b/src/utility/STM32_WPAN/shci.c
188188
@@ -17,6 +17,7 @@
@@ -193,7 +193,7 @@ index 5c32555..40110f4 100644
193193
/* Includes ------------------------------------------------------------------*/
194194
#include "stm32_wpan_common.h"
195195

196-
@@ -759,3 +760,4 @@ SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo )
196+
@@ -777,3 +778,4 @@ SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo )
197197

198198
return (SHCI_Success);
199199
}
@@ -267,7 +267,7 @@ index 4c92864..df6c215 100644
267267
}
268268
+#endif /* STM32WBxx */
269269
diff --git a/src/utility/STM32_WPAN/tl_mbox.c b/src/utility/STM32_WPAN/tl_mbox.c
270-
index c13f098..e2a0400 100644
270+
index 8c059cf..21fa35f 100644
271271
--- a/src/utility/STM32_WPAN/tl_mbox.c
272272
+++ b/src/utility/STM32_WPAN/tl_mbox.c
273273
@@ -16,6 +16,7 @@

extras/STM32_WPAN/0002-fix-include-a-timeout-when-waiting-for-the-cmd_resp.patch

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
1-
From 1af1d327b5532597512216349abb0d1edef1d89e Mon Sep 17 00:00:00 2001
1+
From c8eb16c6412dc617e6e7d97fbedf86133557800f Mon Sep 17 00:00:00 2001
22
From: Frederic Pillon <frederic.pillon@st.com>
33
Date: Thu, 13 Jul 2023 17:16:40 +0200
4-
Subject: [PATCH 2/6] fix: include a timeout when waiting for the cmd_resp
4+
Subject: [PATCH 2/4] fix: include a timeout when waiting for the cmd_resp
55

66
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
77
---
8-
src/utility/STM32_WPAN/shci_tl.c | 10 ++++++----
9-
1 file changed, 6 insertions(+), 4 deletions(-)
8+
src/utility/STM32_WPAN/shci_tl.c | 15 ++++++++++-----
9+
1 file changed, 10 insertions(+), 5 deletions(-)
1010

1111
diff --git a/src/utility/STM32_WPAN/shci_tl.c b/src/utility/STM32_WPAN/shci_tl.c
12-
index daa988c..25e1a21 100644
12+
index daa988c..38dfb57 100644
1313
--- a/src/utility/STM32_WPAN/shci_tl.c
1414
+++ b/src/utility/STM32_WPAN/shci_tl.c
15-
@@ -24,6 +24,7 @@
15+
@@ -24,7 +24,11 @@
1616
#include "stm_list.h"
1717
#include "shci_tl.h"
1818
#include "stm32_def.h"
19+
-
20+
+#if defined(STM32_CORE_VERSION) && (STM32_CORE_VERSION <= 0x020C0000)
1921
+#include "wiring_time.h"
20-
22+
+#else
23+
+#include "wiring.h"
24+
+#endif
2125
/* Private typedef -----------------------------------------------------------*/
2226
typedef enum
23-
@@ -251,10 +252,11 @@ static void TlUserEvtReceived(TL_EvtPacket_t *shcievt)
27+
{
28+
@@ -251,10 +255,11 @@ static void TlUserEvtReceived(TL_EvtPacket_t *shcievt)
2429
/* Weak implementation ----------------------------------------------------------------*/
2530
__WEAK void shci_cmd_resp_wait(uint32_t timeout)
2631
{

extras/STM32_WPAN/0003-chore-add-support-for-customize-app_conf_default.h.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
From 4a42f3ebb91d4065d2ed54a80baab22d6feb5bad Mon Sep 17 00:00:00 2001
1+
From c08c3314fbb5eab1932f3be17e2b8fc77eeb0d06 Mon Sep 17 00:00:00 2001
22
From: Frederic Pillon <frederic.pillon@st.com>
33
Date: Wed, 10 Jan 2024 18:45:17 +0100
4-
Subject: [PATCH 3/6] chore: add support for customize app_conf_default.h
4+
Subject: [PATCH 3/4] chore: add support for customize app_conf_default.h
55

66
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
77
---
88
src/utility/STM32_WPAN/app_conf_default.h | 58 ++++++++++++++++++-----
99
1 file changed, 45 insertions(+), 13 deletions(-)
1010

1111
diff --git a/src/utility/STM32_WPAN/app_conf_default.h b/src/utility/STM32_WPAN/app_conf_default.h
12-
index 8db164d..2fd67c7 100644
12+
index 706ef5f..5fbb234 100644
1313
--- a/src/utility/STM32_WPAN/app_conf_default.h
1414
+++ b/src/utility/STM32_WPAN/app_conf_default.h
1515
@@ -50,7 +50,9 @@

extras/STM32_WPAN/0004-fix-TL_Evt_t-payload-size-for-reset.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
From 8da8c8da4c1f62efc3f49690e8bb42c52c4ffc64 Mon Sep 17 00:00:00 2001
1+
From f534d3f62f405156476ea56ea83b20c4e1117851 Mon Sep 17 00:00:00 2001
22
From: Frederic Pillon <frederic.pillon@st.com>
33
Date: Mon, 24 Jul 2023 10:55:20 +0200
4-
Subject: [PATCH 4/6] fix: TL_Evt_t payload size for reset
4+
Subject: [PATCH 4/4] fix: TL_Evt_t payload size for reset
55

66
Within STM32CubeWB v1.17.0 update TL_Evt_t payload size was reduced.
77
This produce a warning -Warray-bounds due to the reset management

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=STM32duinoBLE
2-
version=1.4.2
2+
version=1.5.0
33
author=Arduino, SRA
44
maintainer=stm32duino
55
sentence=Fork of ArduinoBLE library to add the support of STM32WB, SPBTLE-RF, SPBTLE-1S, BLUENRG-M2SP, BLUENRG-LP and BLUENRG-M0 BLE modules.

src/local/BLELocalDevice.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@
2525

2626
#include "BLELocalDevice.h"
2727

28+
#ifdef __ZEPHYR__
29+
#undef ARDUINO_PORTENTA_H7_M7
30+
#undef ARDUINO_OPTA
31+
#undef ARDUINO_GIGA
32+
#undef ARDUINO_NICLA_VISION
33+
#undef ARDUINO_PORTENTA_C33
34+
#undef ARDUINO_UNO_Q
35+
#endif
36+
37+
#if defined(ARDUINO_PORTENTA_C33)
38+
#include <EspChipManager.h>
39+
#endif
40+
2841
#if defined(PORTENTA_H7_PINS) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_OPTA)
2942
#ifndef BT_REG_ON
3043
#define BT_REG_ON PJ_12
@@ -77,17 +90,9 @@ int BLELocalDevice::begin()
7790
digitalWrite(BT_REG_ON, HIGH);
7891
delay(500);
7992
#elif defined(ARDUINO_PORTENTA_C33)
80-
#define NINA_GPIO0 (100)
81-
#define NINA_RESETN (101)
82-
pinMode(NINA_GPIO0, OUTPUT);
83-
pinMode(NINA_RESETN, OUTPUT);
84-
Serial5.begin(921600);
8593

86-
digitalWrite(NINA_GPIO0, HIGH);
87-
delay(100);
88-
digitalWrite(NINA_RESETN, HIGH);
89-
digitalWrite(NINA_RESETN, LOW);
90-
digitalWrite(NINA_RESETN, HIGH);
94+
Serial5.begin(921600);
95+
CEspChipManager::getInstance().initialize();
9196
auto _start = millis();
9297
while (millis() - _start < 500) {
9398
if (Serial5.available()) {
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/*
2+
This file is part of the ArduinoBLE library.
3+
Copyright (c) 2018-2025 Arduino SA. All rights reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#if defined(ARDUINO_UNO_Q)
21+
22+
#include "HCIVirtualTransportRPC.h"
23+
24+
HCIVirtualTransportRPCClass::HCIVirtualTransportRPCClass() : initialized(false) {
25+
}
26+
27+
HCIVirtualTransportRPCClass::~HCIVirtualTransportRPCClass() {
28+
}
29+
30+
int HCIVirtualTransportRPCClass::begin() {
31+
// Initialize the Bridge if not already started
32+
if (!Bridge) {
33+
if (!Bridge.begin()) {
34+
return 0;
35+
}
36+
}
37+
38+
// Open HCI device through Bridge RPC
39+
if (!HCI.begin("hci0")) {
40+
return 0;
41+
}
42+
43+
rxbuf.clear();
44+
initialized = true;
45+
46+
return 1;
47+
}
48+
49+
void HCIVirtualTransportRPCClass::end() {
50+
if (initialized) {
51+
HCI.end();
52+
initialized = false;
53+
}
54+
}
55+
56+
void HCIVirtualTransportRPCClass::wait(unsigned long timeout) {
57+
delay(timeout);
58+
}
59+
60+
int HCIVirtualTransportRPCClass::available() {
61+
if (!initialized) {
62+
return 0;
63+
}
64+
65+
// Return buffered data if available
66+
if (rxbuf.available()) {
67+
return rxbuf.available();
68+
}
69+
70+
// Check if data is available from Bridge HCI and buffer it
71+
if (HCI.available()) {
72+
uint8_t packet[258];
73+
int received = HCI.recv(packet, sizeof(packet));
74+
75+
if (received > 0) {
76+
// Store received data in ring buffer
77+
for (int i = 0; i < received; i++) {
78+
rxbuf.store_char(packet[i]);
79+
}
80+
}
81+
}
82+
83+
return rxbuf.available();
84+
}
85+
86+
int HCIVirtualTransportRPCClass::peek() {
87+
return -1;
88+
}
89+
90+
int HCIVirtualTransportRPCClass::read() {
91+
if (rxbuf.available()) {
92+
return rxbuf.read_char();
93+
}
94+
95+
return -1;
96+
}
97+
98+
size_t HCIVirtualTransportRPCClass::write(const uint8_t* data, size_t length) {
99+
if (!initialized) {
100+
return 0;
101+
}
102+
103+
int sent = HCI.send(data, length);
104+
if (sent < 0) {
105+
return 0;
106+
}
107+
108+
return sent;
109+
}
110+
111+
HCIVirtualTransportRPCClass HCIVirtualTransportRPC;
112+
HCITransportInterface& HCITransport = HCIVirtualTransportRPC;
113+
114+
#endif
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
This file is part of the ArduinoBLE library.
3+
Copyright (c) 2018-2025 Arduino SA. All rights reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#ifndef _HCI_VIRTUAL_TRANSPORT_RPC_H_
21+
#define _HCI_VIRTUAL_TRANSPORT_RPC_H_
22+
23+
#include "HCITransport.h"
24+
#include "api/RingBuffer.h"
25+
#include <Arduino_RouterBridge.h>
26+
#include <stdint.h>
27+
#include <stdio.h>
28+
#include <string.h>
29+
30+
class HCIVirtualTransportRPCClass : public HCITransportInterface {
31+
public:
32+
HCIVirtualTransportRPCClass();
33+
virtual ~HCIVirtualTransportRPCClass();
34+
35+
virtual int begin();
36+
virtual void end();
37+
38+
virtual void wait(unsigned long timeout);
39+
40+
virtual int available();
41+
virtual int peek();
42+
virtual int read();
43+
44+
virtual size_t write(const uint8_t* data, size_t length);
45+
46+
private:
47+
RingBufferN<258> rxbuf;
48+
bool initialized;
49+
};
50+
51+
extern HCIVirtualTransportRPCClass HCIVirtualTransportRPC;
52+
53+
#endif

0 commit comments

Comments
 (0)