main/config.h

Mon, 17 Apr 2023 14:54:35 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 17 Apr 2023 14:54:35 +0200
changeset 31
ec5c7794dcd6
parent 30
7448b8dd4288
child 32
84e54b14e7db
permissions
-rw-r--r--

Added basic BLE code.

1
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * @file config.h
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 * @brief The 'iotbalkon' configuration data.
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 */
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 #ifndef _CONFIG_H
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 #define _CONFIG_H
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 // Global includes for the project
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 #include <stdio.h>
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 #include <stdlib.h>
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 #include <string.h>
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 #include <stdbool.h>
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 #include <time.h>
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 #include <errno.h>
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 #include <sys/unistd.h>
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 #include <sys/fcntl.h>
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 #include <sys/time.h>
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 #include "freertos/FreeRTOS.h"
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 #include "freertos/task.h"
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 #include "freertos/semphr.h"
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 #include "freertos/event_groups.h"
5
b1f38105ca7e Added task MQTT and some utilities. Added more power measurement variables and code. INA219 measurements are saved in the State record.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
25 #include "freertos/queue.h"
1
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 #include "driver/gpio.h"
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 #include "driver/i2c.h"
9
1659bd3c7a2b Added task_out to drive the relays and led lights. Added NVS namespace to store the state of the outputs. Respond to subscribed MQTT topics to set new output values.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
28 #include "driver/ledc.h"
1
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 #include "esp_log.h"
4
d0155c16e992 Added Wifi task.
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
30 #include "esp_system.h"
18
12506716211c Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents: 12
diff changeset
31 #include "esp_sleep.h"
7
2b337dd92f25 Added volts/current loop calculations. Added millis() timer running on the hardware clock. Completed most of the main state loop. Added MQTT wait for disconnect. MQTT disconnect in two passes, disconnect and stop.
Michiel Broek <mbroek@mbse.eu>
parents: 5
diff changeset
32 #include "esp_timer.h"
5
b1f38105ca7e Added task MQTT and some utilities. Added more power measurement variables and code. INA219 measurements are saved in the State record.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
33 #include "esp_app_desc.h"
4
d0155c16e992 Added Wifi task.
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
34 #include "esp_wifi.h"
d0155c16e992 Added Wifi task.
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
35 #include "esp_event.h"
5
b1f38105ca7e Added task MQTT and some utilities. Added more power measurement variables and code. INA219 measurements are saved in the State record.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
36 #include "esp_netif.h"
30
7448b8dd4288 Preparations for BLE GATT. Added extra time after INA219 is powered on before measurement. Reduced LEDC frequency to 60 Hz, that makes the LED lights less nervous. Hardware mod on output 4, now needs external pulldown resistor.
Michiel Broek <mbroek@mbse.eu>
parents: 18
diff changeset
37 #ifdef CONFIG_ENABLE_BLE_GATT
7448b8dd4288 Preparations for BLE GATT. Added extra time after INA219 is powered on before measurement. Reduced LEDC frequency to 60 Hz, that makes the LED lights less nervous. Hardware mod on output 4, now needs external pulldown resistor.
Michiel Broek <mbroek@mbse.eu>
parents: 18
diff changeset
38 #include "esp_bt.h"
7448b8dd4288 Preparations for BLE GATT. Added extra time after INA219 is powered on before measurement. Reduced LEDC frequency to 60 Hz, that makes the LED lights less nervous. Hardware mod on output 4, now needs external pulldown resistor.
Michiel Broek <mbroek@mbse.eu>
parents: 18
diff changeset
39 #include "esp_gap_ble_api.h"
7448b8dd4288 Preparations for BLE GATT. Added extra time after INA219 is powered on before measurement. Reduced LEDC frequency to 60 Hz, that makes the LED lights less nervous. Hardware mod on output 4, now needs external pulldown resistor.
Michiel Broek <mbroek@mbse.eu>
parents: 18
diff changeset
40 #include "esp_gatts_api.h"
7448b8dd4288 Preparations for BLE GATT. Added extra time after INA219 is powered on before measurement. Reduced LEDC frequency to 60 Hz, that makes the LED lights less nervous. Hardware mod on output 4, now needs external pulldown resistor.
Michiel Broek <mbroek@mbse.eu>
parents: 18
diff changeset
41 #include "esp_bt_defs.h"
7448b8dd4288 Preparations for BLE GATT. Added extra time after INA219 is powered on before measurement. Reduced LEDC frequency to 60 Hz, that makes the LED lights less nervous. Hardware mod on output 4, now needs external pulldown resistor.
Michiel Broek <mbroek@mbse.eu>
parents: 18
diff changeset
42 #include "esp_bt_main.h"
31
ec5c7794dcd6 Added basic BLE code.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
43 #include "esp_gatt_common_api.h"
30
7448b8dd4288 Preparations for BLE GATT. Added extra time after INA219 is powered on before measurement. Reduced LEDC frequency to 60 Hz, that makes the LED lights less nervous. Hardware mod on output 4, now needs external pulldown resistor.
Michiel Broek <mbroek@mbse.eu>
parents: 18
diff changeset
44 #endif
4
d0155c16e992 Added Wifi task.
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
45 #include "nvs_flash.h"
d0155c16e992 Added Wifi task.
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
46 #include "lwip/err.h"
d0155c16e992 Added Wifi task.
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
47 #include "lwip/sys.h"
5
b1f38105ca7e Added task MQTT and some utilities. Added more power measurement variables and code. INA219 measurements are saved in the State record.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
48 #include "mqtt_client.h"
1
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 /*
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 * esp-idf-lib
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 */
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 #include <i2cdev.h>
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 #include <bmp280.h>
3
e5d91caa6ab4 Added begin of INA219 measurements. Added raw main state table.
Michiel Broek <mbroek@mbse.eu>
parents: 1
diff changeset
55 #include <ina219.h>
12
bb72d448e282 In the esp-idf-lib the adps9930 driver uses a device descriptor structure instead of just i2c_dev_t. Fixed a linking issue. Added APDS9930 task. Added getLightValues function. Added wifi quality value to the MQTT payload. The payload is complete and will be published.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
56 #include <apds9930.h>
1
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 /*
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 * Application sources
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60 */
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61 #include "task_bmp280.h"
3
e5d91caa6ab4 Added begin of INA219 measurements. Added raw main state table.
Michiel Broek <mbroek@mbse.eu>
parents: 1
diff changeset
62 #include "task_ina219.h"
12
bb72d448e282 In the esp-idf-lib the adps9930 driver uses a device descriptor structure instead of just i2c_dev_t. Fixed a linking issue. Added APDS9930 task. Added getLightValues function. Added wifi quality value to the MQTT payload. The payload is complete and will be published.
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
63 #include "task_apds9930.h"
30
7448b8dd4288 Preparations for BLE GATT. Added extra time after INA219 is powered on before measurement. Reduced LEDC frequency to 60 Hz, that makes the LED lights less nervous. Hardware mod on output 4, now needs external pulldown resistor.
Michiel Broek <mbroek@mbse.eu>
parents: 18
diff changeset
64 #ifdef CONFIG_ENABLE_BLE_GATT
7448b8dd4288 Preparations for BLE GATT. Added extra time after INA219 is powered on before measurement. Reduced LEDC frequency to 60 Hz, that makes the LED lights less nervous. Hardware mod on output 4, now needs external pulldown resistor.
Michiel Broek <mbroek@mbse.eu>
parents: 18
diff changeset
65 #include "task_ble.h"
31
ec5c7794dcd6 Added basic BLE code.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
66 #include "ble_adv.h"
ec5c7794dcd6 Added basic BLE code.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
67 #include "ble_gap.h"
ec5c7794dcd6 Added basic BLE code.
Michiel Broek <mbroek@mbse.eu>
parents: 30
diff changeset
68 #include "ble_gatts.h"
30
7448b8dd4288 Preparations for BLE GATT. Added extra time after INA219 is powered on before measurement. Reduced LEDC frequency to 60 Hz, that makes the LED lights less nervous. Hardware mod on output 4, now needs external pulldown resistor.
Michiel Broek <mbroek@mbse.eu>
parents: 18
diff changeset
69 #endif
4
d0155c16e992 Added Wifi task.
Michiel Broek <mbroek@mbse.eu>
parents: 3
diff changeset
70 #include "task_wifi.h"
5
b1f38105ca7e Added task MQTT and some utilities. Added more power measurement variables and code. INA219 measurements are saved in the State record.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
71 #include "task_mqtt.h"
9
1659bd3c7a2b Added task_out to drive the relays and led lights. Added NVS namespace to store the state of the outputs. Respond to subscribed MQTT topics to set new output values.
Michiel Broek <mbroek@mbse.eu>
parents: 7
diff changeset
72 #include "task_out.h"
5
b1f38105ca7e Added task MQTT and some utilities. Added more power measurement variables and code. INA219 measurements are saved in the State record.
Michiel Broek <mbroek@mbse.eu>
parents: 4
diff changeset
73 #include "xutil.h"
18
12506716211c Added nvsio utilities to make read/write to nvs namespace easier. Added variables for deep sleep to nvs namespace. In task_wifi, removed some init parameters that might add to instable wifi connect problems.
Michiel Broek <mbroek@mbse.eu>
parents: 12
diff changeset
74 #include "nvsio.h"
1
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76
1c9894662795 Added esp-idf-lib for a lot of sensors. Added the basic design for the BMP280 task.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 #endif

mercurial