cancel
Showing results for 
Search instead for 
Did you mean: 

How to have a READABLE Characteristic to a BlueNRG-M2SP

PCong.1
Associate II

I try to read the data from BlueNRG-M2SP on an android application. For that with my STM32 I send to the UART a "u". On the application, I scan the services and Characteristic and I only find a write Characteristic but no read Characteristic, and I can't find in the documentation (https://www.st.com/resource/en/programming_manual/dm00294449-bluenrg-1-bluenrg-2-ble-stack-v2-x-programming-guidelines-stmicroelectronics.pdf ) how to have a read Characteristic on the custome service.0693W00000KdNpAQAV.png 

i use the code exemple BLE chat Server that can find on the BlueNRG-1 Navigator

0693W00000KdNolQAF.pngOn the code exemple i find some UUID but that doesn't work when i try to read data from the STM32

13 REPLIES 13

That environment looks the same as a STEVAL-IDB008 EVB acts as a Chat server, where the BlueNRG-2 is connected to the onboard STM32L thru UART pin8 and pin11.

With an EVB, the STM32 serves as an USB to UART bridge, to receive messages from the USB virtual terminal and forward to BlueNRG-2 with UART.

The project works for an EVB. Confirm that '\r\n' is required without modification.

So, i suppose if you did not modify UART codes for BlueNRG-2, the issue could be on your Host uC.

Could you doubly check if the string was really transmitted over UART? by sniffing UART for example.

Regarding to your codes:

int a = 10; 
HAL_UART_Transmit_IT(&hlpuart1, (a, '\r\n') , sizeof((a, '\r\n')));

For the 2nd and 3rd parameter given to HAL_UART_Transmit_IT, I am not quite understand the syntax that joins an integer a and a string (or a character) '\r\n' ?

Regarding to the question,

> And what should I change in the attribute?

Change to whatever is sent from your Host uC. Isn't this what you were trying to do?

I checked 4 times to make sure the string was transmitted and the string is sent.

About the code, I tried to do like the printf function which can turn an int into a string and put end characters

int a = 10;
printf("%d\r\n", a);

, but I found how to do it, I created a function int_to_char.

Regarding to the question,

> And what should I change in the attribute?

>>Change to whatever is sent from your Host uC. Isn't this what you were trying to do?

Yes, but I don't know what parameter I need to change inside. 

aci_gatt_update_char_value_ext(connection_handle, chatServHandle , TXCharHandle, 1, 6, 0, 6, &buff);

>Yes, but I don't know what parameter I need to change inside. 

Depending on your application, fill parameters accordingly, usually Char_Length, Value, and Value_Length.

From the function name of your codes, i guess that you need to fill Value with sensor data.

abach.1
Associate II

hello, did it work finally, if so can you please share the code with me to know how it works

Many thanks

Anas