add BLE bonding
Some checks failed
ESP-IDF Build / build (esp32, latest) (push) Failing after 46s
ESP-IDF Build / build (esp32, release-v5.4) (push) Failing after 46s
ESP-IDF Build / build (esp32, release-v5.5) (push) Failing after 45s
ESP-IDF Build / build (esp32c3, latest) (push) Failing after 45s
ESP-IDF Build / build (esp32c3, release-v5.4) (push) Failing after 45s
ESP-IDF Build / build (esp32c3, release-v5.5) (push) Failing after 45s
ESP-IDF Build / build (esp32c5, latest) (push) Failing after 45s
ESP-IDF Build / build (esp32c5, release-v5.4) (push) Failing after 45s
ESP-IDF Build / build (esp32c5, release-v5.5) (push) Failing after 45s
ESP-IDF Build / build (esp32c6, latest) (push) Failing after 45s
ESP-IDF Build / build (esp32c6, release-v5.4) (push) Failing after 45s
ESP-IDF Build / build (esp32c6, release-v5.5) (push) Failing after 45s
ESP-IDF Build / build (esp32h2, latest) (push) Failing after 46s
ESP-IDF Build / build (esp32h2, release-v5.4) (push) Failing after 45s
ESP-IDF Build / build (esp32h2, release-v5.5) (push) Failing after 45s
ESP-IDF Build / build (esp32p4, latest) (push) Failing after 45s
ESP-IDF Build / build (esp32p4, release-v5.4) (push) Failing after 45s
ESP-IDF Build / build (esp32p4, release-v5.5) (push) Failing after 52s
ESP-IDF Build / build (esp32s3, latest) (push) Failing after 56s
ESP-IDF Build / build (esp32s3, release-v5.4) (push) Failing after 46s
ESP-IDF Build / build (esp32s3, release-v5.5) (push) Failing after 45s

Signed-off-by: Peter Siegmund <mars3142@users.noreply.github.com>
This commit is contained in:
2025-09-20 20:26:23 +02:00
parent 07f955d949
commit 8a2c0a60d5
13 changed files with 524 additions and 73 deletions

View File

@@ -3,6 +3,7 @@
#include "persistence.h"
static uint8_t g_beacon_enabled = 0;
static int8_t g_led_value = 0;
/// Characteristic Callbacks
int gatt_svr_chr_light_led_access(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt,
@@ -14,13 +15,18 @@ int gatt_svr_chr_light_led_access(uint16_t conn_handle, uint16_t attr_handle, st
os_mbuf_append(ctxt->om, data, strlen(data));
return 0;
}
if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR)
{
int8_t led_value = 0;
persistence_load(VALUE_TYPE_INT8, "LED_VALUE", &led_value);
}
return BLE_ATT_ERR_UNLIKELY;
}
int gatt_svr_chr_light_beacon_access(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt,
void *arg)
{
persistence_load(VALUE_TYPE_INT32, "BEACON_ENABLED", &g_beacon_enabled);
if (ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR)
{
return os_mbuf_append(ctxt->om, &g_beacon_enabled, sizeof(g_beacon_enabled)) == 0
@@ -29,6 +35,9 @@ int gatt_svr_chr_light_beacon_access(uint16_t conn_handle, uint16_t attr_handle,
}
if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR)
{
int8_t beacon_enabled = 0;
persistence_load(VALUE_TYPE_INT8, "BEACON_ENABLED", &beacon_enabled);
// it has to be 1 Byte (0 or 1)
if (OS_MBUF_PKTLEN(ctxt->om) != 1)
{
@@ -56,7 +65,7 @@ int gatt_svr_chr_light_beacon_access(uint16_t conn_handle, uint16_t attr_handle,
{
beacon_stop();
}
persistence_save(VALUE_TYPE_INT32, "BEACON_ENABLED", &g_beacon_enabled);
persistence_save(VALUE_TYPE_INT8, "BEACON_ENABLED", &g_beacon_enabled);
return 0;
}
return BLE_ATT_ERR_UNLIKELY;