From d90b7274fa8bbfa09f79660b45b550d91f7b0125 Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Tue, 2 Feb 2021 22:09:00 +0100 Subject: Update to nimble 1.3 master branch commit 82153e744833821e20e9a8b0d61c38b2b0dbcfe1 WARNING : heartbeat task is disabled! --- .../mynewt-nimble/apps/blestress/src/rx_stress.c | 19 ++++++++----------- src/libs/mynewt-nimble/apps/blestress/src/stress.c | 7 +++++-- src/libs/mynewt-nimble/apps/blestress/src/stress.h | 3 ++- .../mynewt-nimble/apps/blestress/src/tx_stress.c | 22 +++++++++++----------- 4 files changed, 26 insertions(+), 25 deletions(-) (limited to 'src/libs/mynewt-nimble/apps/blestress') diff --git a/src/libs/mynewt-nimble/apps/blestress/src/rx_stress.c b/src/libs/mynewt-nimble/apps/blestress/src/rx_stress.c index a4253ce6..440966ad 100644 --- a/src/libs/mynewt-nimble/apps/blestress/src/rx_stress.c +++ b/src/libs/mynewt-nimble/apps/blestress/src/rx_stress.c @@ -837,14 +837,6 @@ rx_stress_10_l2cap_event(struct ble_l2cap_event *event, void *arg) MODLOG_DFLT(INFO, "Data buf %s\n", data_buf ? "OK" : "NOK"); assert(data_buf != NULL); - /* The first 2 bytes of data is the size of appended pattern data. */ - rc = os_mbuf_append(data_buf, (uint8_t[]) {data_len >> 8, data_len}, - 2); - if (rc) { - os_mbuf_free_chain(data_buf); - assert(0); - } - /* Fill mbuf with the pattern */ stress_fill_mbuf_with_pattern(data_buf, data_len); @@ -852,8 +844,13 @@ rx_stress_10_l2cap_event(struct ble_l2cap_event *event, void *arg) rc = ble_l2cap_send(rx_stress_ctx->chan, data_buf); MODLOG_DFLT(INFO, "Return code=%d\n", rc); if (rc) { - MODLOG_DFLT(INFO, "L2CAP stalled - waiting\n"); - stalled = true; + if (rc == BLE_HS_ESTALLED) { + MODLOG_DFLT(INFO, "L2CAP stalled - waiting\n"); + stalled = true; + } else { + MODLOG_DFLT(INFO, "Sending data via L2CAP failed with error " + "code %d\n", rc); + } } MODLOG_DFLT(INFO, " %d, %d\n", ++send_cnt, data_len); @@ -1365,7 +1362,7 @@ rx_stress_start(int test_num) break; case 10: console_printf("Stress L2CAP send\033[0m\n"); - rc = ble_l2cap_create_server(1, STRESS_COC_MTU, + rc = ble_l2cap_create_server(TEST_PSM, STRESS_COC_MTU, rx_stress_10_l2cap_event, NULL); assert(rc == 0); rx_stress_simple_adv(&rx_stress_adv_sets[10]); diff --git a/src/libs/mynewt-nimble/apps/blestress/src/stress.c b/src/libs/mynewt-nimble/apps/blestress/src/stress.c index 6f5badf0..1bdbafa9 100644 --- a/src/libs/mynewt-nimble/apps/blestress/src/stress.c +++ b/src/libs/mynewt-nimble/apps/blestress/src/stress.c @@ -19,6 +19,8 @@ #include "stress.h" +static struct os_callout stress_timer_callout; + void com_stress_print_report(const struct com_stress_test_ctx *test_ctxs) { @@ -119,7 +121,7 @@ stress_fill_mbuf_with_pattern(struct os_mbuf *om, uint16_t len) rest = len % STRESS_PAT_LEN; for (i = 0; i < mul; ++i) { - rc = os_mbuf_append(om, &test_6_pattern[29], STRESS_PAT_LEN); + rc = os_mbuf_append(om, &test_6_pattern[0], STRESS_PAT_LEN); if (rc) { os_mbuf_free_chain(om); @@ -127,7 +129,7 @@ stress_fill_mbuf_with_pattern(struct os_mbuf *om, uint16_t len) } } - rc = os_mbuf_append(om, &test_6_pattern[29], rest); + rc = os_mbuf_append(om, &test_6_pattern[0], rest); if (rc) { os_mbuf_free_chain(om); @@ -176,6 +178,7 @@ void stress_start_timer(uint32_t timeout_ms, os_event_fn *ev_cb) { int rc; + os_callout_stop(&stress_timer_callout); os_callout_init(&stress_timer_callout, os_eventq_dflt_get(), ev_cb, NULL); diff --git a/src/libs/mynewt-nimble/apps/blestress/src/stress.h b/src/libs/mynewt-nimble/apps/blestress/src/stress.h index 91ab4f47..db4fbb36 100644 --- a/src/libs/mynewt-nimble/apps/blestress/src/stress.h +++ b/src/libs/mynewt-nimble/apps/blestress/src/stress.h @@ -44,8 +44,9 @@ extern "C" { #define STRESS_FIND_SRV 1 #define STRESS_FIND_CHR 2 #define STRESS_FIND_DSC 3 +/* L2CAP PSM */ +#define TEST_PSM 0x80 -struct os_callout stress_timer_callout; struct stress_gatt_search_ctx; typedef void stress_gatt_disc_end_fn(struct stress_gatt_search_ctx *search_ctx); diff --git a/src/libs/mynewt-nimble/apps/blestress/src/tx_stress.c b/src/libs/mynewt-nimble/apps/blestress/src/tx_stress.c index b73adc8a..4416c568 100644 --- a/src/libs/mynewt-nimble/apps/blestress/src/tx_stress.c +++ b/src/libs/mynewt-nimble/apps/blestress/src/tx_stress.c @@ -1127,7 +1127,7 @@ tx_stress_10_gap_event(struct ble_gap_event *event, void *arg) assert(sdu_rx != NULL); tx_stress_ctx->conn_handle = event->connect.conn_handle; - rc = ble_l2cap_connect(event->connect.conn_handle, 1, + rc = ble_l2cap_connect(event->connect.conn_handle, TEST_PSM, STRESS_COC_MTU, sdu_rx, tx_stress_10_l2cap_event, NULL); assert(rc == 0); @@ -1292,17 +1292,16 @@ tx_stress_14_subs_cb(uint16_t conn_handle, const struct ble_gatt_error *error, assert(error->status == 0); /* If the first subscription after finding cccd */ - if(arg == NULL) { + if (arg == NULL) { return 0; } - sub = (bool*)arg; + sub = (bool *)arg; /* Enable notifications */ - if(*sub == 0) { + if (*sub == 0) { *sub = true; - om = ble_hs_mbuf_from_flat( - (uint8_t[]) {0x01, 0x00}, 2); + om = ble_hs_mbuf_from_flat((uint8_t[]) {0x01, 0x00}, 2); tx_stress_ctx->begin_us = tx_stress_ctx->end_us; @@ -1415,7 +1414,7 @@ tx_stress_14_gap_event(struct ble_gap_event *event, void *arg) static int tx_stress_15_write_cb(uint16_t conn_handle, const struct ble_gatt_error *error, - struct ble_gatt_attr *attr, void *arg) + struct ble_gatt_attr *attr, void *arg) { /* Disconnect */ ble_gap_terminate(conn_handle, BLE_ERR_REM_USER_CONN_TERM); @@ -1464,7 +1463,7 @@ tx_stress_15_gap_event(struct ble_gap_event *event, void *arg) case BLE_GAP_EVENT_DISCONNECT: /* Perform use case specified number of times */ - if(tx_stress_ctx->con_stat[15].num >= MYNEWT_VAL(BLE_STRESS_REPEAT)) { + if (tx_stress_ctx->con_stat[15].num >= MYNEWT_VAL(BLE_STRESS_REPEAT)) { tx_stress_on_test_finish(15); return 0; } @@ -1473,7 +1472,7 @@ tx_stress_15_gap_event(struct ble_gap_event *event, void *arg) return 0; default: - MODLOG_DFLT(INFO, "Other event occurs=%d\n", event->type); + MODLOG_DFLT(INFO, "Other event occurs=%d\n", event->type); return 0; } } @@ -1607,7 +1606,8 @@ tx_stress_test_perform(int test_num) } static void -tx_stress_read_command_cb(void) { +tx_stress_read_command_cb(void) +{ console_printf("Start testing\n"); os_sem_release(&tx_stress_main_sem); } @@ -1642,7 +1642,7 @@ tx_stress_main_task_fn(void *arg) /* Wait for the scan to find the test. Then 1 token will be * released allowing to pass through semaphore. */ os_sem_pend(&tx_stress_main_sem, OS_TIMEOUT_NEVER); - if(tx_stress_ctx->scan_timeout) { + if (tx_stress_ctx->scan_timeout) { break; } -- cgit v1.2.3