Skip to content

Commit cd00787

Browse files
committed
bt_app_spp: add FW+VER? response string
1 parent 0184285 commit cd00787

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

main/src/user/bt_app_spp.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ static const char rsp_str[][24] = {
4949
"OK\r\n", // OK
5050
"DONE\r\n", // Done
5151
"ERROR\r\n", // Error
52+
"VER:%s\r\n", // Version String
5253
"RECV:%ld/%ld\r\n" // Receive Progress
5354
};
5455

@@ -96,13 +97,9 @@ void bt_app_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
9697
} else if (strncmp(fw_cmd[1], (const char *)param->data_ind.data, strlen(fw_cmd[1])) == 0) {
9798
ESP_LOGI(BT_SPP_TAG, "GET command: FW+VER?");
9899

99-
uint8_t str_len = strlen(firmware_get_version()) + 2;
100-
char *str_buf = malloc(str_len * sizeof(char));
101-
strncpy(str_buf, firmware_get_version(), str_len - 2);
102-
str_buf[str_len - 2] = '\r';
103-
str_buf[str_len - 1] = '\n';
104-
105-
esp_spp_write(param->write.handle, str_len, (uint8_t *)str_buf);
100+
char str_buf[24] = {0};
101+
snprintf(str_buf, sizeof(str_buf), rsp_str[3], firmware_get_version());
102+
esp_spp_write(param->write.handle, strlen(str_buf), (uint8_t *)str_buf);
106103
} else if (strncmp(fw_cmd[2], (const char *)param->data_ind.data, 7) == 0) {
107104
sscanf((const char *)param->data_ind.data, fw_cmd[2], &image_length);
108105
ESP_LOGI(BT_SPP_TAG, "GET command: FW+UPD:%ld", image_length);
@@ -141,7 +138,7 @@ void bt_app_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
141138
ESP_LOGD(BT_OTA_TAG, "have written image length %ld", data_num);
142139

143140
char str_buf[24] = {0};
144-
snprintf(str_buf, sizeof(str_buf), rsp_str[3], data_num, image_length);
141+
snprintf(str_buf, sizeof(str_buf), rsp_str[4], data_num, image_length);
145142
esp_spp_write(param->write.handle, strlen(str_buf), (uint8_t *)str_buf);
146143

147144
if (data_num == image_length) {

0 commit comments

Comments
 (0)