cancel
Showing results for 
Search instead for 
Did you mean: 

BlueNRG - How to write my own application

giucax
Associate
Posted on April 01, 2015 at 10:58

Hi, I have the STM32 Nucleo and the X-NUCLEO-IDB04A1 Bluetooth low energy expansion board. I'm using the X-CUBE-BLE1 software package.

My question is how to write my own application that receives characters sent via Bluetooth by a PC (or a common cell phone application)?

#x_nucleo-idb04a1 #bluenrg
3 REPLIES 3
Antonio Vilei
Senior III
Posted on April 07, 2015 at 11:14

Hi,

you can do that by using the SampleApp application:

X-CUBE-BLE1\Projects\Multi\Applications\SampleApp

This application allows you to send and receive an arbitrary array of characters when you press the user button on the STM32 Nucleo board. The default data is {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J'} and you can change it in the User_Process() function in Src\main.c file.

In particular, to see how the data exchange is implemented, please take a look at the receiveData() and sendData() functions in the Src\sample_service.c file.

For more details about SampleApp please refer to its readme.txt file.

Best regards,

Antonio

giucax
Associate
Posted on April 08, 2015 at 10:36

Thanks for your answer Antonio.

I have one more question. I was able to send to my cell phone app a string  using the function sendData().

My doubts are about the function receiveData():

void receiveData(uint8_t* data_buffer, uint8_t Nb_bytes)

{

  BSP_LED_Toggle(LED2);

  for(int i = 0; i < Nb_bytes; i++) {

    PRINTF(''%c'', data_buffer[i]);

  }

}

How this databuffer is received?

Best Regards,

Giuseppe

Andrea Palmieri
ST Employee
Posted on April 08, 2015 at 14:45

Hi Giuseppe,

the receiveData() is triggered depending on the role of the BTLE device.

If the device is configured as a Server, data_buffer is received once the Client device has written the characteristic descriptor by invoking aci_gatt_write_without_response().

If the the device is configured as a Client, data_buffer is received when the Server device updates the characteristic by invoking aci_gatt_update_char_value() and thus the Client gets notified.

Best regards,

Andrea