diff --git a/components/BAROS32 b/components/BAROS32 index 6467f21..da0252f 160000 --- a/components/BAROS32 +++ b/components/BAROS32 @@ -1 +1 @@ -Subproject commit 6467f21fcaf29cc8eb11d9e899a53f73acb13651 +Subproject commit da0252fb53d741ccbf9794a5ce3d801b2b99bef5 diff --git a/dependencies.lock b/dependencies.lock index 4b28670..0bb5a15 100644 --- a/dependencies.lock +++ b/dependencies.lock @@ -113,6 +113,6 @@ direct_dependencies: - espressif/esp_encrypted_img - espressif/led_strip - idf -manifest_hash: 1cb97a3caa49761f939cab42584ada31292591aa3d07b9c39eaf5674fabe7ad1 +manifest_hash: e6ba7eab435ca64e45f1446739419869cebaaf69d8c519cfbadab1d787e2643c target: esp32 version: 2.0.0 diff --git a/main/main.c b/main/main.c index 4c70180..1453fd7 100644 --- a/main/main.c +++ b/main/main.c @@ -13,6 +13,7 @@ #include "led_strip.h" #include "baros.h" +#include "baros_ble.h" #include "configulator.h" #include "barback.h" // TODO main should be merged into barback diff --git a/main/pumps.c b/main/pumps.c index bd5356d..381f6bd 100644 --- a/main/pumps.c +++ b/main/pumps.c @@ -6,7 +6,15 @@ #include "driver/gpio.h" #include "driver/ledc.h" #include "nvs_flash.h" +#include "host/ble_gatt.h" +#include "host/ble_hs.h" +#include "nimble/nimble_port.h" +#include "nimble/nimble_port_freertos.h" +#include "services/gap/ble_svc_gap.h" +#include "esp_bt.h" + +#include "baros.h" #include "main.h" #include "pumps.h" @@ -30,6 +38,41 @@ static uint8_t pumps_enabled[PUMPS] = {0}; static uint8_t pumps_running[PUMPS] = {0}; static uint8_t safety = 1; +// TESTSTST +static uint16_t ble_svc_handle; +static int svc_access_system(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg); +static const struct ble_gatt_svc_def service_defs[] = { + { + .type = BLE_GATT_SVC_TYPE_PRIMARY, + .uuid = BLE_UUID16_DECLARE(0x6666), + .characteristics = (struct ble_gatt_chr_def[]) { + { + .uuid = BLE_UUID16_DECLARE(0x4444), + .access_cb = svc_access_system, + .val_handle = &ble_svc_handle, + .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ + }, + { 0 } + } + }, + { 0 } // no more services +}; + +static int svc_access_system(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) { + uint16_t uuid16 = ble_uuid_u16(ctxt->chr->uuid); + uint8_t value = 0; + uint16_t vlen = 0; + + ESP_LOGI(TAG, "0x%02X access: %d", uuid16, ctxt->op); + + if(ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR) { + } else if(ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) { + } + + return 0; +} +// /TESTSTST + #define RAMP_UP_TIME (500) #define RAMP_DOWN_TIME (250) @@ -276,5 +319,13 @@ uint8_t pumps_init() { xTaskCreate(pump_step_task, "ramp", 4024, NULL, tskIDLE_PRIORITY + 4, NULL); + int err = ble_gatts_count_cfg(service_defs); + ESP_ERROR_CHECK(err); + + err = ble_gatts_add_dynamic_svcs(service_defs); + ESP_ERROR_CHECK(err); + + ESP_LOGI(TAG, "eh?"); + return 0; }