refactor(printer): remove BLE backend and dependencies
This commit is contained in:
@@ -9,8 +9,6 @@
|
||||
|
||||
static const char *printer_backend_str(printer_backend_t backend) {
|
||||
switch (backend) {
|
||||
case PRINTER_BACKEND_BLE:
|
||||
return "ble";
|
||||
case PRINTER_BACKEND_DIRECT:
|
||||
return "direct";
|
||||
default:
|
||||
@@ -26,10 +24,6 @@ static bool parse_printer_backend(const cJSON *json, printer_backend_t *out_back
|
||||
if (!cJSON_IsString(jbackend) || jbackend->valuestring == NULL) {
|
||||
return false;
|
||||
}
|
||||
if (strcasecmp(jbackend->valuestring, "ble") == 0) {
|
||||
*out_backend = PRINTER_BACKEND_BLE;
|
||||
return true;
|
||||
}
|
||||
if (strcasecmp(jbackend->valuestring, "direct") == 0) {
|
||||
*out_backend = PRINTER_BACKEND_DIRECT;
|
||||
return true;
|
||||
@@ -87,8 +81,6 @@ static void fill_runtime_json(cJSON *root) {
|
||||
cJSON_AddStringToObject(root, "printer_backend", printer_backend_str(st.backend));
|
||||
cJSON_AddBoolToObject(root, "printer_connected", st.connected);
|
||||
cJSON_AddBoolToObject(root, "printer_transport_ready", st.transport_ready);
|
||||
cJSON_AddBoolToObject(root, "ble_connected", st.backend == PRINTER_BACKEND_BLE && st.connected);
|
||||
cJSON_AddBoolToObject(root, "ble_notify_ready", st.backend == PRINTER_BACKEND_BLE && st.notify_ready);
|
||||
cJSON_AddBoolToObject(root, "printer_busy", st.busy);
|
||||
cJSON_AddBoolToObject(root, "has_paper", st.has_paper);
|
||||
cJSON_AddNumberToObject(root, "paper_gpio_level", st.paper_gpio_level);
|
||||
@@ -99,7 +91,6 @@ static void fill_runtime_json(cJSON *root) {
|
||||
cJSON_AddBoolToObject(root, "supports_label_offset", st.supports_label_offset);
|
||||
cJSON_AddBoolToObject(root, "supports_ota", st.supports_ota);
|
||||
cJSON_AddNumberToObject(root, "queue_depth", st.queue_depth);
|
||||
cJSON_AddNumberToObject(root, "mtu", st.mtu);
|
||||
cJSON_AddNumberToObject(root, "last_status_ms", (double)st.last_status_ms);
|
||||
|
||||
voice_interaction_status_t voice = {0};
|
||||
@@ -153,7 +144,6 @@ esp_err_t rest_server_connect_post(httpd_req_t *req) {
|
||||
}
|
||||
|
||||
char *body = NULL;
|
||||
char name[32] = "TQPrinter";
|
||||
uint32_t timeout_ms = domain_policy_rest_printer_connect_timeout_ms();
|
||||
printer_backend_t backend = printer_protocol_get_backend();
|
||||
bool backend_specified = false;
|
||||
@@ -170,11 +160,6 @@ esp_err_t rest_server_connect_post(httpd_req_t *req) {
|
||||
return rest_server_send_error(req, "400 Bad Request", "invalid json");
|
||||
}
|
||||
|
||||
cJSON *jname = cJSON_GetObjectItemCaseSensitive(json, "name");
|
||||
if (cJSON_IsString(jname) && jname->valuestring != NULL) {
|
||||
strlcpy(name, jname->valuestring, sizeof(name));
|
||||
}
|
||||
|
||||
cJSON *jtimeout = cJSON_GetObjectItemCaseSensitive(json, "timeout_ms");
|
||||
if (cJSON_IsNumber(jtimeout)) {
|
||||
uint32_t min_ms = domain_policy_rest_printer_connect_timeout_min_ms();
|
||||
@@ -194,7 +179,7 @@ esp_err_t rest_server_connect_post(httpd_req_t *req) {
|
||||
if (!parse_printer_backend(json, &backend)) {
|
||||
cJSON_Delete(json);
|
||||
free(body);
|
||||
return rest_server_send_error(req, "400 Bad Request", "backend must be ble or direct");
|
||||
return rest_server_send_error(req, "400 Bad Request", "backend must be direct");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +189,7 @@ esp_err_t rest_server_connect_post(httpd_req_t *req) {
|
||||
|
||||
printer_connect_options_t opt = {
|
||||
.backend = backend,
|
||||
.name = backend == PRINTER_BACKEND_BLE ? name : NULL,
|
||||
.name = NULL,
|
||||
.timeout_ms = timeout_ms,
|
||||
};
|
||||
char connect_err[96] = {0};
|
||||
|
||||
Reference in New Issue
Block a user