add: receive more controller properties and save them
add: more tests
This commit is contained in:
parent
2a4e0e1075
commit
2b9abff7f1
3 changed files with 29 additions and 12 deletions
|
@ -106,16 +106,10 @@ void controllers::post_discover(const HttpRequestPtr &req, std::function<void(co
|
|||
uuid_t discovered_id;
|
||||
int id_size = sizeof(uuid_t);
|
||||
memcpy(&discovered_id, binn_map_blob(answer_payload, DISCOVERY_MAPPING_ID, &id_size), id_size);
|
||||
//strncpy(&id, binn_map_blob(answer_payload, DISCOVERY_MAPPING_ID, &uuid_size), uuid_size);
|
||||
|
||||
char uuid_str[38];
|
||||
uuid_unparse(discovered_id, uuid_str);
|
||||
LOG_DEBUG << uuid_str;
|
||||
continue;
|
||||
|
||||
free(answer_payload);
|
||||
|
||||
Json::Value client_info;
|
||||
char *discovered_name = binn_map_str(answer_payload, DISCOVERY_MAPPING_NAME);
|
||||
uint32_t discovered_command_port = binn_map_uint32(answer_payload, DISCOVERY_MAPPING_COMMAND_PORT);
|
||||
uint8_t discovered_relay_count = binn_map_uint8(answer_payload, DISCOVERY_MAPPING_RELAY_COUNT);
|
||||
|
||||
bool found_discovered_in_list = false;
|
||||
|
||||
|
@ -143,13 +137,14 @@ void controllers::post_discover(const HttpRequestPtr &req, std::function<void(co
|
|||
controller_dbo discovered_controller{};
|
||||
strcpy(discovered_controller.ip, inet_ntoa(addr.sin_addr));
|
||||
memcpy(discovered_controller.id, discovered_id, sizeof(uuid_t));
|
||||
strcpy(discovered_controller.name, client_info["name"].asCString());
|
||||
discovered_controller.relay_count = client_info["relay_count"].asInt();
|
||||
discovered_controller.port = client_info["port"].asInt();
|
||||
strcpy(discovered_controller.name, discovered_name);
|
||||
discovered_controller.relay_count = discovered_relay_count;
|
||||
discovered_controller.port = discovered_command_port;
|
||||
discovered_controller.active = true;
|
||||
|
||||
discovered_controller.insert();
|
||||
}
|
||||
free(answer_payload);
|
||||
|
||||
discover_answer_buf[0] = config::discover_code_accept;
|
||||
send(client_fd, discover_answer_buf, sizeof(uint8_t), 0);
|
||||
|
|
|
@ -12,6 +12,7 @@ create table controllers
|
|||
ip VARCHAR(16),
|
||||
port INTEGER,
|
||||
relay_count INTEGER,
|
||||
tag varchar(64),
|
||||
active BOOLEAN not null
|
||||
);
|
||||
|
||||
|
|
|
@ -43,3 +43,24 @@ stages:
|
|||
url: "http://localhost:5000/api/v1/schedules/on"
|
||||
response:
|
||||
status_code: 200
|
||||
body:
|
||||
name: "on"
|
||||
periods:
|
||||
- start: "00:00"
|
||||
end: "23:59"
|
||||
- name: overwrite protected on schedule
|
||||
request:
|
||||
method: PUT
|
||||
url: "http://localhost:5000/api/v1/schedules/on"
|
||||
json:
|
||||
name: "turned_on"
|
||||
periods:
|
||||
- start: '00:10'
|
||||
end: '00:20'
|
||||
response:
|
||||
status_code: 200
|
||||
body:
|
||||
name: "{tavern.request_vars.json.name}"
|
||||
periods:
|
||||
- start: "00:00"
|
||||
end: "23:59"
|
||||
|
|
Loading…
Reference in a new issue