commit 3a1c9aa1472ad881a15208b81c4b2687dfae5674
| author | 斟酌 鵬兄 <tgckpg@gmail.com> |
| date | 2026-10-05T07:04:10Z |
| subject | Added some debug logs |
commit 3a1c9aa1472ad881a15208b81c4b2687dfae5674
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date: 2026-10-05T07:04:10Z
Added some debug logs
---
esp32/main/main.c | 11 ++++++++++-
esp32/main/relay.c | 1 +
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/esp32/main/main.c b/esp32/main/main.c
index ccb3caf..df2c8c0 100644
--- a/esp32/main/main.c
+++ b/esp32/main/main.c
@@ -35,8 +35,13 @@ static int status_access(uint16_t conn, uint16_t attr, struct ble_gatt_access_ct
(void)conn;
(void)attr;
(void)arg;
- if (ctxt->op != BLE_GATT_ACCESS_OP_READ_CHR)
+ if (ctxt->op != BLE_GATT_ACCESS_OP_READ_CHR) {
+ ESP_LOGW(TAG, "Unexpected status access: op=%u conn=%u attr=%u",
+ (unsigned)ctxt->op,
+ (unsigned)conn,
+ (unsigned)attr);
return BLE_ATT_ERR_UNLIKELY;
+ }
uint8_t data[18];
size_t n = relay_status(data);
return os_mbuf_append(ctxt->om, data, n) == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
@@ -112,6 +117,10 @@ static void advertise(void);
static int gap_event(struct ble_gap_event *event, void *arg)
{
(void)arg;
+ ESP_LOGI(TAG, "GAP event=%d (CONNECT=%d DISCONNECT=%d)",
+ event->type,
+ BLE_GAP_EVENT_CONNECT,
+ BLE_GAP_EVENT_DISCONNECT);
switch (event->type) {
case BLE_GAP_EVENT_CONNECT:
if (event->connect.status == 0) {
diff --git a/esp32/main/relay.c b/esp32/main/relay.c
index ae1993a..a805823 100644
--- a/esp32/main/relay.c
+++ b/esp32/main/relay.c
@@ -60,6 +60,7 @@ void relay_init(void)
}
void relay_connected(bool value)
{
+ ESP_LOGI("homekey-reader", "relay_connected(%s)", value ? "true" : "false");
xSemaphoreTake(mutex, portMAX_DELAY);
connected = value;
active = false;