Merge branch 'nimble/add_throughput_example_v4.3' into 'release/v4.3'

NimBLE throughput example: Changed write api to write without response

See merge request espressif/esp-idf!16124
This commit is contained in:
Isha Pardikar 2021-10-05 16:06:20 +05:30 committed by isha pardikar
parent 6f9e611725
commit fcd5e502a7
12 changed files with 41 additions and 178 deletions

View File

@ -9,8 +9,8 @@ sample numbers of different throughput test runs for 60 seconds (MTU = 512, conn
|GATT method | Measurement time | Application Throughput|
|--- | --- | ---|
|NOTIFY | 60 seconds | ~530Kbps|
|READ | 60 seconds | ~180kbps|
|WRITE | 60 seconds | ~180kbps|
|NOTIFY | 60 seconds | ~340Kbps|
|READ | 60 seconds | ~200kbps|
|WRITE | 60 seconds | ~500kbps|
The notify output is seen on `bleprph_throughput` console and read/write throughput are seen on `blecent_throughput` console.

View File

@ -1,10 +1,7 @@
/* Console example — various system commands
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdio.h>

View File

@ -1,11 +1,9 @@
/* Console example — various system commands
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#ifdef __cplusplus

View File

@ -37,7 +37,7 @@ menu "Example Configuration"
Set the minimum connection event length in 0.625msec units.
config EXAMPLE_CONN_CE_LEN_MAX
int "Minimum connection itvl"
int "Maximum connection event length"
default 12
help
Set the maximum connection event length in 0.625msec units.

View File

@ -1,22 +1,7 @@
/*
* // Modifications Copyright 2020-2021 Espressif Systems (Shanghai) CO., LTD.
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef H_BLECENT_

View File

@ -1,22 +1,7 @@
/*
* Copyright 2020 Espressif Systems (Shanghai) PTE LTD
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* SPDX-License-Identifier: Apache-2.0
*/
#include "esp_log.h"
@ -117,26 +102,8 @@ err:
return ble_gap_terminate(peer->conn_handle, BLE_ERR_REM_USER_CONN_TERM);
}
static int
blecent_repeat_write(uint16_t conn_handle,
const struct ble_gatt_error *error,
struct ble_gatt_attr *attr,
void *arg)
{
if (error->status == 0) {
xSemaphoreGive(xSemaphore);
ESP_LOGD(tag, " attr_handle=%d value=", attr->handle);
MODLOG_DFLT(INFO, "\n");
} else {
failure_count++;
xSemaphoreGive(xSemaphore);
ESP_LOGE(tag, " Error writing error code = %d", error->status);
}
return error->status;
}
static int blecent_write(uint16_t conn_handle, uint16_t val_handle,
ble_gatt_attr_fn *cb, struct peer *peer, int test_time)
struct peer *peer, int test_time)
{
int64_t start_time, end_time, write_time = 0;
int write_count = 0;
@ -150,13 +117,16 @@ static int blecent_write(uint16_t conn_handle, uint16_t val_handle,
while (write_time < test_time * 1000) {
/* Wait till the previous write is complete. For first time Semaphore
* is already available */
xSemaphoreTake(xSemaphore, portMAX_DELAY);
rc = ble_gattc_write_flat(conn_handle, val_handle,
&value, sizeof value, blecent_repeat_write, NULL);
if (rc != 0) {
ESP_LOGE(tag, "Error: Failed to write characteristic; rc=%d\n",
rc);
goto err;
label:
rc = ble_gattc_write_no_rsp_flat(conn_handle, val_handle, &value, sizeof value);
if(rc == BLE_HS_ENOMEM) {
vTaskDelay(2); /* Wait for buffers to free up and try again */
goto label;
}
else if (rc != 0) {
ESP_LOGE(tag, "Error: Failed to write characteristic; rc=%d\n",rc);
goto err;
}
end_time = esp_timer_get_time();
@ -311,8 +281,7 @@ static void throughput_task(void *arg)
}
if (test_data[1] > 0) {
rc = blecent_write(peer->conn_handle, chr->chr.val_handle,
blecent_repeat_write, (void *) peer, test_data[1]);
rc = blecent_write(peer->conn_handle, chr->chr.val_handle, (void *) peer, test_data[1]);
if (rc != 0) {
ESP_LOGE(tag, "Error while writing data; rc = %d", rc);
}

View File

@ -1,20 +1,7 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* SPDX-License-Identifier: Apache-2.0
*/
#include <assert.h>

View File

@ -1,20 +1,7 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* SPDX-License-Identifier: Apache-2.0
*/
#include <assert.h>

View File

@ -1,22 +1,7 @@
/*
* Copyright 2020 Espressif Systems (Shanghai) PTE LTD
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdio.h>

View File

@ -1,22 +1,7 @@
/*
* Copyright 2020-2021 Espressif Systems (Shanghai) PTE LTD
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* SPDX-License-Identifier: Apache-2.0
*/
#include <assert.h>

View File

@ -1,22 +1,7 @@
/*
* Copyright 2020-21 Espressif Systems (Shanghai) PTE LTD
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef H_GATTS_SENS_

View File

@ -1,22 +1,7 @@
/*
* Copyright 2020 Espressif Systems (Shanghai) PTE LTD
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* SPDX-License-Identifier: Apache-2.0
*/
#include "esp_log.h"