]> granicus.if.org Git - esp-idf/commitdiff
Component/bt: fix throughput_demo_fail
authorzhiweijian <zhiweijian@espressif.com>
Tue, 29 May 2018 12:02:54 +0000 (20:02 +0800)
committerzhiweijian <zhiweijian@espressif.com>
Wed, 30 May 2018 11:58:31 +0000 (19:58 +0800)
components/bt/bt.c
examples/bluetooth/ble_throughput/throughput_client/main/example_ble_client_throughput.c
examples/bluetooth/ble_throughput/throughput_client/sdkconfig.defaults
examples/bluetooth/ble_throughput/throughput_server/main/example_ble_server_throughput.c
examples/bluetooth/ble_throughput/throughput_server/sdkconfig.defaults

index f0640917c089e3b1033e6abe570c24cf6e774371..88a9cd71240bb07f1533e07393f224cc35442f18 100644 (file)
@@ -604,6 +604,8 @@ static bool IRAM_ATTR btdm_sleep_check_duration(uint32_t *slot_cnt)
     if (*slot_cnt < BTDM_MIN_SLEEP_DURATION) {
         return false;
     }
+    /* wake up 3 slots in advance */
+    *slot_cnt = *slot_cnt -3;
     return true;
 }
 
@@ -835,9 +837,9 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
 
     btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
     btdm_lpcycle_us = 32 << btdm_lpcycle_us_frac;
+#if CONFIG_BTDM_MODEM_SLEEP_MODE_ORIG
     bool select_src_ret = false;
     bool set_div_ret = false;
-#if CONFIG_BTDM_MODEM_SLEEP_MODE_ORIG
 #if CONFIG_BTDM_LPCLK_SEL_MAIN_XTAL
     select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL);
     set_div_ret = btdm_lpclk_set_div(rtc_clk_xtal_freq_get() * 32 - 1);
index 48b61d0d82148cab751ed1e4602c9bd4973b8cb9..fefb1236bec3cbd4bf0ce4bbf0fff0315767450d 100644 (file)
@@ -482,14 +482,16 @@ static void throughput_client_task(void *param)
     while(1) {
 #if (CONFIG_GATTS_NOTIFY_THROUGHPUT)
         vTaskDelay(2000 / portTICK_PERIOD_MS);
-        uint32_t bit_rate = 0;
-        if (start_time) {
-            current_time = esp_timer_get_time();
-            bit_rate = notify_len * SECOND_TO_USECOND / (current_time - start_time);
-            ESP_LOGI(GATTC_TAG, "Notify Bit rate = %d Btye/s, = %d bit/s, time = %ds", 
-                     bit_rate, bit_rate<<3, (int)((current_time - start_time) / SECOND_TO_USECOND));
-        } else {
-            ESP_LOGI(GATTC_TAG, "Notify Bit rate = 0 Btye/s, = 0 bit/s");
+        if(is_connecet){
+            uint32_t bit_rate = 0;
+            if (start_time) {
+                current_time = esp_timer_get_time();
+                bit_rate = notify_len * SECOND_TO_USECOND / (current_time - start_time);
+                ESP_LOGI(GATTC_TAG, "Notify Bit rate = %d Btye/s, = %d bit/s, time = %ds", 
+                        bit_rate, bit_rate<<3, (int)((current_time - start_time) / SECOND_TO_USECOND));
+            } else {
+                ESP_LOGI(GATTC_TAG, "Notify Bit rate = 0 Btye/s, = 0 bit/s");
+            }
         }
 #endif /* #if (CONFIG_GATTS_NOTIFY_THROUGHPUT) */
 #if (CONFIG_GATTC_WRITE_THROUGHPUT)        
index e4b501910faca45979db1058fa21237741635c0c..1180c12b0c1140ef4458f112899cfe7fe62be564 100644 (file)
@@ -2,3 +2,4 @@
 # by default in this example
 CONFIG_BT_ENABLED=y
 CONFIG_GATTS_NOTIFY_THROUGHPUT=y
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n
index 9bb06a579b608091cb85bd6f1033c81c0175eb54..9c1b07b66d6d95c4f8835e1561b4bca736028e6d 100644 (file)
@@ -611,7 +611,6 @@ void throughput_server_task(void *param)
     while(1) {
 #if (CONFIG_GATTS_NOTIFY_THROUGHPUT) 
         if (!can_send_notify) {
-            ESP_LOGI(GATTS_TAG, "===");
             int res = xSemaphoreTake(gatts_semaphore, portMAX_DELAY);
             assert(res == pdTRUE);
         } else {
index e4b501910faca45979db1058fa21237741635c0c..1180c12b0c1140ef4458f112899cfe7fe62be564 100644 (file)
@@ -2,3 +2,4 @@
 # by default in this example
 CONFIG_BT_ENABLED=y
 CONFIG_GATTS_NOTIFY_THROUGHPUT=y
+CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=n