From d2e5ac4b7427c376b61d828591c92839e95beed7 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sun, 28 Jan 2024 20:38:41 +0100 Subject: [PATCH] fix right request data for set option --- src/kds_s2000w_handler.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/kds_s2000w_handler.c b/src/kds_s2000w_handler.c index 9ea8c54..5b28681 100644 --- a/src/kds_s2000w_handler.c +++ b/src/kds_s2000w_handler.c @@ -310,14 +310,15 @@ void kds_s2000w_handler_set_option(int option, void* value) break; } - // TODO: send request - // const char* json_string = json_object_to_json_string_ext(resObj, JSON_C_TO_STRING_PLAIN); - // resp = kds_s2000w_client_response_init(); - // resp->data = (char*) json_string; - // resp->size = sizeof(char) * strlen(json_string); - // resp->code = 0; - // kds_s2000w_client_set_option(state->sessionid, resp); - // kds_s2000w_client_response_free(resp); + const char* json_string = json_object_to_json_string_ext(resObj, JSON_C_TO_STRING_PLAIN); + resp = kds_s2000w_client_response_init(); + resp->size = sizeof(char) * strlen(json_string); + resp->code = 0; + resp->data = realloc(resp->data, resp->size); + resp->data = memcpy(resp->data, json_string, resp->size); + kds_s2000w_client_set_option(state->sessionid, resp); + kds_s2000w_client_response_free(resp); + resp = NULL; } void kds_s2000w_handler_set_option_auto(int option) -- 2.39.5