cancel
Showing results for 
Search instead for 
Did you mean: 

How to integrate BlueNRG-2 in an existing application over UART?

AAnki.1
Associate II

I have a project that transmit data on BLE and the old BLE that I was using has command for all there setting and those command were sent over the UART. I was hoping if I can use BlueNRG-2 and do all the settings via UART and stream my data over android application.

Can someone please let me know if BlueNRG has this capability?

8 REPLIES 8
Sebastien DENOUAL
ST Employee

Hi @AAnki.1​ 

There is a specific code example from BlueNRg-1/-2 SDK that may answer your needs.

This code example is named "chat demo" - server config . It act as a bridge from UART to BLE (and vice versa)

> All data received on BlueNRG-2 UART is automatically push over BLE and so received on Rx characteristics by the connected smartphone.

> All data push by smartphone over a TX_characteristic are automatically push over BlueNRG-2 UART.

Hope it helps.

Regards,

Sebastien.

Hi @Sebastien DENOUAL​ 

Thank you for your reply.

I already tried this on but I found few limitation in this.

1) I am unable to receive more than 20Bytes in a message. Only receives a 20 bytes message from the phone.

2) Does get any response on the UART if BLE is connected to the phone? I get a response of "aci_gap_set_discoverable() --> SUCCESS" if I disconnect the phone with BLE, but nothing comes if devices gets connected.

Let me know if any solution possible for this.

Thanks & Regards,

Aman.

Hi,

1) 20 bytes => Yes, this is the default packet size "over the air". You can increase this value by playing with MTU size and activating Data Packet Length extension feature available on BlueNRG-2 .

Now, 20 bytes is the default size of one packet over the air but of course you are allow to send multiple packet. No issue at this point.

2) Does get any response on the UART if BLE is connected to the phone?

On this chat demo, by default choice has been done to get only "data" over UART without information message or status. You can of course modify chat demo example to implement any additional message you want to receive.

As an example, once connected, you will receive hci_le_connection_complete_event() on blueNRG-2 side. At this stage, you can add a printf over UART or send status over UART.

Regards,

Sebastien.

Hi,

Thank you so much. I will try these solutions and let you know how it goes.

Thanks again for all your help.

Regards,

Aman

Hi @Sebastien DENOUAL​ ,

I tries to increase the byte length, Hear are the step that i followed.

1) Changed Macro "CONTROLLER_DATA_LENGTH_EXTENSION_ENABLED" in stack_user_cfg.h file to 1.

2) Changed Macro "DEFAULT_ATT_MTU = 64" but data length bluenrg1_stack.h.

But still I can't sent more then 20 Bytes. Please help with any solution.

I have an application that requires sending 44 bytes at every 15mSec.

Regards,

Aman.

Hi,

I just tested default BLE chat demo (without any modification). I'm able to send/recieved more than 20bytes .

I executed the default demo on STEVAL-IDB008, UART is connected to hyperterminal on PC. I'm able to send big buffer from this hyperterm (and received on second board). Of course packet over the air are 20bytes lenght, but that's not an issue.

If you use a smartphone as receiver, you will receive many 20 bytes packet (notifications) . Packet order is guarantee by protocol so you can retrieve full data you sent.

If you use a BLE debug app such as "BLE scanner" or "NRF connect", you can check in the logs that you really received all datas.

Regards,

Sebastien.

Hi @Sebastien DENOUAL​ ,

Thanks for the suggestion.

I was using "NRF connect" and it was not sending more then 20 bytes in text mode at a time. I tried with "BLE scanner" and it worked.

I want one more thing to do If you can guide me would be great.

I am going to use BlueNRG in the DTM mode. Here are few query I have.

1) I went over the demo examples given in the BlueNRG-2 SDK and found that the code for the BlueNRG-2 to work as DTM mode. But I do not find any application on how master will be able to call these api over the UART.

2) I looked the user manual for evaluation board IDB008V2 and fount this.

3) I also looked at this https://www.st.com/resource/en/design_tip/dt0121-how-to-configure-the-bluenrg1-and-bluenrg2-devices-in-network-coprocessor-mode-stmicroelectronics.pdf link for DTM application. It has written that the source code for this host processor application is available in BlueNRG-2 SDK. Can you guide me where can I find this application code for this. The "DTM " application code available in SDK is for BlueNRG-2 not for STM32L.

If possible please guide at earliest. (I need any application that calls the BlueNRG-2 api via UART.)

Hi @AAnki.1​ ,

Despite schematics are equivalent, using DTM (network processor) instead of "Chat demo/SPP like" is a different philosophy :) .

Indeed, it has a more important impact on host microcontroller side as with DTM BLE application is now running on host µC. But you don't need to manage anymore BlueNRg-2 fw (just reuse prebuilt DTM binaries)

I confirm the DTM code available in SDK is dedicated for BlueNRG-2 side => DTM (network processor mode).

On STM32 side, main SW package is X-CUBE-BLE2 , this expansion pack is compatible with STM32CubeMx and you can easily generate code for your specific STM32 (host side).

Anyway, this SW package intend to be used with DTM over SPI (not UART).

Using SPI for DTM is more common in network processor architecture (HOST µC + BlueNRG-2 network processor). DTM SPI integrates sleep mode management and so a much lower power consumption on BlueNRG-2 side.

Of course, this X-CUBE-BLE2 package can be adapted for UART (transport layer modification replacing SPI by UART) .

Note : inside BlueNRG-2 SDK, there is also some network processor code example (host side) for STM32L476 :

. ..\BlueNRG-1_2 DK 3.2.1\Project\STM32L\...

Regards,

Sebastien.