Thanks guys!
The problem was in the function ble_indicate, or rather in passing parameters to it
Code: Select all
static void ble_indicate(int *value, uint8_t len, uint16_t attr_handle)
{
esp_err_t error;
system_infos.timerTime_sec = 0;
if (gatts_if_for_indicate == ESP_GATT_IF_NONE) {
printf("cannot indicate because gatts_if_for_indicate is NONE\n");
return;
}
//printf("indicate %d to gatts_if:%d\n", value[0], gatts_if_for_indicate);
uint8_t value_len = len;
uint8_t value_arr[value_len];
for (uint8_t i = 0; i < value_len; i++)
{
value_arr[i] = (uint8_t)value[i];
}
error = esp_ble_gatts_send_indicate(gatts_if_for_indicate, 0, attr_handle, value_len, value_arr, false);
if (error != ESP_OK)
{
printf("Indicate send error\n");
}
}
I called her like this:
Code: Select all
int buffer[6];
pLidarTime = system_infos.timerTime;
buffer[0] = pLidarTime >> 24;
buffer[1] = pLidarTime >> 16;
buffer[2] = pLidarTime >> 8;
buffer[3] = pLidarTime;
buffer[4] = pDistanseLidar >> 8;
buffer[5] = pDistanseLidar;
ble_indicate(buffer, sizeof(buffer), heart_rate_handle_table[IDX_CHAR_VAL_LIDAR]);
So the size of the array was not determined correctly.