cancel
Showing results for 
Search instead for 
Did you mean: 

stm32wb55: Read characteristic value in BLE application

sound
Associate

I have established BLE advertisement and connection is established successfully between ST BLE toolbox and the stm32wb55 based board.

I am unable to read the chateristic value from the st ble tool box.

My code is 

in custom_app.c   file

I2C_HandleTypeDef hi2c1;
          int sizecharwrite;
              uint8_t my_value =5;
              float adc_voltage_ble = ADS1115_readSingleEnded_AIN0(&hi2c1);

              uint8_t  pPayload;
              sizecharwrite=snprintf( ble_voltage,sizeof(ble_voltage),"%0.2f", adc_voltage_ble );

              if (sizecharwrite < 0 || sizecharwrite >= sizeof(ble_voltage)) {
                      // Error or truncation
                      return;
                  }
              memcpy(pPayload,&ble_voltage, sizeof(ble_voltage));
 
In the cutom_stm.c    file
      aci_gatt_update_char_value(CustomChemdetectHdle,
                                             CustomCharwriteHdle,
                                             0, /* charValOffset */
                                             SizeCharwrite, /* charValueLen */
                                             (uint8_t )  pPayload);

Edited to apply source code formatting - please see How to insert source code for future reference.

1 REPLY 1
Imen.D
ST Employee

Hello @sound,

Ensure the characteristic is configured with the 'Read' property and correct permissions. 

You can follow the guidelines in the ST wiki articles: 

I advise you to monitor the debug Output logs for errors during characteristic read requests.

 

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen