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
7 files changed
+32
-43
No files matched your search
@@ -2,20 +2,22 @@
|
||||
#include <freertos/task.h>
|
||||
#include <esp_system.h>
|
||||
#include <esp_log.h>
|
||||
#include <esp_event_loop.h>
|
||||
//#include <esp_event_loop.h>
|
||||
#include <nvs_flash.h>
|
||||
#include <esp_wifi.h>
|
||||
#include <esp_http_client.h>
|
||||
#include <cJSON.h>
|
||||
#include <string.h>
|
||||
#include "http_client.h"
|
||||
#include "controller.h"
|
||||
#include "functions.h"
|
||||
|
||||
#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)
|
||||
{
|
||||
@@ -49,24 +51,16 @@ static esp_err_t http_get_event_handler(esp_http_client_event_t *evt)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
void hc_test()
|
||||
{
|
||||
xTaskCreate(&http_get_task, "http_get_task", 16384, NULL, 5, NULL);
|
||||
}
|
||||
*/
|
||||
bool hc_register(unsigned *id) {
|
||||
static bool register_device(unsigned *id) {
|
||||
static esp_http_client_config_t register_config = {
|
||||
.url = "http://tempcontroller.luethi.co/api/config",
|
||||
.event_handler = NULL,
|
||||
.method = HTTP_METHOD_POST,
|
||||
};
|
||||
|
||||
|
||||
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;
|
||||
int content_length = 0;
|
||||
char output_buffer[MAX_HTTP_OUTPUT_BUFFER];
|
||||
@@ -12,7 +12,7 @@ static const char * TAG = "leds.c";
|
||||
|
||||
void led_blink_task(void *pvParameter)
|
||||
{
|
||||
initLEDs();
|
||||
led_init();
|
||||
|
||||
while (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(LED2,GPIO_MODE_OUTPUT);
|
||||
//gpio_set_direction(LED_INT,GPIO_MODE_OUTPUT);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "uart.h"
|
||||
#include "wifi.h"
|
||||
#include "functions.h"
|
||||
#include "http_client.h"
|
||||
#include "controller.h"
|
||||
|
||||
|
||||
|
||||
@@ -22,8 +22,9 @@ void app_main()
|
||||
{
|
||||
//ESP_ERROR_CHECK(nvs_flash_init());
|
||||
|
||||
//wifi_init();
|
||||
initLEDs();
|
||||
led_init();
|
||||
wifi_init();
|
||||
controller_init();
|
||||
|
||||
xTaskCreate(&led_blink_task, "led_blink_task", configMINIMAL_STACK_SIZE, NULL, 5, NULL);
|
||||
xTaskCreate(uart_read_task, "uart_read_task", 2048, NULL, 10, NULL);
|
||||
|
||||
@@ -82,7 +82,7 @@ esp_err_t sht31_read_temp_hum(float *temperature, float *humidity)
|
||||
cmd = i2c_cmd_link_create();
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, (SENSOR_ADDR << 1) | I2C_MASTER_READ, true);
|
||||
i2c_master_read(cmd, data, sizeof(data) - 1, I2C_MASTER_ACK);
|
||||
i2c_master_read (cmd, data, sizeof(data) - 1, I2C_MASTER_ACK);
|
||||
i2c_master_read_byte(cmd, data + sizeof(data) - 1, I2C_MASTER_NACK);
|
||||
i2c_master_stop(cmd);
|
||||
ret = i2c_master_cmd_begin(I2C_NUM_0, cmd, 1000 / portTICK_RATE_MS);
|
||||
|
||||
Reference in new issue
Block a user