2015-04-01 01:58 AM
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 #bluenrg2015-04-07 02:14 AM
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, Antonio2015-04-08 01:36 AM
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,Giuseppe2015-04-08 05:45 AM
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