Skip to content
Snippets Groups Projects
Commit 45c99ff9 authored by Legy (Beini)'s avatar Legy (Beini) Committed by Jens Nolte
Browse files

Move qthing includes to their own dir and clean up

parent 87b6589e
No related branches found
No related tags found
1 merge request!16Merge dev branch into master
Showing
with 60 additions and 54 deletions
#ifndef QTHING_H #pragma once
#define QTHING_H
#include <string> #include <string>
...@@ -46,19 +45,6 @@ namespace qthing { ...@@ -46,19 +45,6 @@ namespace qthing {
void enable_status_led(gpio_num_t gpio = GPIO_NUM_2, bool negated = false); void enable_status_led(gpio_num_t gpio = GPIO_NUM_2, bool negated = false);
void show_activity(); void show_activity();
// network
void enable_wifi();
connection_status_t get_wifi_connection_status();
void add_wifi_connection_status_callback(connection_status_callback_t callback);
void add_combined_mqtt_connection_status_callback(connection_status_callback_t handler);
void enable_ethernet_lan8720();
connection_status_t get_eth_connection_status();
void add_eth_connection_status_callback(connection_status_callback_t callback);
connection_status_t get_network_connection_status();
void add_network_connection_status_callback(connection_status_callback_t callback);
// mqtt // mqtt
void publish_message(const std::string& topic, const std::string& message); void publish_message(const std::string& topic, const std::string& message);
void add_message_callback(const std::string& topic, message_callback_t callback); void add_message_callback(const std::string& topic, message_callback_t callback);
...@@ -83,9 +69,6 @@ namespace qthing { ...@@ -83,9 +69,6 @@ namespace qthing {
void enable_lcd(const std::string& topic, uint8_t rs, uint8_t en, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); void enable_lcd(const std::string& topic, uint8_t rs, uint8_t en, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
// power
void power_managment_max_power();
// LED strips // LED strips
enum led_strip_types_t { enum led_strip_types_t {
LED_WS2812_V1, LED_WS2812_V1,
...@@ -262,11 +245,10 @@ namespace qthing { ...@@ -262,11 +245,10 @@ namespace qthing {
bool get_key_state(uint8_t x, uint8_t y); bool get_key_state(uint8_t x, uint8_t y);
uint32_t get_key_activation_time(uint8_t x, uint8_t y); uint32_t get_key_activation_time(uint8_t x, uint8_t y);
} }
}
// utility // utility
std::string to_string(float value, int precision = 2); std::string to_string(float value, int precision = 2);
std::string to_string(uint32_t value); std::string to_string(uint32_t value);
std::string to_string(struct sockaddr_in6 sourceAddr); std::string to_string(struct sockaddr_in6 sourceAddr);
#endif }
#ifndef RC_433_H #pragma once
#define RC_433_H
#include <string> #include <string>
#include "driver/gpio.h" #include "driver/gpio.h"
namespace qthing { namespace qthing {
#ifndef QTHING_HIDE_PRIVATE_API
void rc_switch_on(const std::string& code); void rc_switch_on(const std::string& code);
void rc_switch_off(const std::string& code); void rc_switch_off(const std::string& code);
void rc_switch(const std::string& code, bool state); void rc_switch(const std::string& code, bool state);
...@@ -14,6 +15,6 @@ void rc_switch(const std::string& code, bool state); ...@@ -14,6 +15,6 @@ void rc_switch(const std::string& code, bool state);
void rc_enable_send(const std::string& send_on_topic, const std::string& send_off_topic, gpio_num_t gpio); void rc_enable_send(const std::string& send_on_topic, const std::string& send_off_topic, gpio_num_t gpio);
void rc_enable_receive(const std::string& topic, gpio_num_t gpio); void rc_enable_receive(const std::string& topic, gpio_num_t gpio);
}
#endif #endif
}
#ifndef SENSOR_H #pragma once
#define SENSOR_H
namespace qthing { namespace qthing {
void add_soil_moisture_sensor(); #ifndef QTHING_HIDE_PRIVATE_API
} void add_soil_moisture_sensor();
#endif #endif
}
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
namespace qthing { namespace qthing {
#ifndef QTHING_HIDE_PRIVATE_API
void start_udp_server(); void start_udp_server();
#endif
} }
#ifndef UTIL_H #pragma once
#define UTIL_H
namespace qthing {
unsigned long millis(); unsigned long millis();
#endif }
#include <qthing.hpp> #include "qthing_legacy.hpp"
#include "io.hpp" #include "io.hpp"
#include "mqtt.hpp" #include "mqtt.hpp"
......
#include <qthing.hpp> #include "qthing_legacy.hpp"
#include "mqtt.hpp" #include "mqtt.hpp"
#include "network.hpp"
#include <string> #include <string>
#include <vector> #include <vector>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "freertos/task.h" #include "freertos/task.h"
#include "esp_log.h" #include "esp_log.h"
#include "qthing.hpp" #include "qthing_legacy.hpp"
#include "mqtt_common.h" #include "mqtt_common.h"
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "esp_system.h" #include "esp_system.h"
#include "esp_ota_ops.h" #include "esp_ota_ops.h"
#include <qthing.hpp> #include "qthing_legacy.hpp"
#define TAG "MQTT_OTA" #define TAG "MQTT_OTA"
......
#include "qthing.hpp" #include "qthing_legacy.hpp"
#include "io.hpp" #include "io.hpp"
#include "environment.h" #include "environment.h"
#include "device_config.h" #include "device_config.h"
#include "event.hpp" #include "event.hpp"
#include "mqtt.hpp" #include "mqtt.hpp"
#include "network/udp.hpp" #include "udp.hpp"
#include "string.h" #include "string.h"
......
#import <qthing.hpp> #import "qthing_legacy.hpp"
#import "peripherals/led_strip.hpp"
#import "led_strip.hpp"
#import <algorithm> #import <algorithm>
#import <vector> #import <vector>
......
#include <qthing.hpp> #include "qthing_legacy.hpp"
#include <map> #include <map>
...@@ -74,7 +74,7 @@ static void udp_server_task(void *pvParameters) ...@@ -74,7 +74,7 @@ static void udp_server_task(void *pvParameters)
} }
// Data received // Data received
else { else {
ESP_LOGI(TAG, "Received %d bytes from %s", len, to_string(sourceAddr).c_str()); ESP_LOGI(TAG, "Received %d bytes from %s", len, qthing::to_string(sourceAddr).c_str());
std::string payload_str(rx_buffer); std::string payload_str(rx_buffer);
int16_t lenBestMatch = -1; int16_t lenBestMatch = -1;
......
#include "qthing.hpp" #include "qthing_legacy.hpp"
#include "network.hpp" #include "network.hpp"
#include "io.hpp" #include "io.hpp"
#include "environment.h" #include "environment.h"
......
#undef __STRICT_ANSI__ #undef __STRICT_ANSI__
#include <qthing.hpp> #include "qthing_legacy.hpp"
#include <freertos/FreeRTOS.h> #include <freertos/FreeRTOS.h>
#include "freertos/task.h" #include "freertos/task.h"
......
#include <qthing.hpp> #include "qthing_legacy.hpp"
#include "event.hpp" #include "event.hpp"
#include "network.hpp"
#include "Arduino.h" #include "Arduino.h"
#include "SSD1306Wire.h" #include "SSD1306Wire.h"
......
#include <qthing.hpp> #include "qthing_legacy.hpp"
#include <io.hpp>
#include "io.hpp"
#include <array> #include <array>
#include <functional> #include <functional>
......
#include <qthing.hpp> #include "qthing_legacy.hpp"
#include "led_strip.hpp" #include "led_strip.hpp"
#include "power.hpp"
#include <algorithm> #include <algorithm>
......
#include "qthing_legacy.hpp"
#include "mqtt.hpp" #include "mqtt.hpp"
#include "polyfill.hpp"
#include <string> #include <string>
#include "polyfill.hpp"
#include "esp_log.h" #include "esp_log.h"
#include <driver/adc.h> #include <driver/adc.h>
...@@ -10,8 +12,6 @@ ...@@ -10,8 +12,6 @@
#define SLEEP_PERIOD 60 * 1000 / portTICK_PERIOD_MS #define SLEEP_PERIOD 60 * 1000 / portTICK_PERIOD_MS
namespace qthing {
bool message = false; bool message = false;
void soil_moisture_sensor_task(void* arg) { void soil_moisture_sensor_task(void* arg) {
adc1_config_width(ADC_WIDTH_12Bit); adc1_config_width(ADC_WIDTH_12Bit);
...@@ -23,11 +23,11 @@ void soil_moisture_sensor_task(void* arg) { ...@@ -23,11 +23,11 @@ void soil_moisture_sensor_task(void* arg) {
value += adc1_get_raw(ADC1_CHANNEL_4); value += adc1_get_raw(ADC1_CHANNEL_4);
vTaskDelay(1000 / 16 / portTICK_PERIOD_MS); vTaskDelay(1000 / 16 / portTICK_PERIOD_MS);
} }
publish_message("device/plant_auto/soil_moisture", to_string(value)); qthing::publish_message("device/plant_auto/soil_moisture", to_string(value));
ESP_LOGI("SOIL_SENSOR", "%i", value); ESP_LOGI("SOIL_SENSOR", "%i", value);
if (!message && value < 30000) { if (!message && value < 30000) {
publish_message("edi/cmd/say", "{\"args\": \"iiiiih, ich bin nass\"}"); qthing::publish_message("edi/cmd/say", "{\"args\": \"iiiiih, ich bin nass\"}");
message = true; message = true;
} }
...@@ -38,5 +38,3 @@ void soil_moisture_sensor_task(void* arg) { ...@@ -38,5 +38,3 @@ void soil_moisture_sensor_task(void* arg) {
void add_soil_moisture_sensor() { void add_soil_moisture_sensor() {
xTaskCreate(soil_moisture_sensor_task, "soil_moisture_sensor_task", 2048, NULL, 4, NULL); xTaskCreate(soil_moisture_sensor_task, "soil_moisture_sensor_task", 2048, NULL, 4, NULL);
} }
}
#include <qthing.hpp> #include "qthing_legacy.hpp"
#include "io.hpp" #include "io.hpp"
#include "network.hpp"
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
......
#include <qthing.hpp> #include "qthing_legacy.hpp"
#include "power.hpp"
#include "esp_pm.h" #include "esp_pm.h"
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
...@@ -8,6 +10,7 @@ ...@@ -8,6 +10,7 @@
static bool max_power = false; static bool max_power = false;
namespace qthing { namespace qthing {
void power_managment_max_power() { void power_managment_max_power() {
if (!max_power) { if (!max_power) {
max_power = true; max_power = true;
...@@ -23,4 +26,5 @@ namespace qthing { ...@@ -23,4 +26,5 @@ namespace qthing {
vTaskDelay(200 / portTICK_PERIOD_MS); vTaskDelay(200 / portTICK_PERIOD_MS);
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment