new file: firmware/main/include/controller.h
deleted: firmware/main/include/http_client.h modified: firmware/main/include/leds.h renamed: firmware/main/src/http_client.c -> firmware/main/src/controller.c modified: firmware/main/src/leds.c modified: firmware/main/src/main.c modified: firmware/main/src/sht31.c Restructured
This commit is contained in:
1 parent
5b58ad5e41
commit
e3d4023d35
6 files changed
+31
-42
No files matched your search
@@ -0,0 +1,16 @@
|
|||||||
|
#ifndef CONTROLLER_H
|
||||||
|
#define CONTROLLER_H
|
||||||
|
#include <freertos/FreeRTOS.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
esp_err_t controller_init();
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
#ifndef HTTP_CLIENT_H
|
|
||||||
#define HTTP_CLIENT_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct hc_dev_config {
|
|
||||||
};
|
|
||||||
|
|
||||||
void hc_test(void);
|
|
||||||
bool hc_check_updates();
|
|
||||||
bool hc_register();
|
|
||||||
struct hc_dev_config hc_get_dev_conf();
|
|
||||||
|
|
||||||
bool hc_send_sensor_data(unsigned id, float humidity, float temperature);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -6,7 +6,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void led_blink_task(void *pvParameter);
|
void led_blink_task(void *pvParameter);
|
||||||
unsigned initLEDs();
|
unsigned led_init();
|
||||||
void led1_on();
|
void led1_on();
|
||||||
void led2_on();
|
void led2_on();
|
||||||
void led1_off();
|
void led1_off();
|
||||||
|
|||||||
@@ -2,20 +2,22 @@
|
|||||||
#include <freertos/task.h>
|
#include <freertos/task.h>
|
||||||
#include <esp_system.h>
|
#include <esp_system.h>
|
||||||
#include <esp_log.h>
|
#include <esp_log.h>
|
||||||
#include <esp_event_loop.h>
|
//#include <esp_event_loop.h>
|
||||||
#include <nvs_flash.h>
|
#include <nvs_flash.h>
|
||||||
#include <esp_wifi.h>
|
#include <esp_wifi.h>
|
||||||
#include <esp_http_client.h>
|
#include <esp_http_client.h>
|
||||||
#include <cJSON.h>
|
#include <cJSON.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "http_client.h"
|
#include "controller.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
|
|
||||||
#define MAX_HTTP_OUTPUT_BUFFER 2048
|
#define MAX_HTTP_OUTPUT_BUFFER 2048
|
||||||
|
|
||||||
static const char * TAG = "http_client.c";
|
static const char * TAG = "controller.c";
|
||||||
|
|
||||||
|
|
||||||
|
esp_err_t controller_init() {
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static esp_err_t http_get_event_handler(esp_http_client_event_t *evt)
|
static esp_err_t http_get_event_handler(esp_http_client_event_t *evt)
|
||||||
{
|
{
|
||||||
@@ -49,24 +51,16 @@ static esp_err_t http_get_event_handler(esp_http_client_event_t *evt)
|
|||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static bool register_device(unsigned *id) {
|
||||||
void hc_test()
|
|
||||||
{
|
|
||||||
xTaskCreate(&http_get_task, "http_get_task", 16384, NULL, 5, NULL);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
bool hc_register(unsigned *id) {
|
|
||||||
static esp_http_client_config_t register_config = {
|
static esp_http_client_config_t register_config = {
|
||||||
.url = "http://tempcontroller.luethi.co/api/config",
|
.url = "http://tempcontroller.luethi.co/api/config",
|
||||||
.event_handler = NULL,
|
.event_handler = NULL,
|
||||||
.method = HTTP_METHOD_POST,
|
.method = HTTP_METHOD_POST,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
return 1; //1 as test ID
|
return 1; //1 as test ID
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hc_send_sensor_data(unsigned id, float humidity, float temperature) {
|
static bool send_sensor_data(unsigned id, float humidity, float temperature) {
|
||||||
esp_err_t err;
|
esp_err_t err;
|
||||||
int content_length = 0;
|
int content_length = 0;
|
||||||
char output_buffer[MAX_HTTP_OUTPUT_BUFFER];
|
char output_buffer[MAX_HTTP_OUTPUT_BUFFER];
|
||||||
@@ -12,7 +12,7 @@ static const char * TAG = "leds.c";
|
|||||||
|
|
||||||
void led_blink_task(void *pvParameter)
|
void led_blink_task(void *pvParameter)
|
||||||
{
|
{
|
||||||
initLEDs();
|
led_init();
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
//gpio_set_level(LED_INT, 1);
|
//gpio_set_level(LED_INT, 1);
|
||||||
@@ -33,7 +33,7 @@ void led_blink_task(void *pvParameter)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned initLEDs() {
|
unsigned led_init() {
|
||||||
gpio_set_direction(LED1,GPIO_MODE_OUTPUT);
|
gpio_set_direction(LED1,GPIO_MODE_OUTPUT);
|
||||||
gpio_set_direction(LED2,GPIO_MODE_OUTPUT);
|
gpio_set_direction(LED2,GPIO_MODE_OUTPUT);
|
||||||
//gpio_set_direction(LED_INT,GPIO_MODE_OUTPUT);
|
//gpio_set_direction(LED_INT,GPIO_MODE_OUTPUT);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
#include "wifi.h"
|
#include "wifi.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "http_client.h"
|
#include "controller.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -22,8 +22,9 @@ void app_main()
|
|||||||
{
|
{
|
||||||
//ESP_ERROR_CHECK(nvs_flash_init());
|
//ESP_ERROR_CHECK(nvs_flash_init());
|
||||||
|
|
||||||
//wifi_init();
|
led_init();
|
||||||
initLEDs();
|
wifi_init();
|
||||||
|
controller_init();
|
||||||
|
|
||||||
xTaskCreate(&led_blink_task, "led_blink_task", configMINIMAL_STACK_SIZE, NULL, 5, NULL);
|
xTaskCreate(&led_blink_task, "led_blink_task", configMINIMAL_STACK_SIZE, NULL, 5, NULL);
|
||||||
xTaskCreate(uart_read_task, "uart_read_task", 2048, NULL, 10, NULL);
|
xTaskCreate(uart_read_task, "uart_read_task", 2048, NULL, 10, NULL);
|
||||||
|
|||||||
Reference in new issue
Block a user