add: models for controller and relay
add: first controller endpoints
This commit is contained in:
		
							parent
							
								
									b5a8523ae0
								
							
						
					
					
						commit
						1171ef22be
					
				
					 11 changed files with 951 additions and 20 deletions
				
			
		| 
						 | 
				
			
			@ -4,12 +4,14 @@
 | 
			
		|||
#include <uuid/uuid.h>
 | 
			
		||||
#include <sqlite3.h>
 | 
			
		||||
 | 
			
		||||
#include <cJSON.h>
 | 
			
		||||
#include <helpers.h>
 | 
			
		||||
#include <models/relay.h>
 | 
			
		||||
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
    uuid_t id;
 | 
			
		||||
    int id;
 | 
			
		||||
    uuid_t uid;
 | 
			
		||||
    char name[128];
 | 
			
		||||
    char ip[17];
 | 
			
		||||
    int active;
 | 
			
		||||
| 
						 | 
				
			
			@ -27,11 +29,14 @@ controller_save(controller_t* contoller);
 | 
			
		|||
int
 | 
			
		||||
controller_remove(controller_t* contoller);
 | 
			
		||||
 | 
			
		||||
char*
 | 
			
		||||
cJSON*
 | 
			
		||||
controller_to_json(controller_t* contoller);
 | 
			
		||||
 | 
			
		||||
controller_t**
 | 
			
		||||
controller_get_by_simple(const char *key, const void *value, intptr_t bind_func, int bind_func_param);
 | 
			
		||||
controller_t*
 | 
			
		||||
controller_get_by_id(int id);
 | 
			
		||||
 | 
			
		||||
controller_t*
 | 
			
		||||
controller_get_by_uid(uuid_t uid);
 | 
			
		||||
 | 
			
		||||
controller_t**
 | 
			
		||||
controller_get_all();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,6 +4,8 @@
 | 
			
		|||
#include <string.h>
 | 
			
		||||
#include <uuid/uuid.h>
 | 
			
		||||
 | 
			
		||||
#include <constants.h>
 | 
			
		||||
#include <cJSON.h>
 | 
			
		||||
#include <helpers.h>
 | 
			
		||||
#include <database.h>
 | 
			
		||||
#include <models/schedule.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -11,21 +13,21 @@
 | 
			
		|||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
    int id;
 | 
			
		||||
    char name[128];
 | 
			
		||||
    char name[MAX_NAME_LENGTH + 1];
 | 
			
		||||
    int number;
 | 
			
		||||
    uuid_t controller_id;
 | 
			
		||||
    int controller_id;
 | 
			
		||||
    int active_schedule_id;
 | 
			
		||||
    schedule_t *active_schedule;
 | 
			
		||||
    schedule_t *schedules[7];
 | 
			
		||||
} relay_t;
 | 
			
		||||
 | 
			
		||||
bool
 | 
			
		||||
int
 | 
			
		||||
relay_save();
 | 
			
		||||
 | 
			
		||||
bool
 | 
			
		||||
int
 | 
			
		||||
relay_remove();
 | 
			
		||||
 | 
			
		||||
char*
 | 
			
		||||
cJSON*
 | 
			
		||||
relay_to_json();
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
| 
						 | 
				
			
			@ -46,4 +48,7 @@ relay_valid_num_is_for_controller(uuid_t controller_id, int relay_num);
 | 
			
		|||
relay_t**
 | 
			
		||||
relay_get_all();
 | 
			
		||||
 | 
			
		||||
relay_t**
 | 
			
		||||
relay_get_by_controller_id(int controller_id);
 | 
			
		||||
 | 
			
		||||
#endif /* CORE_RELAY_H */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -40,9 +40,6 @@ schedule_free_list(schedule_t **schedules_list);
 | 
			
		|||
uint16_t*
 | 
			
		||||
schedule_periods_to_blob(schedule_t *schedule);
 | 
			
		||||
 | 
			
		||||
schedule_t**
 | 
			
		||||
schedule_get_by_simple(const char *key, const void *value, intptr_t bind_func, int bind_func_param);
 | 
			
		||||
 | 
			
		||||
schedule_t*
 | 
			
		||||
schedule_get_by_id_or_off(int id);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue