Compare commits
2 commits
96dafc4941
...
30ae25fa04
Author | SHA1 | Date | |
---|---|---|---|
|
30ae25fa04 | ||
|
aba57662ee |
4 changed files with 17 additions and 20 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -4,3 +4,6 @@
|
||||||
[submodule "esp-idf"]
|
[submodule "esp-idf"]
|
||||||
path = esp-idf
|
path = esp-idf
|
||||||
url = https://github.com/espressif/esp-idf
|
url = https://github.com/espressif/esp-idf
|
||||||
|
[submodule "components/BAROS32"]
|
||||||
|
path = components/BAROS32
|
||||||
|
url = https://git.oit.cloud/Barback/BAROS32.git
|
||||||
|
|
1
components/BAROS32
Submodule
1
components/BAROS32
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 54c7a2d2d65dc9159dad27d6388d8a5409b59dd0
|
|
@ -6,6 +6,6 @@ set(COMPONENT_SRCS "\
|
||||||
user_button.c\
|
user_button.c\
|
||||||
")
|
")
|
||||||
set(COMPONENT_ADD_INCLUDEDIRS ". ../include")
|
set(COMPONENT_ADD_INCLUDEDIRS ". ../include")
|
||||||
set(REQUIRES idf-dfplayermini)
|
set(REQUIRES BAROS32)
|
||||||
|
|
||||||
register_component()
|
register_component()
|
||||||
|
|
31
main/ble.c
31
main/ble.c
|
@ -16,6 +16,7 @@
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
|
|
||||||
#include "barback.h"
|
#include "barback.h"
|
||||||
|
#include "baros.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "ble.h"
|
#include "ble.h"
|
||||||
#include "pumps.h"
|
#include "pumps.h"
|
||||||
|
@ -46,21 +47,13 @@ static int svc_access_system(uint16_t conn_handle, uint16_t attr_handle, struct
|
||||||
|
|
||||||
static int barback_ble_char_access(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg);
|
static int barback_ble_char_access(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg);
|
||||||
|
|
||||||
#define BLE_SERVICE_PUMP_ENABLED (0x4200)
|
|
||||||
#define BLE_SERVICE_PUMP_STATE (0x4300)
|
|
||||||
#define BLE_SERVICE_PUMP_DURATION (0x4350)
|
|
||||||
|
|
||||||
#define BLE_SERVICE_BARBACK (0x4400)
|
|
||||||
#define CHAR_POUR (BLE_SERVICE_BARBACK + 1) // 0x4401
|
|
||||||
#define CHAR_BUTTON (BLE_SERVICE_BARBACK + 2) // 0x4402
|
|
||||||
|
|
||||||
static barback_ble_access_t barback_ble_pump_access_enabled = {
|
static barback_ble_access_t barback_ble_pump_access_enabled = {
|
||||||
.read = pumps_get_enabled,
|
.read = pumps_get_enabled,
|
||||||
.write = pumps_set_enabled
|
.write = pumps_set_enabled
|
||||||
};
|
};
|
||||||
|
|
||||||
#define BLE_CHAR_PUMP_ENABLED(idx) {\
|
#define BLE_CHAR_PUMP_ENABLED(idx) {\
|
||||||
.uuid = BLE_UUID16_DECLARE(BLE_SERVICE_PUMP_ENABLED + idx),\
|
.uuid = BLE_UUID16_DECLARE(BAROS_BLE_SERVICE_PUMP_ENABLED + idx),\
|
||||||
.access_cb = barback_ble_char_access,\
|
.access_cb = barback_ble_char_access,\
|
||||||
.arg = &barback_ble_pump_access_enabled,\
|
.arg = &barback_ble_pump_access_enabled,\
|
||||||
.val_handle = &ble_svc_handle,\
|
.val_handle = &ble_svc_handle,\
|
||||||
|
@ -72,7 +65,7 @@ static barback_ble_access_t barback_ble_pump_access_state = {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define BLE_CHAR_PUMP_STATE(idx) {\
|
#define BLE_CHAR_PUMP_STATE(idx) {\
|
||||||
.uuid = BLE_UUID16_DECLARE(BLE_SERVICE_PUMP_STATE + idx),\
|
.uuid = BLE_UUID16_DECLARE(BAROS_BLE_SERVICE_PUMP_STATE + idx),\
|
||||||
.access_cb = barback_ble_char_access,\
|
.access_cb = barback_ble_char_access,\
|
||||||
.arg = &barback_ble_pump_access_state,\
|
.arg = &barback_ble_pump_access_state,\
|
||||||
.val_handle = &ble_svc_handle,\
|
.val_handle = &ble_svc_handle,\
|
||||||
|
@ -85,7 +78,7 @@ static barback_ble_access_t barback_ble_pump_access_duration = {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define BLE_CHAR_PUMP_DURATION(idx) {\
|
#define BLE_CHAR_PUMP_DURATION(idx) {\
|
||||||
.uuid = BLE_UUID16_DECLARE(BLE_SERVICE_PUMP_DURATION + idx),\
|
.uuid = BLE_UUID16_DECLARE(BAROS_BLE_SERVICE_PUMP_DURATION + idx),\
|
||||||
.access_cb = barback_ble_char_access,\
|
.access_cb = barback_ble_char_access,\
|
||||||
.arg = &barback_ble_pump_access_duration,\
|
.arg = &barback_ble_pump_access_duration,\
|
||||||
.val_handle = &pump_duration_svc_val_handles[idx - 1],\
|
.val_handle = &pump_duration_svc_val_handles[idx - 1],\
|
||||||
|
@ -95,7 +88,7 @@ static barback_ble_access_t barback_ble_pump_access_duration = {
|
||||||
static const struct ble_gatt_svc_def service_defs[] = {
|
static const struct ble_gatt_svc_def service_defs[] = {
|
||||||
{
|
{
|
||||||
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
||||||
.uuid = BLE_UUID16_DECLARE(BLE_SERVICE_PUMP_ENABLED),
|
.uuid = BLE_UUID16_DECLARE(BAROS_BLE_SERVICE_PUMP_ENABLED),
|
||||||
|
|
||||||
.characteristics = (struct ble_gatt_chr_def[]) {
|
.characteristics = (struct ble_gatt_chr_def[]) {
|
||||||
BLE_CHAR_PUMP_ENABLED(1),
|
BLE_CHAR_PUMP_ENABLED(1),
|
||||||
|
@ -106,7 +99,7 @@ static const struct ble_gatt_svc_def service_defs[] = {
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
||||||
.uuid = BLE_UUID16_DECLARE(BLE_SERVICE_PUMP_STATE),
|
.uuid = BLE_UUID16_DECLARE(BAROS_BLE_SERVICE_PUMP_STATE),
|
||||||
.characteristics = (struct ble_gatt_chr_def[]) {
|
.characteristics = (struct ble_gatt_chr_def[]) {
|
||||||
BLE_CHAR_PUMP_STATE(1),
|
BLE_CHAR_PUMP_STATE(1),
|
||||||
BLE_CHAR_PUMP_STATE(2),
|
BLE_CHAR_PUMP_STATE(2),
|
||||||
|
@ -116,7 +109,7 @@ static const struct ble_gatt_svc_def service_defs[] = {
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
||||||
.uuid = BLE_UUID16_DECLARE(BLE_SERVICE_PUMP_DURATION),
|
.uuid = BLE_UUID16_DECLARE(BAROS_BLE_SERVICE_PUMP_DURATION),
|
||||||
.characteristics = (struct ble_gatt_chr_def[]) {
|
.characteristics = (struct ble_gatt_chr_def[]) {
|
||||||
BLE_CHAR_PUMP_DURATION(1),
|
BLE_CHAR_PUMP_DURATION(1),
|
||||||
BLE_CHAR_PUMP_DURATION(2),
|
BLE_CHAR_PUMP_DURATION(2),
|
||||||
|
@ -126,15 +119,15 @@ static const struct ble_gatt_svc_def service_defs[] = {
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
||||||
.uuid = BLE_UUID16_DECLARE(BLE_SERVICE_BARBACK),
|
.uuid = BLE_UUID16_DECLARE(BAROS_BLE_SERVICE_BARBACK),
|
||||||
.characteristics = (struct ble_gatt_chr_def[]) {
|
.characteristics = (struct ble_gatt_chr_def[]) {
|
||||||
{
|
{
|
||||||
.uuid = BLE_UUID16_DECLARE(CHAR_POUR),
|
.uuid = BLE_UUID16_DECLARE(BAROS_CHAR_POUR),
|
||||||
.access_cb = svc_access_system,
|
.access_cb = svc_access_system,
|
||||||
.val_handle = &ble_svc_handle,
|
.val_handle = &ble_svc_handle,
|
||||||
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
|
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
|
||||||
}, {
|
}, {
|
||||||
.uuid = BLE_UUID16_DECLARE(CHAR_BUTTON),
|
.uuid = BLE_UUID16_DECLARE(BAROS_CHAR_BUTTON),
|
||||||
.access_cb = svc_access_system,
|
.access_cb = svc_access_system,
|
||||||
.val_handle = &svc_handle_button,
|
.val_handle = &svc_handle_button,
|
||||||
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY
|
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY
|
||||||
|
@ -179,7 +172,7 @@ static int svc_access_system(uint16_t conn_handle, uint16_t attr_handle, struct
|
||||||
);
|
);
|
||||||
|
|
||||||
switch(uuid16) {
|
switch(uuid16) {
|
||||||
case CHAR_POUR:
|
case BAROS_CHAR_POUR:
|
||||||
if(value == 1) {
|
if(value == 1) {
|
||||||
ESP_LOGI(TAG, "starting pumps");
|
ESP_LOGI(TAG, "starting pumps");
|
||||||
pumps_run();
|
pumps_run();
|
||||||
|
@ -189,7 +182,7 @@ static int svc_access_system(uint16_t conn_handle, uint16_t attr_handle, struct
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CHAR_BUTTON:
|
case BAROS_CHAR_BUTTON:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue