From 929b540b051eeb8621ad681c6922806cf9501a23 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 8 Feb 2023 16:50:46 +0100 Subject: [PATCH 1/4] fix: warning outside array bounds array subscript 'TL_CcEvt_t[0]' is partly outside array bounds Signed-off-by: Frederic Pillon --- src/utility/STM32Cube_FW/shci.c | 56 ++++++++++++++++----------------- src/utility/STM32Cube_FW/tl.h | 3 ++ 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/src/utility/STM32Cube_FW/shci.c b/src/utility/STM32Cube_FW/shci.c index a8475222..8b241bbe 100644 --- a/src/utility/STM32Cube_FW/shci.c +++ b/src/utility/STM32Cube_FW/shci.c @@ -42,7 +42,7 @@ uint8_t SHCI_C2_FUS_GetState( SHCI_FUS_GetState_ErrorCode_t *p_error_code ) /** * A command status event + payload has the same size than the expected command complete */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE + 1]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -66,7 +66,7 @@ SHCI_CmdStatus_t SHCI_C2_FUS_FwUpgrade( uint32_t fw_src_add, uint32_t fw_dest_a * TL_BLEEVT_CS_BUFFER_SIZE is 15 bytes so it is large enough to hold the 8 bytes of command parameters * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; uint32_t *p_cmd; uint8_t cmd_length; @@ -101,7 +101,7 @@ SHCI_CmdStatus_t SHCI_C2_FUS_FwDelete( void ) /** * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -119,7 +119,7 @@ SHCI_CmdStatus_t SHCI_C2_FUS_UpdateAuthKey( SHCI_C2_FUS_UpdateAuthKey_Cmd_Param_ /** * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -137,7 +137,7 @@ SHCI_CmdStatus_t SHCI_C2_FUS_LockAuthKey( void ) /** * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -155,7 +155,7 @@ SHCI_CmdStatus_t SHCI_C2_FUS_StoreUsrKey( SHCI_C2_FUS_StoreUsrKey_Cmd_Param_t *p /** * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE + 1]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; uint8_t local_payload_len; @@ -189,7 +189,7 @@ SHCI_CmdStatus_t SHCI_C2_FUS_LoadUsrKey( uint8_t key_index ) /** * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -209,7 +209,7 @@ SHCI_CmdStatus_t SHCI_C2_FUS_StartWs( void ) /** * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -227,7 +227,7 @@ SHCI_CmdStatus_t SHCI_C2_FUS_LockUsrKey( uint8_t key_index ) /** * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -247,7 +247,7 @@ SHCI_CmdStatus_t SHCI_C2_FUS_UnloadUsrKey( uint8_t key_index ) /** * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -267,7 +267,7 @@ SHCI_CmdStatus_t SHCI_C2_FUS_ActivateAntiRollback( void ) /** * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -285,7 +285,7 @@ SHCI_CmdStatus_t SHCI_C2_BLE_Init( SHCI_C2_Ble_Init_Cmd_Packet_t *pCmdPacket ) /** * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -303,7 +303,7 @@ SHCI_CmdStatus_t SHCI_C2_THREAD_Init( void ) /** * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -321,7 +321,7 @@ SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init( uint8_t param_size, uint8_t * p_param ) /** * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -339,7 +339,7 @@ SHCI_CmdStatus_t SHCI_C2_BLE_LLD_Init( uint8_t param_size, uint8_t * p_param ) /** * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -357,7 +357,7 @@ SHCI_CmdStatus_t SHCI_C2_DEBUG_Init( SHCI_C2_DEBUG_Init_Cmd_Packet_t *pCmdPacket /** * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -375,7 +375,7 @@ SHCI_CmdStatus_t SHCI_C2_FLASH_EraseActivity( SHCI_EraseActivity_t erase_activit /** * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -395,7 +395,7 @@ SHCI_CmdStatus_t SHCI_C2_CONCURRENT_SetMode( SHCI_C2_CONCURRENT_Mode_Param_t Mod /** * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -415,7 +415,7 @@ SHCI_CmdStatus_t SHCI_C2_CONCURRENT_GetNextBleEvtTime( SHCI_C2_CONCURRENT_GetNex /** * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE+4]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -435,7 +435,7 @@ SHCI_CmdStatus_t SHCI_C2_CONCURRENT_EnableNext_802154_EvtNotification( void ) /** * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -453,7 +453,7 @@ SHCI_CmdStatus_t SHCI_C2_FLASH_StoreData( SHCI_C2_FLASH_Ip_t Ip ) /** * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -473,7 +473,7 @@ SHCI_CmdStatus_t SHCI_C2_FLASH_EraseData( SHCI_C2_FLASH_Ip_t Ip ) /** * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -493,7 +493,7 @@ SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t Fla /** * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -514,7 +514,7 @@ SHCI_CmdStatus_t SHCI_C2_Reinit( void ) /** * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -533,7 +533,7 @@ SHCI_CmdStatus_t SHCI_C2_ExtpaConfig(uint32_t gpio_port, uint16_t gpio_pin_numbe * TL_BLEEVT_CS_BUFFER_SIZE is 15 bytes so it is large enough to hold the 8 bytes of command parameters * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -557,7 +557,7 @@ SHCI_CmdStatus_t SHCI_C2_SetFlashActivityControl(SHCI_C2_SET_FLASH_ACTIVITY_CONT * TL_BLEEVT_CS_BUFFER_SIZE is 15 bytes so it is large enough to hold the 1 byte of command parameter * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -577,7 +577,7 @@ SHCI_CmdStatus_t SHCI_C2_Config(SHCI_C2_CONFIG_Cmd_Param_t *pCmdPacket) /** * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; @@ -595,7 +595,7 @@ SHCI_CmdStatus_t SHCI_C2_802_15_4_DeInit( void ) /** * Buffer is large enough to hold command complete without payload */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + uint8_t local_buffer[TL_BLEEVT_CC_BUFFER_SIZE]; TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; diff --git a/src/utility/STM32Cube_FW/tl.h b/src/utility/STM32Cube_FW/tl.h index 982bb586..354851ac 100644 --- a/src/utility/STM32Cube_FW/tl.h +++ b/src/utility/STM32Cube_FW/tl.h @@ -61,6 +61,9 @@ extern "C" { #define TL_BLEEVT_CS_PACKET_SIZE (TL_EVT_HDR_SIZE + sizeof(TL_CsEvt_t)) #define TL_BLEEVT_CS_BUFFER_SIZE (sizeof(TL_PacketHeader_t) + TL_BLEEVT_CS_PACKET_SIZE) +#define TL_BLEEVT_CC_PACKET_SIZE (TL_EVT_HDR_SIZE + sizeof(TL_CcEvt_t)) +#define TL_BLEEVT_CC_BUFFER_SIZE (sizeof(TL_PacketHeader_t) + TL_BLEEVT_CC_PACKET_SIZE) + /* Exported types ------------------------------------------------------------*/ /**< Packet header */ typedef PACKED_STRUCT From a5e0fed7d1dd3a5553d8b2ffda878cc22f23b88e Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 29 Mar 2023 10:05:59 +0200 Subject: [PATCH 2/4] examples: add P_NUCLEO_WB55_USB_DONGLE support Signed-off-by: Frederic Pillon --- examples/Central/LedControl/LedControl.ino | 3 ++- examples/Central/PeripheralExplorer/PeripheralExplorer.ino | 3 ++- examples/Central/Scan/Scan.ino | 3 ++- examples/Central/ScanCallback/ScanCallback.ino | 3 ++- examples/Central/SensorTagButton/SensorTagButton.ino | 3 ++- examples/Peripheral/ButtonLED/ButtonLED.ino | 3 ++- examples/Peripheral/CallbackLED/CallbackLED.ino | 3 ++- examples/Peripheral/LED/LED.ino | 3 ++- 8 files changed, 16 insertions(+), 8 deletions(-) diff --git a/examples/Central/LedControl/LedControl.ino b/examples/Central/LedControl/LedControl.ino index 13768360..08db7aca 100644 --- a/examples/Central/LedControl/LedControl.ino +++ b/examples/Central/LedControl/LedControl.ino @@ -56,7 +56,8 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000, BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) +#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) ||\ + defined(ARDUINO_STM32WB5MM_DK) || defined(P_NUCLEO_WB55_USB_DONGLE) HCISharedMemTransportClass HCISharedMemTransport; #if !defined(FAKE_BLELOCALDEVICE) BLELocalDevice BLEObj(&HCISharedMemTransport); diff --git a/examples/Central/PeripheralExplorer/PeripheralExplorer.ino b/examples/Central/PeripheralExplorer/PeripheralExplorer.ino index 52da33ca..44aa00c4 100644 --- a/examples/Central/PeripheralExplorer/PeripheralExplorer.ino +++ b/examples/Central/PeripheralExplorer/PeripheralExplorer.ino @@ -50,7 +50,8 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000, BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) +#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) ||\ + defined(ARDUINO_STM32WB5MM_DK) || defined(P_NUCLEO_WB55_USB_DONGLE) HCISharedMemTransportClass HCISharedMemTransport; #if !defined(FAKE_BLELOCALDEVICE) BLELocalDevice BLEObj(&HCISharedMemTransport); diff --git a/examples/Central/Scan/Scan.ino b/examples/Central/Scan/Scan.ino index cc7275fd..4c34e563 100644 --- a/examples/Central/Scan/Scan.ino +++ b/examples/Central/Scan/Scan.ino @@ -46,7 +46,8 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000, BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) +#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) ||\ + defined(ARDUINO_STM32WB5MM_DK) || defined(P_NUCLEO_WB55_USB_DONGLE) HCISharedMemTransportClass HCISharedMemTransport; #if !defined(FAKE_BLELOCALDEVICE) BLELocalDevice BLEObj(&HCISharedMemTransport); diff --git a/examples/Central/ScanCallback/ScanCallback.ino b/examples/Central/ScanCallback/ScanCallback.ino index f2ca6d6c..bba10789 100644 --- a/examples/Central/ScanCallback/ScanCallback.ino +++ b/examples/Central/ScanCallback/ScanCallback.ino @@ -48,7 +48,8 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000, BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) +#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) ||\ + defined(ARDUINO_STM32WB5MM_DK) || defined(P_NUCLEO_WB55_USB_DONGLE) HCISharedMemTransportClass HCISharedMemTransport; #if !defined(FAKE_BLELOCALDEVICE) BLELocalDevice BLEObj(&HCISharedMemTransport); diff --git a/examples/Central/SensorTagButton/SensorTagButton.ino b/examples/Central/SensorTagButton/SensorTagButton.ino index 75ccf254..b371617f 100644 --- a/examples/Central/SensorTagButton/SensorTagButton.ino +++ b/examples/Central/SensorTagButton/SensorTagButton.ino @@ -50,7 +50,8 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000, BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) +#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) ||\ + defined(ARDUINO_STM32WB5MM_DK) || defined(P_NUCLEO_WB55_USB_DONGLE) HCISharedMemTransportClass HCISharedMemTransport; #if !defined(FAKE_BLELOCALDEVICE) BLELocalDevice BLEObj(&HCISharedMemTransport); diff --git a/examples/Peripheral/ButtonLED/ButtonLED.ino b/examples/Peripheral/ButtonLED/ButtonLED.ino index 8d014ade..fb186766 100644 --- a/examples/Peripheral/ButtonLED/ButtonLED.ino +++ b/examples/Peripheral/ButtonLED/ButtonLED.ino @@ -57,7 +57,8 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000, BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) +#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) ||\ + defined(ARDUINO_STM32WB5MM_DK) || defined(P_NUCLEO_WB55_USB_DONGLE) HCISharedMemTransportClass HCISharedMemTransport; #if !defined(FAKE_BLELOCALDEVICE) BLELocalDevice BLEObj(&HCISharedMemTransport); diff --git a/examples/Peripheral/CallbackLED/CallbackLED.ino b/examples/Peripheral/CallbackLED/CallbackLED.ino index 5f3e6d97..0326f732 100644 --- a/examples/Peripheral/CallbackLED/CallbackLED.ino +++ b/examples/Peripheral/CallbackLED/CallbackLED.ino @@ -51,7 +51,8 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000, BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) +#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) ||\ + defined(ARDUINO_STM32WB5MM_DK) || defined(P_NUCLEO_WB55_USB_DONGLE) HCISharedMemTransportClass HCISharedMemTransport; #if !defined(FAKE_BLELOCALDEVICE) BLELocalDevice BLEObj(&HCISharedMemTransport); diff --git a/examples/Peripheral/LED/LED.ino b/examples/Peripheral/LED/LED.ino index 1ce9ea81..1ba9c9a8 100644 --- a/examples/Peripheral/LED/LED.ino +++ b/examples/Peripheral/LED/LED.ino @@ -49,7 +49,8 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000, BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) +#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) ||\ + defined(ARDUINO_STM32WB5MM_DK) || defined(P_NUCLEO_WB55_USB_DONGLE) HCISharedMemTransportClass HCISharedMemTransport; #if !defined(FAKE_BLELOCALDEVICE) BLELocalDevice BLEObj(&HCISharedMemTransport); From 902a770a9d2deb7d807d891ad8c0974e55290511 Mon Sep 17 00:00:00 2001 From: Lorenzo Bini Date: Thu, 30 Mar 2023 12:03:37 +0200 Subject: [PATCH 3/4] Add support for latest firmware in BLUENRG-M2SP chips. This requires changing the SPI dummy package to 0x00 due to signaling over the MOSI pin --- src/utility/HCISpiTransport.cpp | 54 ++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/src/utility/HCISpiTransport.cpp b/src/utility/HCISpiTransport.cpp index 5c18083f..ac9b4814 100644 --- a/src/utility/HCISpiTransport.cpp +++ b/src/utility/HCISpiTransport.cpp @@ -67,10 +67,10 @@ int HCISpiTransportClass::begin() digitalWrite(_ble_rst, HIGH); delay(5); - if (_ble_chip == SPBTLE_RF || _ble_chip == BLUENRG_M0 || _ble_chip == BLUENRG_LP) { + if (_ble_chip == SPBTLE_RF || _ble_chip == BLUENRG_M0 || _ble_chip == BLUENRG_LP || _ble_chip == BLUENRG_M2SP) { // Wait for Blue Initialize wait_for_blue_initialize(); - } else if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { + } else if (_ble_chip == SPBTLE_1S) { // Wait a while for the reset of the BLE module delay(300); } else { @@ -146,7 +146,7 @@ int HCISpiTransportClass::available() /* Read the response */ for (int j = 0; j < byte_count; j++) { - _rxbuff[_write_index_initial] = _spi->transfer(0xFF); + _rxbuff[_write_index_initial] = _spi->transfer(0x00); _write_index_initial++; } @@ -172,7 +172,7 @@ int HCISpiTransportClass::available() /* Read the response */ for (int j = 0; j < byte_count; j++) { - _rxbuff[_write_index] = _spi->transfer(0xFF); + _rxbuff[_write_index] = _spi->transfer(0x00); _write_index++; } } @@ -190,7 +190,7 @@ int HCISpiTransportClass::available() /* Read the response */ for (int j = 0; j < byte_count; j++) { - _rxbuff[_write_index_initial] = _spi->transfer(0xFF); + _rxbuff[_write_index_initial] = _spi->transfer(0x00); _write_index_initial++; } @@ -217,7 +217,7 @@ int HCISpiTransportClass::available() /* Read the response */ for (int j = 0; j < byte_count; j++) { - _rxbuff[_write_index] = _spi->transfer(0xFF); + _rxbuff[_write_index] = _spi->transfer(0x00); _write_index++; } } @@ -234,11 +234,15 @@ int HCISpiTransportClass::available() } if (ble_reset) { - if (_ble_chip == SPBTLE_RF || _ble_chip == BLUENRG_M0 || _ble_chip == BLUENRG_LP) { + if (_ble_chip == BLUENRG_M2SP) { + wait_for_blue_initialize(); + } + + if (_ble_chip == SPBTLE_RF || _ble_chip == BLUENRG_M0 || _ble_chip == BLUENRG_LP || _ble_chip == BLUENRG_M2SP) { /* BLE chip was reset: we need to enable LL_ONLY */ enable_ll_only(); wait_for_enable_ll_only(); - } else if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { + } else if (_ble_chip == SPBTLE_1S) { /* BLE chip was reset: we need to wait for a while */ delay(300); } @@ -447,7 +451,7 @@ void HCISpiTransportClass::wait_for_blue_initialize() /* Read the response */ if (byte_count == 6) { for (int j = 0; j < byte_count; j++) { - event[j] = _spi->transfer(0xFF); + event[j] = _spi->transfer(0x00); } if (event[0] == 0x04 && @@ -460,7 +464,7 @@ void HCISpiTransportClass::wait_for_blue_initialize() } } else { for (int j = 0; j < byte_count; j++) { - _spi->transfer(0xFF); + _spi->transfer(0x00); } } } @@ -472,7 +476,7 @@ void HCISpiTransportClass::wait_for_blue_initialize() /* Read the response */ if (byte_count == 6) { for (int j = 0; j < byte_count; j++) { - event[j] = _spi->transfer(0xFF); + event[j] = _spi->transfer(0x00); } if (event[0] == 0x04 && @@ -485,7 +489,7 @@ void HCISpiTransportClass::wait_for_blue_initialize() } } else { for (int j = 0; j < byte_count; j++) { - _spi->transfer(0xFF); + _spi->transfer(0x00); } } } @@ -496,7 +500,7 @@ void HCISpiTransportClass::wait_for_blue_initialize() /* Read the response */ if (byte_count == 7) { for (int j = 0; j < byte_count; j++) { - event[j] = _spi->transfer(0xFF); + event[j] = _spi->transfer(0x00); } if (event[0] == 0x82 && @@ -510,7 +514,7 @@ void HCISpiTransportClass::wait_for_blue_initialize() } } else { for (int j = 0; j < byte_count; j++) { - _spi->transfer(0xFF); + _spi->transfer(0x00); } } } @@ -563,7 +567,7 @@ void HCISpiTransportClass::wait_for_enable_ll_only() if (byte_count > 0) { /* Read the response */ for (int j = 0; j < byte_count; j++) { - data[j] = _spi->transfer(0xFF); + data[j] = _spi->transfer(0x00); } if (byte_count >= 7) { @@ -585,7 +589,7 @@ void HCISpiTransportClass::wait_for_enable_ll_only() if (byte_count > 0) { /* Read the response */ for (int j = 0; j < byte_count; j++) { - data[j] = _spi->transfer(0xFF); + data[j] = _spi->transfer(0x00); } if (byte_count >= 7) { @@ -725,7 +729,7 @@ void HCISpiTransportClass::wait_for_aci_gatt_init() if (byte_count > 0) { /* Read the response */ for (int j = 0; j < byte_count; j++) { - data[j] = _spi->transfer(0xFF); + data[j] = _spi->transfer(0x00); } if (byte_count >= 7) { @@ -747,7 +751,7 @@ void HCISpiTransportClass::wait_for_aci_gatt_init() if (byte_count > 0) { /* Read the response */ for (int j = 0; j < byte_count; j++) { - data[j] = _spi->transfer(0xFF); + data[j] = _spi->transfer(0x00); } if (byte_count >= 7) { @@ -887,7 +891,7 @@ void HCISpiTransportClass::wait_for_aci_gap_init() if (byte_count > 0) { /* Read the response */ for (int j = 0; j < byte_count; j++) { - data[j] = _spi->transfer(0xFF); + data[j] = _spi->transfer(0x00); } if (byte_count >= 13) { @@ -909,7 +913,7 @@ void HCISpiTransportClass::wait_for_aci_gap_init() if (byte_count > 0) { /* Read the response */ for (int j = 0; j < byte_count; j++) { - data[j] = _spi->transfer(0xFF); + data[j] = _spi->transfer(0x00); } if (byte_count >= 13) { @@ -1058,7 +1062,7 @@ void HCISpiTransportClass::wait_for_aci_read_config_parameter() if (byte_count > 0) { /* Read the response */ for (int j = 0; j < byte_count; j++) { - data[j] = _spi->transfer(0xFF); + data[j] = _spi->transfer(0x00); } if (byte_count >= 13) { @@ -1081,7 +1085,7 @@ void HCISpiTransportClass::wait_for_aci_read_config_parameter() if (byte_count > 0) { /* Read the response */ for (int j = 0; j < byte_count; j++) { - data[j] = _spi->transfer(0xFF); + data[j] = _spi->transfer(0x00); } if (byte_count >= 14) { @@ -1293,7 +1297,9 @@ void HCISpiTransportClass::wait_for_set_address() uint8_t data[15]; int status = 0; - if (_ble_chip != BLUENRG_LP) return; + if (_ble_chip != BLUENRG_LP) { + return; + } do { while (!data_avail); @@ -1321,7 +1327,7 @@ void HCISpiTransportClass::wait_for_set_address() if (byte_count > 0) { /* Read the response */ for (int j = 0; j < byte_count; j++) { - data[j] = _spi->transfer(0xFF); + data[j] = _spi->transfer(0x00); } if (byte_count >= 7) { // 040E0401052000 From bd27383c8f197387ac7a828ea23cb15efcea88d5 Mon Sep 17 00:00:00 2001 From: Carlo Parata Date: Thu, 30 Mar 2023 16:15:07 +0200 Subject: [PATCH 4/4] Update library.properties Signed-off-by: Carlo Parata --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 16bc2da4..c8a3119d 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=STM32duinoBLE -version=1.2.3 +version=1.2.4 author=Arduino, SRA maintainer=stm32duino sentence=Fork of ArduinoBLE library to add the support of STM32WB, SPBTLE-RF, SPBTLE-1S, BLUENRG-M2SP and BLUENRG-M0 BLE modules. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy