aboutsummaryrefslogtreecommitdiff
path: root/stm32f091/protocol.c
diff options
context:
space:
mode:
Diffstat (limited to 'stm32f091/protocol.c')
-rw-r--r--stm32f091/protocol.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/stm32f091/protocol.c b/stm32f091/protocol.c
index 589ee5d..3a8d78b 100644
--- a/stm32f091/protocol.c
+++ b/stm32f091/protocol.c
@@ -3,6 +3,8 @@
#include "../shared/protocol.h"
#include "backlog.h"
#include "util.h"
+#include "server.h"
+#include "esp8266.h"
void ws_protocol_res_last_records(ws_s_protocol_parsed_req_cmd* parsed_cmd, ws_s_protocol_res* response, bool send) {
static unsigned int record_amount = 0;
@@ -16,6 +18,7 @@ void ws_protocol_res_last_records(ws_s_protocol_parsed_req_cmd* parsed_cmd, ws_s
response->csh = true;
response->msg = ws_bin_s_alloc(0);
response->msg->bytes = strlen(response_header) + response_line_size * record_amount;
+ ws_server_req_respond_start(0, response->msg->bytes + ws_protocol_get_header_size(response));
} else {
ws_protocol_send_data(response_header, strlen(response_header));
char line[response_line_size + 1]; // +1 for null terminator -> sprintf
@@ -24,10 +27,11 @@ void ws_protocol_res_last_records(ws_s_protocol_parsed_req_cmd* parsed_cmd, ws_s
sprintf(line, "%04x,%02x,%02x,%02x\n", record->id, record->sens_temperature, record->sens_humidity, record->sens_atm_pressure);
ws_protocol_send_data(line, response_line_size);
}
+ ws_protocol_send_data("\r\n", 2); // test
}
}
void ws_protocol_send_data(const char* data, unsigned int length) {
- //TODO: implement on esp data channels
- HAL_UART_Transmit(&huart2, (uint8_t*) data, length, HAL_MAX_DELAY);
+ ws_server_buffer_send_append((uint8_t*) data, length);
+ // HAL_UART_Transmit(&huart1, (uint8_t*) data, length, HAL_MAX_DELAY);
}