From 2b68d05efb9dd394a3afcf8168a2de044139a2a3 Mon Sep 17 00:00:00 2001 From: zwsd Date: Fri, 5 Aug 2022 15:27:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=8C=89=E9=94=AE=E6=8C=89?= =?UTF-8?q?=E4=B8=8B=E8=93=9D=E7=89=99=E5=8F=91=E9=80=81=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9A=84=E7=89=B9=E5=BE=81=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/ble_spp_client_demo.c | 8 ++++---- main/ble_spp_client_demo.h | 2 +- main/key.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/main/ble_spp_client_demo.c b/main/ble_spp_client_demo.c index 3f64e82..7c6f16d 100644 --- a/main/ble_spp_client_demo.c +++ b/main/ble_spp_client_demo.c @@ -602,7 +602,7 @@ void uart_task(void *pvParameters) { // Event of UART receving data case UART_DATA: - if (event.size && (is_connect == true) && (db != NULL) && ((db + SPP_IDX_SPP_COMMAND_VAL)->properties & (ESP_GATT_CHAR_PROP_BIT_WRITE_NR | ESP_GATT_CHAR_PROP_BIT_WRITE))) + if (event.size && (is_connect == true) && (db != NULL) && ((db + SPP_IDX_SPP_DATA_RECV_VAL)->properties & (ESP_GATT_CHAR_PROP_BIT_WRITE_NR | ESP_GATT_CHAR_PROP_BIT_WRITE))) { uint8_t *temp = NULL; temp = (uint8_t *)malloc(sizeof(uint8_t) * event.size); @@ -615,7 +615,7 @@ void uart_task(void *pvParameters) uart_read_bytes(UART_NUM_0, temp, event.size, portMAX_DELAY); esp_ble_gattc_write_char(spp_gattc_if, spp_conn_id, - (db + SPP_IDX_SPP_COMMAND_VAL)->attribute_handle, + (db + SPP_IDX_SPP_DATA_RECV_VAL)->attribute_handle, event.size, temp, ESP_GATT_WRITE_TYPE_RSP, @@ -695,11 +695,11 @@ void ble_init() void ble_key_cb(char* string) { - if ((is_connect == true) && (db != NULL) && ((db + SPP_IDX_SPP_COMMAND_VAL)->properties & (ESP_GATT_CHAR_PROP_BIT_WRITE_NR | ESP_GATT_CHAR_PROP_BIT_WRITE))) + if ((is_connect == true) && (db != NULL) && ((db + SPP_IDX_SPP_DATA_RECV_VAL)->properties & (ESP_GATT_CHAR_PROP_BIT_WRITE_NR | ESP_GATT_CHAR_PROP_BIT_WRITE))) { esp_ble_gattc_write_char(spp_gattc_if, spp_conn_id, - (db + SPP_IDX_SPP_COMMAND_VAL)->attribute_handle, + (db + SPP_IDX_SPP_DATA_RECV_VAL)->attribute_handle, strlen(string), (uint8_t *)string, ESP_GATT_WRITE_TYPE_RSP, diff --git a/main/ble_spp_client_demo.h b/main/ble_spp_client_demo.h index d034d7b..0f0363f 100644 --- a/main/ble_spp_client_demo.h +++ b/main/ble_spp_client_demo.h @@ -22,7 +22,7 @@ enum SPP_IDX_SPP_DATA_RECV_VAL, - SPP_IDX_SPP_COMMAND_VAL, + // SPP_IDX_SPP_COMMAND_VAL, #ifdef SUPPORT_HEARTBEAT SPP_IDX_SPP_HEARTBEAT_VAL, diff --git a/main/key.c b/main/key.c index 0166261..3bee427 100644 --- a/main/key.c +++ b/main/key.c @@ -26,7 +26,7 @@ void key_schedule() while (gpio_get_level(KEY_REC) == 0) { } - s_ble_key_cb("setPosition180"); + s_ble_key_cb("{ \"order\": \"setPosition\", \"index\": 0, \"speedLevel\": 0, \"position\": 180, \"direction\": 1 }"); ESP_LOGI("Finny", "stop"); } if (gpio_get_level(KEY_MODE) == 0) @@ -36,7 +36,7 @@ void key_schedule() while (gpio_get_level(KEY_MODE) == 0) { } - s_ble_key_cb("setPosition360"); + s_ble_key_cb("{ \"order\": \"setPosition\", \"index\": 0, \"speedLevel\": 0, \"position\": 360, \"direction\": 1 }"); ESP_LOGI("Finny", "stop"); } }