|
@@ -68,6 +68,7 @@ int handle_time(struct http_request *req) {
|
|
|
char *result_string;
|
|
|
cJSON *time_json, *json_min, *json_hour, *json_mday,
|
|
|
*json_mon, *json_year, *json_sec, *json_wday;
|
|
|
+ http_response_header(req, "Access-Control-Allow-Origin", "*");
|
|
|
if(req->method == HTTP_METHOD_GET) {
|
|
|
time_json = cJSON_CreateObject();
|
|
|
fdesc = open("/dev/rtc", O_RDONLY);
|
|
@@ -91,7 +92,6 @@ int handle_time(struct http_request *req) {
|
|
|
result_string = cJSON_Print(time_json);
|
|
|
cJSON_Delete(time_json);
|
|
|
http_response_header(req, "Content-Type", "application/json");
|
|
|
- http_response_header(req, "Access-Control-Allow-Origin", "*");
|
|
|
http_response(req, 200, result_string, strlen(result_string));
|
|
|
return KORE_RESULT_OK;
|
|
|
}
|
|
@@ -145,7 +145,6 @@ int handle_time(struct http_request *req) {
|
|
|
http_response(req, 500, result_string, strlen(result_string));
|
|
|
return (KORE_RESULT_OK);
|
|
|
}
|
|
|
- http_response_header(req, "Access-Control-Allow-Origin", "*");
|
|
|
http_response(req, 200, NULL, 0);
|
|
|
return KORE_RESULT_OK;
|
|
|
} else {
|
|
@@ -162,6 +161,7 @@ int handle_wkalrm(struct http_request *req) {
|
|
|
cJSON *alarm_json, *json_min, *json_hour, *json_mday,
|
|
|
*json_mon, *json_year, *json_sec, *json_wday,
|
|
|
*json_enabled, *json_pending;
|
|
|
+ http_response_header(req, "Access-Control-Allow-Origin", "*");
|
|
|
if(req->method == HTTP_METHOD_GET) {
|
|
|
alarm_json = cJSON_CreateObject();
|
|
|
fdesc = open("/dev/rtc", O_RDONLY);
|
|
@@ -190,7 +190,6 @@ int handle_wkalrm(struct http_request *req) {
|
|
|
result_string = cJSON_Print(alarm_json);
|
|
|
cJSON_Delete(alarm_json);
|
|
|
http_response_header(req, "Content-Type", "application/json");
|
|
|
- http_response_header(req, "Access-Control-Allow-Origin", "*");
|
|
|
http_response(req, 200, result_string, strlen(result_string));
|
|
|
return KORE_RESULT_OK;
|
|
|
}
|
|
@@ -246,7 +245,6 @@ int handle_wkalrm(struct http_request *req) {
|
|
|
http_response(req, 500, result_string, strlen(result_string));
|
|
|
return (KORE_RESULT_OK);
|
|
|
}
|
|
|
- http_response_header(req, "Access-Control-Allow-Origin", "*");
|
|
|
http_response(req, 200, NULL, 0);
|
|
|
return KORE_RESULT_OK;
|
|
|
} else {
|
|
@@ -278,6 +276,7 @@ int handle_nvmem(struct http_request *req) {
|
|
|
char * result_object;
|
|
|
char * result_string;
|
|
|
cJSON *json_response, *json_string;
|
|
|
+ http_response_header(req, "Access-Control-Allow-Origin", "*");
|
|
|
if(req->method == HTTP_METHOD_GET) {
|
|
|
fdesc = open("/sys/bus/nvmem/devices/ds1307_nvram0/nvmem", O_RDONLY);
|
|
|
bytes_read = read(fdesc, &buf, 56);
|
|
@@ -298,7 +297,6 @@ int handle_nvmem(struct http_request *req) {
|
|
|
result_object = cJSON_Print(json_response);
|
|
|
cJSON_Delete(json_response);
|
|
|
http_response_header(req, "Content-Type", "application/json");
|
|
|
- http_response_header(req, "Access-Control-Allow-Origin", "*");
|
|
|
http_response(req, 200, result_object, strlen(result_object));
|
|
|
} else {
|
|
|
result_string = "Error: could not read from nvmem\n";
|
|
@@ -336,6 +334,8 @@ int handle_nvmem(struct http_request *req) {
|
|
|
buf3 += input_string[i] - '0';
|
|
|
} else if ((input_string[i] >= 'A') && (input_string[i] <= 'Z')) {
|
|
|
buf3 += input_string[i] - 55;
|
|
|
+ } else if ((input_string[i] >= 'a') && (input_string[i] <= 'z')) {
|
|
|
+ buf3 += input_string[i] - 87;
|
|
|
}
|
|
|
if (i%2 != 0) {
|
|
|
to_write[i/2] = (unsigned char) buf3;
|
|
@@ -346,7 +346,6 @@ int handle_nvmem(struct http_request *req) {
|
|
|
bytes_written = write(fdesc, to_write, 56);
|
|
|
close(fdesc);
|
|
|
if (bytes_written == 56) {
|
|
|
- http_response_header(req, "Access-Control-Allow-Origin", "*");
|
|
|
http_response(req, 200, NULL, 0);
|
|
|
return (KORE_RESULT_OK);
|
|
|
}
|