mroe work on barback ble services
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
f2c4454689
commit
e59612e426
4 changed files with 54 additions and 2 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit 6467f21fcaf29cc8eb11d9e899a53f73acb13651
|
||||
Subproject commit da0252fb53d741ccbf9794a5ce3d801b2b99bef5
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
51
main/pumps.c
51
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue