* # License
* Copyright 2019 Silicon Laboratories Inc.
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
#include "gos.h"
#include "common.h"
extern bool led_value;
* This handles a standard GET request
* GET http://<domain>/toggle_light
gos_result_t toggle_light_request(const gos_hs_request_t *request, const char *arg)
gos_result_t result;
char buffer[256];
led_value = !led_value;
GOS_LOG("New LED value: %d", led_value);
int len = sprintf(buffer, "<h3>LED%d value: %d</h3>", PLATFORM_STD_LED, led_value);
if (GOS_FAILED(result, gos_hs_write_reply_header(request, "text/html", len, GOS_HS_RESPONSE_FLAG_NONE)))
else if (GOS_FAILED(result, gos_hs_write_data(request, buffer, len, true)))
return result;