cancel
Showing results for 
Search instead for 
Did you mean: 

X-CUBE-BLE1 drivers usage in new project

Hans Meier
Associate II

Posted on June 02, 2018 at 17:29

Hello,

I am working with the X-NUCLEO-IDB05A1 BLE expansion board on the NUCLEO-L476RG board and I want to send sampled ADC values via Bluetooth LE. 

Software I use: STM32CubeMX V4.25.0, SystemWorkbench for STM32.

I successfully imported the sample project 'SensorDemo' into SW4STM32 and flashed it on the board, no problem.

But now I want to create my own project, which brings me to my limits.

My workflow is like this:

  1. initialize the used hardware in CubeMX. For example, I initialize my ADC and also the SPI interface, which is needed for communication with the BLE expansion board. For the SPI, I reverse engineered the setup used in the sample project and entered it in CubeMX. (similar to 
  2. https://community.st.com/s/question/0D50X00009XkWqn/xnucleoidb05a1-with-stm32f4discovery
  3.  )
  4. now I copy the stm32_bluenrg_ble.c/.h files from Drivers/BSP/X-NUCLEO... into my existing project in SW4STM32 and made some adjustments. For instance, I delete the SPI_Init as this was already done in CubeMX.
  5.  
  6. Middlewares are also copied into the workspace, as they contain HCI functions and so on.

Now it gets complicated. I follow the guide in UM1873 on page 16, but I run into tons of errors. By comparing with the SensorDemo example it is nearly impossible to keep track of the necessary files because each file includes many other files, some even from the SensorDemo directory. This spans out a huge net of includes and so on.

Which files/folders are used to create my own projects? It is really confusing to create own projects with the software library, as this question was asked several times in this forum. I think this cannot be so hard, as simple things like importing the sample project into an IDE or connecting the shield to the Nucleo board were explained down to the smallest detail.

As you might recognize, I am new to the SMT32. As I could not find any UMs/Blogs/Tutorials on how to work with the BLE Expansion Software, I ask here for help. Maybe my entire workflow is incorrect?

10 REPLIES 10
Antonio Vilei
Senior III
Posted on June 06, 2018 at 14:19

Dear Hans,

latest version (V4.26.0) of STM32CubeMX has introduced support for the BlueNRG-MS chip (the one used in the SPBTLE-RF module of your X-NUCLEO-IDB05A1).

BLE support has been added by means of a dedicated .pack file that you can download directly from STM32CubeMX user interface. This has been just released.

If you download V4.26.0 of the tool, you can install BLE support from the menu by clicking on

Help > Manage embedded software packages

From that window, you can then press the 'Refresh' button to get an updated list of the add-on packs. If you now go to the 'STMicrolectronics' tab, you'll find the BlueNRG-MS one, that you need to select and install.

We are currently preparing some additional documentation that I will share with you.

If you have any further questions about how to use this feature, please feel free to ask for more information here.

As you have pointed out, questions like yours have been asked several times. We took this precious feedback into account and came up with a solution to simplify the workflow that you have described.

Best regards,

Antonio
Posted on June 06, 2018 at 18:34

Please find attached a guide about how to use the BlueNRG-MS pack within STM32CubeMX.

Best regards,

Antonio

________________

Attachments :

STMicroelectronics.BlueNRG-MS_GettingStarted_2018-06-06.pdf : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HxXE&d=%2Fa%2F0X0000000azU%2FLiWa4wWRhmEPJrexQTPFCQh61qb0wRFrNtfFApjn1lo&asPdf=false
Not applicable

Hello,

I had the same problem as Hans. I tried out Antonios solution but if i include the additional softwarepackages in STM32CubeMX (I don't know which one I have to select to create a simple BLE Project without large example code) and generate the code for SW4STM32 the folling warning is displayed:

"These IPs still have some not configured or wrong parameter values:[STMicroelectronics.BlueNRG-MS.1.0.0, Verify the Plateform Settings Tab ]

Do you still want to generate code?"

I ignore this and build the project in SW4STM32. This errors are produced:

"C:/Users/ComputeCard/Documents/STM32CubeMX/Test_Leer2/Middlewares/ST/Application/BlueNRG-MS/hci/hci_tl_patterns/Basic/hci_tl.h:19:10: fatal error: hci_tl_interface.h: No such file or directory

 #include "hci_tl_interface.h"

         ^~~~~~~~~~~~~~~~~~~~

compilation terminated.

Src/subdir.mk:36: recipe for target 'Src/app_bluenrg-ms.o' failed

make: *** [Src/app_bluenrg-ms.o] Error 1"

Additionally I had to say I'm new in the STM32 and invest a lot of time to solve this problem, but I didn't find a solution.

I'm very pleased about help.

Best regards,

Tobias

Hans Meier
Associate II

Hello Tobias,

Did you get the PDF file Antonio attached in his answer? This is a guide explaining how to configure the project in STM32CubeMX. Apparently, the attachment is gone and I cannot find the document anywhere on STM website.

However, I still have that guide on my disk. I hope this is as helpful to you as it was to me 🙂

Not applicable

Dear Hans,

thanks a lot for your pdf and your help!! Now I can build with CubeMX an empty BLE project and projects with BLE examples.

Now i try to initialise an "easy" bluetooth connection with no security and co. for sending and receiving data.

In the pdf UM1873 (I attached it) on page 16 I find an example to realise a bluetooth connection. My problem is a lot of the parameters of the functions did not exist in my project. A few I can found out but many are not known. Do you know how to build up a connection?

Best regards

Tobias

Hans Meier
Associate II

I did this by building the sensor demo example with this guide and comparing every single step they have done. This way you can see what you have to include in each case. The procedure is a bit different from UM1873.

For example, the SPI is initialized in the hci_tl_interface.c file, which is included in the src/ folder. In my case I had to add some lines of code to the hci_tl_interface.c/h files. You can compare the sensor demo and your own hci_tl_interface.c in notepad++ or something.

Basically make your own sensor demo application. If it runs, throw out the code you don't need and add your own. I think I only had to rebuild the init- and SensorDemoService functions from the example.

Not applicable

I don't understand how I can connect the board with the smartphone without the sensor demo application. I want connect it to a terminal app (or something else) on the smartphone where I can see the transfered data. Is this possible?

Does I have to implement services and characteristics for only the BLE initialisation ?

Hans Meier
Associate II

To connect and test I use the nRF Connect App. There you can connect to the BlueNRG (if initialization was successful) and read / write characteristics.

Services and characteristics are usually initialized in the BLE initialization. After that you can use them for exchange of data.

Not applicable

I connected the board with the app and send data from the board to the smartphone. I work with the BlueNRG GUI and that is running. Now I want to send data from the smartphone to the board and read it. Unfortunately a error is generating. I attached a screenshot where you can see it. I think the connection handle and the attr_handle are correct. The uuid from service and characteristic are 128 bit long, so they are unique. I tried following commands but the errors are the same:

ACI_GATT_READ_CHAR_VALUE

ACI_GATT_READ_USING_CHAR_UUID

ACI_READ_HANDLE_VALUE