Skip to content

Commit

Permalink
#85: return dummy status if process has not started
Browse files Browse the repository at this point in the history
  • Loading branch information
alvieboy committed Jun 26, 2021
1 parent 9f8fca0 commit bd3e4f8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions esp32/main/firmware_ws.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,21 @@ int firmware_ws__read(struct firmware_ws_context *ctx, void *buf, size_t size, b

#ifdef WS_STATUS_ONLY_ON_REQUEST

static const char *emptystatus = "{\"percent\":0,\"phase\":\"Not started\"}";

static int firmware_ws__send_status(struct firmware_ws_context *ctx, httpd_req_t *req)
{
char str[256];
char *ptr = str;
bool delim = false;
int r = 0;

// If process has not started, return a dummy status
if (!ctx) {
firmware_ws__send_text_frame(req, emptystatus, __builtin_strlen(emptystatus));
return 0;
}

// Prepare text to be sent.
semaphore__take(ctx->sem, OS_MAX_DELAY);

Expand Down

0 comments on commit bd3e4f8

Please sign in to comment.