add: file sending capability
This commit is contained in:
parent
6178ef3c7b
commit
760cec9a20
18 changed files with 79 additions and 53 deletions
|
@ -8,10 +8,11 @@
|
|||
#include <models/tag.h>
|
||||
|
||||
void
|
||||
api_v1_controllers_GET(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
api_v1_controllers_GET(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
{
|
||||
(void)args;
|
||||
(void)hm;
|
||||
(void)nc;
|
||||
controller_t** all_controllers = controller_get_all();
|
||||
|
||||
cJSON *json = cJSON_CreateArray();
|
||||
|
|
|
@ -8,9 +8,10 @@
|
|||
#include <models/tag.h>
|
||||
|
||||
void
|
||||
api_v1_controllers_STR_GET(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
api_v1_controllers_STR_GET(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
{
|
||||
(void)hm;
|
||||
(void)nc;
|
||||
|
||||
uuid_t target_uid;
|
||||
if(uuid_parse(args[0].value.v_str, target_uid))
|
||||
|
@ -41,9 +42,10 @@ api_v1_controllers_STR_GET(struct http_message *hm, endpoint_args_t *args, endpo
|
|||
}
|
||||
|
||||
void
|
||||
api_v1_controllers_STR_PUT(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
api_v1_controllers_STR_PUT(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
{
|
||||
(void)hm;
|
||||
(void)nc;
|
||||
|
||||
uuid_t target_uid;
|
||||
if(uuid_parse(args[0].value.v_str, target_uid))
|
||||
|
@ -134,9 +136,10 @@ api_v1_controllers_STR_PUT(struct http_message *hm, endpoint_args_t *args, endpo
|
|||
}
|
||||
|
||||
void
|
||||
api_v1_controllers_STR_DELETE(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
api_v1_controllers_STR_DELETE(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
{
|
||||
(void)hm;
|
||||
(void)nc;
|
||||
|
||||
const char *target_uid_str = args[0].value.v_str;
|
||||
|
||||
|
|
|
@ -7,9 +7,10 @@
|
|||
#include <models/tag.h>
|
||||
|
||||
void
|
||||
api_v1_controllers_STR_relays_GET(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
api_v1_controllers_STR_relays_GET(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
{
|
||||
(void)hm;
|
||||
(void)nc;
|
||||
|
||||
uuid_t target_uid;
|
||||
if(uuid_parse(args[0].value.v_str, target_uid))
|
||||
|
|
|
@ -10,9 +10,10 @@
|
|||
#include <models/tag.h>
|
||||
|
||||
void
|
||||
api_v1_controllers_STR_relays_INT_GET(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
api_v1_controllers_STR_relays_INT_GET(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
{
|
||||
(void)hm;
|
||||
(void)nc;
|
||||
|
||||
uuid_t target_uid;
|
||||
if(uuid_parse(args[0].value.v_str, target_uid))
|
||||
|
@ -55,9 +56,10 @@ api_v1_controllers_STR_relays_INT_GET(struct http_message *hm, endpoint_args_t *
|
|||
}
|
||||
|
||||
void
|
||||
api_v1_controllers_STR_relays_INT_PUT(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
api_v1_controllers_STR_relays_INT_PUT(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
{
|
||||
(void)hm;
|
||||
(void)nc;
|
||||
|
||||
uuid_t target_uid;
|
||||
if(uuid_parse(args[0].value.v_str, target_uid))
|
||||
|
|
|
@ -105,8 +105,10 @@ send_udp_broadcast(const char *addr, uint16_t port, void *message, size_t length
|
|||
}
|
||||
|
||||
void
|
||||
api_v1_controllers_discover_POST(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
api_v1_controllers_discover_POST(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
{
|
||||
(void)nc;
|
||||
(void)hm;
|
||||
int discover_server_socket = bind_tcp_server("0.0.0.0", "0", 20);
|
||||
int discover_server_port = get_server_port(discover_server_socket);
|
||||
|
||||
|
@ -303,5 +305,5 @@ api_v1_controllers_discover_POST(struct http_message *hm, endpoint_args_t *args,
|
|||
}
|
||||
controller_free_list(known_controllers);
|
||||
|
||||
api_v1_controllers_GET(hm, args, response);
|
||||
api_v1_controllers_GET(nc, hm, args, response);
|
||||
}
|
||||
|
|
|
@ -8,10 +8,12 @@
|
|||
#include <models/tag.h>
|
||||
|
||||
void
|
||||
api_v1_relays_GET(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
api_v1_relays_GET(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
{
|
||||
(void)args;
|
||||
(void)hm;
|
||||
(void)nc;
|
||||
|
||||
relay_t** all_relays = relay_get_all();
|
||||
|
||||
cJSON *json = cJSON_CreateArray();
|
||||
|
|
|
@ -8,9 +8,10 @@
|
|||
#include <models/tag.h>
|
||||
|
||||
void
|
||||
api_v1_relays_tag_STR_GET(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
api_v1_relays_tag_STR_GET(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
{
|
||||
(void)hm;
|
||||
(void)nc;
|
||||
|
||||
int tag_id = tag_get_id(args[0].value.v_str);
|
||||
int *relays_ids = junction_tag_get_relays_for_tag_id(tag_id);
|
||||
|
|
|
@ -8,9 +8,10 @@
|
|||
#include <models/tag.h>
|
||||
|
||||
void
|
||||
api_v1_schedules_POST(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
api_v1_schedules_POST(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
{
|
||||
(void)args;
|
||||
(void)nc;
|
||||
cJSON *json = cJSON_ParseWithLength(hm->body.p, hm->body.len);
|
||||
|
||||
if(json == NULL)
|
||||
|
@ -133,10 +134,12 @@ api_v1_schedules_POST(struct http_message *hm, endpoint_args_t *args, endpoint_r
|
|||
}
|
||||
|
||||
void
|
||||
api_v1_schedules_GET(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
api_v1_schedules_GET(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
{
|
||||
(void)args;
|
||||
(void)hm;
|
||||
(void)nc;
|
||||
|
||||
schedule_t** all_schedules = schedule_get_all();
|
||||
|
||||
cJSON *json = cJSON_CreateArray();
|
||||
|
|
|
@ -11,9 +11,10 @@
|
|||
#include <models/tag.h>
|
||||
|
||||
void
|
||||
api_v1_schedules_STR_GET(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
api_v1_schedules_STR_GET(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
{
|
||||
(void)hm;
|
||||
(void)nc;
|
||||
|
||||
uuid_t target_uid;
|
||||
if(schedule_uid_parse(args[0].value.v_str, target_uid))
|
||||
|
@ -44,9 +45,10 @@ api_v1_schedules_STR_GET(struct http_message *hm, endpoint_args_t *args, endpoin
|
|||
}
|
||||
|
||||
void
|
||||
api_v1_schedules_STR_PUT(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
api_v1_schedules_STR_PUT(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
{
|
||||
(void)hm;
|
||||
(void)nc;
|
||||
|
||||
uuid_t target_uid;
|
||||
if(schedule_uid_parse(args[0].value.v_str, target_uid))
|
||||
|
@ -183,9 +185,10 @@ api_v1_schedules_STR_PUT(struct http_message *hm, endpoint_args_t *args, endpoin
|
|||
}
|
||||
|
||||
void
|
||||
api_v1_schedules_STR_DELETE(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
api_v1_schedules_STR_DELETE(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
{
|
||||
(void)hm;
|
||||
(void)nc;
|
||||
|
||||
const char *target_uid_str = args[0].value.v_str;
|
||||
|
||||
|
|
|
@ -8,9 +8,10 @@
|
|||
#include <models/tag.h>
|
||||
|
||||
void
|
||||
api_v1_schedules_tag_STR_GET(struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
api_v1_schedules_tag_STR_GET(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response)
|
||||
{
|
||||
(void)hm;
|
||||
(void)nc;
|
||||
|
||||
int tag_id = tag_get_id(args[0].value.v_str);
|
||||
int *schedules_ids = junction_tag_get_schedules_for_tag_id(tag_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue